Skip to content

Commit 2dc6af8

Browse files
kuba-moodavem330
authored andcommitted
gro: move the tc_ext comparison to a helper
The double ifdefs (one for the variable declaration and one around the code) are quite aesthetically displeasing. Factor this code out into a helper for easier wrapping. This will become even more ugly when another skb ext comparison is added in the future. The resulting machine code looks the same, the compiler seems to try to use %rax more and some blocks more around but I haven't spotted minor differences. Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 988e8d9 commit 2dc6af8

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

net/core/gro.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,24 @@ void napi_gro_flush(struct napi_struct *napi, bool flush_old)
304304
}
305305
EXPORT_SYMBOL(napi_gro_flush);
306306

307+
static unsigned long gro_list_prepare_tc_ext(const struct sk_buff *skb,
308+
const struct sk_buff *p,
309+
unsigned long diffs)
310+
{
311+
#if IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
312+
struct tc_skb_ext *skb_ext;
313+
struct tc_skb_ext *p_ext;
314+
315+
skb_ext = skb_ext_find(skb, TC_SKB_EXT);
316+
p_ext = skb_ext_find(p, TC_SKB_EXT);
317+
318+
diffs |= (!!p_ext) ^ (!!skb_ext);
319+
if (!diffs && unlikely(skb_ext))
320+
diffs |= p_ext->chain ^ skb_ext->chain;
321+
#endif
322+
return diffs;
323+
}
324+
307325
static void gro_list_prepare(const struct list_head *head,
308326
const struct sk_buff *skb)
309327
{
@@ -338,23 +356,11 @@ static void gro_list_prepare(const struct list_head *head,
338356
* avoid trying too hard to skip each of them individually
339357
*/
340358
if (!diffs && unlikely(skb->slow_gro | p->slow_gro)) {
341-
#if IS_ENABLED(CONFIG_SKB_EXTENSIONS) && IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
342-
struct tc_skb_ext *skb_ext;
343-
struct tc_skb_ext *p_ext;
344-
#endif
345-
346359
diffs |= p->sk != skb->sk;
347360
diffs |= skb_metadata_dst_cmp(p, skb);
348361
diffs |= skb_get_nfct(p) ^ skb_get_nfct(skb);
349362

350-
#if IS_ENABLED(CONFIG_SKB_EXTENSIONS) && IS_ENABLED(CONFIG_NET_TC_SKB_EXT)
351-
skb_ext = skb_ext_find(skb, TC_SKB_EXT);
352-
p_ext = skb_ext_find(p, TC_SKB_EXT);
353-
354-
diffs |= (!!p_ext) ^ (!!skb_ext);
355-
if (!diffs && unlikely(skb_ext))
356-
diffs |= p_ext->chain ^ skb_ext->chain;
357-
#endif
363+
diffs |= gro_list_prepare_tc_ext(skb, p, diffs);
358364
}
359365

360366
NAPI_GRO_CB(p)->same_flow = !diffs;

0 commit comments

Comments
 (0)