aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/udp.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-06-16 20:11:50 -0400
committerDavid S. Miller <davem@davemloft.net>2008-06-16 20:11:50 -0400
commitd6266281f8175e3ad68c28b20a609b278b47ade5 (patch)
tree16e8643eb5560d70daf1097c3a09df21b6d186c1 /net/ipv4/udp.c
parent942e7b102a4827fdb69a39c7f07c544542589ef9 (diff)
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>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r--net/ipv4/udp.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index eba790dcd16b..d8f527d15701 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -134,7 +134,7 @@ static inline int __udp_lib_lport_inuse(struct net *net, __u16 num,
134 struct sock *sk; 134 struct sock *sk;
135 struct hlist_node *node; 135 struct hlist_node *node;
136 136
137 sk_for_each(sk, node, &udptable[num & (UDP_HTABLE_SIZE - 1)]) 137 sk_for_each(sk, node, &udptable[udp_hashfn(num)])
138 if (net_eq(sock_net(sk), net) && sk->sk_hash == num) 138 if (net_eq(sock_net(sk), net) && sk->sk_hash == num)
139 return 1; 139 return 1;
140 return 0; 140 return 0;
@@ -174,7 +174,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
174 for (i = 0; i < UDP_HTABLE_SIZE; i++) { 174 for (i = 0; i < UDP_HTABLE_SIZE; i++) {
175 int size = 0; 175 int size = 0;
176 176
177 head = &udptable[rover & (UDP_HTABLE_SIZE - 1)]; 177 head = &udptable[udp_hashfn(rover)];
178 if (hlist_empty(head)) 178 if (hlist_empty(head))
179 goto gotit; 179 goto gotit;
180 180
@@ -211,7 +211,7 @@ int udp_lib_get_port(struct sock *sk, unsigned short snum,
211gotit: 211gotit:
212 snum = rover; 212 snum = rover;
213 } else { 213 } else {
214 head = &udptable[snum & (UDP_HTABLE_SIZE - 1)]; 214 head = &udptable[udp_hashfn(snum)];
215 215
216 sk_for_each(sk2, node, head) 216 sk_for_each(sk2, node, head)
217 if (sk2->sk_hash == snum && 217 if (sk2->sk_hash == snum &&
@@ -227,7 +227,7 @@ gotit:
227 inet_sk(sk)->num = snum; 227 inet_sk(sk)->num = snum;
228 sk->sk_hash = snum; 228 sk->sk_hash = snum;
229 if (sk_unhashed(sk)) { 229 if (sk_unhashed(sk)) {
230 head = &udptable[snum & (UDP_HTABLE_SIZE - 1)]; 230 head = &udptable[udp_hashfn(snum)];
231 sk_add_node(sk, head); 231 sk_add_node(sk, head);
232 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); 232 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
233 } 233 }
@@ -264,7 +264,7 @@ static struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
264 int badness = -1; 264 int badness = -1;
265 265
266 read_lock(&udp_hash_lock); 266 read_lock(&udp_hash_lock);
267 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { 267 sk_for_each(sk, node, &udptable[udp_hashfn(hnum)]) {
268 struct inet_sock *inet = inet_sk(sk); 268 struct inet_sock *inet = inet_sk(sk);
269 269
270 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum && 270 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
@@ -1068,7 +1068,7 @@ static int __udp4_lib_mcast_deliver(struct sk_buff *skb,
1068 int dif; 1068 int dif;
1069 1069
1070 read_lock(&udp_hash_lock); 1070 read_lock(&udp_hash_lock);
1071 sk = sk_head(&udptable[ntohs(uh->dest) & (UDP_HTABLE_SIZE - 1)]); 1071 sk = sk_head(&udptable[udp_hashfn(ntohs(uh->dest))]);
1072 dif = skb->dev->ifindex; 1072 dif = skb->dev->ifindex;
1073 sk = udp_v4_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif); 1073 sk = udp_v4_mcast_next(sk, uh->dest, daddr, uh->source, saddr, dif);
1074 if (sk) { 1074 if (sk) {