Skip to content

Commit d1dab4f

Browse files
Florian Westphalkuba-moo
authored andcommitted
net: add and use __skb_get_hash_symmetric_net
Similar to previous patch: apply same logic for __skb_get_hash_symmetric and let callers pass the netns to the dissector core. Existing function is turned into a wrapper to avoid adjusting all callers, nft_hash.c uses new function. Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b975d3e commit d1dab4f

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

include/linux/skbuff.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1498,8 +1498,14 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)
14981498
__skb_set_hash(skb, hash, true, is_l4);
14991499
}
15001500

1501+
u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *skb);
1502+
1503+
static inline u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
1504+
{
1505+
return __skb_get_hash_symmetric_net(NULL, skb);
1506+
}
1507+
15011508
void __skb_get_hash_net(const struct net *net, struct sk_buff *skb);
1502-
u32 __skb_get_hash_symmetric(const struct sk_buff *skb);
15031509
u32 skb_get_poff(const struct sk_buff *skb);
15041510
u32 __skb_get_poff(const struct sk_buff *skb, const void *data,
15051511
const struct flow_keys_basic *keys, int hlen);

net/core/flow_dissector.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,19 +1845,19 @@ EXPORT_SYMBOL(make_flow_keys_digest);
18451845

18461846
static struct flow_dissector flow_keys_dissector_symmetric __read_mostly;
18471847

1848-
u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
1848+
u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *skb)
18491849
{
18501850
struct flow_keys keys;
18511851

18521852
__flow_hash_secret_init();
18531853

18541854
memset(&keys, 0, sizeof(keys));
1855-
__skb_flow_dissect(NULL, skb, &flow_keys_dissector_symmetric,
1855+
__skb_flow_dissect(net, skb, &flow_keys_dissector_symmetric,
18561856
&keys, NULL, 0, 0, 0, 0);
18571857

18581858
return __flow_hash_from_keys(&keys, &hashrnd);
18591859
}
1860-
EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);
1860+
EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric_net);
18611861

18621862
/**
18631863
* __skb_get_hash_net: calculate a flow hash

net/netfilter/nft_hash.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ static void nft_symhash_eval(const struct nft_expr *expr,
5151
struct sk_buff *skb = pkt->skb;
5252
u32 h;
5353

54-
h = reciprocal_scale(__skb_get_hash_symmetric(skb), priv->modulus);
54+
h = reciprocal_scale(__skb_get_hash_symmetric_net(nft_net(pkt), skb),
55+
priv->modulus);
5556

5657
regs->data[priv->dreg] = h + priv->offset;
5758
}

0 commit comments

Comments
 (0)