From: Richard Gobert <richardbgobert@gmail.com>
To: edumazet@google.com, davem@davemloft.net,
yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 1/2] gro: simplify flush logic
Date: Thu, 24 Nov 2022 12:54:19 +0100 [thread overview]
Message-ID: <20221124115316.GA73682@debian> (raw)
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
reply other threads:[~2022-11-24 11:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221124115316.GA73682@debian \
--to=richardbgobert@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).