]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/sctp/protocol.c
avr32: proc: use non-racy method for /proc/tlb creation
[linux-2.6-omap-h63xx.git] / net / sctp / protocol.c
index 5aea91137fbb3c8760dc210b72b74b09930a8218..0ec234b762c20f3a876e326017df3626a4ee9759 100644 (file)
@@ -74,7 +74,7 @@ DEFINE_SPINLOCK(sctp_assocs_id_lock);
  * the Out-of-the-blue (OOTB) packets.  A control sock will be created
  * for this socket at the initialization time.
  */
-static struct socket *sctp_ctl_socket;
+static struct sock *sctp_ctl_sock;
 
 static struct sctp_pf *sctp_pf_inet6_specific;
 static struct sctp_pf *sctp_pf_inet_specific;
@@ -91,7 +91,7 @@ int sysctl_sctp_wmem[3];
 /* Return the address of the control sock. */
 struct sock *sctp_get_ctl_sock(void)
 {
-       return sctp_ctl_socket->sk;
+       return sctp_ctl_sock;
 }
 
 /* Set up the proc fs entry for the SCTP protocol. */
@@ -650,7 +650,9 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
                spin_lock_bh(&sctp_local_addr_lock);
                list_for_each_entry_safe(addr, temp,
                                        &sctp_local_addr_list, list) {
-                       if (addr->a.v4.sin_addr.s_addr == ifa->ifa_local) {
+                       if (addr->a.sa.sa_family == AF_INET &&
+                                       addr->a.v4.sin_addr.s_addr ==
+                                       ifa->ifa_local) {
                                found = 1;
                                addr->valid = 0;
                                list_del_rcu(&addr->list);
@@ -680,16 +682,13 @@ static int sctp_ctl_sock_init(void)
        else
                family = PF_INET;
 
-       err = sock_create_kern(family, SOCK_SEQPACKET, IPPROTO_SCTP,
-                              &sctp_ctl_socket);
+       err = inet_ctl_sock_create(&sctp_ctl_sock, family,
+                                  SOCK_SEQPACKET, IPPROTO_SCTP, &init_net);
        if (err < 0) {
                printk(KERN_ERR
                       "SCTP: Failed to create the SCTP control socket.\n");
                return err;
        }
-       sctp_ctl_socket->sk->sk_allocation = GFP_ATOMIC;
-       inet_sk(sctp_ctl_socket->sk)->uc_ttl = -1;
-
        return 0;
 }
 
@@ -975,24 +974,14 @@ int sctp_register_pf(struct sctp_pf *pf, sa_family_t family)
        return 1;
 }
 
-static int __init init_sctp_mibs(void)
+static inline int init_sctp_mibs(void)
 {
-       sctp_statistics[0] = alloc_percpu(struct sctp_mib);
-       if (!sctp_statistics[0])
-               return -ENOMEM;
-       sctp_statistics[1] = alloc_percpu(struct sctp_mib);
-       if (!sctp_statistics[1]) {
-               free_percpu(sctp_statistics[0]);
-               return -ENOMEM;
-       }
-       return 0;
-
+       return snmp_mib_init((void**)sctp_statistics, sizeof(struct sctp_mib));
 }
 
-static void cleanup_sctp_mibs(void)
+static inline void cleanup_sctp_mibs(void)
 {
-       free_percpu(sctp_statistics[0]);
-       free_percpu(sctp_statistics[1]);
+       snmp_mib_free((void**)sctp_statistics);
 }
 
 static void sctp_v4_pf_init(void)
@@ -1287,7 +1276,7 @@ err_v6_add_protocol:
        sctp_v6_del_protocol();
 err_add_protocol:
        sctp_v4_del_protocol();
-       sock_release(sctp_ctl_socket);
+       inet_ctl_sock_destroy(sctp_ctl_sock);
 err_ctl_sock_init:
        sctp_v6_protosw_exit();
 err_v6_protosw_init:
@@ -1331,7 +1320,7 @@ SCTP_STATIC __exit void sctp_exit(void)
        sctp_v4_del_protocol();
 
        /* Free the control endpoint.  */
-       sock_release(sctp_ctl_socket);
+       inet_ctl_sock_destroy(sctp_ctl_sock);
 
        /* Free protosw registrations */
        sctp_v6_protosw_exit();