udp: introduce a udp_hashfn function
Currently the chain to store a UDP socket is calculated with simple (x & (UDP_HTABLE_SIZE - 1)). But taking net into account would make this calculation a bit more complex, so moving it into a function would help. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
942e7b102a
commit
d6266281f8
@@ -65,7 +65,7 @@ static struct sock *__udp6_lib_lookup(struct net *net,
|
||||
int badness = -1;
|
||||
|
||||
read_lock(&udp_hash_lock);
|
||||
sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
|
||||
sk_for_each(sk, node, &udptable[udp_hashfn(hnum)]) {
|
||||
struct inet_sock *inet = inet_sk(sk);
|
||||
|
||||
if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
|
||||
@@ -361,7 +361,7 @@ static int __udp6_lib_mcast_deliver(struct sk_buff *skb, struct in6_addr *saddr,
|
||||
int dif;
|
||||
|
||||
read_lock(&udp_hash_lock);
|
||||
sk = sk_head(&udptable[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]);
|
||||
sk = sk_head(&udptable[udp_hashfn(ntohs(uh->dest))]);
|
||||
dif = inet6_iif(skb);
|
||||
sk = udp_v6_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif);
|
||||
if (!sk) {
|
||||
|
Reference in New Issue
Block a user