Skip to contentSkip to conversation

veth: Update XDP feature set when bringing up device

PATCH Applied Toke Høiland-Jørgensen 3 participants 6 messages Sep 11, 2023 – Sep 12, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 veth: Update XDP feature set when bringing up device

There's an early return in veth_set_features() if the device is in a down state, which leads to the XDP feature flags not being updated when enabling GRO while the device is down. Which in turn leads to XDP_REDIRECT not working, because the redirect code now checks the flags.

Fix this by updating the feature flags after bringing the device up.

Before this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: no
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: no

After this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: yes
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: yes

Fixes fccca038f300 ("veth: take into account device reconfiguration for xdp_features flag")
Fixes 66c0e13ad236 ("drivers: net: turn on XDP features")
---
 drivers/net/veth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/veth.c +2 -0
index 9c6f4f83f22b..0deefd1573cf 100644
@@ -1446,6 +1446,8 @@ static int veth_open(struct net_device *dev)
 		netif_carrier_on(peer);
 	}
 
+	veth_set_xdp_features(dev);
+
 	return 0;
 }
 
Signature · 1 line
2.42.0
maintainer
#1 lore raw

Hi,

Quoted 39 lines · Toke Høiland-Jørgensen

There's an early return in veth_set_features() if the device is in a down state, which leads to the XDP feature flags not being updated when enabling GRO while the device is down. Which in turn leads to XDP_REDIRECT not working, because the redirect code now checks the flags.

Fix this by updating the feature flags after bringing the device up.

Before this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: no
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: no

After this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: yes
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: yes

Fixes fccca038f300 ("veth: take into account device reconfiguration for xdp_features flag")
Fixes 66c0e13ad236 ("drivers: net: turn on XDP features")
---
 drivers/net/veth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/veth.c +0 -0
index 9c6f4f83f22b..0deefd1573cf 100644

drivers/net/veth.c static int veth_open(struct net_device *dev) · line 1452

Quoted 7 lines
drivers/net/veth.c +2 -0
@@ -1446,6 +1446,8 @@ static int veth_open(struct net_device *dev)
 		netif_carrier_on(peer);
 	}
 
+	veth_set_xdp_features(dev);
+
 	return 0;
 }

The patch LGTM, thanks!

I think it would be nice to add some specific self-tests here. Could you please consider following-up with them?

Thanks,

Paolo

#2 lore raw
Quoted 52 lines · Paolo Abeni

Hi,

Quoted 39 lines · Toke Høiland-Jørgensen

There's an early return in veth_set_features() if the device is in a down state, which leads to the XDP feature flags not being updated when enabling GRO while the device is down. Which in turn leads to XDP_REDIRECT not working, because the redirect code now checks the flags.

Fix this by updating the feature flags after bringing the device up.

Before this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: no
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: no

After this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: yes
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: yes

Fixes fccca038f300 ("veth: take into account device reconfiguration for xdp_features flag")
Fixes 66c0e13ad236 ("drivers: net: turn on XDP features")
---
 drivers/net/veth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/veth.c +0 -0
index 9c6f4f83f22b..0deefd1573cf 100644

drivers/net/veth.c static int veth_open(struct net_device *dev) · line 1452

Quoted 7 lines
drivers/net/veth.c +2 -0
@@ -1446,6 +1446,8 @@ static int veth_open(struct net_device *dev)
 		netif_carrier_on(peer);
 	}
 
+	veth_set_xdp_features(dev);
+
 	return 0;
 }

The patch LGTM, thanks!

Quoted 2 lines

I think it would be nice to add some specific self-tests here. Could you please consider following-up with them?

Sure! Do you want me to resubmit this as well, or are you just going to apply it as-is and do the selftest as a follow-up?

-Toke

maintainer
#3 lore raw
Quoted 54 lines · Toke Høiland-Jørgensen
Quoted 52 lines · Paolo Abeni

Hi,

Quoted 39 lines · Toke Høiland-Jørgensen

