diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-03-22 19:51:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-03-22 19:51:21 -0400 |
commit | 6ba5a3c52da00015e739469e3b00cd6d0d4c5c67 (patch) | |
tree | 0cbccb2dac9307cec25176eb94ff4f406a2061f7 /net/ipv4/udp.c | |
parent | 39d8cda76cfb1178455f9d196b39e773878e6c05 (diff) |
[UDP]: Make full use of proto.h.udp_hash innovation.
After this we have only udp_lib_get_port to get the port and two
stubs for ipv4 and ipv6. No difference in udp and udplite except
for initialized h.udp_hash member.
I tried to find a graceful way to drop the only difference between
udp_v4_get_port and udp_v6_get_port (i.e. the rcv_saddr comparison
routine), but adding one more callback on the struct proto didn't
appear such :( Maybe later.
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.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index fa946829d1e8..8c1f5eaafcd2 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -143,18 +143,17 @@ static inline int __udp_lib_lport_inuse(struct net *net, __u16 num, | |||
143 | } | 143 | } |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * __udp_lib_get_port - UDP/-Lite port lookup for IPv4 and IPv6 | 146 | * udp_lib_get_port - UDP/-Lite port lookup for IPv4 and IPv6 |
147 | * | 147 | * |
148 | * @sk: socket struct in question | 148 | * @sk: socket struct in question |
149 | * @snum: port number to look up | 149 | * @snum: port number to look up |
150 | * @udptable: hash list table, must be of UDP_HTABLE_SIZE | ||
151 | * @saddr_comp: AF-dependent comparison of bound local IP addresses | 150 | * @saddr_comp: AF-dependent comparison of bound local IP addresses |
152 | */ | 151 | */ |
153 | int __udp_lib_get_port(struct sock *sk, unsigned short snum, | 152 | int udp_lib_get_port(struct sock *sk, unsigned short snum, |
154 | struct hlist_head udptable[], | ||
155 | int (*saddr_comp)(const struct sock *sk1, | 153 | int (*saddr_comp)(const struct sock *sk1, |
156 | const struct sock *sk2 ) ) | 154 | const struct sock *sk2 ) ) |
157 | { | 155 | { |
156 | struct hlist_head *udptable = sk->sk_prot->h.udp_hash; | ||
158 | struct hlist_node *node; | 157 | struct hlist_node *node; |
159 | struct hlist_head *head; | 158 | struct hlist_head *head; |
160 | struct sock *sk2; | 159 | struct sock *sk2; |
@@ -240,13 +239,7 @@ fail: | |||
240 | return error; | 239 | return error; |
241 | } | 240 | } |
242 | 241 | ||
243 | int udp_get_port(struct sock *sk, unsigned short snum, | 242 | static int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2) |
244 | int (*scmp)(const struct sock *, const struct sock *)) | ||
245 | { | ||
246 | return __udp_lib_get_port(sk, snum, udp_hash, scmp); | ||
247 | } | ||
248 | |||
249 | int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2) | ||
250 | { | 243 | { |
251 | struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2); | 244 | struct inet_sock *inet1 = inet_sk(sk1), *inet2 = inet_sk(sk2); |
252 | 245 | ||
@@ -255,9 +248,9 @@ int ipv4_rcv_saddr_equal(const struct sock *sk1, const struct sock *sk2) | |||
255 | inet1->rcv_saddr == inet2->rcv_saddr )); | 248 | inet1->rcv_saddr == inet2->rcv_saddr )); |
256 | } | 249 | } |
257 | 250 | ||
258 | static inline int udp_v4_get_port(struct sock *sk, unsigned short snum) | 251 | int udp_v4_get_port(struct sock *sk, unsigned short snum) |
259 | { | 252 | { |
260 | return udp_get_port(sk, snum, ipv4_rcv_saddr_equal); | 253 | return udp_lib_get_port(sk, snum, ipv4_rcv_saddr_equal); |
261 | } | 254 | } |
262 | 255 | ||
263 | /* UDP is nearly always wildcards out the wazoo, it makes no sense to try | 256 | /* UDP is nearly always wildcards out the wazoo, it makes no sense to try |
@@ -1498,6 +1491,7 @@ struct proto udp_prot = { | |||
1498 | .sysctl_wmem = &sysctl_udp_wmem_min, | 1491 | .sysctl_wmem = &sysctl_udp_wmem_min, |
1499 | .sysctl_rmem = &sysctl_udp_rmem_min, | 1492 | .sysctl_rmem = &sysctl_udp_rmem_min, |
1500 | .obj_size = sizeof(struct udp_sock), | 1493 | .obj_size = sizeof(struct udp_sock), |
1494 | .h.udp_hash = udp_hash, | ||
1501 | #ifdef CONFIG_COMPAT | 1495 | #ifdef CONFIG_COMPAT |
1502 | .compat_setsockopt = compat_udp_setsockopt, | 1496 | .compat_setsockopt = compat_udp_setsockopt, |
1503 | .compat_getsockopt = compat_udp_getsockopt, | 1497 | .compat_getsockopt = compat_udp_getsockopt, |
@@ -1741,12 +1735,12 @@ EXPORT_SYMBOL(udp_disconnect); | |||
1741 | EXPORT_SYMBOL(udp_hash); | 1735 | EXPORT_SYMBOL(udp_hash); |
1742 | EXPORT_SYMBOL(udp_hash_lock); | 1736 | EXPORT_SYMBOL(udp_hash_lock); |
1743 | EXPORT_SYMBOL(udp_ioctl); | 1737 | EXPORT_SYMBOL(udp_ioctl); |
1744 | EXPORT_SYMBOL(udp_get_port); | ||
1745 | EXPORT_SYMBOL(udp_prot); | 1738 | EXPORT_SYMBOL(udp_prot); |
1746 | EXPORT_SYMBOL(udp_sendmsg); | 1739 | EXPORT_SYMBOL(udp_sendmsg); |
1747 | EXPORT_SYMBOL(udp_lib_getsockopt); | 1740 | EXPORT_SYMBOL(udp_lib_getsockopt); |
1748 | EXPORT_SYMBOL(udp_lib_setsockopt); | 1741 | EXPORT_SYMBOL(udp_lib_setsockopt); |
1749 | EXPORT_SYMBOL(udp_poll); | 1742 | EXPORT_SYMBOL(udp_poll); |
1743 | EXPORT_SYMBOL(udp_lib_get_port); | ||
1750 | 1744 | ||
1751 | #ifdef CONFIG_PROC_FS | 1745 | #ifdef CONFIG_PROC_FS |
1752 | EXPORT_SYMBOL(udp_proc_register); | 1746 | EXPORT_SYMBOL(udp_proc_register); |