aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/udp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/udp.c')
-rw-r--r--net/ipv6/udp.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 53739de829db..1fd784f3e2ec 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -51,9 +51,9 @@
51#include <linux/seq_file.h> 51#include <linux/seq_file.h>
52#include "udp_impl.h" 52#include "udp_impl.h"
53 53
54static inline int udp_v6_get_port(struct sock *sk, unsigned short snum) 54int udp_v6_get_port(struct sock *sk, unsigned short snum)
55{ 55{
56 return udp_get_port(sk, snum, ipv6_rcv_saddr_equal); 56 return udp_lib_get_port(sk, snum, ipv6_rcv_saddr_equal);
57} 57}
58 58
59static struct sock *__udp6_lib_lookup(struct net *net, 59static struct sock *__udp6_lib_lookup(struct net *net,
@@ -70,7 +70,7 @@ static struct sock *__udp6_lib_lookup(struct net *net,
70 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) { 70 sk_for_each(sk, node, &udptable[hnum & (UDP_HTABLE_SIZE - 1)]) {
71 struct inet_sock *inet = inet_sk(sk); 71 struct inet_sock *inet = inet_sk(sk);
72 72
73 if (sk->sk_net == net && sk->sk_hash == hnum && 73 if (net_eq(sock_net(sk), net) && sk->sk_hash == hnum &&
74 sk->sk_family == PF_INET6) { 74 sk->sk_family == PF_INET6) {
75 struct ipv6_pinfo *np = inet6_sk(sk); 75 struct ipv6_pinfo *np = inet6_sk(sk);
76 int score = 0; 76 int score = 0;
@@ -235,7 +235,7 @@ void __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
235 struct sock *sk; 235 struct sock *sk;
236 int err; 236 int err;
237 237
238 sk = __udp6_lib_lookup(skb->dev->nd_net, daddr, uh->dest, 238 sk = __udp6_lib_lookup(dev_net(skb->dev), daddr, uh->dest,
239 saddr, uh->source, inet6_iif(skb), udptable); 239 saddr, uh->source, inet6_iif(skb), udptable);
240 if (sk == NULL) 240 if (sk == NULL)
241 return; 241 return;
@@ -323,6 +323,9 @@ static struct sock *udp_v6_mcast_next(struct sock *sk,
323 sk_for_each_from(s, node) { 323 sk_for_each_from(s, node) {
324 struct inet_sock *inet = inet_sk(s); 324 struct inet_sock *inet = inet_sk(s);
325 325
326 if (sock_net(s) != sock_net(sk))
327 continue;
328
326 if (s->sk_hash == num && s->sk_family == PF_INET6) { 329 if (s->sk_hash == num && s->sk_family == PF_INET6) {
327 struct ipv6_pinfo *np = inet6_sk(s); 330 struct ipv6_pinfo *np = inet6_sk(s);
328 if (inet->dport) { 331 if (inet->dport) {
@@ -480,7 +483,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[],
480 * check socket cache ... must talk to Alan about his plans 483 * check socket cache ... must talk to Alan about his plans
481 * for sock caches... i'll skip this for now. 484 * for sock caches... i'll skip this for now.
482 */ 485 */
483 sk = __udp6_lib_lookup(skb->dev->nd_net, saddr, uh->source, 486 sk = __udp6_lib_lookup(dev_net(skb->dev), saddr, uh->source,
484 daddr, uh->dest, inet6_iif(skb), udptable); 487 daddr, uh->dest, inet6_iif(skb), udptable);
485 488
486 if (sk == NULL) { 489 if (sk == NULL) {
@@ -749,7 +752,10 @@ do_udp_sendmsg:
749 opt = ipv6_fixup_options(&opt_space, opt); 752 opt = ipv6_fixup_options(&opt_space, opt);
750 753
751 fl.proto = sk->sk_protocol; 754 fl.proto = sk->sk_protocol;
752 ipv6_addr_copy(&fl.fl6_dst, daddr); 755 if (!ipv6_addr_any(daddr))
756 ipv6_addr_copy(&fl.fl6_dst, daddr);
757 else
758 fl.fl6_dst.s6_addr[15] = 0x1; /* :: means loopback (BSD'ism) */
753 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) 759 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
754 ipv6_addr_copy(&fl.fl6_src, &np->saddr); 760 ipv6_addr_copy(&fl.fl6_src, &np->saddr);
755 fl.fl_ip_sport = inet->sport; 761 fl.fl_ip_sport = inet->sport;
@@ -789,9 +795,7 @@ do_udp_sendmsg:
789 else 795 else
790 hlimit = np->hop_limit; 796 hlimit = np->hop_limit;
791 if (hlimit < 0) 797 if (hlimit < 0)
792 hlimit = dst_metric(dst, RTAX_HOPLIMIT); 798 hlimit = ip6_dst_hoplimit(dst);
793 if (hlimit < 0)
794 hlimit = ipv6_get_hoplimit(dst->dev);
795 } 799 }
796 800
797 if (tclass < 0) { 801 if (tclass < 0) {
@@ -976,30 +980,30 @@ int udp6_seq_show(struct seq_file *seq, void *v)
976 return 0; 980 return 0;
977} 981}
978 982
979static struct file_operations udp6_seq_fops;
980static struct udp_seq_afinfo udp6_seq_afinfo = { 983static struct udp_seq_afinfo udp6_seq_afinfo = {
981 .owner = THIS_MODULE,
982 .name = "udp6", 984 .name = "udp6",
983 .family = AF_INET6, 985 .family = AF_INET6,
984 .hashtable = udp_hash, 986 .hashtable = udp_hash,
985 .seq_show = udp6_seq_show, 987 .seq_fops = {
986 .seq_fops = &udp6_seq_fops, 988 .owner = THIS_MODULE,
989 },
990 .seq_ops = {
991 .show = udp6_seq_show,
992 },
987}; 993};
988 994
989int __init udp6_proc_init(void) 995int udp6_proc_init(struct net *net)
990{ 996{
991 return udp_proc_register(&udp6_seq_afinfo); 997 return udp_proc_register(net, &udp6_seq_afinfo);
992} 998}
993 999
994void udp6_proc_exit(void) { 1000void udp6_proc_exit(struct net *net) {
995 udp_proc_unregister(&udp6_seq_afinfo); 1001 udp_proc_unregister(net, &udp6_seq_afinfo);
996} 1002}
997#endif /* CONFIG_PROC_FS */ 1003#endif /* CONFIG_PROC_FS */
998 1004
999/* ------------------------------------------------------------------------ */ 1005/* ------------------------------------------------------------------------ */
1000 1006
1001DEFINE_PROTO_INUSE(udpv6)
1002
1003struct proto udpv6_prot = { 1007struct proto udpv6_prot = {
1004 .name = "UDPv6", 1008 .name = "UDPv6",
1005 .owner = THIS_MODULE, 1009 .owner = THIS_MODULE,
@@ -1021,11 +1025,11 @@ struct proto udpv6_prot = {
1021 .sysctl_wmem = &sysctl_udp_wmem_min, 1025 .sysctl_wmem = &sysctl_udp_wmem_min,
1022 .sysctl_rmem = &sysctl_udp_rmem_min, 1026 .sysctl_rmem = &sysctl_udp_rmem_min,
1023 .obj_size = sizeof(struct udp6_sock), 1027 .obj_size = sizeof(struct udp6_sock),
1028 .h.udp_hash = udp_hash,
1024#ifdef CONFIG_COMPAT 1029#ifdef CONFIG_COMPAT
1025 .compat_setsockopt = compat_udpv6_setsockopt, 1030 .compat_setsockopt = compat_udpv6_setsockopt,
1026 .compat_getsockopt = compat_udpv6_getsockopt, 1031 .compat_getsockopt = compat_udpv6_getsockopt,
1027#endif 1032#endif
1028 REF_PROTO_INUSE(udpv6)
1029}; 1033};
1030 1034
1031static struct inet_protosw udpv6_protosw = { 1035static struct inet_protosw udpv6_protosw = {