]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: add and use __skb_get_hash_symmetric_net
authorFlorian Westphal <fw@strlen.de>
Sat, 8 Jun 2024 22:10:40 +0000 (00:10 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 12 Jun 2024 21:33:38 +0000 (14:33 -0700)
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 <willemb@google.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20240608221057.16070-3-fw@strlen.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/skbuff.h
net/core/flow_dissector.c
net/netfilter/nft_hash.c

index 6e78019f899a712f03c790f3e2af3b57b808bdc8..813406a9bd6c2efa4d6f4092659b9634020ad311 100644 (file)
@@ -1498,8 +1498,14 @@ __skb_set_sw_hash(struct sk_buff *skb, __u32 hash, bool is_l4)
        __skb_set_hash(skb, hash, true, is_l4);
 }
 
+u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *skb);
+
+static inline u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
+{
+       return __skb_get_hash_symmetric_net(NULL, skb);
+}
+
 void __skb_get_hash_net(const struct net *net, struct sk_buff *skb);
-u32 __skb_get_hash_symmetric(const struct sk_buff *skb);
 u32 skb_get_poff(const struct sk_buff *skb);
 u32 __skb_get_poff(const struct sk_buff *skb, const void *data,
                   const struct flow_keys_basic *keys, int hlen);
index 702b4f0a70b67214759b389398df4c8420177f32..e479790db0f72378fe407ee6434423767c5f7db0 100644 (file)
@@ -1845,19 +1845,19 @@ EXPORT_SYMBOL(make_flow_keys_digest);
 
 static struct flow_dissector flow_keys_dissector_symmetric __read_mostly;
 
-u32 __skb_get_hash_symmetric(const struct sk_buff *skb)
+u32 __skb_get_hash_symmetric_net(const struct net *net, const struct sk_buff *skb)
 {
        struct flow_keys keys;
 
        __flow_hash_secret_init();
 
        memset(&keys, 0, sizeof(keys));
-       __skb_flow_dissect(NULL, skb, &flow_keys_dissector_symmetric,
+       __skb_flow_dissect(net, skb, &flow_keys_dissector_symmetric,
                           &keys, NULL, 0, 0, 0, 0);
 
        return __flow_hash_from_keys(&keys, &hashrnd);
 }
-EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric);
+EXPORT_SYMBOL_GPL(__skb_get_hash_symmetric_net);
 
 /**
  * __skb_get_hash_net: calculate a flow hash
index 92d47e4692046ddb5febcd199c9684fc8dec4a28..868d68302d224d6e1f556ccd6824d99217f281be 100644 (file)
@@ -51,7 +51,8 @@ static void nft_symhash_eval(const struct nft_expr *expr,
        struct sk_buff *skb = pkt->skb;
        u32 h;
 
-       h = reciprocal_scale(__skb_get_hash_symmetric(skb), priv->modulus);
+       h = reciprocal_scale(__skb_get_hash_symmetric_net(nft_net(pkt), skb),
+                            priv->modulus);
 
        regs->data[priv->dreg] = h + priv->offset;
 }