|
@@ -445,7 +445,7 @@ static struct sock *udp4_lib_lookup2(struct net *net,
|
|
|
struct sk_buff *skb)
|
|
|
{
|
|
|
struct sock *sk, *result;
|
|
|
- int score, badness, matches = 0, reuseport = 0;
|
|
|
+ int score, badness;
|
|
|
u32 hash = 0;
|
|
|
|
|
|
result = NULL;
|
|
@@ -454,23 +454,16 @@ static struct sock *udp4_lib_lookup2(struct net *net,
|
|
|
score = compute_score(sk, net, saddr, sport,
|
|
|
daddr, hnum, dif, sdif, exact_dif);
|
|
|
if (score > badness) {
|
|
|
- reuseport = sk->sk_reuseport;
|
|
|
- if (reuseport) {
|
|
|
+ if (sk->sk_reuseport) {
|
|
|
hash = udp_ehashfn(net, daddr, hnum,
|
|
|
saddr, sport);
|
|
|
result = reuseport_select_sock(sk, hash, skb,
|
|
|
sizeof(struct udphdr));
|
|
|
if (result)
|
|
|
return result;
|
|
|
- matches = 1;
|
|
|
}
|
|
|
badness = score;
|
|
|
result = sk;
|
|
|
- } else if (score == badness && reuseport) {
|
|
|
- matches++;
|
|
|
- if (reciprocal_scale(hash, matches) == 0)
|
|
|
- result = sk;
|
|
|
- hash = next_pseudo_random32(hash);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
@@ -488,7 +481,7 @@ struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
|
|
|
unsigned int hash2, slot2, slot = udp_hashfn(net, hnum, udptable->mask);
|
|
|
struct udp_hslot *hslot2, *hslot = &udptable->hash[slot];
|
|
|
bool exact_dif = udp_lib_exact_dif_match(net, skb);
|
|
|
- int score, badness, matches = 0, reuseport = 0;
|
|
|
+ int score, badness;
|
|
|
u32 hash = 0;
|
|
|
|
|
|
if (hslot->count > 10) {
|
|
@@ -526,23 +519,16 @@ begin:
|
|
|
score = compute_score(sk, net, saddr, sport,
|
|
|
daddr, hnum, dif, sdif, exact_dif);
|
|
|
if (score > badness) {
|
|
|
- reuseport = sk->sk_reuseport;
|
|
|
- if (reuseport) {
|
|
|
+ if (sk->sk_reuseport) {
|
|
|
hash = udp_ehashfn(net, daddr, hnum,
|
|
|
saddr, sport);
|
|
|
result = reuseport_select_sock(sk, hash, skb,
|
|
|
sizeof(struct udphdr));
|
|
|
if (result)
|
|
|
return result;
|
|
|
- matches = 1;
|
|
|
}
|
|
|
result = sk;
|
|
|
badness = score;
|
|
|
- } else if (score == badness && reuseport) {
|
|
|
- matches++;
|
|
|
- if (reciprocal_scale(hash, matches) == 0)
|
|
|
- result = sk;
|
|
|
- hash = next_pseudo_random32(hash);
|
|
|
}
|
|
|
}
|
|
|
return result;
|