]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: export inet_lookup_reuseport and inet6_lookup_reuseport
authorLorenz Bauer <lmb@isovalent.com>
Thu, 20 Jul 2023 15:30:07 +0000 (17:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 16 Jun 2024 11:39:21 +0000 (13:39 +0200)
[ Upstream commit ce796e60b3b196b61fcc565df195443cbb846ef0 ]

Rename the existing reuseport helpers for IPv4 and IPv6 so that they
can be invoked in the follow up commit. Export them so that building
DCCP and IPv6 as a module works.

No change in functionality.

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Link: https://lore.kernel.org/r/20230720-so-reuseport-v6-3-7021b683cdae@isovalent.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Stable-dep-of: 50aee97d1511 ("udp: Avoid call to compute_score on multiple sites")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/inet6_hashtables.h
include/net/inet_hashtables.h
net/ipv4/inet_hashtables.c
net/ipv6/inet6_hashtables.c

index 56f1286583d3ca0eed52ae81bb0b539291399a88..032ddab48f8f875fc819dae1e0edb4d2e963a489 100644 (file)
@@ -48,6 +48,13 @@ struct sock *__inet6_lookup_established(struct net *net,
                                        const u16 hnum, const int dif,
                                        const int sdif);
 
+struct sock *inet6_lookup_reuseport(struct net *net, struct sock *sk,
+                                   struct sk_buff *skb, int doff,
+                                   const struct in6_addr *saddr,
+                                   __be16 sport,
+                                   const struct in6_addr *daddr,
+                                   unsigned short hnum);
+
 struct sock *inet6_lookup_listener(struct net *net,
                                   struct inet_hashinfo *hashinfo,
                                   struct sk_buff *skb, int doff,
index a7a8e66a1bad01b4e90ef51654ca3f5006c08d13..1e81b130cfb0c3d6ba928e56c7fa319535dc43b0 100644 (file)
@@ -279,6 +279,11 @@ struct sock *__inet_lookup_established(struct net *net,
                                       const __be32 daddr, const u16 hnum,
                                       const int dif, const int sdif);
 
+struct sock *inet_lookup_reuseport(struct net *net, struct sock *sk,
+                                  struct sk_buff *skb, int doff,
+                                  __be32 saddr, __be16 sport,
+                                  __be32 daddr, unsigned short hnum);
+
 static inline struct sock *
        inet_lookup_established(struct net *net, struct inet_hashinfo *hashinfo,
                                const __be32 saddr, const __be16 sport,
index b4e0120af9c2bed52915ac4aa0e76ee40f35c202..34828b4488ce507e565a916e1605aa64d6e84f39 100644 (file)
@@ -216,10 +216,10 @@ static inline int compute_score(struct sock *sk, struct net *net,
        return score;
 }
 
-static inline struct sock *lookup_reuseport(struct net *net, struct sock *sk,
-                                           struct sk_buff *skb, int doff,
-                                           __be32 saddr, __be16 sport,
-                                           __be32 daddr, unsigned short hnum)
+struct sock *inet_lookup_reuseport(struct net *net, struct sock *sk,
+                                  struct sk_buff *skb, int doff,
+                                  __be32 saddr, __be16 sport,
+                                  __be32 daddr, unsigned short hnum)
 {
        struct sock *reuse_sk = NULL;
        u32 phash;
@@ -230,6 +230,7 @@ static inline struct sock *lookup_reuseport(struct net *net, struct sock *sk,
        }
        return reuse_sk;
 }
+EXPORT_SYMBOL_GPL(inet_lookup_reuseport);
 
 /*
  * Here are some nice properties to exploit here. The BSD API
@@ -253,8 +254,8 @@ static struct sock *inet_lhash2_lookup(struct net *net,
        sk_nulls_for_each_rcu(sk, node, &ilb2->nulls_head) {
                score = compute_score(sk, net, hnum, daddr, dif, sdif);
                if (score > hiscore) {
-                       result = lookup_reuseport(net, sk, skb, doff,
-                                                 saddr, sport, daddr, hnum);
+                       result = inet_lookup_reuseport(net, sk, skb, doff,
+                                                      saddr, sport, daddr, hnum);
                        if (result)
                                return result;
 
@@ -283,7 +284,7 @@ static inline struct sock *inet_lookup_run_bpf(struct net *net,
        if (no_reuseport || IS_ERR_OR_NULL(sk))
                return sk;
 
-       reuse_sk = lookup_reuseport(net, sk, skb, doff, saddr, sport, daddr, hnum);
+       reuse_sk = inet_lookup_reuseport(net, sk, skb, doff, saddr, sport, daddr, hnum);
        if (reuse_sk)
                sk = reuse_sk;
        return sk;
index c40cbdfc6247fef04ce9a52bf93473c04f36bee4..356455d557f4ca4e5d0368e18369514c54d21ad0 100644 (file)
@@ -113,12 +113,12 @@ static inline int compute_score(struct sock *sk, struct net *net,
        return score;
 }
 
-static inline struct sock *lookup_reuseport(struct net *net, struct sock *sk,
-                                           struct sk_buff *skb, int doff,
-                                           const struct in6_addr *saddr,
-                                           __be16 sport,
-                                           const struct in6_addr *daddr,
-                                           unsigned short hnum)
+struct sock *inet6_lookup_reuseport(struct net *net, struct sock *sk,
+                                   struct sk_buff *skb, int doff,
+                                   const struct in6_addr *saddr,
+                                   __be16 sport,
+                                   const struct in6_addr *daddr,
+                                   unsigned short hnum)
 {
        struct sock *reuse_sk = NULL;
        u32 phash;
@@ -129,6 +129,7 @@ static inline struct sock *lookup_reuseport(struct net *net, struct sock *sk,
        }
        return reuse_sk;
 }
+EXPORT_SYMBOL_GPL(inet6_lookup_reuseport);
 
 /* called with rcu_read_lock() */
 static struct sock *inet6_lhash2_lookup(struct net *net,
@@ -145,8 +146,8 @@ static struct sock *inet6_lhash2_lookup(struct net *net,
        sk_nulls_for_each_rcu(sk, node, &ilb2->nulls_head) {
                score = compute_score(sk, net, hnum, daddr, dif, sdif);
                if (score > hiscore) {
-                       result = lookup_reuseport(net, sk, skb, doff,
-                                                 saddr, sport, daddr, hnum);
+                       result = inet6_lookup_reuseport(net, sk, skb, doff,
+                                                       saddr, sport, daddr, hnum);
                        if (result)
                                return result;
 
@@ -177,7 +178,7 @@ static inline struct sock *inet6_lookup_run_bpf(struct net *net,
        if (no_reuseport || IS_ERR_OR_NULL(sk))
                return sk;
 
-       reuse_sk = lookup_reuseport(net, sk, skb, doff, saddr, sport, daddr, hnum);
+       reuse_sk = inet6_lookup_reuseport(net, sk, skb, doff, saddr, sport, daddr, hnum);
        if (reuse_sk)
                sk = reuse_sk;
        return sk;