lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20221124115316.GA73682@debian>
Date:   Thu, 24 Nov 2022 12:54:19 +0100
From:   Richard Gobert <richardbgobert@...il.com>
To:     edumazet@...gle.com, davem@...emloft.net, yoshfuji@...ux-ipv6.org,
        dsahern@...nel.org, kuba@...nel.org, pabeni@...hat.com,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH net-next 1/2] gro: simplify flush logic

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@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