From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-25 17:25:15
This series improves the UDP L4 - either 'forward' or 'frag_list' -
co-existence with UDP tunnel GRO, allowing the first to take place
correctly even for encapsulated UDP traffic.
The first for patches are mostly bugfixes, addressing some GRO
edge-cases when both tunnels and L4 are present, enabled and in use.
The next 3 patches avoid unneeded segmentation when UDP GRO
traffic traverses in the receive path UDP tunnels.
Finally, some self-tests are included, covering the relevant
GRO scenarios.
Even if most patches are actually bugfixes, this series is
targeting net-next, as overall it makes available a new feature.
v1 -> v2:
- restrict post segmentation csum fixup to the only the relevant pkts
- use individual 'accept_gso_type' fields instead of whole gso bitmask
(Willem)
- use only ipv6 addesses from test range in self-tests (Willem)
- hopefully clarified most individual patches commit messages
Paolo Abeni (8):
udp: fixup csum for GSO receive slow path
udp: skip L4 aggregation for UDP tunnel packets
udp: properly complete L4 GRO over UDP tunnel packet
udp: never accept GSO_FRAGLIST packets
vxlan: allow L4 GRO passthrough
geneve: allow UDP L4 GRO passthrou
bareudp: allow UDP L4 GRO passthrou
selftests: net: add UDP GRO forwarding self-tests
drivers/net/bareudp.c | 1 +
drivers/net/geneve.c | 1 +
drivers/net/vxlan.c | 1 +
include/linux/udp.h | 22 +-
include/net/udp.h | 18 ++
net/ipv4/udp.c | 5 +
net/ipv4/udp_offload.c | 27 ++-
net/ipv6/udp.c | 1 +
net/ipv6/udp_offload.c | 3 +-
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/udpgro_fwd.sh | 251 ++++++++++++++++++++++
11 files changed, 318 insertions(+), 13 deletions(-)
create mode 100755 tools/testing/selftests/net/udpgro_fwd.sh
--
2.26.2
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-25 17:25:15
When UDP packets generated locally by a socket with UDP_SEGMENT
traverse the following path:
UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) ->
UDP tunnel (rx) -> UDP socket (no UDP_GRO)
they are segmented as part of the rx socket receive operation, and
present a CHECKSUM_NONE after segmentation.
Additionally the segmented packets UDP CB still refers to the original
GSO packet len. Overall that causes unexpected/wrong csum validation
errors later in the UDP receive path.
We could possibly address the issue with some additional checks and
csum mangling in the UDP tunnel code. Since the issue affects only
this UDP receive slow path, let's set a suitable csum status there.
v1 -> v2:
- restrict the csum update to the packets strictly needing them
- hopefully clarify the commit message and code comments
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
include/net/udp.h | 18 ++++++++++++++++++
net/ipv4/udp.c | 2 ++
net/ipv6/udp.c | 1 +
3 files changed, 21 insertions(+)
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Date: 2021-03-26 18:31:41
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
When UDP packets generated locally by a socket with UDP_SEGMENT
traverse the following path:
UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) ->
UDP tunnel (rx) -> UDP socket (no UDP_GRO)
they are segmented as part of the rx socket receive operation, and
present a CHECKSUM_NONE after segmentation.
would be good to capture how this happens, as it was not immediately obvious.
Additionally the segmented packets UDP CB still refers to the original
GSO packet len. Overall that causes unexpected/wrong csum validation
errors later in the UDP receive path.
We could possibly address the issue with some additional checks and
csum mangling in the UDP tunnel code. Since the issue affects only
this UDP receive slow path, let's set a suitable csum status there.
v1 -> v2:
- restrict the csum update to the packets strictly needing them
- hopefully clarify the commit message and code comments
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Not entirely obvious is that UDP packets arriving on a device with rx
checksum offload off, i.e., with CHECKSUM_NONE, are not matched by
this test.
I assume that such packets are not coalesced by the GRO layer in the
first place. But I can't immediately spot the reason for it..
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-29 11:26:33
On Fri, 2021-03-26 at 14:30 -0400, Willem de Bruijn wrote:
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
quoted
When UDP packets generated locally by a socket with UDP_SEGMENT
traverse the following path:
UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) ->
UDP tunnel (rx) -> UDP socket (no UDP_GRO)
they are segmented as part of the rx socket receive operation, and
present a CHECKSUM_NONE after segmentation.
would be good to capture how this happens, as it was not immediately obvious.
The CHECKSUM_PARTIAL is propagated up to the UDP tunnel processing,
where we have:
__iptunnel_pull_header() -> skb_pull_rcsum() ->
skb_postpull_rcsum() -> __skb_postpull_rcsum() and the latter do the
conversion.
quoted
Additionally the segmented packets UDP CB still refers to the original
GSO packet len. Overall that causes unexpected/wrong csum validation
errors later in the UDP receive path.
We could possibly address the issue with some additional checks and
csum mangling in the UDP tunnel code. Since the issue affects only
this UDP receive slow path, let's set a suitable csum status there.
v1 -> v2:
- restrict the csum update to the packets strictly needing them
- hopefully clarify the commit message and code comments
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+ if (skb->ip_summed == CHECKSUM_NONE && !skb->csum_valid)
+ skb->csum_valid = 1;
Not entirely obvious is that UDP packets arriving on a device with rx
checksum offload off, i.e., with CHECKSUM_NONE, are not matched by
this test.
I assume that such packets are not coalesced by the GRO layer in the
first place. But I can't immediately spot the reason for it..
Packets with CHECKSUM_NONE are actually aggregated by the GRO engine.
Their checksum is validated by:
udp4_gro_receive -> skb_gro_checksum_validate_zero_check()
-> __skb_gro_checksum_validate -> __skb_gro_checksum_validate_complete()
and skb->ip_summed is changed to CHECKSUM_UNNECESSARY by:
__skb_gro_checksum_validate -> skb_gro_incr_csum_unnecessary
-> __skb_incr_checksum_unnecessary()
and finally to CHECKSUM_PARTIAL by:
udp4_gro_complete() -> udp_gro_complete() -> udp_gro_complete_segment()
Do you prefer I resubmit with some more comments, either in the commit
message or in the code?
Thanks
Paolo
side note: perf probe here is fooled by skb->ip_summed being a bitfield
and does not dump the real value. I had to look at skb-
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Date: 2021-03-29 12:29:37
On Mon, Mar 29, 2021 at 7:26 AM Paolo Abeni [off-list ref] wrote:
On Fri, 2021-03-26 at 14:30 -0400, Willem de Bruijn wrote:
quoted
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
quoted
When UDP packets generated locally by a socket with UDP_SEGMENT
traverse the following path:
UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) ->
UDP tunnel (rx) -> UDP socket (no UDP_GRO)
they are segmented as part of the rx socket receive operation, and
present a CHECKSUM_NONE after segmentation.
would be good to capture how this happens, as it was not immediately obvious.
The CHECKSUM_PARTIAL is propagated up to the UDP tunnel processing,
where we have:
__iptunnel_pull_header() -> skb_pull_rcsum() ->
skb_postpull_rcsum() -> __skb_postpull_rcsum() and the latter do the
conversion.
Please capture this in the commit message.
quoted
quoted
Additionally the segmented packets UDP CB still refers to the original
GSO packet len. Overall that causes unexpected/wrong csum validation
errors later in the UDP receive path.
We could possibly address the issue with some additional checks and
csum mangling in the UDP tunnel code. Since the issue affects only
this UDP receive slow path, let's set a suitable csum status there.
v1 -> v2:
- restrict the csum update to the packets strictly needing them
- hopefully clarify the commit message and code comments
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+ if (skb->ip_summed == CHECKSUM_NONE && !skb->csum_valid)
+ skb->csum_valid = 1;
Not entirely obvious is that UDP packets arriving on a device with rx
checksum offload off, i.e., with CHECKSUM_NONE, are not matched by
this test.
I assume that such packets are not coalesced by the GRO layer in the
first place. But I can't immediately spot the reason for it..
Packets with CHECKSUM_NONE are actually aggregated by the GRO engine.
Their checksum is validated by:
udp4_gro_receive -> skb_gro_checksum_validate_zero_check()
-> __skb_gro_checksum_validate -> __skb_gro_checksum_validate_complete()
and skb->ip_summed is changed to CHECKSUM_UNNECESSARY by:
__skb_gro_checksum_validate -> skb_gro_incr_csum_unnecessary
-> __skb_incr_checksum_unnecessary()
and finally to CHECKSUM_PARTIAL by:
udp4_gro_complete() -> udp_gro_complete() -> udp_gro_complete_segment()
Do you prefer I resubmit with some more comments, either in the commit
message or in the code?
That breaks the checksum-and-copy optimization when delivering to
local sockets. I wonder if that is a regression.
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-29 13:25:45
On Mon, 2021-03-29 at 08:28 -0400, Willem de Bruijn wrote:
On Mon, Mar 29, 2021 at 7:26 AM Paolo Abeni [off-list ref] wrote:
quoted
On Fri, 2021-03-26 at 14:30 -0400, Willem de Bruijn wrote:
quoted
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
quoted
When UDP packets generated locally by a socket with UDP_SEGMENT
traverse the following path:
UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) ->
UDP tunnel (rx) -> UDP socket (no UDP_GRO)
they are segmented as part of the rx socket receive operation, and
present a CHECKSUM_NONE after segmentation.
would be good to capture how this happens, as it was not immediately obvious.
The CHECKSUM_PARTIAL is propagated up to the UDP tunnel processing,
where we have:
__iptunnel_pull_header() -> skb_pull_rcsum() ->
skb_postpull_rcsum() -> __skb_postpull_rcsum() and the latter do the
conversion.
Please capture this in the commit message.
I will do.
quoted
quoted
quoted
Additionally the segmented packets UDP CB still refers to the original
GSO packet len. Overall that causes unexpected/wrong csum validation
errors later in the UDP receive path.
We could possibly address the issue with some additional checks and
csum mangling in the UDP tunnel code. Since the issue affects only
this UDP receive slow path, let's set a suitable csum status there.
v1 -> v2:
- restrict the csum update to the packets strictly needing them
- hopefully clarify the commit message and code comments
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+ if (skb->ip_summed == CHECKSUM_NONE && !skb->csum_valid)
+ skb->csum_valid = 1;
Not entirely obvious is that UDP packets arriving on a device with rx
checksum offload off, i.e., with CHECKSUM_NONE, are not matched by
this test.
I assume that such packets are not coalesced by the GRO layer in the
first place. But I can't immediately spot the reason for it..
Packets with CHECKSUM_NONE are actually aggregated by the GRO engine.
Their checksum is validated by:
udp4_gro_receive -> skb_gro_checksum_validate_zero_check()
-> __skb_gro_checksum_validate -> __skb_gro_checksum_validate_complete()
and skb->ip_summed is changed to CHECKSUM_UNNECESSARY by:
__skb_gro_checksum_validate -> skb_gro_incr_csum_unnecessary
-> __skb_incr_checksum_unnecessary()
and finally to CHECKSUM_PARTIAL by:
udp4_gro_complete() -> udp_gro_complete() -> udp_gro_complete_segment()
Do you prefer I resubmit with some more comments, either in the commit
message or in the code?
That breaks the checksum-and-copy optimization when delivering to
local sockets. I wonder if that is a regression.
The conversion to CHECKSUM_UNNECESSARY happens since
commit 573e8fca255a27e3573b51f9b183d62641c47a3d.
Even the conversion to CHECKSUM_PARTIAL happens independently from this
series, since commit 6f1c0ea133a6e4a193a7b285efe209664caeea43.
I don't see a regression here ?!?
Thanks!
Paolo
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Date: 2021-03-29 13:54:05
quoted
quoted
quoted
quoted
Additionally the segmented packets UDP CB still refers to the original
GSO packet len. Overall that causes unexpected/wrong csum validation
errors later in the UDP receive path.
We could possibly address the issue with some additional checks and
csum mangling in the UDP tunnel code. Since the issue affects only
this UDP receive slow path, let's set a suitable csum status there.
v1 -> v2:
- restrict the csum update to the packets strictly needing them
- hopefully clarify the commit message and code comments
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+ if (skb->ip_summed == CHECKSUM_NONE && !skb->csum_valid)
+ skb->csum_valid = 1;
Not entirely obvious is that UDP packets arriving on a device with rx
checksum offload off, i.e., with CHECKSUM_NONE, are not matched by
this test.
I assume that such packets are not coalesced by the GRO layer in the
first place. But I can't immediately spot the reason for it..
Packets with CHECKSUM_NONE are actually aggregated by the GRO engine.
Their checksum is validated by:
udp4_gro_receive -> skb_gro_checksum_validate_zero_check()
-> __skb_gro_checksum_validate -> __skb_gro_checksum_validate_complete()
and skb->ip_summed is changed to CHECKSUM_UNNECESSARY by:
__skb_gro_checksum_validate -> skb_gro_incr_csum_unnecessary
-> __skb_incr_checksum_unnecessary()
and finally to CHECKSUM_PARTIAL by:
udp4_gro_complete() -> udp_gro_complete() -> udp_gro_complete_segment()
Do you prefer I resubmit with some more comments, either in the commit
message or in the code?
That breaks the checksum-and-copy optimization when delivering to
local sockets. I wonder if that is a regression.
The conversion to CHECKSUM_UNNECESSARY happens since
commit 573e8fca255a27e3573b51f9b183d62641c47a3d.
Even the conversion to CHECKSUM_PARTIAL happens independently from this
series, since commit 6f1c0ea133a6e4a193a7b285efe209664caeea43.
I don't see a regression here ?!?
I mean that UDP packets with local destination socket and no tunnels
that arrive with CHECKSUM_NONE normally benefit from the
checksum-and-copy optimization in recvmsg() when copying to user.
If those packets are now checksummed during GRO, that voids that
optimization, and the packet payload is now touched twice.
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-29 15:01:05
On Mon, 2021-03-29 at 09:52 -0400, Willem de Bruijn wrote:
quoted
quoted
That breaks the checksum-and-copy optimization when delivering to
local sockets. I wonder if that is a regression.
The conversion to CHECKSUM_UNNECESSARY happens since
commit 573e8fca255a27e3573b51f9b183d62641c47a3d.
Even the conversion to CHECKSUM_PARTIAL happens independently from this
series, since commit 6f1c0ea133a6e4a193a7b285efe209664caeea43.
I don't see a regression here ?!?
I mean that UDP packets with local destination socket and no tunnels
that arrive with CHECKSUM_NONE normally benefit from the
checksum-and-copy optimization in recvmsg() when copying to user.
If those packets are now checksummed during GRO, that voids that
optimization, and the packet payload is now touched twice.
The 'now' part confuses me. Nothing in this patch or this series
changes the processing of CHECKSUM_NONE UDP packets with no tunnel.
I do see checksum validation in the GRO engine for CHECKSUM_NONE UDP
packet prior to this series.
I *think* the checksum-and-copy optimization is lost
since 573e8fca255a27e3573b51f9b183d62641c47a3d.
Regards,
Paolo
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Date: 2021-03-29 15:26:09
On Mon, Mar 29, 2021 at 11:01 AM Paolo Abeni [off-list ref] wrote:
On Mon, 2021-03-29 at 09:52 -0400, Willem de Bruijn wrote:
quoted
quoted
quoted
That breaks the checksum-and-copy optimization when delivering to
local sockets. I wonder if that is a regression.
The conversion to CHECKSUM_UNNECESSARY happens since
commit 573e8fca255a27e3573b51f9b183d62641c47a3d.
Even the conversion to CHECKSUM_PARTIAL happens independently from this
series, since commit 6f1c0ea133a6e4a193a7b285efe209664caeea43.
I don't see a regression here ?!?
I mean that UDP packets with local destination socket and no tunnels
that arrive with CHECKSUM_NONE normally benefit from the
checksum-and-copy optimization in recvmsg() when copying to user.
If those packets are now checksummed during GRO, that voids that
optimization, and the packet payload is now touched twice.
The 'now' part confuses me. Nothing in this patch or this series
changes the processing of CHECKSUM_NONE UDP packets with no tunnel.
Agreed. I did not mean to imply that this patch changes that. I was
responding to
Not entirely obvious is that UDP packets arriving on a device with rx
checksum offload off, i.e., with CHECKSUM_NONE, are not matched by
this test.
I assume that such packets are not coalesced by the GRO layer in the
first place. But I can't immediately spot the reason for it..
As you point out, such packets will already have had their checksum
verified at this point, so this branch only matches tunneled packets.
That point is just not immediately obvious from the code.
I do see checksum validation in the GRO engine for CHECKSUM_NONE UDP
packet prior to this series.
I *think* the checksum-and-copy optimization is lost
since 573e8fca255a27e3573b51f9b183d62641c47a3d.
Not entirely obvious is that UDP packets arriving on a device with rx
checksum offload off, i.e., with CHECKSUM_NONE, are not matched by
this test.
I assume that such packets are not coalesced by the GRO layer in the
first place. But I can't immediately spot the reason for it..
As you point out, such packets will already have had their checksum
verified at this point, so this branch only matches tunneled packets.
That point is just not immediately obvious from the code.
I understand is a matter of comment clarity ?!?
I'll rewrite the related code comment - in udp_post_segment_fix_csum()
- as:
/* UDP packets generated with UDP_SEGMENT and traversing:
*
* UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) -> UDP tunnel (rx)
*
* land here with CHECKSUM_NONE, because __iptunnel_pull_header() converts
* CHECKSUM_PARTIAL into NONE.
* SKB_GSO_UDP_L4 or SKB_GSO_FRAGLIST packets with no UDP tunnel will land
* here with valid checksum, as the GRO engine validates the UDP csum
* before the aggregation and nobody strips such info in between.
* Instead of adding another check in the tunnel fastpath, we can force
* a valid csum here.
* Additionally fixup the UDP CB.
*/
Would that be clear enough?
quoted
I do see checksum validation in the GRO engine for CHECKSUM_NONE UDP
packet prior to this series.
I *think* the checksum-and-copy optimization is lost
since 573e8fca255a27e3573b51f9b183d62641c47a3d.
Wouldn't this have been introduced with UDP_GRO?
Uhmm.... looks like the checksum-and-copy optimization has been lost
and recovered a few times. I think the last one
with 9fd1ff5d2ac7181844735806b0a703c942365291, which move the csum
validation before the static branch on udp_encap_needed_key.
Can we agree re-introducing the optimization is independent from this
series?
Thanks!
Paolo
Not entirely obvious is that UDP packets arriving on a device with rx
checksum offload off, i.e., with CHECKSUM_NONE, are not matched by
this test.
I assume that such packets are not coalesced by the GRO layer in the
first place. But I can't immediately spot the reason for it..
As you point out, such packets will already have had their checksum
verified at this point, so this branch only matches tunneled packets.
That point is just not immediately obvious from the code.
I understand is a matter of comment clarity ?!?
I'll rewrite the related code comment - in udp_post_segment_fix_csum()
- as:
/* UDP packets generated with UDP_SEGMENT and traversing:
*
* UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) -> UDP tunnel (rx)
*
* land here with CHECKSUM_NONE, because __iptunnel_pull_header() converts
* CHECKSUM_PARTIAL into NONE.
* SKB_GSO_UDP_L4 or SKB_GSO_FRAGLIST packets with no UDP tunnel will land
* here with valid checksum, as the GRO engine validates the UDP csum
* before the aggregation and nobody strips such info in between.
* Instead of adding another check in the tunnel fastpath, we can force
* a valid csum here.
* Additionally fixup the UDP CB.
*/
Would that be clear enough?
Definitely. Thanks!
quoted
quoted
I do see checksum validation in the GRO engine for CHECKSUM_NONE UDP
packet prior to this series.
I *think* the checksum-and-copy optimization is lost
since 573e8fca255a27e3573b51f9b183d62641c47a3d.
Wouldn't this have been introduced with UDP_GRO?
Uhmm.... looks like the checksum-and-copy optimization has been lost
and recovered a few times. I think the last one
with 9fd1ff5d2ac7181844735806b0a703c942365291, which move the csum
validation before the static branch on udp_encap_needed_key.
Can we agree re-introducing the optimization is independent from this
series?
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-25 17:25:16
Currently the UDP protocol delivers GSO_FRAGLIST packets to
the sockets without the expected segmentation.
This change addresses the issue introducing and maintaining
a couple of new fields to explicitly accept SKB_GSO_UDP_L4
or GSO_FRAGLIST packets. Additionally updates udp_unexpected_gso()
accordingly.
UDP sockets enabling UDP_GRO stil keep accept_udp_fraglist
zeroed.
v1 -> v2:
- use 2 bits instead of a whole GSO bitmask (Willem)
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
include/linux/udp.h | 16 +++++++++++++---
net/ipv4/udp.c | 3 +++
2 files changed, 16 insertions(+), 3 deletions(-)
@@ -2666,9 +2666,12 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,caseUDP_GRO:lock_sock(sk);++/* when enabling GRO, accept the related GSO packet type */if(valbool)udp_tunnel_encap_enable(sk->sk_socket);up->gro_enabled=valbool;+up->accept_udp_l4=valbool;release_sock(sk);break;
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Date: 2021-03-26 18:16:57
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
Currently the UDP protocol delivers GSO_FRAGLIST packets to
the sockets without the expected segmentation.
This change addresses the issue introducing and maintaining
a couple of new fields to explicitly accept SKB_GSO_UDP_L4
or GSO_FRAGLIST packets. Additionally updates udp_unexpected_gso()
accordingly.
UDP sockets enabling UDP_GRO stil keep accept_udp_fraglist
zeroed.
v1 -> v2:
- use 2 bits instead of a whole GSO bitmask (Willem)
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This looks good to me in principle, thanks for the revision.
I hadn't fully appreciated that gro_enabled implies accept_udp_l4, but
not necessarily vice versa.
It is equivalent to (accept_udp_l4 && !up->gro_receive), right?
Could the extra bit be avoided with
"
+ /* Prefer fraglist GRO unless target is a socket with UDP_GRO,
+ * which requires all but last segments to be of same gso_size,
passed in cmsg */
if (skb->dev->features & NETIF_F_GRO_FRAGLIST)
- NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled: 1;
+ NAPI_GRO_CB(skb)->is_flist = sk ?
(!udp_sk(sk)->gro_enabled || udp_sk(sk)->accept_udp_fraglist) : 1;
+ /* Apply transport layer GRO if forwarding is enabled or the
flow lands at a local socket */
if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) ||
NAPI_GRO_CB(skb)->is_flist) {
pp = call_gro_receive(udp_gro_receive_segment, head, skb);
return pp;
}
+ /* Continue with tunnel GRO */
"
.. not that the extra bit matters a lot. And these two conditions with
gro_enabled are not very obvious.
Just a thought.
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-29 08:13:35
On Fri, 2021-03-26 at 14:15 -0400, Willem de Bruijn wrote:
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
quoted
Currently the UDP protocol delivers GSO_FRAGLIST packets to
the sockets without the expected segmentation.
This change addresses the issue introducing and maintaining
a couple of new fields to explicitly accept SKB_GSO_UDP_L4
or GSO_FRAGLIST packets. Additionally updates udp_unexpected_gso()
accordingly.
UDP sockets enabling UDP_GRO stil keep accept_udp_fraglist
zeroed.
v1 -> v2:
- use 2 bits instead of a whole GSO bitmask (Willem)
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This looks good to me in principle, thanks for the revision.
I hadn't fully appreciated that gro_enabled implies accept_udp_l4, but
not necessarily vice versa.
It is equivalent to (accept_udp_l4 && !up->gro_receive), right?
In this series, yes.
Could the extra bit be avoided with
"
+ /* Prefer fraglist GRO unless target is a socket with UDP_GRO,
+ * which requires all but last segments to be of same gso_size,
passed in cmsg */
if (skb->dev->features & NETIF_F_GRO_FRAGLIST)
- NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled: 1;
+ NAPI_GRO_CB(skb)->is_flist = sk ?
(!udp_sk(sk)->gro_enabled || udp_sk(sk)->accept_udp_fraglist) : 1;
This is not ovious at all to me.
+ /* Apply transport layer GRO if forwarding is enabled or the
flow lands at a local socket */
if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) ||
NAPI_GRO_CB(skb)->is_flist) {
pp = call_gro_receive(udp_gro_receive_segment, head, skb);
return pp;
}
+ /* Continue with tunnel GRO */
"
.. not that the extra bit matters a lot. And these two conditions with
gro_enabled are not very obvious.
Just a thought.
Overall looks more complex to me. I would keep the extra bit, unless
you have strong opinion.
Side note: I was wondering about a follow-up to simplify the condition:
if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) || NAPI_GRO_CB(skb)->is_flist) {
Since UDP sockets could process (segmenting as needed) unexpected GSO
packets, we could always do 'NETIF_F_GRO_UDP_FWD', when enabled on the
device level. The above becomes:
if (skb->dev->features & NETIF_F_GRO_UDP_FWD) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) ||
NAPI_GRO_CB(skb)->is_flist) {
which is hopefully more clear (and simpler). As said, non for this
series anyhow.
Thanks,
Paolo
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Date: 2021-03-29 12:32:49
On Mon, Mar 29, 2021 at 4:14 AM Paolo Abeni [off-list ref] wrote:
On Fri, 2021-03-26 at 14:15 -0400, Willem de Bruijn wrote:
quoted
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
quoted
Currently the UDP protocol delivers GSO_FRAGLIST packets to
the sockets without the expected segmentation.
This change addresses the issue introducing and maintaining
a couple of new fields to explicitly accept SKB_GSO_UDP_L4
or GSO_FRAGLIST packets. Additionally updates udp_unexpected_gso()
accordingly.
UDP sockets enabling UDP_GRO stil keep accept_udp_fraglist
zeroed.
v1 -> v2:
- use 2 bits instead of a whole GSO bitmask (Willem)
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This looks good to me in principle, thanks for the revision.
I hadn't fully appreciated that gro_enabled implies accept_udp_l4, but
not necessarily vice versa.
It is equivalent to (accept_udp_l4 && !up->gro_receive), right?
In this series, yes.
quoted
Could the extra bit be avoided with
"
+ /* Prefer fraglist GRO unless target is a socket with UDP_GRO,
+ * which requires all but last segments to be of same gso_size,
passed in cmsg */
if (skb->dev->features & NETIF_F_GRO_FRAGLIST)
- NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled: 1;
+ NAPI_GRO_CB(skb)->is_flist = sk ?
(!udp_sk(sk)->gro_enabled || udp_sk(sk)->accept_udp_fraglist) : 1;
This is not ovious at all to me.
quoted
+ /* Apply transport layer GRO if forwarding is enabled or the
flow lands at a local socket */
if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) ||
NAPI_GRO_CB(skb)->is_flist) {
pp = call_gro_receive(udp_gro_receive_segment, head, skb);
return pp;
}
+ /* Continue with tunnel GRO */
"
.. not that the extra bit matters a lot. And these two conditions with
gro_enabled are not very obvious.
Just a thought.
Overall looks more complex to me. I would keep the extra bit, unless
you have strong opinion.
Sounds good.
Side note: I was wondering about a follow-up to simplify the condition:
if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) || NAPI_GRO_CB(skb)->is_flist) {
Since UDP sockets could process (segmenting as needed) unexpected GSO
packets, we could always do 'NETIF_F_GRO_UDP_FWD', when enabled on the
device level. The above becomes:
if (skb->dev->features & NETIF_F_GRO_UDP_FWD) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) ||
NAPI_GRO_CB(skb)->is_flist) {
which is hopefully more clear (and simpler). As said, non for this
series anyhow.
UDP sockets can segment, but it is expensive. In this case I think the
simplification is not worth the possible regression.
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-29 13:31:05
On Mon, 2021-03-29 at 08:31 -0400, Willem de Bruijn wrote:
On Mon, Mar 29, 2021 at 4:14 AM Paolo Abeni [off-list ref] wrote:
quoted
On Fri, 2021-03-26 at 14:15 -0400, Willem de Bruijn wrote:
quoted
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
quoted
Currently the UDP protocol delivers GSO_FRAGLIST packets to
the sockets without the expected segmentation.
This change addresses the issue introducing and maintaining
a couple of new fields to explicitly accept SKB_GSO_UDP_L4
or GSO_FRAGLIST packets. Additionally updates udp_unexpected_gso()
accordingly.
UDP sockets enabling UDP_GRO stil keep accept_udp_fraglist
zeroed.
v1 -> v2:
- use 2 bits instead of a whole GSO bitmask (Willem)
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This looks good to me in principle, thanks for the revision.
I hadn't fully appreciated that gro_enabled implies accept_udp_l4, but
not necessarily vice versa.
It is equivalent to (accept_udp_l4 && !up->gro_receive), right?
In this series, yes.
quoted
Could the extra bit be avoided with
"
+ /* Prefer fraglist GRO unless target is a socket with UDP_GRO,
+ * which requires all but last segments to be of same gso_size,
passed in cmsg */
if (skb->dev->features & NETIF_F_GRO_FRAGLIST)
- NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled: 1;
+ NAPI_GRO_CB(skb)->is_flist = sk ?
(!udp_sk(sk)->gro_enabled || udp_sk(sk)->accept_udp_fraglist) : 1;
This is not ovious at all to me.
quoted
+ /* Apply transport layer GRO if forwarding is enabled or the
flow lands at a local socket */
if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) ||
NAPI_GRO_CB(skb)->is_flist) {
pp = call_gro_receive(udp_gro_receive_segment, head, skb);
return pp;
}
+ /* Continue with tunnel GRO */
"
.. not that the extra bit matters a lot. And these two conditions with
gro_enabled are not very obvious.
Just a thought.
Overall looks more complex to me. I would keep the extra bit, unless
you have strong opinion.
Sounds good.
quoted
Side note: I was wondering about a follow-up to simplify the condition:
if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) || NAPI_GRO_CB(skb)->is_flist) {
Since UDP sockets could process (segmenting as needed) unexpected GSO
packets, we could always do 'NETIF_F_GRO_UDP_FWD', when enabled on the
device level. The above becomes:
if (skb->dev->features & NETIF_F_GRO_UDP_FWD) ||
(sk && udp_sk(sk)->gro_enabled && !up->encap_rcv) ||
NAPI_GRO_CB(skb)->is_flist) {
which is hopefully more clear (and simpler). As said, non for this
series anyhow.
UDP sockets can segment, but it is expensive. In this case I think the
simplification is not worth the possible regression.
No strong opinion here, I will not do the thing mentioned above.
Thanks!
Paolo
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-25 17:25:16
If NETIF_F_GRO_FRAGLIST or NETIF_F_GRO_UDP_FWD are enabled, and there
are UDP tunnels available in the system, udp_gro_receive() could end-up
doing L4 aggregation (either SKB_GSO_UDP_L4 or SKB_GSO_FRAGLIST) at
the outer UDP tunnel level for packets effectively carrying and UDP
tunnel header.
That could cause inner protocol corruption. If e.g. the relevant
packets carry a vxlan header, different vxlan ids will be ignored/
aggregated to the same GSO packet. Inner headers will be ignored, too,
so that e.g. TCP over vxlan push packets will be held in the GRO
engine till the next flush, etc.
Just skip the SKB_GSO_UDP_L4 and SKB_GSO_FRAGLIST code path if the
current packet could land in a UDP tunnel, and let udp_gro_receive()
do GRO via udp_sk(sk)->gro_receive.
The check implemented in this patch is broader than what is strictly
needed, as the existing UDP tunnel could be e.g. configured on top of
a different device: we could end-up skipping GRO at-all for some packets.
Anyhow, the latter is a very thin corner case and covering it would add
quite a bit of complexity.
v1 -> v2:
- hopefully clarify the commit message
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Fixes: 36707061d6ba ("udp: allow forwarding of plain (non-fraglisted) UDP GRO packets")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
net/ipv4/udp_offload.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
@@ -515,21 +515,24 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,unsignedintoff=skb_gro_offset(skb);intflush=1;+/* we can do L4 aggregation only if the packet can't land in a tunnel+*otherwisewecouldcorrupttheinnerstream+*/NAPI_GRO_CB(skb)->is_flist=0;-if(skb->dev->features&NETIF_F_GRO_FRAGLIST)-NAPI_GRO_CB(skb)->is_flist=sk?!udp_sk(sk)->gro_enabled:1;+if(!sk||!udp_sk(sk)->gro_receive){+if(skb->dev->features&NETIF_F_GRO_FRAGLIST)+NAPI_GRO_CB(skb)->is_flist=sk?!udp_sk(sk)->gro_enabled:1;-if((!sk&&(skb->dev->features&NETIF_F_GRO_UDP_FWD))||-(sk&&udp_sk(sk)->gro_enabled)||NAPI_GRO_CB(skb)->is_flist){-pp=call_gro_receive(udp_gro_receive_segment,head,skb);+if((!sk&&(skb->dev->features&NETIF_F_GRO_UDP_FWD))||+(sk&&udp_sk(sk)->gro_enabled)||NAPI_GRO_CB(skb)->is_flist)+pp=call_gro_receive(udp_gro_receive_segment,head,skb);returnpp;}-if(!sk||NAPI_GRO_CB(skb)->encap_mark||+if(NAPI_GRO_CB(skb)->encap_mark||(uh->check&&skb->ip_summed!=CHECKSUM_PARTIAL&&NAPI_GRO_CB(skb)->csum_cnt==0&&-!NAPI_GRO_CB(skb)->csum_valid)||-!udp_sk(sk)->gro_receive)+!NAPI_GRO_CB(skb)->csum_valid))gotoout;/* mark that this skb passed once through the tunnel gro layer */
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Date: 2021-03-26 18:25:10
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
If NETIF_F_GRO_FRAGLIST or NETIF_F_GRO_UDP_FWD are enabled, and there
are UDP tunnels available in the system, udp_gro_receive() could end-up
doing L4 aggregation (either SKB_GSO_UDP_L4 or SKB_GSO_FRAGLIST) at
the outer UDP tunnel level for packets effectively carrying and UDP
tunnel header.
That could cause inner protocol corruption. If e.g. the relevant
packets carry a vxlan header, different vxlan ids will be ignored/
aggregated to the same GSO packet. Inner headers will be ignored, too,
so that e.g. TCP over vxlan push packets will be held in the GRO
engine till the next flush, etc.
Just skip the SKB_GSO_UDP_L4 and SKB_GSO_FRAGLIST code path if the
current packet could land in a UDP tunnel, and let udp_gro_receive()
do GRO via udp_sk(sk)->gro_receive.
The check implemented in this patch is broader than what is strictly
needed, as the existing UDP tunnel could be e.g. configured on top of
a different device: we could end-up skipping GRO at-all for some packets.
Anyhow, the latter is a very thin corner case and covering it would add
quite a bit of complexity.
v1 -> v2:
- hopefully clarify the commit message
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Fixes: 36707061d6ba ("udp: allow forwarding of plain (non-fraglisted) UDP GRO packets")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Key is that udp tunnel GRO must take precedence over transport GRO,
but the way the code is structured, the latter is tried first.
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-25 17:25:16
After the previous patch, the stack can do L4 UDP aggregation
on top of a UDP tunnel.
In such scenario, udp{4,6}_gro_complete will be called twice. This function
will enter its is_flist branch immediately, even though that is only
correct on the second call, as GSO_FRAGLIST is only relevant for the
inner packet.
Instead, we need to try first UDP tunnel-based aggregation, if the GRO
packet requires that.
This patch changes udp{4,6}_gro_complete to skip the frag list processing
when while encap_mark == 1, identifying processing of the outer tunnel
header.
Additionally, clears the field in udp_gro_complete() so that we can enter
the frag list path on the next round, for the inner header.
v1 -> v2:
- hopefully clarified the commit message
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
net/ipv4/udp_offload.c | 8 +++++++-
net/ipv6/udp_offload.c | 3 ++-
2 files changed, 9 insertions(+), 2 deletions(-)
@@ -642,6 +642,11 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff,skb_shinfo(skb)->gso_type=uh->check?SKB_GSO_UDP_TUNNEL_CSUM:SKB_GSO_UDP_TUNNEL;+/* clear the encap mark, so that inner frag_list gro_complete+*cantakeplace+*/+NAPI_GRO_CB(skb)->encap_mark=0;+/* Set encapsulation before calling into inner gro_complete()*functionstomakethemsetuptheinneroffsets.*/
@@ -665,7 +670,8 @@ INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff)conststructiphdr*iph=ip_hdr(skb);structudphdr*uh=(structudphdr*)(skb->data+nhoff);-if(NAPI_GRO_CB(skb)->is_flist){+/* do fraglist only if there is no outer UDP encap (or we already processed it) */+if(NAPI_GRO_CB(skb)->is_flist&&!NAPI_GRO_CB(skb)->encap_mark){uh->len=htons(skb->len-nhoff);skb_shinfo(skb)->gso_type|=(SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4);
@@ -163,7 +163,8 @@ INDIRECT_CALLABLE_SCOPE int udp6_gro_complete(struct sk_buff *skb, int nhoff)conststructipv6hdr*ipv6h=ipv6_hdr(skb);structudphdr*uh=(structudphdr*)(skb->data+nhoff);-if(NAPI_GRO_CB(skb)->is_flist){+/* do fraglist only if there is no outer UDP encap (or we already processed it) */+if(NAPI_GRO_CB(skb)->is_flist&&!NAPI_GRO_CB(skb)->encap_mark){uh->len=htons(skb->len-nhoff);skb_shinfo(skb)->gso_type|=(SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4);
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com> Date: 2021-03-26 17:53:16
On Thu, Mar 25, 2021 at 1:24 PM Paolo Abeni [off-list ref] wrote:
After the previous patch, the stack can do L4 UDP aggregation
on top of a UDP tunnel.
In such scenario, udp{4,6}_gro_complete will be called twice. This function
will enter its is_flist branch immediately, even though that is only
correct on the second call, as GSO_FRAGLIST is only relevant for the
inner packet.
Instead, we need to try first UDP tunnel-based aggregation, if the GRO
packet requires that.
This patch changes udp{4,6}_gro_complete to skip the frag list processing
when while encap_mark == 1, identifying processing of the outer tunnel
header.
Additionally, clears the field in udp_gro_complete() so that we can enter
the frag list path on the next round, for the inner header.
v1 -> v2:
- hopefully clarified the commit message
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-25 17:25:48
Similar to the previous commit, let even geneve
passthrou the L4 GRO packets
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
drivers/net/bareudp.c | 1 +
1 file changed, 1 insertion(+)
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-25 17:25:48
When passing up an UDP GSO packet with L4 aggregation, there is
no need to segment it at the vxlan level. We can propagate the
packet untouched and let it be segmented later, if needed.
Introduce an helper to allow let the UDP socket to accept any
L4 aggregation and use it in the vxlan driver.
v1 -> v2:
- updated to use the newly introduced UDP socket 'accept*' fields
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
drivers/net/vxlan.c | 1 +
include/linux/udp.h | 6 ++++++
2 files changed, 7 insertions(+)
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-25 17:25:49
Create a bunch of virtual topologies and verify that
NETIF_F_GRO_FRAGLIST or NETIF_F_GRO_UDP_FWD-enabled
devices aggregate the ingress packets as expected.
Additionally check that the aggregate packets are
segmented correctly when landing on a socket
Also test SKB_GSO_FRAGLIST and SKB_GSO_UDP_L4 aggregation
on top of UDP tunnel (vxlan)
v1 -> v2:
- hopefully clarify the commit message
- moved the overlay network ipv6 range into the 'documentation'
reserved range (Willem)
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/udpgro_fwd.sh | 251 ++++++++++++++++++++++
2 files changed, 252 insertions(+)
create mode 100755 tools/testing/selftests/net/udpgro_fwd.sh
@@ -0,0 +1,251 @@+#!/bin/sh+# SPDX-License-Identifier: GPL-2.0++readonlyBASE="ns-$(mktemp-uXXXXXX)"+readonlySRC=2+readonlyDST=1+readonlyDST_NAT=100+readonlyNS_SRC=$BASE$SRC+readonlyNS_DST=$BASE$DST++# "baremetal" network used for raw UDP traffic+readonlyBM_NET_V4=192.168.1.+readonlyBM_NET_V6=2001:db8::++# "overlay" network used for UDP over UDP tunnel traffic+readonlyOL_NET_V4=172.16.1.+readonlyOL_NET_V6=2001:db8:1::+readonlyNPROCS=`nproc`++cleanup(){+localns+local-rjobs="$(jobs-p)"+[-n"${jobs}"]&&kill-1${jobs}2>/dev/null++fornsin$NS_SRC$NS_DST;do+ipnetnsdel$ns2>/dev/null+done+}++trapcleanupEXIT++create_ns(){+localnet+localns++fornsin$NS_SRC$NS_DST;do+ipnetnsadd$ns+ip-n$nslinksetdevloup+done++iplinkaddnameveth$SRCtypevethpeernameveth$DST++fornsin$SRC$DST;do+iplinksetdevveth$nsnetns$BASE$ns+ip-n$BASE$nslinksetdevveth$nsup+ip-n$BASE$nsaddradddevveth$ns$BM_NET_V4$ns/24+ip-n$BASE$nsaddradddevveth$ns$BM_NET_V6$ns/64nodad+done+ip-n$NS_DSTlinksetveth$DSTxdpobject../bpf/xdp_dummy.osectionxdp_dummy2>/dev/null+}++create_vxlan_endpoint(){+local-rnetns=$1+local-rbm_dev=$2+local-rbm_rem_addr=$3+local-rvxlan_dev=$4+local-rvxlan_id=$5+local-rvxlan_port=4789++ip-n$netnslinksetdev$bm_devup+ip-n$netnslinkadddev$vxlan_devtypevxlanid$vxlan_id\+dstport$vxlan_portremote$bm_rem_addr+ip-n$netnslinksetdev$vxlan_devup+}++create_vxlan_pair(){+localns++create_ns++fornsin$SRC$DST;do+# note that 3 - $SRC == $DST and 3 - $DST == $SRC+create_vxlan_endpoint$BASE$nsveth$ns$BM_NET_V4$((3-$ns))vxlan$ns4+ip-n$BASE$nsaddradddevvxlan$ns$OL_NET_V4$ns/24+done+fornsin$SRC$DST;do+create_vxlan_endpoint$BASE$nsveth$ns$BM_NET_V6$((3-$ns))vxlan6$ns6+ip-n$BASE$nsaddradddevvxlan6$ns$OL_NET_V6$ns/24nodad+done+}++is_ipv6(){+if[[$1=~.*:.*]];then+return0+fi+return1+}++run_test(){+local-rmsg=$1+local-rdst=$2+local-rpkts=$3+local-rvxpkts=$4+localbind=$5+localrx_args=""+localrx_family="-4"+localfamily=-4+localfilter=IpInReceives+localipt=iptables++printf"%-40s""$msg"++ifis_ipv6$dst;then+# rx program does not support '-6' and implies ipv6 usage by default+rx_family=""+family=-6+filter=Ip6InReceives+ipt=ip6tables+fi++rx_args="$rx_family"+[-n"$bind"]&&rx_args="$rx_args -b $bind"++# send a single GSO packet, segmented in 10 UDP frames.+# Always expect 10 UDP frames on RX side as rx socket does+# not enable GRO+ipnetnsexec$NS_DST$ipt-AINPUT-pudp--dport4789+ipnetnsexec$NS_DST$ipt-AINPUT-pudp--dport8000+ipnetnsexec$NS_DST./udpgso_bench_rx-C1000-R10-n10-l1300$rx_args&+localspid=$!+sleep0.1+ipnetnsexec$NS_SRC./udpgso_bench_tx$family-M1-s13000-S1300-D$dst+localretc=$?+wait$spid+localrets=$?+if[${rets}-ne0]||[${retc}-ne0];then+echo" fail client exit code $retc, server $rets"+ret=1+return+fi++localrcv=`ipnetnsexec$NS_DST$ipt"-save"-c|grep'dport 8000'|\+sed-e's/\[//'-e's/:.*//'`+if[$rcv!=$pkts];then+echo" fail - received $rvs packets, expected $pkts"+ret=1+return+fi++localvxrcv=`ipnetnsexec$NS_DST$ipt"-save"-c|grep'dport 4789'|\+sed-e's/\[//'-e's/:.*//'`++# upper net can generate a little noise, allow some tolerance+if[$vxrcv-lt$vxpkts-o$vxrcv-gt$((vxpkts+3))];then+echo" fail - received $vxrcv vxlan packets, expected $vxpkts"+ret=1+return+fi+echo" ok"+}++run_bench(){+local-rmsg=$1+local-rdst=$2+localfamily=-4++printf"%-40s""$msg"+if[$NPROCS-lt2];then+echo" skip - needed 2 CPUs found $NPROCS"+return+fi++is_ipv6$dst&&family=-6++# bind the sender and the receiver to different CPUs to try+# get reproducible results+ipnetnsexec$NS_DSTbash-c"echo 2 > /sys/class/net/veth$DST/queues/rx-0/rps_cpus"+ipnetnsexec$NS_DSTtaskset0x2./udpgso_bench_rx-C1000-R10&+localspid=$!+sleep0.1+ipnetnsexec$NS_SRCtaskset0x1./udpgso_bench_tx$family-l3-S1300-D$dst+localretc=$?+wait$spid+localrets=$?+if[${rets}-ne0]||[${retc}-ne0];then+echo" fail client exit code $retc, server $rets"+ret=1+return+fi+}++forfamilyin46;do+BM_NET=$BM_NET_V4+OL_NET=$OL_NET_V4+IPT=iptables+SUFFIX=24+VXDEV=vxlan++if[$family=6];then+BM_NET=$BM_NET_V6+OL_NET=$OL_NET_V6+SUFFIX="64 nodad"+VXDEV=vxlan6+IPT=ip6tables+fi++echo"IPv$family"++create_ns+run_test"No GRO"$BM_NET$DST100+cleanup++create_ns+ipnetnsexec$NS_DSTethtool-Kveth$DSTrx-gro-liston+run_test"GRO frag list"$BM_NET$DST10+cleanup++# UDP GRO fwd skips aggregation when find an udp socket with the GRO option+# if there is an UDP tunnel in the running system, such lookup happen+# take place.+# use NAT to circumvent GRO FWD check+create_ns+ip-n$NS_DSTaddradddevveth$DST$BM_NET$DST_NAT/$SUFFIX+ipnetnsexec$NS_DSTethtool-Kveth$DSTrx-udp-gro-forwardingon+ipnetnsexec$NS_DST$IPT-tnat-IPREROUTING-d$BM_NET$DST_NAT\+-jDNAT--to-destination$BM_NET$DST+run_test"GRO fwd"$BM_NET$DST_NAT10$BM_NET$DST+cleanup++create_ns+run_bench"UDP fwd perf"$BM_NET$DST+ipnetnsexec$NS_DSTethtool-Kveth$DSTrx-udp-gro-forwardingon+run_bench"UDP GRO fwd perf"$BM_NET$DST+cleanup++create_vxlan_pair+ipnetnsexec$NS_DSTethtool-Kveth$DSTrx-gro-liston+run_test"GRO frag list over UDP tunnel"$OL_NET$DST11+cleanup++# use NAT to circumvent GRO FWD check+create_vxlan_pair+ip-n$NS_DSTaddradddev$VXDEV$DST$OL_NET$DST_NAT/$SUFFIX+ipnetnsexec$NS_DSTethtool-Kveth$DSTrx-udp-gro-forwardingon+ipnetnsexec$NS_DST$IPT-tnat-IPREROUTING-d$OL_NET$DST_NAT\+-jDNAT--to-destination$OL_NET$DST++# load arp cache before running the test to reduce the amount of+# stray traffic on top of the UDP tunnel+ipnetnsexec$NS_SRCping-q-c1$OL_NET$DST_NAT>/dev/null+run_test"GRO fwd over UDP tunnel"$OL_NET$DST_NAT11$OL_NET$DST+cleanup++create_vxlan_pair+run_bench"UDP tunnel fwd perf"$OL_NET$DST+ipnetnsexec$NS_DSTethtool-Kveth$DSTrx-udp-gro-forwardingon+run_bench"UDP tunnel GRO fwd perf"$OL_NET$DST+cleanup+done++exit$ret
From: Paolo Abeni <pabeni@redhat.com> Date: 2021-03-25 17:25:49
Similar to the previous commit, let even geneve
passthrou the L4 GRO packets
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
drivers/net/geneve.c | 1 +
1 file changed, 1 insertion(+)