Skip to contentSkip to conversation

udp: Remove an unnecessary variable in udp[46]_lib_lookup2().

PATCH In review Kuniyuki Iwashima 4 participants 8 messages Jul 22, 2020 – Jul 25, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udp: Remove an unnecessary variable in udp[46]_lib_lookup2().

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.

Fixes efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")
Cc Willem de Bruijn <[email protected]>
---
 net/ipv4/udp.c | 15 ++++++++-------
 net/ipv6/udp.c | 15 ++++++++-------
 2 files changed, 16 insertions(+), 14 deletions(-)
net/ipv4/udp.c +8 -7
index 4077d589b72e..22fb231e27c3 100644
@@ -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;
 		}
 	}
net/ipv6/udp.c +8 -7
index a8d74f44056a..29c7bb2609c4 100644
@@ -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;
 		}
 	}
Signature · 1 line
2.17.2 (Apple Git-113)
maintainer
#1 lore raw

From: Kuniyuki Iwashima <[email protected]>
Date: Thu, 23 Jul 2020 01:52:27 +0900

Quoted 9 lines

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.

Fixes efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")
Cc Willem de Bruijn <[email protected]>

This doesn't apply to net-next.

#2 lore raw
From:   David Miller <[email protected]>
Date:   Thu, 23 Jul 2020 15:10:51 -0700 (PDT)
Quoted 7 lines

From: Kuniyuki Iwashima <[email protected]>
Date: Thu, 23 Jul 2020 01:52:27 +0900

Quoted 4 lines

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.

Quoted 7 lines
Quoted 5 lines
Fixes efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")
Cc Willem de Bruijn <[email protected]>

This doesn't apply to net-next.

Yes. I think this kind of patch should be submitted to net-next, but this is for the net tree. Please let me add more description.

Currently, the net and net-next trees conflict in udp[46]_lib_lookup2() between

efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")

and

7629c73a1466 ("udp: Extract helper for selecting socket from reuseport group") 2a08748cd384 ("udp6: Extract helper for selecting socket from reuseport group")
.

The conflict is reported in the link[0] and Jakub suggested how to resolve it[1]. To ease the merge conflict, Jakub and I have to send follow up patches to the bpf-next and net trees.

Now, his patchset (7629c73a1466 and 2a08748cd384) to bpf-next is merged into net-next, and his follow up patch is applied in bpf-next[2].

I fixed a bug in efc6b6f6c311, but it introduced an unnecessary variable and made the conflict worse. So I sent this follow up patch to net tree.

However, I do not know the best way to resolve the conflict, so any comments are welcome.

[0] https://lore.kernel.org/linux-next/[email protected]/
[1] https://lore.kernel.org/linux-next/[email protected]/
[2] https://lore.kernel.org/netdev/[email protected]/T/#t

Best Regards,
Kuniyuki

maintainer
#3 lore raw
Quoted 36 lines · Kuniyuki Iwashima
From:   David Miller <[email protected]>
Date:   Thu, 23 Jul 2020 15:10:51 -0700 (PDT)
Quoted 7 lines

From: Kuniyuki Iwashima <[email protected]>
Date: Thu, 23 Jul 2020 01:52:27 +0900

Quoted 4 lines

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.

Quoted 7 lines
Quoted 5 lines
Fixes efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")
Cc Willem de Bruijn <[email protected]>

This doesn't apply to net-next.

Yes. I think this kind of patch should be submitted to net-next, but this is for the net tree. Please let me add more description.

Currently, the net and net-next trees conflict in udp[46]_lib_lookup2() between

efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")

and

7629c73a1466 ("udp: Extract helper for selecting socket from reuseport group") 2a08748cd384 ("udp6: Extract helper for selecting socket from reuseport group")
.

The conflict is reported in the link[0] and Jakub suggested how to resolve it[1]. To ease the merge conflict, Jakub and I have to send follow up patches to the bpf-next and net trees.

Quoted 8 lines

Now, his patchset (7629c73a1466 and 2a08748cd384) to bpf-next is merged into net-next, and his follow up patch is applied in bpf-next[2].

I fixed a bug in efc6b6f6c311, but it introduced an unnecessary variable and made the conflict worse. So I sent this follow up patch to net tree.

However, I do not know the best way to resolve the conflict, so any comments are welcome.

Perhaps simpler is to apply this change to bpf-next:

"

                        badness = score;

- result = sk;
+ if (!result)
+ result = sk;
"

After which the remaining conflict between bpf-next and net is

"
++<<<<<<< HEAD
+ result = lookup_reuseport(net, sk, skb,
+ saddr, sport, daddr, hnum);
+ if (result && !reuseport_has_conns(sk, false))
+ return result;
+
+ badness = score;
+ if (!result)
+ result = sk;
++=======
+ reuseport_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_result ? : sk;
+ badness = score;
++>>>>>>> netdev-net/master
"

And we can just take bpf-next HEAD. Either that or handle the corresponding change in the merge fix-up itself.

(note that bpf-next is one patch ahead of netdev-nn)

#4 lore raw
Quoted 41 lines · Willem de Bruijn
Quoted 39 lines · Kuniyuki Iwashima
From:   David Miller <[email protected]>
Date:   Thu, 23 Jul 2020 15:10:51 -0700 (PDT)
Quoted 7 lines

