linux-sctp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 net-next 0/2] net: fix the features flag in sctp_gso_segment
@ 2021-01-15  8:21 Xin Long
  2021-01-15  8:21 ` [PATCHv2 net-next 1/2] net: move the hsize check to the else block in skb_segment Xin Long
  2021-01-15  9:31 ` [PATCHv2 net-next 0/2] net: fix the features flag in sctp_gso_segment Xin Long
  0 siblings, 2 replies; 4+ messages in thread
From: Xin Long @ 2021-01-15  8:21 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, davem, Jakub Kicinski,
	Alexander Duyck

Patch 1/2 is to improve the code in skb_segment(), and it is needed
by Patch 2/2.

v1->v2:
  - see Patch 1/2.

Xin Long (2):
  net: move the hsize check to the else block in skb_segment
  udp: remove CRC flag from dev features in __skb_udp_tunnel_segment

 net/core/skbuff.c      | 11 ++++++-----
 net/ipv4/udp_offload.c |  4 ++--
 2 files changed, 8 insertions(+), 7 deletions(-)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCHv2 net-next 1/2] net: move the hsize check to the else block in skb_segment
  2021-01-15  8:21 [PATCHv2 net-next 0/2] net: fix the features flag in sctp_gso_segment Xin Long
@ 2021-01-15  8:21 ` Xin Long
  2021-01-15  8:21   ` [PATCHv2 net-next 2/2] udp: remove CRC flag from dev features in __skb_udp_tunnel_segment Xin Long
  2021-01-15  9:31 ` [PATCHv2 net-next 0/2] net: fix the features flag in sctp_gso_segment Xin Long
  1 sibling, 1 reply; 4+ messages in thread
From: Xin Long @ 2021-01-15  8:21 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, davem, Jakub Kicinski,
	Alexander Duyck

After commit 89319d3801d1 ("net: Add frag_list support to skb_segment"),
it goes to process frag_list when !hsize in skb_segment(). However, when
using skb frag_list, sg normally should not be set. In this case, hsize
will be set with len right before !hsize check, then it won't go to
frag_list processing code.

So the right thing to do is move the hsize check to the else block, so
that it won't affect the !hsize check for frag_list processing.

v1->v2:
  - change to do "hsize <= 0" check instead of "!hsize", and also move
    "hsize < 0" into else block, to save some cycles, as Alex suggested.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/core/skbuff.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 6039069..e835193 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3894,12 +3894,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
 		}
 
 		hsize = skb_headlen(head_skb) - offset;
-		if (hsize < 0)
-			hsize = 0;
-		if (hsize > len || !sg)
-			hsize = len;
 
-		if (!hsize && i >= nfrags && skb_headlen(list_skb) &&
+		if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) &&
 		    (skb_headlen(list_skb) == len || sg)) {
 			BUG_ON(skb_headlen(list_skb) > len);
 
@@ -3942,6 +3938,11 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
 			skb_release_head_state(nskb);
 			__skb_push(nskb, doffset);
 		} else {
+			if (hsize > len || !sg)
+				hsize = len;
+			else if (hsize < 0)
+				hsize = 0;
+
 			nskb = __alloc_skb(hsize + doffset + headroom,
 					   GFP_ATOMIC, skb_alloc_rx_flag(head_skb),
 					   NUMA_NO_NODE);
-- 
2.1.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCHv2 net-next 2/2] udp: remove CRC flag from dev features in __skb_udp_tunnel_segment
  2021-01-15  8:21 ` [PATCHv2 net-next 1/2] net: move the hsize check to the else block in skb_segment Xin Long
@ 2021-01-15  8:21   ` Xin Long
  0 siblings, 0 replies; 4+ messages in thread
From: Xin Long @ 2021-01-15  8:21 UTC (permalink / raw)
  To: network dev, linux-sctp
  Cc: Marcelo Ricardo Leitner, Neil Horman, davem, Jakub Kicinski,
	Alexander Duyck

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv4/udp_offload.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c
index ff39e94..1168d18 100644
--- a/net/ipv4/udp_offload.c
+++ b/net/ipv4/udp_offload.c
@@ -68,8 +68,8 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
 				      (NETIF_F_HW_CSUM | NETIF_F_IP_CSUM))));
 
 	features &= skb->dev->hw_enc_features;
-	/* CRC checksum can't be handled by HW when it's a UDP tunneling packet. */
-	features &= ~NETIF_F_SCTP_CRC;
+	if (need_csum)
+		features &= ~NETIF_F_SCTP_CRC;
 
 	/* The only checksum offload we care about from here on out is the
 	 * outer one so strip the existing checksum feature flags and
-- 
2.1.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCHv2 net-next 0/2] net: fix the features flag in sctp_gso_segment
  2021-01-15  8:21 [PATCHv2 net-next 0/2] net: fix the features flag in sctp_gso_segment Xin Long
  2021-01-15  8:21 ` [PATCHv2 net-next 1/2] net: move the hsize check to the else block in skb_segment Xin Long
@ 2021-01-15  9:31 ` Xin Long
  1 sibling, 0 replies; 4+ messages in thread
From: Xin Long @ 2021-01-15  9:31 UTC (permalink / raw)
  To: network dev, linux-sctp @ vger . kernel . org
  Cc: Marcelo Ricardo Leitner, Neil Horman, davem, Jakub Kicinski,
	Alexander Duyck

Please drop this patchset, the second one is incorrect.
I will post v3, thanks.

On Fri, Jan 15, 2021 at 4:21 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> Patch 1/2 is to improve the code in skb_segment(), and it is needed
> by Patch 2/2.
>
> v1->v2:
>   - see Patch 1/2.
>
> Xin Long (2):
>   net: move the hsize check to the else block in skb_segment
>   udp: remove CRC flag from dev features in __skb_udp_tunnel_segment
>
>  net/core/skbuff.c      | 11 ++++++-----
>  net/ipv4/udp_offload.c |  4 ++--
>  2 files changed, 8 insertions(+), 7 deletions(-)
>
> --
> 2.1.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-15  9:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-15  8:21 [PATCHv2 net-next 0/2] net: fix the features flag in sctp_gso_segment Xin Long
2021-01-15  8:21 ` [PATCHv2 net-next 1/2] net: move the hsize check to the else block in skb_segment Xin Long
2021-01-15  8:21   ` [PATCHv2 net-next 2/2] udp: remove CRC flag from dev features in __skb_udp_tunnel_segment Xin Long
2021-01-15  9:31 ` [PATCHv2 net-next 0/2] net: fix the features flag in sctp_gso_segment Xin Long

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).