From: Dongseok Yi <hidden> Date: 2021-01-15 06:11:46
UDP/IP header of UDP GROed frag_skbs are not updated even after NAT
forwarding. Only the header of head_skb from ip_finish_output_gso ->
skb_gso_segment is updated but following frag_skbs are not updated.
A call path skb_mac_gso_segment -> inet_gso_segment ->
udp4_ufo_fragment -> __udp_gso_segment -> __udp_gso_segment_list
does not try to update UDP/IP header of the segment list.
Update dport, daddr and checksums of each skb of the segment list
after __udp_gso_segment.
Fixes: 9fd1ff5d2ac7 (udp: Support UDP fraglist GRO/GSO.)
Signed-off-by: Dongseok Yi <redacted>
---
Steffen Klassert said, there could be 2 options.
https://lore.kernel.org/patchwork/patch/1362257/
I was trying to write a quick fix, but it was not easy to forward
segmented list. Currently, assuming DNAT only. Should we consider
SNAT too?
net/ipv4/udp_offload.c | 45 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 41 insertions(+), 4 deletions(-)
On Fri, Jan 15, 2021 at 02:58:24PM +0900, Dongseok Yi wrote:
UDP/IP header of UDP GROed frag_skbs are not updated even after NAT
forwarding. Only the header of head_skb from ip_finish_output_gso ->
skb_gso_segment is updated but following frag_skbs are not updated.
A call path skb_mac_gso_segment -> inet_gso_segment ->
udp4_ufo_fragment -> __udp_gso_segment -> __udp_gso_segment_list
does not try to update UDP/IP header of the segment list.
We still need to find out why it works for Alexander, but not for you.
Different usecases?
We copy only the MAC header in skb_segment_list(), so I think
this is a valid bug when NAT changed the UDP header.
Update dport, daddr and checksums of each skb of the segment list
after __udp_gso_segment.
Fixes: 9fd1ff5d2ac7 (udp: Support UDP fraglist GRO/GSO.)
Signed-off-by: Dongseok Yi <redacted>
---
Steffen Klassert said, there could be 2 options.
https://lore.kernel.org/patchwork/patch/1362257/
I was trying to write a quick fix, but it was not easy to forward
segmented list. Currently, assuming DNAT only. Should we consider
SNAT too?
If it is broken, then it is broken for both, so yes.
I would not like to add this to a generic codepath. I think we can
relatively easy copy the full headers in skb_segment_list().
I think about something like the (completely untested) patch below:
@@ -190,9 +190,22 @@ EXPORT_SYMBOL(skb_udp_tunnel_segment);staticstructsk_buff*__udp_gso_segment_list(structsk_buff*skb,netdev_features_tfeatures){+structsk_buff*list_skb=skb_shinfo(skb)->frag_list;unsignedintmss=skb_shinfo(skb)->gso_size;+unsignedintoffset;-skb=skb_segment_list(skb,features,skb_mac_header_len(skb));+skb_headers_offset_update(list_skb,skb_headroom(list_skb)-skb_headroom(skb));++/* Check for header changes and copy the full header in that case. */+if((udp_hdr(skb)->dest==udp_hdr(list_skb)->dest)&&+(udp_hdr(skb)->source==udp_hdr(list_skb)->source)&&+(ip_hdr(skb)->daddr==ip_hdr(list_skb)->daddr)&&+(ip_hdr(skb)->saddr==ip_hdr(list_skb)->saddr))+offset=skb_mac_header_len(skb);+else+offset=skb->data-skb_mac_header(skb);++skb=skb_segment_list(skb,features,offset);if(IS_ERR(skb))returnskb;
After that you can apply the CSUM magic in __udp_gso_segment_list().
From: Dongseok Yi <hidden> Date: 2021-01-15 08:56:27
On 2021-01-15 17:12, Steffen Klassert wrote:
On Fri, Jan 15, 2021 at 02:58:24PM +0900, Dongseok Yi wrote:
quoted
UDP/IP header of UDP GROed frag_skbs are not updated even after NAT
forwarding. Only the header of head_skb from ip_finish_output_gso ->
skb_gso_segment is updated but following frag_skbs are not updated.
A call path skb_mac_gso_segment -> inet_gso_segment ->
udp4_ufo_fragment -> __udp_gso_segment -> __udp_gso_segment_list
does not try to update UDP/IP header of the segment list.
We still need to find out why it works for Alexander, but not for you.
Different usecases?
We copy only the MAC header in skb_segment_list(), so I think
this is a valid bug when NAT changed the UDP header.
quoted
Update dport, daddr and checksums of each skb of the segment list
after __udp_gso_segment.
Fixes: 9fd1ff5d2ac7 (udp: Support UDP fraglist GRO/GSO.)
Signed-off-by: Dongseok Yi <redacted>
---
Steffen Klassert said, there could be 2 options.
https://lore.kernel.org/patchwork/patch/1362257/
I was trying to write a quick fix, but it was not easy to forward
segmented list. Currently, assuming DNAT only. Should we consider
SNAT too?
If it is broken, then it is broken for both, so yes.
@@ -190,9 +190,22 @@ EXPORT_SYMBOL(skb_udp_tunnel_segment);staticstructsk_buff*__udp_gso_segment_list(structsk_buff*skb,netdev_features_tfeatures){+structsk_buff*list_skb=skb_shinfo(skb)->frag_list;unsignedintmss=skb_shinfo(skb)->gso_size;+unsignedintoffset;-skb=skb_segment_list(skb,features,skb_mac_header_len(skb));+skb_headers_offset_update(list_skb,skb_headroom(list_skb)-skb_headroom(skb));++/* Check for header changes and copy the full header in that case. */+if((udp_hdr(skb)->dest==udp_hdr(list_skb)->dest)&&+(udp_hdr(skb)->source==udp_hdr(list_skb)->source)&&+(ip_hdr(skb)->daddr==ip_hdr(list_skb)->daddr)&&+(ip_hdr(skb)->saddr==ip_hdr(list_skb)->saddr))+offset=skb_mac_header_len(skb);+else+offset=skb->data-skb_mac_header(skb);++skb=skb_segment_list(skb,features,offset);if(IS_ERR(skb))returnskb;
After that you can apply the CSUM magic in __udp_gso_segment_list().
Sorry, I don't know CSUM magic well. Is it used for checksum
incremental update too?
On Fri, Jan 15, 2021 at 05:55:22PM +0900, Dongseok Yi wrote:
On 2021-01-15 17:12, Steffen Klassert wrote:
quoted
On Fri, Jan 15, 2021 at 02:58:24PM +0900, Dongseok Yi wrote:
quoted
UDP/IP header of UDP GROed frag_skbs are not updated even after NAT
forwarding. Only the header of head_skb from ip_finish_output_gso ->
skb_gso_segment is updated but following frag_skbs are not updated.
A call path skb_mac_gso_segment -> inet_gso_segment ->
udp4_ufo_fragment -> __udp_gso_segment -> __udp_gso_segment_list
does not try to update UDP/IP header of the segment list.
We still need to find out why it works for Alexander, but not for you.
Different usecases?
@@ -190,9 +190,22 @@ EXPORT_SYMBOL(skb_udp_tunnel_segment);staticstructsk_buff*__udp_gso_segment_list(structsk_buff*skb,netdev_features_tfeatures){+structsk_buff*list_skb=skb_shinfo(skb)->frag_list;unsignedintmss=skb_shinfo(skb)->gso_size;+unsignedintoffset;-skb=skb_segment_list(skb,features,skb_mac_header_len(skb));+skb_headers_offset_update(list_skb,skb_headroom(list_skb)-skb_headroom(skb));++/* Check for header changes and copy the full header in that case. */+if((udp_hdr(skb)->dest==udp_hdr(list_skb)->dest)&&+(udp_hdr(skb)->source==udp_hdr(list_skb)->source)&&+(ip_hdr(skb)->daddr==ip_hdr(list_skb)->daddr)&&+(ip_hdr(skb)->saddr==ip_hdr(list_skb)->saddr))+offset=skb_mac_header_len(skb);+else+offset=skb->data-skb_mac_header(skb);++skb=skb_segment_list(skb,features,offset);if(IS_ERR(skb))returnskb;
After that you can apply the CSUM magic in __udp_gso_segment_list().
Sorry, I don't know CSUM magic well. Is it used for checksum
incremental update too?
With that I meant the checksum updating you did in your patch.
On Fri, Jan 15, 2021 at 05:55:22PM +0900, Dongseok Yi wrote:
quoted
On 2021-01-15 17:12, Steffen Klassert wrote:
quoted
On Fri, Jan 15, 2021 at 02:58:24PM +0900, Dongseok Yi wrote:
quoted
UDP/IP header of UDP GROed frag_skbs are not updated even after NAT
forwarding. Only the header of head_skb from ip_finish_output_gso ->
skb_gso_segment is updated but following frag_skbs are not updated.
A call path skb_mac_gso_segment -> inet_gso_segment ->
udp4_ufo_fragment -> __udp_gso_segment -> __udp_gso_segment_list
does not try to update UDP/IP header of the segment list.
We still need to find out why it works for Alexander, but not for you.
Different usecases?
Yes, I know. But he said that fraglist GRO + NAT works for him.
I want to find out why it works for him, but not for you.
I found that it worked for me because I advertised fraglist GSO
support in my driver (and added actual support for xmitting
fraglists). If so, kernel won't resegment GSO into a list of
plain packets, so no __udp_gso_segment_list() will be called.
I think it will break if I disable fraglist GSO feature through
Ethtool, so I could test your patches.
quoted
quoted
I would not like to add this to a generic codepath. I think we can
relatively easy copy the full headers in skb_segment_list().
I tried to copy the full headers with the similar approach, but it
copies length too. Can we keep the length of each skb of the fraglist?
Ah yes, good point.
Then maybe you can move your approach into __udp_gso_segment_list()
so that we dont touch generic code.
quoted
quoted
I think about something like the (completely untested) patch below:
@@ -190,9 +190,22 @@ EXPORT_SYMBOL(skb_udp_tunnel_segment);staticstructsk_buff*__udp_gso_segment_list(structsk_buff*skb,netdev_features_tfeatures){+structsk_buff*list_skb=skb_shinfo(skb)->frag_list;unsignedintmss=skb_shinfo(skb)->gso_size;+unsignedintoffset;-skb=skb_segment_list(skb,features,skb_mac_header_len(skb));+skb_headers_offset_update(list_skb,skb_headroom(list_skb)-skb_headroom(skb));++/* Check for header changes and copy the full header in that case. */+if((udp_hdr(skb)->dest==udp_hdr(list_skb)->dest)&&+(udp_hdr(skb)->source==udp_hdr(list_skb)->source)&&+(ip_hdr(skb)->daddr==ip_hdr(list_skb)->daddr)&&+(ip_hdr(skb)->saddr==ip_hdr(list_skb)->saddr))+offset=skb_mac_header_len(skb);+else+offset=skb->data-skb_mac_header(skb);++skb=skb_segment_list(skb,features,offset);if(IS_ERR(skb))returnskb;
After that you can apply the CSUM magic in __udp_gso_segment_list().
I'll test and let you know if it works. If doesn't, I think I'll be
able to get a working one based on this.
quoted
Sorry, I don't know CSUM magic well. Is it used for checksum
incremental update too?
With that I meant the checksum updating you did in your patch.
On Fri, Jan 15, 2021 at 05:55:22PM +0900, Dongseok Yi wrote:
quoted
On 2021-01-15 17:12, Steffen Klassert wrote:
quoted
On Fri, Jan 15, 2021 at 02:58:24PM +0900, Dongseok Yi wrote:
quoted
UDP/IP header of UDP GROed frag_skbs are not updated even after NAT
forwarding. Only the header of head_skb from ip_finish_output_gso ->
skb_gso_segment is updated but following frag_skbs are not updated.
A call path skb_mac_gso_segment -> inet_gso_segment ->
udp4_ufo_fragment -> __udp_gso_segment -> __udp_gso_segment_list
does not try to update UDP/IP header of the segment list.
We still need to find out why it works for Alexander, but not for you.
Different usecases?
Yes, I know. But he said that fraglist GRO + NAT works for him.
I want to find out why it works for him, but not for you.
I found that it worked for me because I advertised fraglist GSO
support in my driver (and added actual support for xmitting
fraglists). If so, kernel won't resegment GSO into a list of
plain packets, so no __udp_gso_segment_list() will be called.
I think it will break if I disable fraglist GSO feature through
Ethtool, so I could test your patches.
Thanks for the reply. In my case I enabled NETIF_F_GRO_FRAGLIST on
my driver. It expected that NAT done on each skb of the forwarded
fraglist.
quoted
quoted
quoted
I would not like to add this to a generic codepath. I think we can
relatively easy copy the full headers in skb_segment_list().
I tried to copy the full headers with the similar approach, but it
copies length too. Can we keep the length of each skb of the fraglist?
Ah yes, good point.
Then maybe you can move your approach into __udp_gso_segment_list()
so that we dont touch generic code.
Okay, I will move it into __udp_gso_segment_list() on v3.
quoted
quoted
quoted
I think about something like the (completely untested) patch below:
@@ -190,9 +190,22 @@ EXPORT_SYMBOL(skb_udp_tunnel_segment);staticstructsk_buff*__udp_gso_segment_list(structsk_buff*skb,netdev_features_tfeatures){+structsk_buff*list_skb=skb_shinfo(skb)->frag_list;unsignedintmss=skb_shinfo(skb)->gso_size;+unsignedintoffset;-skb=skb_segment_list(skb,features,skb_mac_header_len(skb));+skb_headers_offset_update(list_skb,skb_headroom(list_skb)-skb_headroom(skb));++/* Check for header changes and copy the full header in that case. */+if((udp_hdr(skb)->dest==udp_hdr(list_skb)->dest)&&+(udp_hdr(skb)->source==udp_hdr(list_skb)->source)&&+(ip_hdr(skb)->daddr==ip_hdr(list_skb)->daddr)&&+(ip_hdr(skb)->saddr==ip_hdr(list_skb)->saddr))+offset=skb_mac_header_len(skb);+else+offset=skb->data-skb_mac_header(skb);++skb=skb_segment_list(skb,features,offset);if(IS_ERR(skb))returnskb;
After that you can apply the CSUM magic in __udp_gso_segment_list().
I'll test and let you know if it works. If doesn't, I think I'll be
able to get a working one based on this.
quoted
quoted
Sorry, I don't know CSUM magic well. Is it used for checksum
incremental update too?
With that I meant the checksum updating you did in your patch.
On Fri, Jan 15, 2021 at 05:55:22PM +0900, Dongseok Yi wrote:
quoted
On 2021-01-15 17:12, Steffen Klassert wrote:
quoted
On Fri, Jan 15, 2021 at 02:58:24PM +0900, Dongseok Yi wrote:
quoted
UDP/IP header of UDP GROed frag_skbs are not updated even after NAT
forwarding. Only the header of head_skb from ip_finish_output_gso ->
skb_gso_segment is updated but following frag_skbs are not updated.
A call path skb_mac_gso_segment -> inet_gso_segment ->
udp4_ufo_fragment -> __udp_gso_segment -> __udp_gso_segment_list
does not try to update UDP/IP header of the segment list.
We still need to find out why it works for Alexander, but not for you.
Different usecases?
Yes, I know. But he said that fraglist GRO + NAT works for him.
I want to find out why it works for him, but not for you.
I found that it worked for me because I advertised fraglist GSO
support in my driver (and added actual support for xmitting
fraglists). If so, kernel won't resegment GSO into a list of
plain packets, so no __udp_gso_segment_list() will be called.
I think it will break if I disable fraglist GSO feature through
Ethtool, so I could test your patches.
Thanks for the reply. In my case I enabled NETIF_F_GRO_FRAGLIST on
my driver. It expected that NAT done on each skb of the forwarded
fraglist.
quoted
quoted
quoted
quoted
I would not like to add this to a generic codepath. I think we can
relatively easy copy the full headers in skb_segment_list().
I tried to copy the full headers with the similar approach, but it
copies length too. Can we keep the length of each skb of the fraglist?
Ah yes, good point.
Then maybe you can move your approach into __udp_gso_segment_list()
so that we dont touch generic code.
Okay, I will move it into __udp_gso_segment_list() on v3.
I'll take this one. We also need to cover cases with altered headroom
size, e.g. when the NIC is behind the switch and sends packets with
CPU tags that is being added prior to resegmentation.
The base suggested by Steffen in good enough, just needs a bit more
handling. I'll publish a final fix soon.
quoted
quoted
quoted
quoted
I think about something like the (completely untested) patch below:
@@ -190,9 +190,22 @@ EXPORT_SYMBOL(skb_udp_tunnel_segment);staticstructsk_buff*__udp_gso_segment_list(structsk_buff*skb,netdev_features_tfeatures){+structsk_buff*list_skb=skb_shinfo(skb)->frag_list;unsignedintmss=skb_shinfo(skb)->gso_size;+unsignedintoffset;-skb=skb_segment_list(skb,features,skb_mac_header_len(skb));+skb_headers_offset_update(list_skb,skb_headroom(list_skb)-skb_headroom(skb));++/* Check for header changes and copy the full header in that case. */+if((udp_hdr(skb)->dest==udp_hdr(list_skb)->dest)&&+(udp_hdr(skb)->source==udp_hdr(list_skb)->source)&&+(ip_hdr(skb)->daddr==ip_hdr(list_skb)->daddr)&&+(ip_hdr(skb)->saddr==ip_hdr(list_skb)->saddr))+offset=skb_mac_header_len(skb);+else+offset=skb->data-skb_mac_header(skb);++skb=skb_segment_list(skb,features,offset);if(IS_ERR(skb))returnskb;
After that you can apply the CSUM magic in __udp_gso_segment_list().
I'll test and let you know if it works. If doesn't, I think I'll be
able to get a working one based on this.
quoted
quoted
Sorry, I don't know CSUM magic well. Is it used for checksum
incremental update too?
With that I meant the checksum updating you did in your patch.