linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: Call ip_hdrlen() when skbuff is not fragment
@ 2020-08-27 11:17 Miaohe Lin
  2020-08-27 16:11 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Miaohe Lin @ 2020-08-27 11:17 UTC (permalink / raw)
  To: davem, kuba, pshelar, fw, martin.varghese, edumazet, dcaratti,
	steffen.klassert, pabeni, shmulik, kyk.segfault
  Cc: netdev, linux-kernel, linmiaohe

When skbuff is fragment, we exit immediately and leave ip_hdrlen() as
unused. And remove the unnecessary local variable fragment.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 net/core/skbuff.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 4dc92290becd..0b24aed04060 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4843,28 +4843,20 @@ static __sum16 *skb_checksum_setup_ip(struct sk_buff *skb,
 static int skb_checksum_setup_ipv4(struct sk_buff *skb, bool recalculate)
 {
 	unsigned int off;
-	bool fragment;
 	__sum16 *csum;
 	int err;
 
-	fragment = false;
-
 	err = skb_maybe_pull_tail(skb,
 				  sizeof(struct iphdr),
 				  MAX_IP_HDR_LEN);
 	if (err < 0)
 		goto out;
 
-	if (ip_is_fragment(ip_hdr(skb)))
-		fragment = true;
-
-	off = ip_hdrlen(skb);
-
 	err = -EPROTO;
-
-	if (fragment)
+	if (ip_is_fragment(ip_hdr(skb)))
 		goto out;
 
+	off = ip_hdrlen(skb);
 	csum = skb_checksum_setup_ip(skb, ip_hdr(skb)->protocol, off);
 	if (IS_ERR(csum))
 		return PTR_ERR(csum);
-- 
2.19.1


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

* Re: [PATCH] net: Call ip_hdrlen() when skbuff is not fragment
  2020-08-27 11:17 [PATCH] net: Call ip_hdrlen() when skbuff is not fragment Miaohe Lin
@ 2020-08-27 16:11 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-08-27 16:11 UTC (permalink / raw)
  To: linmiaohe
  Cc: kuba, pshelar, fw, martin.varghese, edumazet, dcaratti,
	steffen.klassert, pabeni, shmulik, kyk.segfault, netdev,
	linux-kernel

From: Miaohe Lin <linmiaohe@huawei.com>
Date: Thu, 27 Aug 2020 07:17:59 -0400

> When skbuff is fragment, we exit immediately and leave ip_hdrlen() as
> unused. And remove the unnecessary local variable fragment.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

I don't think this is a useful optimization sorry, the common case
will be just as likely to be a fragment as not so it's arbitrary
whether we read this simple value or not.

I'm not applying this, sorry.

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

end of thread, other threads:[~2020-08-27 16:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27 11:17 [PATCH] net: Call ip_hdrlen() when skbuff is not fragment Miaohe Lin
2020-08-27 16:11 ` David Miller

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