Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 352470
b: refs/heads/master
c: 9754e29
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed Feb 14, 2013
1 parent 6bceaad commit 959b5a6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ba7797119b486bb5992beda74bdb26be9a291b46
refs/heads/master: 9754e293491e3a4e6c1ac020d25140b1ed3d9cd2
46 changes: 28 additions & 18 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3457,7 +3457,7 @@ static bool skb_pfmemalloc_protocol(struct sk_buff *skb)
}
}

static int __netif_receive_skb(struct sk_buff *skb)
static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
{
struct packet_type *ptype, *pt_prev;
rx_handler_func_t *rx_handler;
Expand All @@ -3466,24 +3466,11 @@ static int __netif_receive_skb(struct sk_buff *skb)
bool deliver_exact = false;
int ret = NET_RX_DROP;
__be16 type;
unsigned long pflags = current->flags;

net_timestamp_check(!netdev_tstamp_prequeue, skb);

trace_netif_receive_skb(skb);

/*
* PFMEMALLOC skbs are special, they should
* - be delivered to SOCK_MEMALLOC sockets only
* - stay away from userspace
* - have bounded memory usage
*
* Use PF_MEMALLOC as this saves us from propagating the allocation
* context down to all allocation sites.
*/
if (sk_memalloc_socks() && skb_pfmemalloc(skb))
current->flags |= PF_MEMALLOC;

/* if we've gotten here through NAPI, check netpoll */
if (netpoll_receive_skb(skb))
goto out;
Expand Down Expand Up @@ -3517,7 +3504,7 @@ static int __netif_receive_skb(struct sk_buff *skb)
}
#endif

if (sk_memalloc_socks() && skb_pfmemalloc(skb))
if (pfmemalloc)
goto skip_taps;

list_for_each_entry_rcu(ptype, &ptype_all, list) {
Expand All @@ -3536,8 +3523,7 @@ static int __netif_receive_skb(struct sk_buff *skb)
ncls:
#endif

if (sk_memalloc_socks() && skb_pfmemalloc(skb)
&& !skb_pfmemalloc_protocol(skb))
if (pfmemalloc && !skb_pfmemalloc_protocol(skb))
goto drop;

if (vlan_tx_tag_present(skb)) {
Expand Down Expand Up @@ -3607,7 +3593,31 @@ static int __netif_receive_skb(struct sk_buff *skb)
unlock:
rcu_read_unlock();
out:
tsk_restore_flags(current, pflags, PF_MEMALLOC);
return ret;
}

static int __netif_receive_skb(struct sk_buff *skb)
{
int ret;

if (sk_memalloc_socks() && skb_pfmemalloc(skb)) {
unsigned long pflags = current->flags;

/*
* PFMEMALLOC skbs are special, they should
* - be delivered to SOCK_MEMALLOC sockets only
* - stay away from userspace
* - have bounded memory usage
*
* Use PF_MEMALLOC as this saves us from propagating the allocation
* context down to all allocation sites.
*/
current->flags |= PF_MEMALLOC;
ret = __netif_receive_skb_core(skb, true);
tsk_restore_flags(current, pflags, PF_MEMALLOC);
} else
ret = __netif_receive_skb_core(skb, false);

return ret;
}

Expand Down

0 comments on commit 959b5a6

Please sign in to comment.