aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2017-09-09 00:11:01 -0400
committerDavid S. Miller <davem@davemloft.net>2017-09-09 00:11:01 -0400
commita7bc57749f231dcd5fdbc7b653bc260064caf0b9 (patch)
tree0925d65fb3e7e0eec9f6d08f22086a861d294dac /net
parent109980b894e9dae66c37c3d804a415aa68b19c7e (diff)
parent374fb014fc5b15e420faa00af036868a635eadd3 (diff)
Merge branch 'xdp-bpf-fixes'
John Fastabend says: ==================== net: Fixes for XDP/BPF The following fixes, UAPI updates, and small improvement, i. XDP needs to be called inside RCU with preempt disabled. ii. Not strictly a bug fix but we have an attach command in the sockmap UAPI already to avoid having a single kernel released with only the attach and not the detach I'm pushing this into net branch. Its early in the RC cycle so I think this is OK (not ideal but better than supporting a UAPI with a missing detach forever). iii. Final patch replace cpu_relax with cond_resched in devmap. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/dev.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 6f845e4fec17..fb766d906148 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3981,8 +3981,13 @@ static int netif_rx_internal(struct sk_buff *skb)
3981 trace_netif_rx(skb); 3981 trace_netif_rx(skb);
3982 3982
3983 if (static_key_false(&generic_xdp_needed)) { 3983 if (static_key_false(&generic_xdp_needed)) {
3984 int ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), 3984 int ret;
3985 skb); 3985
3986 preempt_disable();
3987 rcu_read_lock();
3988 ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb);
3989 rcu_read_unlock();
3990 preempt_enable();
3986 3991
3987 /* Consider XDP consuming the packet a success from 3992 /* Consider XDP consuming the packet a success from
3988 * the netdev point of view we do not want to count 3993 * the netdev point of view we do not want to count
@@ -4500,18 +4505,20 @@ static int netif_receive_skb_internal(struct sk_buff *skb)
4500 if (skb_defer_rx_timestamp(skb)) 4505 if (skb_defer_rx_timestamp(skb))
4501 return NET_RX_SUCCESS; 4506 return NET_RX_SUCCESS;
4502 4507
4503 rcu_read_lock();
4504
4505 if (static_key_false(&generic_xdp_needed)) { 4508 if (static_key_false(&generic_xdp_needed)) {
4506 int ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), 4509 int ret;
4507 skb);
4508 4510
4509 if (ret != XDP_PASS) { 4511 preempt_disable();
4510 rcu_read_unlock(); 4512 rcu_read_lock();
4513 ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb);
4514 rcu_read_unlock();
4515 preempt_enable();
4516
4517 if (ret != XDP_PASS)
4511 return NET_RX_DROP; 4518 return NET_RX_DROP;
4512 }
4513 } 4519 }
4514 4520
4521 rcu_read_lock();
4515#ifdef CONFIG_RPS 4522#ifdef CONFIG_RPS
4516 if (static_key_false(&rps_needed)) { 4523 if (static_key_false(&rps_needed)) {
4517 struct rps_dev_flow voidflow, *rflow = &voidflow; 4524 struct rps_dev_flow voidflow, *rflow = &voidflow;