diff options
Diffstat (limited to 'net/sctp/protocol.c')
-rw-r--r-- | net/sctp/protocol.c | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index c2dd65d9f38d..0ec234b762c2 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -74,7 +74,7 @@ DEFINE_SPINLOCK(sctp_assocs_id_lock); | |||
74 | * the Out-of-the-blue (OOTB) packets. A control sock will be created | 74 | * the Out-of-the-blue (OOTB) packets. A control sock will be created |
75 | * for this socket at the initialization time. | 75 | * for this socket at the initialization time. |
76 | */ | 76 | */ |
77 | static struct socket *sctp_ctl_socket; | 77 | static struct sock *sctp_ctl_sock; |
78 | 78 | ||
79 | static struct sctp_pf *sctp_pf_inet6_specific; | 79 | static struct sctp_pf *sctp_pf_inet6_specific; |
80 | static struct sctp_pf *sctp_pf_inet_specific; | 80 | static struct sctp_pf *sctp_pf_inet_specific; |
@@ -91,7 +91,7 @@ int sysctl_sctp_wmem[3]; | |||
91 | /* Return the address of the control sock. */ | 91 | /* Return the address of the control sock. */ |
92 | struct sock *sctp_get_ctl_sock(void) | 92 | struct sock *sctp_get_ctl_sock(void) |
93 | { | 93 | { |
94 | return sctp_ctl_socket->sk; | 94 | return sctp_ctl_sock; |
95 | } | 95 | } |
96 | 96 | ||
97 | /* Set up the proc fs entry for the SCTP protocol. */ | 97 | /* Set up the proc fs entry for the SCTP protocol. */ |
@@ -363,7 +363,7 @@ static int sctp_v4_addr_valid(union sctp_addr *addr, | |||
363 | return 0; | 363 | return 0; |
364 | 364 | ||
365 | /* Is this a broadcast address? */ | 365 | /* Is this a broadcast address? */ |
366 | if (skb && ((struct rtable *)skb->dst)->rt_flags & RTCF_BROADCAST) | 366 | if (skb && skb->rtable->rt_flags & RTCF_BROADCAST) |
367 | return 0; | 367 | return 0; |
368 | 368 | ||
369 | return 1; | 369 | return 1; |
@@ -451,7 +451,7 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc, | |||
451 | fl.fl4_src = saddr->v4.sin_addr.s_addr; | 451 | fl.fl4_src = saddr->v4.sin_addr.s_addr; |
452 | 452 | ||
453 | SCTP_DEBUG_PRINTK("%s: DST:%u.%u.%u.%u, SRC:%u.%u.%u.%u - ", | 453 | SCTP_DEBUG_PRINTK("%s: DST:%u.%u.%u.%u, SRC:%u.%u.%u.%u - ", |
454 | __FUNCTION__, NIPQUAD(fl.fl4_dst), | 454 | __func__, NIPQUAD(fl.fl4_dst), |
455 | NIPQUAD(fl.fl4_src)); | 455 | NIPQUAD(fl.fl4_src)); |
456 | 456 | ||
457 | if (!ip_route_output_key(&init_net, &rt, &fl)) { | 457 | if (!ip_route_output_key(&init_net, &rt, &fl)) { |
@@ -539,7 +539,7 @@ static void sctp_v4_get_saddr(struct sctp_association *asoc, | |||
539 | /* What interface did this skb arrive on? */ | 539 | /* What interface did this skb arrive on? */ |
540 | static int sctp_v4_skb_iif(const struct sk_buff *skb) | 540 | static int sctp_v4_skb_iif(const struct sk_buff *skb) |
541 | { | 541 | { |
542 | return ((struct rtable *)skb->dst)->rt_iif; | 542 | return skb->rtable->rt_iif; |
543 | } | 543 | } |
544 | 544 | ||
545 | /* Was this packet marked by Explicit Congestion Notification? */ | 545 | /* Was this packet marked by Explicit Congestion Notification? */ |
@@ -554,7 +554,7 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk, | |||
554 | { | 554 | { |
555 | struct inet_sock *inet = inet_sk(sk); | 555 | struct inet_sock *inet = inet_sk(sk); |
556 | struct inet_sock *newinet; | 556 | struct inet_sock *newinet; |
557 | struct sock *newsk = sk_alloc(sk->sk_net, PF_INET, GFP_KERNEL, | 557 | struct sock *newsk = sk_alloc(sock_net(sk), PF_INET, GFP_KERNEL, |
558 | sk->sk_prot); | 558 | sk->sk_prot); |
559 | 559 | ||
560 | if (!newsk) | 560 | if (!newsk) |
@@ -630,6 +630,9 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, | |||
630 | struct sctp_sockaddr_entry *temp; | 630 | struct sctp_sockaddr_entry *temp; |
631 | int found = 0; | 631 | int found = 0; |
632 | 632 | ||
633 | if (dev_net(ifa->ifa_dev->dev) != &init_net) | ||
634 | return NOTIFY_DONE; | ||
635 | |||
633 | switch (ev) { | 636 | switch (ev) { |
634 | case NETDEV_UP: | 637 | case NETDEV_UP: |
635 | addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC); | 638 | addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC); |
@@ -679,16 +682,13 @@ static int sctp_ctl_sock_init(void) | |||
679 | else | 682 | else |
680 | family = PF_INET; | 683 | family = PF_INET; |
681 | 684 | ||
682 | err = sock_create_kern(family, SOCK_SEQPACKET, IPPROTO_SCTP, | 685 | err = inet_ctl_sock_create(&sctp_ctl_sock, family, |
683 | &sctp_ctl_socket); | 686 | SOCK_SEQPACKET, IPPROTO_SCTP, &init_net); |
684 | if (err < 0) { | 687 | if (err < 0) { |
685 | printk(KERN_ERR | 688 | printk(KERN_ERR |
686 | "SCTP: Failed to create the SCTP control socket.\n"); | 689 | "SCTP: Failed to create the SCTP control socket.\n"); |
687 | return err; | 690 | return err; |
688 | } | 691 | } |
689 | sctp_ctl_socket->sk->sk_allocation = GFP_ATOMIC; | ||
690 | inet_sk(sctp_ctl_socket->sk)->uc_ttl = -1; | ||
691 | |||
692 | return 0; | 692 | return 0; |
693 | } | 693 | } |
694 | 694 | ||
@@ -828,9 +828,9 @@ static inline int sctp_v4_xmit(struct sk_buff *skb, | |||
828 | { | 828 | { |
829 | SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, " | 829 | SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, " |
830 | "src:%u.%u.%u.%u, dst:%u.%u.%u.%u\n", | 830 | "src:%u.%u.%u.%u, dst:%u.%u.%u.%u\n", |
831 | __FUNCTION__, skb, skb->len, | 831 | __func__, skb, skb->len, |
832 | NIPQUAD(((struct rtable *)skb->dst)->rt_src), | 832 | NIPQUAD(skb->rtable->rt_src), |
833 | NIPQUAD(((struct rtable *)skb->dst)->rt_dst)); | 833 | NIPQUAD(skb->rtable->rt_dst)); |
834 | 834 | ||
835 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); | 835 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); |
836 | return ip_queue_xmit(skb, ipfragok); | 836 | return ip_queue_xmit(skb, ipfragok); |
@@ -974,24 +974,14 @@ int sctp_register_pf(struct sctp_pf *pf, sa_family_t family) | |||
974 | return 1; | 974 | return 1; |
975 | } | 975 | } |
976 | 976 | ||
977 | static int __init init_sctp_mibs(void) | 977 | static inline int init_sctp_mibs(void) |
978 | { | 978 | { |
979 | sctp_statistics[0] = alloc_percpu(struct sctp_mib); | 979 | return snmp_mib_init((void**)sctp_statistics, sizeof(struct sctp_mib)); |
980 | if (!sctp_statistics[0]) | ||
981 | return -ENOMEM; | ||
982 | sctp_statistics[1] = alloc_percpu(struct sctp_mib); | ||
983 | if (!sctp_statistics[1]) { | ||
984 | free_percpu(sctp_statistics[0]); | ||
985 | return -ENOMEM; | ||
986 | } | ||
987 | return 0; | ||
988 | |||
989 | } | 980 | } |
990 | 981 | ||
991 | static void cleanup_sctp_mibs(void) | 982 | static inline void cleanup_sctp_mibs(void) |
992 | { | 983 | { |
993 | free_percpu(sctp_statistics[0]); | 984 | snmp_mib_free((void**)sctp_statistics); |
994 | free_percpu(sctp_statistics[1]); | ||
995 | } | 985 | } |
996 | 986 | ||
997 | static void sctp_v4_pf_init(void) | 987 | static void sctp_v4_pf_init(void) |
@@ -1286,7 +1276,7 @@ err_v6_add_protocol: | |||
1286 | sctp_v6_del_protocol(); | 1276 | sctp_v6_del_protocol(); |
1287 | err_add_protocol: | 1277 | err_add_protocol: |
1288 | sctp_v4_del_protocol(); | 1278 | sctp_v4_del_protocol(); |
1289 | sock_release(sctp_ctl_socket); | 1279 | inet_ctl_sock_destroy(sctp_ctl_sock); |
1290 | err_ctl_sock_init: | 1280 | err_ctl_sock_init: |
1291 | sctp_v6_protosw_exit(); | 1281 | sctp_v6_protosw_exit(); |
1292 | err_v6_protosw_init: | 1282 | err_v6_protosw_init: |
@@ -1330,7 +1320,7 @@ SCTP_STATIC __exit void sctp_exit(void) | |||
1330 | sctp_v4_del_protocol(); | 1320 | sctp_v4_del_protocol(); |
1331 | 1321 | ||
1332 | /* Free the control endpoint. */ | 1322 | /* Free the control endpoint. */ |
1333 | sock_release(sctp_ctl_socket); | 1323 | inet_ctl_sock_destroy(sctp_ctl_sock); |
1334 | 1324 | ||
1335 | /* Free protosw registrations */ | 1325 | /* Free protosw registrations */ |
1336 | sctp_v6_protosw_exit(); | 1326 | sctp_v6_protosw_exit(); |