All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] gro: simplify flush logic
@ 2022-11-24 11:54 Richard Gobert
  0 siblings, 0 replies; only message in thread
From: Richard Gobert @ 2022-11-24 11:54 UTC (permalink / raw)
  To: edumazet, davem, yoshfuji, dsahern, kuba, pabeni, netdev,
	linux-kernel

In tcp_gro_receive, the variable mss is sometimes assigned 1 to make the check
"flush = len < mss" fail, and indirectly set flush to 0.

This somewhat obfuscates the meaning of the code. Also, setting mss to 1 doesn't
influence the value of flush in the case when skb_is_gso(skb) is true.

This patch changes the code to set flush to 0 directly. The out_check_final can
then be moved, which avoids unnecessary conditions.

Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
---
 net/ipv4/tcp_offload.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index 45dda7889387..f17271e5c7c5 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -187,7 +187,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb)
 	unsigned int len;
 	unsigned int thlen;
 	__be32 flags;
-	unsigned int mss = 1;
+	unsigned int mss;
 	unsigned int hlen;
 	unsigned int off;
 	int flush = 1;
@@ -229,6 +229,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb)
 		goto found;
 	}
 	p = NULL;
+	flush = 0;
 	goto out_check_final;
 
 found:
@@ -270,19 +271,19 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb)
 #endif
 
 	if (flush || skb_gro_receive(p, skb)) {
-		mss = 1;
+		flush = 0;
 		goto out_check_final;
 	}
 
 	tcp_flag_word(th2) |= flags & (TCP_FLAG_FIN | TCP_FLAG_PSH);
 
-out_check_final:
 	/* Force a flush if last segment is smaller than mss. */
 	if (unlikely(skb_is_gso(skb)))
 		flush = len != NAPI_GRO_CB(skb)->count * skb_shinfo(skb)->gso_size;
 	else
 		flush = len < mss;
 
+out_check_final:
 	flush |= (__force int)(flags & (TCP_FLAG_URG | TCP_FLAG_PSH |
 					TCP_FLAG_RST | TCP_FLAG_SYN |
 					TCP_FLAG_FIN));
-- 
2.36.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-24 11:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-24 11:54 [PATCH net-next 1/2] gro: simplify flush logic Richard Gobert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.