From: Kuniyuki Iwashima <[email protected]>
Date: Thu, 23 Jul 2020 01:52:27 +0900

Quoted 4 lines

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.

Quoted 7 lines
Quoted 5 lines
Fixes efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")
Cc Willem de Bruijn <[email protected]>

This doesn't apply to net-next.

Yes. I think this kind of patch should be submitted to net-next, but this is for the net tree. Please let me add more description.

Currently, the net and net-next trees conflict in udp[46]_lib_lookup2() between

efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")

and

7629c73a1466 ("udp: Extract helper for selecting socket from reuseport group") 2a08748cd384 ("udp6: Extract helper for selecting socket from reuseport group")
.

The conflict is reported in the link[0] and Jakub suggested how to resolve it[1]. To ease the merge conflict, Jakub and I have to send follow up patches to the bpf-next and net trees.

Now, his patchset (7629c73a1466 and 2a08748cd384) to bpf-next is merged into net-next, and his follow up patch is applied in bpf-next[2].

Quoted 7 lines
Quoted 5 lines

I fixed a bug in efc6b6f6c311, but it introduced an unnecessary variable and made the conflict worse. So I sent this follow up patch to net tree.

However, I do not know the best way to resolve the conflict, so any comments are welcome.

Perhaps simpler is to apply this change to bpf-next:

I'm fine whichever way.
Could you please submit an official patch?

maintainer
#5 lore raw
Quoted 47 lines · Alexei Starovoitov
Quoted 44 lines · Willem de Bruijn
Quoted 42 lines · Kuniyuki Iwashima
From:   David Miller <[email protected]>
Date:   Thu, 23 Jul 2020 15:10:51 -0700 (PDT)
Quoted 7 lines

From: Kuniyuki Iwashima <[email protected]>
Date: Thu, 23 Jul 2020 01:52:27 +0900

Quoted 4 lines

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.

Quoted 7 lines
Quoted 5 lines
Fixes efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")
Cc Willem de Bruijn <[email protected]>

This doesn't apply to net-next.

Yes. I think this kind of patch should be submitted to net-next, but this is for the net tree. Please let me add more description.

Currently, the net and net-next trees conflict in udp[46]_lib_lookup2() between

efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.")

and

7629c73a1466 ("udp: Extract helper for selecting socket from reuseport group") 2a08748cd384 ("udp6: Extract helper for selecting socket from reuseport group")
.

The conflict is reported in the link[0] and Jakub suggested how to resolve it[1]. To ease the merge conflict, Jakub and I have to send follow up patches to the bpf-next and net trees.

Now, his patchset (7629c73a1466 and 2a08748cd384) to bpf-next is merged into net-next, and his follow up patch is applied in bpf-next[2].

I fixed a bug in efc6b6f6c311, but it introduced an unnecessary variable and made the conflict worse. So I sent this follow up patch to net tree.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

However, I do not know the best way to resolve the conflict, so any comments are welcome.

Perhaps simpler is to apply this change to bpf-next:

I'm fine whichever way.
Could you please submit an official patch?

http://patchwork.ozlabs.org/project/netdev/patch/[email protected]/

Not sure whether it helps vs doing this as part of the merge conflict (which remains). Either way after conflict resolution should be

"
static struct sock *udp4_lib_lookup2(struct net *net,
__be32 saddr, __be16 sport, __be32 daddr, unsigned int hnum, int dif, int sdif, struct udp_hslot *hslot2, struct sk_buff *skb)

{
        struct sock *sk, *result;
        int score, badness;

        result = NULL;
        badness = 0;
        udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) {
                score = compute_score(sk, net, saddr, sport,
                                      daddr, hnum, dif, sdif);
                if (score > badness) {
                        result = lookup_reuseport(net, sk, skb,
                                                  saddr, sport, daddr, hnum);
                        if (result && !reuseport_has_conns(sk, false))
                                return result;

                        badness = score;
                        if (!result)
                                result = sk;
                }
        }
        return result;
}

"

maintainer
#6 lore raw
In reply to Kuniyuki Iwashima

From: Kuniyuki Iwashima <[email protected]>
Date: Fri, 24 Jul 2020 15:13:04 +0900

Quoted 2 lines

Yes. I think this kind of patch should be submitted to net-next, but this is for the net tree. Please let me add more description.

This does not fix a bug, therefore 'net' is not appropriate.

The merge conflicts should be handled by the appropriate maintainer when the merges happen.

#7 lore raw
From:   David Miller <[email protected]>
Date:   Fri, 24 Jul 2020 16:48:47 -0700 (PDT)
Quoted 7 lines

From: Kuniyuki Iwashima <[email protected]>
Date: Fri, 24 Jul 2020 15:13:04 +0900

Quoted 2 lines

Yes. I think this kind of patch should be submitted to net-next, but this is for the net tree. Please let me add more description.

This does not fix a bug, therefore 'net' is not appropriate.

Exactly, I am sorry for the confusion.

Quoted 2 lines

The merge conflicts should be handled by the appropriate maintainer when the merges happen.

I will keep this in mind, thank you.

Best Regards,
Kuniyuki