* [PATCH net v3 0/3] Don't take HW USO path when packets can't be checksummed by device
@ 2024-08-07 17:55 Jakub Sitnicki
2024-08-07 17:55 ` [PATCH net v3 1/3] net: Make USO depend on CSUM offload Jakub Sitnicki
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Jakub Sitnicki @ 2024-08-07 17:55 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Willem de Bruijn, kernel-team, Jakub Sitnicki,
syzbot+e15b7e15b8a751a91d9a
This series addresses a recent regression report from syzbot [1].
After enabling UDP_SEGMENT for egress devices which don't support checksum
offload [2], we need to tighten down the checks which let packets take the
HW USO path.
The fix consists of two parts:
1. don't let devices offer USO without checksum offload, and
2. force software USO fallback in presence of IPv6 extension headers.
[1] https://lore.kernel.org/all/000000000000e1609a061d5330ce@google.com/
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=10154dbded6d6a2fecaebdfda206609de0f121a9
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
---
Changes in v3:
- Make USO depend on checksum offload (Willem)
- Contain the bad offload warning fix within the USO callback (Willem)
- Link to v2: https://lore.kernel.org/r/20240801-udp-gso-egress-from-tunnel-v2-0-9a2af2f15d8d@cloudflare.com
Changes in v2:
- Contain the fix inside the GSO stack after discussing with Willem
- Rework tests after realizing the regression has nothing to do with tunnels
- Link to v1: https://lore.kernel.org/r/20240725-udp-gso-egress-from-tunnel-v1-0-5e5530ead524@cloudflare.com
---
Jakub Sitnicki (3):
net: Make USO depend on CSUM offload
udp: Fall back to software USO if IPv6 extension headers are present
selftests/net: Add coverage for UDP GSO with IPv6 extension headers
net/core/dev.c | 27 ++++++++++++++++++---------
net/ipv4/udp_offload.c | 6 ++++++
tools/testing/selftests/net/udpgso.c | 25 ++++++++++++++++++++++++-
3 files changed, 48 insertions(+), 10 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH net v3 1/3] net: Make USO depend on CSUM offload 2024-08-07 17:55 [PATCH net v3 0/3] Don't take HW USO path when packets can't be checksummed by device Jakub Sitnicki @ 2024-08-07 17:55 ` Jakub Sitnicki 2024-08-08 2:29 ` Willem de Bruijn 2024-08-07 17:55 ` [PATCH net v3 2/3] udp: Fall back to software USO if IPv6 extension headers are present Jakub Sitnicki 2024-08-07 17:55 ` [PATCH net v3 3/3] selftests/net: Add coverage for UDP GSO with IPv6 extension headers Jakub Sitnicki 2 siblings, 1 reply; 8+ messages in thread From: Jakub Sitnicki @ 2024-08-07 17:55 UTC (permalink / raw) To: netdev Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn, kernel-team, Jakub Sitnicki UDP segmentation offload inherently depends on checksum offload. It should not be possible to disable checksum offload while leaving USO enabled. Enforce this dependency in code. There is a single tx-udp-segmentation feature flag to indicate support for both IPv4/6, hence the devices wishing to support USO must offer checksum offload for both IP versions. Fixes: 83aa025f535f ("udp: add gso support to virtual devices") Suggested-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> --- net/core/dev.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 751d9b70e6ad..dfb12164b35d 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -9912,6 +9912,16 @@ static void netdev_sync_lower_features(struct net_device *upper, } } +#define IP_CSUM_MASK (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM) + +static bool has_ip_or_hw_csum(netdev_features_t features) +{ + bool ip_csum = (features & IP_CSUM_MASK) == IP_CSUM_MASK; + bool hw_csum = features & NETIF_F_HW_CSUM; + + return ip_csum || hw_csum; +} + static netdev_features_t netdev_fix_features(struct net_device *dev, netdev_features_t features) { @@ -9993,15 +10003,9 @@ static netdev_features_t netdev_fix_features(struct net_device *dev, features &= ~NETIF_F_LRO; } - if (features & NETIF_F_HW_TLS_TX) { - bool ip_csum = (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) == - (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); - bool hw_csum = features & NETIF_F_HW_CSUM; - - if (!ip_csum && !hw_csum) { - netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); - features &= ~NETIF_F_HW_TLS_TX; - } + if ((features & NETIF_F_HW_TLS_TX) && !has_ip_or_hw_csum(features)) { + netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); + features &= ~NETIF_F_HW_TLS_TX; } if ((features & NETIF_F_HW_TLS_RX) && !(features & NETIF_F_RXCSUM)) { @@ -10009,6 +10013,11 @@ static netdev_features_t netdev_fix_features(struct net_device *dev, features &= ~NETIF_F_HW_TLS_RX; } + if ((features & NETIF_F_GSO_UDP_L4) && !has_ip_or_hw_csum(features)) { + netdev_dbg(dev, "Dropping USO feature since no CSUM feature.\n"); + features &= ~NETIF_F_GSO_UDP_L4; + } + return features; } -- 2.40.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v3 1/3] net: Make USO depend on CSUM offload 2024-08-07 17:55 ` [PATCH net v3 1/3] net: Make USO depend on CSUM offload Jakub Sitnicki @ 2024-08-08 2:29 ` Willem de Bruijn 2024-08-08 8:28 ` Jakub Sitnicki 0 siblings, 1 reply; 8+ messages in thread From: Willem de Bruijn @ 2024-08-08 2:29 UTC (permalink / raw) To: Jakub Sitnicki, netdev Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn, kernel-team, Jakub Sitnicki Jakub Sitnicki wrote: > UDP segmentation offload inherently depends on checksum offload. It should > not be possible to disable checksum offload while leaving USO enabled. > Enforce this dependency in code. > > There is a single tx-udp-segmentation feature flag to indicate support for > both IPv4/6, hence the devices wishing to support USO must offer checksum > offload for both IP versions. > > Fixes: 83aa025f535f ("udp: add gso support to virtual devices") Was this not introduced by removing the CHECKSUM_PARTIAL check in udp_send_skb? > Suggested-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com> > Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> > --- > net/core/dev.c | 27 ++++++++++++++++++--------- > 1 file changed, 18 insertions(+), 9 deletions(-) > > diff --git a/net/core/dev.c b/net/core/dev.c > index 751d9b70e6ad..dfb12164b35d 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -9912,6 +9912,16 @@ static void netdev_sync_lower_features(struct net_device *upper, > } > } > > +#define IP_CSUM_MASK (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM) > + Perhaps NETIF_F_IP_CSUM_MASK in netdev_features.h right below #define NETIF_F_CSUM_MASK Then again, for a stable patch we want a small patch. Then I'd define as a constant netdev_features_t inside the function scope. Minor: still prefix with netdev_ even though it's a static function? > +static bool has_ip_or_hw_csum(netdev_features_t features) > +{ > + bool ip_csum = (features & IP_CSUM_MASK) == IP_CSUM_MASK; > + bool hw_csum = features & NETIF_F_HW_CSUM; > + > + return ip_csum || hw_csum; > +} > + > static netdev_features_t netdev_fix_features(struct net_device *dev, > netdev_features_t features) > { > @@ -9993,15 +10003,9 @@ static netdev_features_t netdev_fix_features(struct net_device *dev, > features &= ~NETIF_F_LRO; > } > > - if (features & NETIF_F_HW_TLS_TX) { > - bool ip_csum = (features & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)) == > - (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM); > - bool hw_csum = features & NETIF_F_HW_CSUM; > - > - if (!ip_csum && !hw_csum) { > - netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); > - features &= ~NETIF_F_HW_TLS_TX; > - } > + if ((features & NETIF_F_HW_TLS_TX) && !has_ip_or_hw_csum(features)) { > + netdev_dbg(dev, "Dropping TLS TX HW offload feature since no CSUM feature.\n"); > + features &= ~NETIF_F_HW_TLS_TX; > } > > if ((features & NETIF_F_HW_TLS_RX) && !(features & NETIF_F_RXCSUM)) { > @@ -10009,6 +10013,11 @@ static netdev_features_t netdev_fix_features(struct net_device *dev, > features &= ~NETIF_F_HW_TLS_RX; > } > > + if ((features & NETIF_F_GSO_UDP_L4) && !has_ip_or_hw_csum(features)) { > + netdev_dbg(dev, "Dropping USO feature since no CSUM feature.\n"); > + features &= ~NETIF_F_GSO_UDP_L4; > + } > + > return features; > } > > > -- > 2.40.1 > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net v3 1/3] net: Make USO depend on CSUM offload 2024-08-08 2:29 ` Willem de Bruijn @ 2024-08-08 8:28 ` Jakub Sitnicki 0 siblings, 0 replies; 8+ messages in thread From: Jakub Sitnicki @ 2024-08-08 8:28 UTC (permalink / raw) To: Willem de Bruijn Cc: netdev, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, kernel-team On Wed, Aug 07, 2024 at 10:29 PM -04, Willem de Bruijn wrote: > Jakub Sitnicki wrote: >> UDP segmentation offload inherently depends on checksum offload. It should >> not be possible to disable checksum offload while leaving USO enabled. >> Enforce this dependency in code. >> >> There is a single tx-udp-segmentation feature flag to indicate support for >> both IPv4/6, hence the devices wishing to support USO must offer checksum >> offload for both IP versions. >> >> Fixes: 83aa025f535f ("udp: add gso support to virtual devices") > > Was this not introduced by removing the CHECKSUM_PARTIAL check in > udp_send_skb? Makes sense. It only became a problem after that change. Will update. > >> Suggested-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com> >> Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> >> --- >> net/core/dev.c | 27 ++++++++++++++++++--------- >> 1 file changed, 18 insertions(+), 9 deletions(-) >> >> diff --git a/net/core/dev.c b/net/core/dev.c >> index 751d9b70e6ad..dfb12164b35d 100644 >> --- a/net/core/dev.c >> +++ b/net/core/dev.c >> @@ -9912,6 +9912,16 @@ static void netdev_sync_lower_features(struct net_device *upper, >> } >> } >> >> +#define IP_CSUM_MASK (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM) >> + > > Perhaps NETIF_F_IP_CSUM_MASK in netdev_features.h right below > > #define NETIF_F_CSUM_MASK > > Then again, for a stable patch we want a small patch. Then I'd define > as a constant netdev_features_t inside the function scope. > > Minor: still prefix with netdev_ even though it's a static function? Will apply all feedback. Thanks. [...] ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net v3 2/3] udp: Fall back to software USO if IPv6 extension headers are present 2024-08-07 17:55 [PATCH net v3 0/3] Don't take HW USO path when packets can't be checksummed by device Jakub Sitnicki 2024-08-07 17:55 ` [PATCH net v3 1/3] net: Make USO depend on CSUM offload Jakub Sitnicki @ 2024-08-07 17:55 ` Jakub Sitnicki 2024-08-08 2:29 ` Willem de Bruijn 2024-08-07 17:55 ` [PATCH net v3 3/3] selftests/net: Add coverage for UDP GSO with IPv6 extension headers Jakub Sitnicki 2 siblings, 1 reply; 8+ messages in thread From: Jakub Sitnicki @ 2024-08-07 17:55 UTC (permalink / raw) To: netdev Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn, kernel-team, Jakub Sitnicki, syzbot+e15b7e15b8a751a91d9a In commit 10154dbded6d ("udp: Allow GSO transmit from devices with no checksum offload") we have intentionally allowed UDP GSO packets marked CHECKSUM_NONE to pass to the GSO stack, so that they can be segmented and checksummed by a software fallback when the egress device lacks these features. What was not taken into consideration is that a CHECKSUM_NONE skb can be handed over to the GSO stack also when the egress device advertises the tx-udp-segmentation / NETIF_F_GSO_UDP_L4 feature. This will happen when there are IPv6 extension headers present, which we check for in __ip6_append_data(). Syzbot has discovered this scenario, producing a warning as below: ip6tnl0: caps=(0x00000006401d7869, 0x00000006401d7869) WARNING: CPU: 0 PID: 5112 at net/core/dev.c:3293 skb_warn_bad_offload+0x166/0x1a0 net/core/dev.c:3291 Modules linked in: CPU: 0 PID: 5112 Comm: syz-executor391 Not tainted 6.10.0-rc7-syzkaller-01603-g80ab5445da62 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 RIP: 0010:skb_warn_bad_offload+0x166/0x1a0 net/core/dev.c:3291 [...] Call Trace: <TASK> __skb_gso_segment+0x3be/0x4c0 net/core/gso.c:127 skb_gso_segment include/net/gso.h:83 [inline] validate_xmit_skb+0x585/0x1120 net/core/dev.c:3661 __dev_queue_xmit+0x17a4/0x3e90 net/core/dev.c:4415 neigh_output include/net/neighbour.h:542 [inline] ip6_finish_output2+0xffa/0x1680 net/ipv6/ip6_output.c:137 ip6_finish_output+0x41e/0x810 net/ipv6/ip6_output.c:222 ip6_send_skb+0x112/0x230 net/ipv6/ip6_output.c:1958 udp_v6_send_skb+0xbf5/0x1870 net/ipv6/udp.c:1292 udpv6_sendmsg+0x23b3/0x3270 net/ipv6/udp.c:1588 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0xef/0x270 net/socket.c:745 ____sys_sendmsg+0x525/0x7d0 net/socket.c:2585 ___sys_sendmsg net/socket.c:2639 [inline] __sys_sendmmsg+0x3b2/0x740 net/socket.c:2725 __do_sys_sendmmsg net/socket.c:2754 [inline] __se_sys_sendmmsg net/socket.c:2751 [inline] __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2751 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f [...] </TASK> We are hitting the bad offload warning because when an egress device is capable of handling segmentation offload requested by skb_shinfo(skb)->gso_type, the chain of gso_segment callbacks won't produce any segment skbs and return NULL. See the skb_gso_ok() branch in {__udp,tcp,sctp}_gso_segment helpers. To fix it, force a fallback to software USO when processing a packet with IPv6 extension headers, since we don't know if these can checksummed by all devices which offer USO. Fixes: 10154dbded6d ("udp: Allow GSO transmit from devices with no checksum offload") Reported-by: syzbot+e15b7e15b8a751a91d9a@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/000000000000e1609a061d5330ce@google.com/ Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> --- net/ipv4/udp_offload.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c index bc8a9da750fe..b254a5dadfcf 100644 --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -282,6 +282,12 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, skb_transport_header(gso_skb))) return ERR_PTR(-EINVAL); + /* We don't know if egress device can segment and checksum the packet + * when IPv6 extension headers are present. Fall back to software GSO. + */ + if (gso_skb->ip_summed != CHECKSUM_PARTIAL) + features &= ~(NETIF_F_GSO_UDP_L4 | NETIF_F_CSUM_MASK); + if (skb_gso_ok(gso_skb, features | NETIF_F_GSO_ROBUST)) { /* Packet is from an untrusted source, reset gso_segs. */ skb_shinfo(gso_skb)->gso_segs = DIV_ROUND_UP(gso_skb->len - sizeof(*uh), -- 2.40.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v3 2/3] udp: Fall back to software USO if IPv6 extension headers are present 2024-08-07 17:55 ` [PATCH net v3 2/3] udp: Fall back to software USO if IPv6 extension headers are present Jakub Sitnicki @ 2024-08-08 2:29 ` Willem de Bruijn 0 siblings, 0 replies; 8+ messages in thread From: Willem de Bruijn @ 2024-08-08 2:29 UTC (permalink / raw) To: Jakub Sitnicki, netdev Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn, kernel-team, Jakub Sitnicki, syzbot+e15b7e15b8a751a91d9a Jakub Sitnicki wrote: > In commit 10154dbded6d ("udp: Allow GSO transmit from devices with no > checksum offload") we have intentionally allowed UDP GSO packets marked > CHECKSUM_NONE to pass to the GSO stack, so that they can be segmented and > checksummed by a software fallback when the egress device lacks these > features. > > What was not taken into consideration is that a CHECKSUM_NONE skb can be > handed over to the GSO stack also when the egress device advertises the > tx-udp-segmentation / NETIF_F_GSO_UDP_L4 feature. > > This will happen when there are IPv6 extension headers present, which we > check for in __ip6_append_data(). Syzbot has discovered this scenario, > producing a warning as below: > > ip6tnl0: caps=(0x00000006401d7869, 0x00000006401d7869) > WARNING: CPU: 0 PID: 5112 at net/core/dev.c:3293 skb_warn_bad_offload+0x166/0x1a0 net/core/dev.c:3291 > Modules linked in: > CPU: 0 PID: 5112 Comm: syz-executor391 Not tainted 6.10.0-rc7-syzkaller-01603-g80ab5445da62 #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024 > RIP: 0010:skb_warn_bad_offload+0x166/0x1a0 net/core/dev.c:3291 > [...] > Call Trace: > <TASK> > __skb_gso_segment+0x3be/0x4c0 net/core/gso.c:127 > skb_gso_segment include/net/gso.h:83 [inline] > validate_xmit_skb+0x585/0x1120 net/core/dev.c:3661 > __dev_queue_xmit+0x17a4/0x3e90 net/core/dev.c:4415 > neigh_output include/net/neighbour.h:542 [inline] > ip6_finish_output2+0xffa/0x1680 net/ipv6/ip6_output.c:137 > ip6_finish_output+0x41e/0x810 net/ipv6/ip6_output.c:222 > ip6_send_skb+0x112/0x230 net/ipv6/ip6_output.c:1958 > udp_v6_send_skb+0xbf5/0x1870 net/ipv6/udp.c:1292 > udpv6_sendmsg+0x23b3/0x3270 net/ipv6/udp.c:1588 > sock_sendmsg_nosec net/socket.c:730 [inline] > __sock_sendmsg+0xef/0x270 net/socket.c:745 > ____sys_sendmsg+0x525/0x7d0 net/socket.c:2585 > ___sys_sendmsg net/socket.c:2639 [inline] > __sys_sendmmsg+0x3b2/0x740 net/socket.c:2725 > __do_sys_sendmmsg net/socket.c:2754 [inline] > __se_sys_sendmmsg net/socket.c:2751 [inline] > __x64_sys_sendmmsg+0xa0/0xb0 net/socket.c:2751 > do_syscall_x64 arch/x86/entry/common.c:52 [inline] > do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 > entry_SYSCALL_64_after_hwframe+0x77/0x7f > [...] > </TASK> > > We are hitting the bad offload warning because when an egress device is > capable of handling segmentation offload requested by > skb_shinfo(skb)->gso_type, the chain of gso_segment callbacks won't produce > any segment skbs and return NULL. See the skb_gso_ok() branch in > {__udp,tcp,sctp}_gso_segment helpers. > > To fix it, force a fallback to software USO when processing a packet with > IPv6 extension headers, since we don't know if these can checksummed by > all devices which offer USO. > > Fixes: 10154dbded6d ("udp: Allow GSO transmit from devices with no checksum offload") > Reported-by: syzbot+e15b7e15b8a751a91d9a@syzkaller.appspotmail.com > Closes: https://lore.kernel.org/all/000000000000e1609a061d5330ce@google.com/ > Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Reviewed-by: Willem de Bruijn <willemb@google.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH net v3 3/3] selftests/net: Add coverage for UDP GSO with IPv6 extension headers 2024-08-07 17:55 [PATCH net v3 0/3] Don't take HW USO path when packets can't be checksummed by device Jakub Sitnicki 2024-08-07 17:55 ` [PATCH net v3 1/3] net: Make USO depend on CSUM offload Jakub Sitnicki 2024-08-07 17:55 ` [PATCH net v3 2/3] udp: Fall back to software USO if IPv6 extension headers are present Jakub Sitnicki @ 2024-08-07 17:55 ` Jakub Sitnicki 2024-08-08 2:43 ` Willem de Bruijn 2 siblings, 1 reply; 8+ messages in thread From: Jakub Sitnicki @ 2024-08-07 17:55 UTC (permalink / raw) To: netdev Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn, kernel-team, Jakub Sitnicki After enabling UDP GSO for devices not offering checksum offload, we have hit a regression where a bad offload warning can be triggered when sending a datagram with IPv6 extension headers. Extend the UDP GSO IPv6 tests to cover this scenario. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> --- tools/testing/selftests/net/udpgso.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/udpgso.c b/tools/testing/selftests/net/udpgso.c index 3e74cfa1a2bf..3f2fca02fec5 100644 --- a/tools/testing/selftests/net/udpgso.c +++ b/tools/testing/selftests/net/udpgso.c @@ -67,6 +67,7 @@ struct testcase { int gso_len; /* mss after applying gso */ int r_num_mss; /* recv(): number of calls of full mss */ int r_len_last; /* recv(): size of last non-mss dgram, if any */ + bool v6_ext_hdr; /* send() dgrams with IPv6 extension headers */ }; const struct in6_addr addr6 = { @@ -77,6 +78,8 @@ const struct in_addr addr4 = { __constant_htonl(0x0a000001), /* 10.0.0.1 */ }; +static const char ipv6_hopopts_pad1[8] = { 0 }; + struct testcase testcases_v4[] = { { /* no GSO: send a single byte */ @@ -255,6 +258,13 @@ struct testcase testcases_v6[] = { .gso_len = 1, .r_num_mss = 2, }, + { + /* send 2 1B segments with extension headers */ + .tlen = 2, + .gso_len = 1, + .r_num_mss = 2, + .v6_ext_hdr = true, + }, { /* send 2B + 2B + 1B segments */ .tlen = 5, @@ -396,11 +406,18 @@ static void run_one(struct testcase *test, int fdt, int fdr, int i, ret, val, mss; bool sent; - fprintf(stderr, "ipv%d tx:%d gso:%d %s\n", + fprintf(stderr, "ipv%d tx:%d gso:%d %s%s\n", addr->sa_family == AF_INET ? 4 : 6, test->tlen, test->gso_len, + test->v6_ext_hdr ? "ext-hdr " : "", test->tfail ? "(fail)" : ""); + if (test->v6_ext_hdr) { + if (setsockopt(fdt, IPPROTO_IPV6, IPV6_HOPOPTS, + ipv6_hopopts_pad1, sizeof(ipv6_hopopts_pad1))) + error(1, errno, "setsockopt ipv6 hopopts"); + } + val = test->gso_len; if (cfg_do_setsockopt) { if (setsockopt(fdt, SOL_UDP, UDP_SEGMENT, &val, sizeof(val))) @@ -412,6 +429,12 @@ static void run_one(struct testcase *test, int fdt, int fdr, error(1, 0, "send succeeded while expecting failure"); if (!sent && !test->tfail) error(1, 0, "send failed while expecting success"); + + if (test->v6_ext_hdr) { + if (setsockopt(fdt, IPPROTO_IPV6, IPV6_HOPOPTS, NULL, 0)) + error(1, errno, "setsockopt ipv6 hopopts clear"); + } + if (!sent) return; -- 2.40.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH net v3 3/3] selftests/net: Add coverage for UDP GSO with IPv6 extension headers 2024-08-07 17:55 ` [PATCH net v3 3/3] selftests/net: Add coverage for UDP GSO with IPv6 extension headers Jakub Sitnicki @ 2024-08-08 2:43 ` Willem de Bruijn 0 siblings, 0 replies; 8+ messages in thread From: Willem de Bruijn @ 2024-08-08 2:43 UTC (permalink / raw) To: Jakub Sitnicki, netdev Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn, kernel-team, Jakub Sitnicki Jakub Sitnicki wrote: > After enabling UDP GSO for devices not offering checksum offload, we have > hit a regression where a bad offload warning can be triggered when sending > a datagram with IPv6 extension headers. > > Extend the UDP GSO IPv6 tests to cover this scenario. > > Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Reviewed-by: Willem de Bruijn <willemb@google.com> (Accidentally reviewed v2 for a second time. Meant to review this) ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-08-08 8:28 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-08-07 17:55 [PATCH net v3 0/3] Don't take HW USO path when packets can't be checksummed by device Jakub Sitnicki 2024-08-07 17:55 ` [PATCH net v3 1/3] net: Make USO depend on CSUM offload Jakub Sitnicki 2024-08-08 2:29 ` Willem de Bruijn 2024-08-08 8:28 ` Jakub Sitnicki 2024-08-07 17:55 ` [PATCH net v3 2/3] udp: Fall back to software USO if IPv6 extension headers are present Jakub Sitnicki 2024-08-08 2:29 ` Willem de Bruijn 2024-08-07 17:55 ` [PATCH net v3 3/3] selftests/net: Add coverage for UDP GSO with IPv6 extension headers Jakub Sitnicki 2024-08-08 2:43 ` Willem de Bruijn
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).