X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=net%2Fsctp%2Fprotocol.c;h=0ec234b762c20f3a876e326017df3626a4ee9759;hb=44473d991332053eb3fea1e08f8a6ee2c6fb409c;hp=beea2fb18b157f5903f5618ccf1952184cc7ede8;hpb=a25606c845856e5ca5ed54d23cab077e3a49bf10;p=linux-2.6 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index beea2fb18b..0ec234b762 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -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. */ @@ -554,7 +554,7 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk, { struct inet_sock *inet = inet_sk(sk); struct inet_sock *newinet; - struct sock *newsk = sk_alloc(sk->sk_net, PF_INET, GFP_KERNEL, + struct sock *newsk = sk_alloc(sock_net(sk), PF_INET, GFP_KERNEL, sk->sk_prot); if (!newsk) @@ -630,7 +630,7 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, struct sctp_sockaddr_entry *temp; int found = 0; - if (ifa->ifa_dev->dev->nd_net != &init_net) + if (dev_net(ifa->ifa_dev->dev) != &init_net) return NOTIFY_DONE; switch (ev) { @@ -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();