From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
Jakub Kicinski <kuba@kernel.org>,
richardbgobert@gmail.com
Subject: [PATCH net-next] gro: move the tc_ext comparison to a helper
Date: Tue, 13 Jun 2023 13:51:05 -0700 [thread overview]
Message-ID: <20230613205105.1996166-1-kuba@kernel.org> (raw)
The double ifdefs are quite aesthetically displeasing.
Use a helper function to make the code more compact.
The resulting machine code looks the same (with minor
movement of some basic blocks).
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: richardbgobert@gmail.com
---
net/core/gro.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/net/core/gro.c b/net/core/gro.c
index ab9a447dfba7..90889e1f3f9a 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -305,6 +305,23 @@ void napi_gro_flush(struct napi_struct *napi, bool flush_old)
}
EXPORT_SYMBOL(napi_gro_flush);
+static void gro_list_prepare_tc_ext(const struct sk_buff *skb,
+ const struct sk_buff *p,
+ unsigned long *diffs)
+{
+#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
+ struct tc_skb_ext *skb_ext;
+ struct tc_skb_ext *p_ext;
+
+ skb_ext = skb_ext_find(skb, TC_SKB_EXT);
+ p_ext = skb_ext_find(p, TC_SKB_EXT);
+
+ *diffs |= (!!p_ext) ^ (!!skb_ext);
+ if (!*diffs && unlikely(skb_ext))
+ *diffs |= p_ext->chain ^ skb_ext->chain;
+#endif
+}
+
static void gro_list_prepare(const struct list_head *head,
const struct sk_buff *skb)
{
@@ -339,23 +356,11 @@ static void gro_list_prepare(const struct list_head *head,
* avoid trying too hard to skip each of them individually
*/
if (!diffs && unlikely(skb->slow_gro | p->slow_gro)) {
-#if IS_ENABLED(CONFIG_SKB_EXTENSIONS) && IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
- struct tc_skb_ext *skb_ext;
- struct tc_skb_ext *p_ext;
-#endif
-
diffs |= p->sk != skb->sk;
diffs |= skb_metadata_dst_cmp(p, skb);
diffs |= skb_get_nfct(p) ^ skb_get_nfct(skb);
-#if IS_ENABLED(CONFIG_SKB_EXTENSIONS) && IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
- skb_ext = skb_ext_find(skb, TC_SKB_EXT);
- p_ext = skb_ext_find(p, TC_SKB_EXT);
-
- diffs |= (!!p_ext) ^ (!!skb_ext);
- if (!diffs && unlikely(skb_ext))
- diffs |= p_ext->chain ^ skb_ext->chain;
-#endif
+ gro_list_prepare_tc_ext(skb, p, &diffs);
}
NAPI_GRO_CB(p)->same_flow = !diffs;
--
2.40.1
next reply other threads:[~2023-06-13 20:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 20:51 Jakub Kicinski [this message]
2023-06-14 12:23 ` [PATCH net-next] gro: move the tc_ext comparison to a helper Simon Horman
2023-06-14 17:44 ` Jakub Kicinski
2023-06-14 18:06 ` Simon Horman
2023-06-14 12:58 ` Yunsheng Lin
2023-06-14 17:55 ` Jakub Kicinski
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=20230613205105.1996166-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardbgobert@gmail.com \
/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).