There's an early return in veth_set_features() if the device is in a down state, which leads to the XDP feature flags not being updated when enabling GRO while the device is down. Which in turn leads to XDP_REDIRECT not working, because the redirect code now checks the flags.

Fix this by updating the feature flags after bringing the device up.

Before this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: no
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: no

After this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: yes
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: yes

Fixes fccca038f300 ("veth: take into account device reconfiguration for xdp_features flag")
Fixes 66c0e13ad236 ("drivers: net: turn on XDP features")
---
 drivers/net/veth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/veth.c +0 -0
index 9c6f4f83f22b..0deefd1573cf 100644

drivers/net/veth.c static int veth_open(struct net_device *dev) · line 1452

Quoted 7 lines
drivers/net/veth.c +2 -0
@@ -1446,6 +1446,8 @@ static int veth_open(struct net_device *dev)
 		netif_carrier_on(peer);
 	}
 
+	veth_set_xdp_features(dev);
+
 	return 0;
 }

The patch LGTM, thanks!

Quoted 5 lines
Quoted 2 lines

I think it would be nice to add some specific self-tests here. Could you please consider following-up with them?

Sure! Do you want me to resubmit this as well, or are you just going to apply it as-is and do the selftest as a follow-up?

I think the latter is simpler and works for me. The self-test could target net-next, the fix is going to land there shortly after -net.

Thanks!

Paolo

#4 lore raw
Quoted 55 lines · Paolo Abeni
Quoted 54 lines · Toke Høiland-Jørgensen
Quoted 52 lines · Paolo Abeni

Hi,

Quoted 39 lines · Toke Høiland-Jørgensen

There's an early return in veth_set_features() if the device is in a down state, which leads to the XDP feature flags not being updated when enabling GRO while the device is down. Which in turn leads to XDP_REDIRECT not working, because the redirect code now checks the flags.

Fix this by updating the feature flags after bringing the device up.

Before this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: no
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: no

After this patch:

NETDEV_XDP_ACT_BASIC: yes
NETDEV_XDP_ACT_REDIRECT: yes
NETDEV_XDP_ACT_NDO_XMIT: yes
NETDEV_XDP_ACT_XSK_ZEROCOPY: no
NETDEV_XDP_ACT_HW_OFFLOAD: no
NETDEV_XDP_ACT_RX_SG: yes
NETDEV_XDP_ACT_NDO_XMIT_SG: yes

Fixes fccca038f300 ("veth: take into account device reconfiguration for xdp_features flag")
Fixes 66c0e13ad236 ("drivers: net: turn on XDP features")
---
 drivers/net/veth.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/veth.c +0 -0
index 9c6f4f83f22b..0deefd1573cf 100644

drivers/net/veth.c static int veth_open(struct net_device *dev) · line 1452

Quoted 7 lines
drivers/net/veth.c +2 -0
@@ -1446,6 +1446,8 @@ static int veth_open(struct net_device *dev)
 		netif_carrier_on(peer);
 	}
 
+	veth_set_xdp_features(dev);
+
 	return 0;
 }

The patch LGTM, thanks!

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I think it would be nice to add some specific self-tests here. Could you please consider following-up with them?

Sure! Do you want me to resubmit this as well, or are you just going to apply it as-is and do the selftest as a follow-up?

I think the latter is simpler and works for me. The self-test could target net-next, the fix is going to land there shortly after -net.

ACK, SGTM!

-Toke

#5 lore raw
In reply to Toke Høiland-Jørgensen
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Mon, 11 Sep 2023 15:58:25 +0200 you wrote:

There's an early return in veth_set_features() if the device is in a down state, which leads to the XDP feature flags not being updated when enabling GRO while the device is down. Which in turn leads to XDP_REDIRECT not working, because the redirect code now checks the flags.

Fix this by updating the feature flags after bringing the device up.

[...]

Here is the summary with links:
- [net] veth: Update XDP feature set when bringing up device

    https://git.kernel.org/netdev/net/c/7a6102aa6df0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html