* [PATCH PATCH v4 0/2] XDP generic fixes
@ 2019-05-28 18:47 Stephen Hemminger
2019-05-28 18:47 ` [PATCH PATCH v4 1/2] netvsc: unshare skb in VF rx handler Stephen Hemminger
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stephen Hemminger @ 2019-05-28 18:47 UTC (permalink / raw)
To: davem, saeedm, jasowang, brouer; +Cc: netdev, xdp-newbies, Stephen Hemminger
This set of patches came about while investigating XDP
generic on Azure. The split brain nature of the accelerated
networking exposed issues with the stack device model.
Stephen Hemminger (2):
netvsc: unshare skb in VF rx handler
net: core: support XDP generic on stacked devices.
drivers/net/hyperv/netvsc_drv.c | 6 ++++
net/core/dev.c | 58 +++++++--------------------------
2 files changed, 18 insertions(+), 46 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH PATCH v4 1/2] netvsc: unshare skb in VF rx handler
2019-05-28 18:47 [PATCH PATCH v4 0/2] XDP generic fixes Stephen Hemminger
@ 2019-05-28 18:47 ` Stephen Hemminger
2019-05-28 18:47 ` [PATCH PATCH v4 2/2] net: core: support XDP generic on stacked devices Stephen Hemminger
2019-05-30 18:12 ` [PATCH PATCH v4 0/2] XDP generic fixes David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2019-05-28 18:47 UTC (permalink / raw)
To: davem, saeedm, jasowang, brouer; +Cc: netdev, xdp-newbies, Stephen Hemminger
The netvsc VF skb handler should make sure that skb is not
shared. Similar logic already exists in bonding and team device
drivers.
This is not an issue in practice because the VF devicex
does not send up shared skb's. But the netvsc driver
should do the right thing if it did.
Fixes: 0c195567a8f6 ("netvsc: transparent VF management")
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 06393b215102..9873b8679f81 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -2000,6 +2000,12 @@ static rx_handler_result_t netvsc_vf_handle_frame(struct sk_buff **pskb)
struct netvsc_vf_pcpu_stats *pcpu_stats
= this_cpu_ptr(ndev_ctx->vf_stats);
+ skb = skb_share_check(skb, GFP_ATOMIC);
+ if (unlikely(!skb))
+ return RX_HANDLER_CONSUMED;
+
+ *pskb = skb;
+
skb->dev = ndev;
u64_stats_update_begin(&pcpu_stats->syncp);
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH PATCH v4 2/2] net: core: support XDP generic on stacked devices.
2019-05-28 18:47 [PATCH PATCH v4 0/2] XDP generic fixes Stephen Hemminger
2019-05-28 18:47 ` [PATCH PATCH v4 1/2] netvsc: unshare skb in VF rx handler Stephen Hemminger
@ 2019-05-28 18:47 ` Stephen Hemminger
2019-05-30 18:12 ` [PATCH PATCH v4 0/2] XDP generic fixes David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2019-05-28 18:47 UTC (permalink / raw)
To: davem, saeedm, jasowang, brouer; +Cc: netdev, xdp-newbies, Stephen Hemminger
When a device is stacked like (team, bonding, failsafe or netvsc) the
XDP generic program for the parent device was not called.
Move the call to XDP generic inside __netif_receive_skb_core where
it can be done multiple times for stacked case.
Fixes: d445516966dc ("net: xdp: support xdp generic on virtual devices")
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
v1 - call xdp_generic in netvsc handler
v2 - do xdp_generic in generic rx handler processing
v3 - move xdp_generic call inside the another pass loop
v4 - reset skb mac_len after xdp is called
net/core/dev.c | 58 +++++++++++---------------------------------------
1 file changed, 12 insertions(+), 46 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index b6b8505cfb3e..cc2a4e257324 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4502,23 +4502,6 @@ static int netif_rx_internal(struct sk_buff *skb)
trace_netif_rx(skb);
- if (static_branch_unlikely(&generic_xdp_needed_key)) {
- int ret;
-
- preempt_disable();
- rcu_read_lock();
- ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb);
- rcu_read_unlock();
- preempt_enable();
-
- /* Consider XDP consuming the packet a success from
- * the netdev point of view we do not want to count
- * this as an error.
- */
- if (ret != XDP_PASS)
- return NET_RX_SUCCESS;
- }
-
#ifdef CONFIG_RPS
if (static_branch_unlikely(&rps_needed)) {
struct rps_dev_flow voidflow, *rflow = &voidflow;
@@ -4858,6 +4841,18 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc,
__this_cpu_inc(softnet_data.processed);
+ if (static_branch_unlikely(&generic_xdp_needed_key)) {
+ int ret2;
+
+ preempt_disable();
+ ret2 = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb);
+ preempt_enable();
+
+ if (ret2 != XDP_PASS)
+ return NET_RX_DROP;
+ skb_reset_mac_len(skb);
+ }
+
if (skb->protocol == cpu_to_be16(ETH_P_8021Q) ||
skb->protocol == cpu_to_be16(ETH_P_8021AD)) {
skb = skb_vlan_untag(skb);
@@ -5178,19 +5173,6 @@ static int netif_receive_skb_internal(struct sk_buff *skb)
if (skb_defer_rx_timestamp(skb))
return NET_RX_SUCCESS;
- if (static_branch_unlikely(&generic_xdp_needed_key)) {
- int ret;
-
- preempt_disable();
- rcu_read_lock();
- ret = do_xdp_generic(rcu_dereference(skb->dev->xdp_prog), skb);
- rcu_read_unlock();
- preempt_enable();
-
- if (ret != XDP_PASS)
- return NET_RX_DROP;
- }
-
rcu_read_lock();
#ifdef CONFIG_RPS
if (static_branch_unlikely(&rps_needed)) {
@@ -5211,7 +5193,6 @@ static int netif_receive_skb_internal(struct sk_buff *skb)
static void netif_receive_skb_list_internal(struct list_head *head)
{
- struct bpf_prog *xdp_prog = NULL;
struct sk_buff *skb, *next;
struct list_head sublist;
@@ -5224,21 +5205,6 @@ static void netif_receive_skb_list_internal(struct list_head *head)
}
list_splice_init(&sublist, head);
- if (static_branch_unlikely(&generic_xdp_needed_key)) {
- preempt_disable();
- rcu_read_lock();
- list_for_each_entry_safe(skb, next, head, list) {
- xdp_prog = rcu_dereference(skb->dev->xdp_prog);
- skb_list_del_init(skb);
- if (do_xdp_generic(xdp_prog, skb) == XDP_PASS)
- list_add_tail(&skb->list, &sublist);
- }
- rcu_read_unlock();
- preempt_enable();
- /* Put passed packets back on main list */
- list_splice_init(&sublist, head);
- }
-
rcu_read_lock();
#ifdef CONFIG_RPS
if (static_branch_unlikely(&rps_needed)) {
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH PATCH v4 0/2] XDP generic fixes
2019-05-28 18:47 [PATCH PATCH v4 0/2] XDP generic fixes Stephen Hemminger
2019-05-28 18:47 ` [PATCH PATCH v4 1/2] netvsc: unshare skb in VF rx handler Stephen Hemminger
2019-05-28 18:47 ` [PATCH PATCH v4 2/2] net: core: support XDP generic on stacked devices Stephen Hemminger
@ 2019-05-30 18:12 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-05-30 18:12 UTC (permalink / raw)
To: stephen; +Cc: saeedm, jasowang, brouer, netdev, xdp-newbies, sthemmin
From: Stephen Hemminger <stephen@networkplumber.org>
Date: Tue, 28 May 2019 11:47:29 -0700
> This set of patches came about while investigating XDP
> generic on Azure. The split brain nature of the accelerated
> networking exposed issues with the stack device model.
Series applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-05-30 18:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-28 18:47 [PATCH PATCH v4 0/2] XDP generic fixes Stephen Hemminger
2019-05-28 18:47 ` [PATCH PATCH v4 1/2] netvsc: unshare skb in VF rx handler Stephen Hemminger
2019-05-28 18:47 ` [PATCH PATCH v4 2/2] net: core: support XDP generic on stacked devices Stephen Hemminger
2019-05-30 18:12 ` [PATCH PATCH v4 0/2] XDP generic fixes David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).