aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/udp.c22
-rw-r--r--net/ipv4/udp_impl.h6
-rw-r--r--net/ipv4/udplite.c15
3 files changed, 11 insertions, 32 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 */
153int __udp_lib_get_port(struct sock *sk, unsigned short snum, 152int 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
243int udp_get_port(struct sock *sk, unsigned short snum, 242static 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
249int 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
258static inline int udp_v4_get_port(struct sock *sk, unsigned short snum) 251int 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);
1741EXPORT_SYMBOL(udp_hash); 1735EXPORT_SYMBOL(udp_hash);
1742EXPORT_SYMBOL(udp_hash_lock); 1736EXPORT_SYMBOL(udp_hash_lock);
1743EXPORT_SYMBOL(udp_ioctl); 1737EXPORT_SYMBOL(udp_ioctl);
1744EXPORT_SYMBOL(udp_get_port);
1745EXPORT_SYMBOL(udp_prot); 1738EXPORT_SYMBOL(udp_prot);
1746EXPORT_SYMBOL(udp_sendmsg); 1739EXPORT_SYMBOL(udp_sendmsg);
1747EXPORT_SYMBOL(udp_lib_getsockopt); 1740EXPORT_SYMBOL(udp_lib_getsockopt);
1748EXPORT_SYMBOL(udp_lib_setsockopt); 1741EXPORT_SYMBOL(udp_lib_setsockopt);
1749EXPORT_SYMBOL(udp_poll); 1742EXPORT_SYMBOL(udp_poll);
1743EXPORT_SYMBOL(udp_lib_get_port);
1750 1744
1751#ifdef CONFIG_PROC_FS 1745#ifdef CONFIG_PROC_FS
1752EXPORT_SYMBOL(udp_proc_register); 1746EXPORT_SYMBOL(udp_proc_register);
diff --git a/net/ipv4/udp_impl.h b/net/ipv4/udp_impl.h
index 6c55828e41ba..7288bf7977fb 100644
--- a/net/ipv4/udp_impl.h
+++ b/net/ipv4/udp_impl.h
@@ -8,11 +8,7 @@
8extern int __udp4_lib_rcv(struct sk_buff *, struct hlist_head [], int ); 8extern int __udp4_lib_rcv(struct sk_buff *, struct hlist_head [], int );
9extern void __udp4_lib_err(struct sk_buff *, u32, struct hlist_head []); 9extern void __udp4_lib_err(struct sk_buff *, u32, struct hlist_head []);
10 10
11extern int __udp_lib_get_port(struct sock *sk, unsigned short snum, 11extern int udp_v4_get_port(struct sock *sk, unsigned short snum);
12 struct hlist_head udptable[],
13 int (*)(const struct sock*,const struct sock*));
14extern int ipv4_rcv_saddr_equal(const struct sock *, const struct sock *);
15
16 12
17extern int udp_setsockopt(struct sock *sk, int level, int optname, 13extern int udp_setsockopt(struct sock *sk, int level, int optname,
18 char __user *optval, int optlen); 14 char __user *optval, int optlen);
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c
index 2469b5104587..8d42e344b043 100644
--- a/net/ipv4/udplite.c
+++ b/net/ipv4/udplite.c
@@ -17,17 +17,6 @@ DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics) __read_mostly;
17 17
18struct hlist_head udplite_hash[UDP_HTABLE_SIZE]; 18struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
19 19
20int udplite_get_port(struct sock *sk, unsigned short p,
21 int (*c)(const struct sock *, const struct sock *))
22{
23 return __udp_lib_get_port(sk, p, udplite_hash, c);
24}
25
26static int udplite_v4_get_port(struct sock *sk, unsigned short snum)
27{
28 return udplite_get_port(sk, snum, ipv4_rcv_saddr_equal);
29}
30
31static int udplite_rcv(struct sk_buff *skb) 20static int udplite_rcv(struct sk_buff *skb)
32{ 21{
33 return __udp4_lib_rcv(skb, udplite_hash, IPPROTO_UDPLITE); 22 return __udp4_lib_rcv(skb, udplite_hash, IPPROTO_UDPLITE);
@@ -63,8 +52,9 @@ struct proto udplite_prot = {
63 .backlog_rcv = udp_queue_rcv_skb, 52 .backlog_rcv = udp_queue_rcv_skb,
64 .hash = udp_lib_hash, 53 .hash = udp_lib_hash,
65 .unhash = udp_lib_unhash, 54 .unhash = udp_lib_unhash,
66 .get_port = udplite_v4_get_port, 55 .get_port = udp_v4_get_port,
67 .obj_size = sizeof(struct udp_sock), 56 .obj_size = sizeof(struct udp_sock),
57 .h.udp_hash = udplite_hash,
68#ifdef CONFIG_COMPAT 58#ifdef CONFIG_COMPAT
69 .compat_setsockopt = compat_udp_setsockopt, 59 .compat_setsockopt = compat_udp_setsockopt,
70 .compat_getsockopt = compat_udp_getsockopt, 60 .compat_getsockopt = compat_udp_getsockopt,
@@ -118,4 +108,3 @@ out_register_err:
118 108
119EXPORT_SYMBOL(udplite_hash); 109EXPORT_SYMBOL(udplite_hash);
120EXPORT_SYMBOL(udplite_prot); 110EXPORT_SYMBOL(udplite_prot);
121EXPORT_SYMBOL(udplite_get_port);