This patch removes an unnecessary variable in udp[46]_lib_lookup2() and
makes it easier to resolve a merge conflict with bpf-next reported in
the link below.

Link: 
https://lore.kernel.org/linux-next/20200722132143.700a5...@canb.auug.org.au/
Fixes: efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")
Signed-off-by: Kuniyuki Iwashima <kun...@amazon.co.jp>
Signed-off-by: Jakub Sitnicki <ja...@cloudflare.com>
Cc: Willem de Bruijn <willemdebruijn.ker...@gmail.com>
---
 net/ipv4/udp.c | 15 ++++++++-------
 net/ipv6/udp.c | 15 ++++++++-------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 4077d589b72e..22fb231e27c3 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -416,7 +416,7 @@ static struct sock *udp4_lib_lookup2(struct net *net,
                                     struct udp_hslot *hslot2,
                                     struct sk_buff *skb)
 {
-       struct sock *sk, *result, *reuseport_result;
+       struct sock *sk, *result;
        int score, badness;
        u32 hash = 0;
 
@@ -426,19 +426,20 @@ static struct sock *udp4_lib_lookup2(struct net *net,
                score = compute_score(sk, net, saddr, sport,
                                      daddr, hnum, dif, sdif);
                if (score > badness) {
-                       reuseport_result = NULL;
+                       result = NULL;
 
                        if (sk->sk_reuseport &&
                            sk->sk_state != TCP_ESTABLISHED) {
                                hash = udp_ehashfn(net, daddr, hnum,
                                                   saddr, sport);
-                               reuseport_result = reuseport_select_sock(sk, 
hash, skb,
-                                                                        
sizeof(struct udphdr));
-                               if (reuseport_result && 
!reuseport_has_conns(sk, false))
-                                       return reuseport_result;
+                               result = reuseport_select_sock(sk, hash, skb,
+                                                              sizeof(struct 
udphdr));
+                               if (result && !reuseport_has_conns(sk, false))
+                                       return result;
                        }
 
-                       result = reuseport_result ? : sk;
+                       if (!result)
+                               result = sk;
                        badness = score;
                }
        }
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index a8d74f44056a..29c7bb2609c4 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -148,7 +148,7 @@ static struct sock *udp6_lib_lookup2(struct net *net,
                int dif, int sdif, struct udp_hslot *hslot2,
                struct sk_buff *skb)
 {
-       struct sock *sk, *result, *reuseport_result;
+       struct sock *sk, *result;
        int score, badness;
        u32 hash = 0;
 
@@ -158,20 +158,21 @@ static struct sock *udp6_lib_lookup2(struct net *net,
                score = compute_score(sk, net, saddr, sport,
                                      daddr, hnum, dif, sdif);
                if (score > badness) {
-                       reuseport_result = NULL;
+                       result = NULL;
 
                        if (sk->sk_reuseport &&
                            sk->sk_state != TCP_ESTABLISHED) {
                                hash = udp6_ehashfn(net, daddr, hnum,
                                                    saddr, sport);
 
-                               reuseport_result = reuseport_select_sock(sk, 
hash, skb,
-                                                                        
sizeof(struct udphdr));
-                               if (reuseport_result && 
!reuseport_has_conns(sk, false))
-                                       return reuseport_result;
+                               result = reuseport_select_sock(sk, hash, skb,
+                                                              sizeof(struct 
udphdr));
+                               if (result && !reuseport_has_conns(sk, false))
+                                       return result;
                        }
 
-                       result = reuseport_result ? : sk;
+                       if (!result)
+                               result = sk;
                        badness = score;
                }
        }
-- 
2.17.2 (Apple Git-113)

Reply via email to