diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-02 16:38:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-02 16:38:27 -0400 |
commit | aecdc33e111b2c447b622e287c6003726daa1426 (patch) | |
tree | 3e7657eae4b785e1a1fb5dfb225dbae0b2f0cfc6 /net/sctp/protocol.c | |
parent | a20acf99f75e49271381d65db097c9763060a1e8 (diff) | |
parent | a3a6cab5ea10cca64d036851fe0d932448f2fe4f (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking changes from David Miller:
1) GRE now works over ipv6, from Dmitry Kozlov.
2) Make SCTP more network namespace aware, from Eric Biederman.
3) TEAM driver now works with non-ethernet devices, from Jiri Pirko.
4) Make openvswitch network namespace aware, from Pravin B Shelar.
5) IPV6 NAT implementation, from Patrick McHardy.
6) Server side support for TCP Fast Open, from Jerry Chu and others.
7) Packet BPF filter supports MOD and XOR, from Eric Dumazet and Daniel
Borkmann.
8) Increate the loopback default MTU to 64K, from Eric Dumazet.
9) Use a per-task rather than per-socket page fragment allocator for
outgoing networking traffic. This benefits processes that have very
many mostly idle sockets, which is quite common.
From Eric Dumazet.
10) Use up to 32K for page fragment allocations, with fallbacks to
smaller sizes when higher order page allocations fail. Benefits are
a) less segments for driver to process b) less calls to page
allocator c) less waste of space.
From Eric Dumazet.
11) Allow GRO to be used on GRE tunnels, from Eric Dumazet.
12) VXLAN device driver, one way to handle VLAN issues such as the
limitation of 4096 VLAN IDs yet still have some level of isolation.
From Stephen Hemminger.
13) As usual there is a large boatload of driver changes, with the scale
perhaps tilted towards the wireless side this time around.
Fix up various fairly trivial conflicts, mostly caused by the user
namespace changes.
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1012 commits)
hyperv: Add buffer for extended info after the RNDIS response message.
hyperv: Report actual status in receive completion packet
hyperv: Remove extra allocated space for recv_pkt_list elements
hyperv: Fix page buffer handling in rndis_filter_send_request()
hyperv: Fix the missing return value in rndis_filter_set_packet_filter()
hyperv: Fix the max_xfer_size in RNDIS initialization
vxlan: put UDP socket in correct namespace
vxlan: Depend on CONFIG_INET
sfc: Fix the reported priorities of different filter types
sfc: Remove EFX_FILTER_FLAG_RX_OVERRIDE_IP
sfc: Fix loopback self-test with separate_tx_channels=1
sfc: Fix MCDI structure field lookup
sfc: Add parentheses around use of bitfield macro arguments
sfc: Fix null function pointer in efx_sriov_channel_type
vxlan: virtual extensible lan
igmp: export symbol ip_mc_leave_group
netlink: add attributes to fdb interface
tg3: unconditionally select HWMON support when tg3 is enabled.
Revert "net: ti cpsw ethernet: allow reading phy interface mode from DT"
gre: fix sparse warning
...
Diffstat (limited to 'net/sctp/protocol.c')
-rw-r--r-- | net/sctp/protocol.c | 454 |
1 files changed, 232 insertions, 222 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 1f89c4e69645..2d518425d598 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -69,21 +69,10 @@ | |||
69 | 69 | ||
70 | /* Global data structures. */ | 70 | /* Global data structures. */ |
71 | struct sctp_globals sctp_globals __read_mostly; | 71 | struct sctp_globals sctp_globals __read_mostly; |
72 | DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics) __read_mostly; | ||
73 | |||
74 | #ifdef CONFIG_PROC_FS | ||
75 | struct proc_dir_entry *proc_net_sctp; | ||
76 | #endif | ||
77 | 72 | ||
78 | struct idr sctp_assocs_id; | 73 | struct idr sctp_assocs_id; |
79 | DEFINE_SPINLOCK(sctp_assocs_id_lock); | 74 | DEFINE_SPINLOCK(sctp_assocs_id_lock); |
80 | 75 | ||
81 | /* This is the global socket data structure used for responding to | ||
82 | * the Out-of-the-blue (OOTB) packets. A control sock will be created | ||
83 | * for this socket at the initialization time. | ||
84 | */ | ||
85 | static struct sock *sctp_ctl_sock; | ||
86 | |||
87 | static struct sctp_pf *sctp_pf_inet6_specific; | 76 | static struct sctp_pf *sctp_pf_inet6_specific; |
88 | static struct sctp_pf *sctp_pf_inet_specific; | 77 | static struct sctp_pf *sctp_pf_inet_specific; |
89 | static struct sctp_af *sctp_af_v4_specific; | 78 | static struct sctp_af *sctp_af_v4_specific; |
@@ -96,74 +85,54 @@ long sysctl_sctp_mem[3]; | |||
96 | int sysctl_sctp_rmem[3]; | 85 | int sysctl_sctp_rmem[3]; |
97 | int sysctl_sctp_wmem[3]; | 86 | int sysctl_sctp_wmem[3]; |
98 | 87 | ||
99 | /* Return the address of the control sock. */ | ||
100 | struct sock *sctp_get_ctl_sock(void) | ||
101 | { | ||
102 | return sctp_ctl_sock; | ||
103 | } | ||
104 | |||
105 | /* Set up the proc fs entry for the SCTP protocol. */ | 88 | /* Set up the proc fs entry for the SCTP protocol. */ |
106 | static __init int sctp_proc_init(void) | 89 | static __net_init int sctp_proc_init(struct net *net) |
107 | { | 90 | { |
108 | if (percpu_counter_init(&sctp_sockets_allocated, 0)) | ||
109 | goto out_nomem; | ||
110 | #ifdef CONFIG_PROC_FS | 91 | #ifdef CONFIG_PROC_FS |
111 | if (!proc_net_sctp) { | 92 | net->sctp.proc_net_sctp = proc_net_mkdir(net, "sctp", net->proc_net); |
112 | proc_net_sctp = proc_mkdir("sctp", init_net.proc_net); | 93 | if (!net->sctp.proc_net_sctp) |
113 | if (!proc_net_sctp) | 94 | goto out_proc_net_sctp; |
114 | goto out_free_percpu; | 95 | if (sctp_snmp_proc_init(net)) |
115 | } | ||
116 | |||
117 | if (sctp_snmp_proc_init()) | ||
118 | goto out_snmp_proc_init; | 96 | goto out_snmp_proc_init; |
119 | if (sctp_eps_proc_init()) | 97 | if (sctp_eps_proc_init(net)) |
120 | goto out_eps_proc_init; | 98 | goto out_eps_proc_init; |
121 | if (sctp_assocs_proc_init()) | 99 | if (sctp_assocs_proc_init(net)) |
122 | goto out_assocs_proc_init; | 100 | goto out_assocs_proc_init; |
123 | if (sctp_remaddr_proc_init()) | 101 | if (sctp_remaddr_proc_init(net)) |
124 | goto out_remaddr_proc_init; | 102 | goto out_remaddr_proc_init; |
125 | 103 | ||
126 | return 0; | 104 | return 0; |
127 | 105 | ||
128 | out_remaddr_proc_init: | 106 | out_remaddr_proc_init: |
129 | sctp_assocs_proc_exit(); | 107 | sctp_assocs_proc_exit(net); |
130 | out_assocs_proc_init: | 108 | out_assocs_proc_init: |
131 | sctp_eps_proc_exit(); | 109 | sctp_eps_proc_exit(net); |
132 | out_eps_proc_init: | 110 | out_eps_proc_init: |
133 | sctp_snmp_proc_exit(); | 111 | sctp_snmp_proc_exit(net); |
134 | out_snmp_proc_init: | 112 | out_snmp_proc_init: |
135 | if (proc_net_sctp) { | 113 | remove_proc_entry("sctp", net->proc_net); |
136 | proc_net_sctp = NULL; | 114 | net->sctp.proc_net_sctp = NULL; |
137 | remove_proc_entry("sctp", init_net.proc_net); | 115 | out_proc_net_sctp: |
138 | } | ||
139 | out_free_percpu: | ||
140 | percpu_counter_destroy(&sctp_sockets_allocated); | ||
141 | #else | ||
142 | return 0; | ||
143 | #endif /* CONFIG_PROC_FS */ | ||
144 | |||
145 | out_nomem: | ||
146 | return -ENOMEM; | 116 | return -ENOMEM; |
117 | #endif /* CONFIG_PROC_FS */ | ||
118 | return 0; | ||
147 | } | 119 | } |
148 | 120 | ||
149 | /* Clean up the proc fs entry for the SCTP protocol. | 121 | /* Clean up the proc fs entry for the SCTP protocol. |
150 | * Note: Do not make this __exit as it is used in the init error | 122 | * Note: Do not make this __exit as it is used in the init error |
151 | * path. | 123 | * path. |
152 | */ | 124 | */ |
153 | static void sctp_proc_exit(void) | 125 | static void sctp_proc_exit(struct net *net) |
154 | { | 126 | { |
155 | #ifdef CONFIG_PROC_FS | 127 | #ifdef CONFIG_PROC_FS |
156 | sctp_snmp_proc_exit(); | 128 | sctp_snmp_proc_exit(net); |
157 | sctp_eps_proc_exit(); | 129 | sctp_eps_proc_exit(net); |
158 | sctp_assocs_proc_exit(); | 130 | sctp_assocs_proc_exit(net); |
159 | sctp_remaddr_proc_exit(); | 131 | sctp_remaddr_proc_exit(net); |
160 | 132 | ||
161 | if (proc_net_sctp) { | 133 | remove_proc_entry("sctp", net->proc_net); |
162 | proc_net_sctp = NULL; | 134 | net->sctp.proc_net_sctp = NULL; |
163 | remove_proc_entry("sctp", init_net.proc_net); | ||
164 | } | ||
165 | #endif | 135 | #endif |
166 | percpu_counter_destroy(&sctp_sockets_allocated); | ||
167 | } | 136 | } |
168 | 137 | ||
169 | /* Private helper to extract ipv4 address and stash them in | 138 | /* Private helper to extract ipv4 address and stash them in |
@@ -201,29 +170,29 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist, | |||
201 | /* Extract our IP addresses from the system and stash them in the | 170 | /* Extract our IP addresses from the system and stash them in the |
202 | * protocol structure. | 171 | * protocol structure. |
203 | */ | 172 | */ |
204 | static void sctp_get_local_addr_list(void) | 173 | static void sctp_get_local_addr_list(struct net *net) |
205 | { | 174 | { |
206 | struct net_device *dev; | 175 | struct net_device *dev; |
207 | struct list_head *pos; | 176 | struct list_head *pos; |
208 | struct sctp_af *af; | 177 | struct sctp_af *af; |
209 | 178 | ||
210 | rcu_read_lock(); | 179 | rcu_read_lock(); |
211 | for_each_netdev_rcu(&init_net, dev) { | 180 | for_each_netdev_rcu(net, dev) { |
212 | __list_for_each(pos, &sctp_address_families) { | 181 | __list_for_each(pos, &sctp_address_families) { |
213 | af = list_entry(pos, struct sctp_af, list); | 182 | af = list_entry(pos, struct sctp_af, list); |
214 | af->copy_addrlist(&sctp_local_addr_list, dev); | 183 | af->copy_addrlist(&net->sctp.local_addr_list, dev); |
215 | } | 184 | } |
216 | } | 185 | } |
217 | rcu_read_unlock(); | 186 | rcu_read_unlock(); |
218 | } | 187 | } |
219 | 188 | ||
220 | /* Free the existing local addresses. */ | 189 | /* Free the existing local addresses. */ |
221 | static void sctp_free_local_addr_list(void) | 190 | static void sctp_free_local_addr_list(struct net *net) |
222 | { | 191 | { |
223 | struct sctp_sockaddr_entry *addr; | 192 | struct sctp_sockaddr_entry *addr; |
224 | struct list_head *pos, *temp; | 193 | struct list_head *pos, *temp; |
225 | 194 | ||
226 | list_for_each_safe(pos, temp, &sctp_local_addr_list) { | 195 | list_for_each_safe(pos, temp, &net->sctp.local_addr_list) { |
227 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); | 196 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); |
228 | list_del(pos); | 197 | list_del(pos); |
229 | kfree(addr); | 198 | kfree(addr); |
@@ -231,17 +200,17 @@ static void sctp_free_local_addr_list(void) | |||
231 | } | 200 | } |
232 | 201 | ||
233 | /* Copy the local addresses which are valid for 'scope' into 'bp'. */ | 202 | /* Copy the local addresses which are valid for 'scope' into 'bp'. */ |
234 | int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope, | 203 | int sctp_copy_local_addr_list(struct net *net, struct sctp_bind_addr *bp, |
235 | gfp_t gfp, int copy_flags) | 204 | sctp_scope_t scope, gfp_t gfp, int copy_flags) |
236 | { | 205 | { |
237 | struct sctp_sockaddr_entry *addr; | 206 | struct sctp_sockaddr_entry *addr; |
238 | int error = 0; | 207 | int error = 0; |
239 | 208 | ||
240 | rcu_read_lock(); | 209 | rcu_read_lock(); |
241 | list_for_each_entry_rcu(addr, &sctp_local_addr_list, list) { | 210 | list_for_each_entry_rcu(addr, &net->sctp.local_addr_list, list) { |
242 | if (!addr->valid) | 211 | if (!addr->valid) |
243 | continue; | 212 | continue; |
244 | if (sctp_in_scope(&addr->a, scope)) { | 213 | if (sctp_in_scope(net, &addr->a, scope)) { |
245 | /* Now that the address is in scope, check to see if | 214 | /* Now that the address is in scope, check to see if |
246 | * the address type is really supported by the local | 215 | * the address type is really supported by the local |
247 | * sock as well as the remote peer. | 216 | * sock as well as the remote peer. |
@@ -397,7 +366,8 @@ static int sctp_v4_addr_valid(union sctp_addr *addr, | |||
397 | /* Should this be available for binding? */ | 366 | /* Should this be available for binding? */ |
398 | static int sctp_v4_available(union sctp_addr *addr, struct sctp_sock *sp) | 367 | static int sctp_v4_available(union sctp_addr *addr, struct sctp_sock *sp) |
399 | { | 368 | { |
400 | int ret = inet_addr_type(&init_net, addr->v4.sin_addr.s_addr); | 369 | struct net *net = sock_net(&sp->inet.sk); |
370 | int ret = inet_addr_type(net, addr->v4.sin_addr.s_addr); | ||
401 | 371 | ||
402 | 372 | ||
403 | if (addr->v4.sin_addr.s_addr != htonl(INADDR_ANY) && | 373 | if (addr->v4.sin_addr.s_addr != htonl(INADDR_ANY) && |
@@ -484,7 +454,7 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr, | |||
484 | SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ", | 454 | SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ", |
485 | __func__, &fl4->daddr, &fl4->saddr); | 455 | __func__, &fl4->daddr, &fl4->saddr); |
486 | 456 | ||
487 | rt = ip_route_output_key(&init_net, fl4); | 457 | rt = ip_route_output_key(sock_net(sk), fl4); |
488 | if (!IS_ERR(rt)) | 458 | if (!IS_ERR(rt)) |
489 | dst = &rt->dst; | 459 | dst = &rt->dst; |
490 | 460 | ||
@@ -530,7 +500,7 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr, | |||
530 | (AF_INET == laddr->a.sa.sa_family)) { | 500 | (AF_INET == laddr->a.sa.sa_family)) { |
531 | fl4->saddr = laddr->a.v4.sin_addr.s_addr; | 501 | fl4->saddr = laddr->a.v4.sin_addr.s_addr; |
532 | fl4->fl4_sport = laddr->a.v4.sin_port; | 502 | fl4->fl4_sport = laddr->a.v4.sin_port; |
533 | rt = ip_route_output_key(&init_net, fl4); | 503 | rt = ip_route_output_key(sock_net(sk), fl4); |
534 | if (!IS_ERR(rt)) { | 504 | if (!IS_ERR(rt)) { |
535 | dst = &rt->dst; | 505 | dst = &rt->dst; |
536 | goto out_unlock; | 506 | goto out_unlock; |
@@ -627,14 +597,15 @@ static void sctp_v4_ecn_capable(struct sock *sk) | |||
627 | 597 | ||
628 | void sctp_addr_wq_timeout_handler(unsigned long arg) | 598 | void sctp_addr_wq_timeout_handler(unsigned long arg) |
629 | { | 599 | { |
600 | struct net *net = (struct net *)arg; | ||
630 | struct sctp_sockaddr_entry *addrw, *temp; | 601 | struct sctp_sockaddr_entry *addrw, *temp; |
631 | struct sctp_sock *sp; | 602 | struct sctp_sock *sp; |
632 | 603 | ||
633 | spin_lock_bh(&sctp_addr_wq_lock); | 604 | spin_lock_bh(&net->sctp.addr_wq_lock); |
634 | 605 | ||
635 | list_for_each_entry_safe(addrw, temp, &sctp_addr_waitq, list) { | 606 | list_for_each_entry_safe(addrw, temp, &net->sctp.addr_waitq, list) { |
636 | SCTP_DEBUG_PRINTK_IPADDR("sctp_addrwq_timo_handler: the first ent in wq %p is ", | 607 | SCTP_DEBUG_PRINTK_IPADDR("sctp_addrwq_timo_handler: the first ent in wq %p is ", |
637 | " for cmd %d at entry %p\n", &sctp_addr_waitq, &addrw->a, addrw->state, | 608 | " for cmd %d at entry %p\n", &net->sctp.addr_waitq, &addrw->a, addrw->state, |
638 | addrw); | 609 | addrw); |
639 | 610 | ||
640 | #if IS_ENABLED(CONFIG_IPV6) | 611 | #if IS_ENABLED(CONFIG_IPV6) |
@@ -648,7 +619,7 @@ void sctp_addr_wq_timeout_handler(unsigned long arg) | |||
648 | goto free_next; | 619 | goto free_next; |
649 | 620 | ||
650 | in6 = (struct in6_addr *)&addrw->a.v6.sin6_addr; | 621 | in6 = (struct in6_addr *)&addrw->a.v6.sin6_addr; |
651 | if (ipv6_chk_addr(&init_net, in6, NULL, 0) == 0 && | 622 | if (ipv6_chk_addr(net, in6, NULL, 0) == 0 && |
652 | addrw->state == SCTP_ADDR_NEW) { | 623 | addrw->state == SCTP_ADDR_NEW) { |
653 | unsigned long timeo_val; | 624 | unsigned long timeo_val; |
654 | 625 | ||
@@ -656,12 +627,12 @@ void sctp_addr_wq_timeout_handler(unsigned long arg) | |||
656 | SCTP_ADDRESS_TICK_DELAY); | 627 | SCTP_ADDRESS_TICK_DELAY); |
657 | timeo_val = jiffies; | 628 | timeo_val = jiffies; |
658 | timeo_val += msecs_to_jiffies(SCTP_ADDRESS_TICK_DELAY); | 629 | timeo_val += msecs_to_jiffies(SCTP_ADDRESS_TICK_DELAY); |
659 | mod_timer(&sctp_addr_wq_timer, timeo_val); | 630 | mod_timer(&net->sctp.addr_wq_timer, timeo_val); |
660 | break; | 631 | break; |
661 | } | 632 | } |
662 | } | 633 | } |
663 | #endif | 634 | #endif |
664 | list_for_each_entry(sp, &sctp_auto_asconf_splist, auto_asconf_list) { | 635 | list_for_each_entry(sp, &net->sctp.auto_asconf_splist, auto_asconf_list) { |
665 | struct sock *sk; | 636 | struct sock *sk; |
666 | 637 | ||
667 | sk = sctp_opt2sk(sp); | 638 | sk = sctp_opt2sk(sp); |
@@ -679,31 +650,32 @@ free_next: | |||
679 | list_del(&addrw->list); | 650 | list_del(&addrw->list); |
680 | kfree(addrw); | 651 | kfree(addrw); |
681 | } | 652 | } |
682 | spin_unlock_bh(&sctp_addr_wq_lock); | 653 | spin_unlock_bh(&net->sctp.addr_wq_lock); |
683 | } | 654 | } |
684 | 655 | ||
685 | static void sctp_free_addr_wq(void) | 656 | static void sctp_free_addr_wq(struct net *net) |
686 | { | 657 | { |
687 | struct sctp_sockaddr_entry *addrw; | 658 | struct sctp_sockaddr_entry *addrw; |
688 | struct sctp_sockaddr_entry *temp; | 659 | struct sctp_sockaddr_entry *temp; |
689 | 660 | ||
690 | spin_lock_bh(&sctp_addr_wq_lock); | 661 | spin_lock_bh(&net->sctp.addr_wq_lock); |
691 | del_timer(&sctp_addr_wq_timer); | 662 | del_timer(&net->sctp.addr_wq_timer); |
692 | list_for_each_entry_safe(addrw, temp, &sctp_addr_waitq, list) { | 663 | list_for_each_entry_safe(addrw, temp, &net->sctp.addr_waitq, list) { |
693 | list_del(&addrw->list); | 664 | list_del(&addrw->list); |
694 | kfree(addrw); | 665 | kfree(addrw); |
695 | } | 666 | } |
696 | spin_unlock_bh(&sctp_addr_wq_lock); | 667 | spin_unlock_bh(&net->sctp.addr_wq_lock); |
697 | } | 668 | } |
698 | 669 | ||
699 | /* lookup the entry for the same address in the addr_waitq | 670 | /* lookup the entry for the same address in the addr_waitq |
700 | * sctp_addr_wq MUST be locked | 671 | * sctp_addr_wq MUST be locked |
701 | */ | 672 | */ |
702 | static struct sctp_sockaddr_entry *sctp_addr_wq_lookup(struct sctp_sockaddr_entry *addr) | 673 | static struct sctp_sockaddr_entry *sctp_addr_wq_lookup(struct net *net, |
674 | struct sctp_sockaddr_entry *addr) | ||
703 | { | 675 | { |
704 | struct sctp_sockaddr_entry *addrw; | 676 | struct sctp_sockaddr_entry *addrw; |
705 | 677 | ||
706 | list_for_each_entry(addrw, &sctp_addr_waitq, list) { | 678 | list_for_each_entry(addrw, &net->sctp.addr_waitq, list) { |
707 | if (addrw->a.sa.sa_family != addr->a.sa.sa_family) | 679 | if (addrw->a.sa.sa_family != addr->a.sa.sa_family) |
708 | continue; | 680 | continue; |
709 | if (addrw->a.sa.sa_family == AF_INET) { | 681 | if (addrw->a.sa.sa_family == AF_INET) { |
@@ -719,7 +691,7 @@ static struct sctp_sockaddr_entry *sctp_addr_wq_lookup(struct sctp_sockaddr_entr | |||
719 | return NULL; | 691 | return NULL; |
720 | } | 692 | } |
721 | 693 | ||
722 | void sctp_addr_wq_mgmt(struct sctp_sockaddr_entry *addr, int cmd) | 694 | void sctp_addr_wq_mgmt(struct net *net, struct sctp_sockaddr_entry *addr, int cmd) |
723 | { | 695 | { |
724 | struct sctp_sockaddr_entry *addrw; | 696 | struct sctp_sockaddr_entry *addrw; |
725 | unsigned long timeo_val; | 697 | unsigned long timeo_val; |
@@ -730,38 +702,38 @@ void sctp_addr_wq_mgmt(struct sctp_sockaddr_entry *addr, int cmd) | |||
730 | * new address after a couple of addition and deletion of that address | 702 | * new address after a couple of addition and deletion of that address |
731 | */ | 703 | */ |
732 | 704 | ||
733 | spin_lock_bh(&sctp_addr_wq_lock); | 705 | spin_lock_bh(&net->sctp.addr_wq_lock); |
734 | /* Offsets existing events in addr_wq */ | 706 | /* Offsets existing events in addr_wq */ |
735 | addrw = sctp_addr_wq_lookup(addr); | 707 | addrw = sctp_addr_wq_lookup(net, addr); |
736 | if (addrw) { | 708 | if (addrw) { |
737 | if (addrw->state != cmd) { | 709 | if (addrw->state != cmd) { |
738 | SCTP_DEBUG_PRINTK_IPADDR("sctp_addr_wq_mgmt offsets existing entry for %d ", | 710 | SCTP_DEBUG_PRINTK_IPADDR("sctp_addr_wq_mgmt offsets existing entry for %d ", |
739 | " in wq %p\n", addrw->state, &addrw->a, | 711 | " in wq %p\n", addrw->state, &addrw->a, |
740 | &sctp_addr_waitq); | 712 | &net->sctp.addr_waitq); |
741 | list_del(&addrw->list); | 713 | list_del(&addrw->list); |
742 | kfree(addrw); | 714 | kfree(addrw); |
743 | } | 715 | } |
744 | spin_unlock_bh(&sctp_addr_wq_lock); | 716 | spin_unlock_bh(&net->sctp.addr_wq_lock); |
745 | return; | 717 | return; |
746 | } | 718 | } |
747 | 719 | ||
748 | /* OK, we have to add the new address to the wait queue */ | 720 | /* OK, we have to add the new address to the wait queue */ |
749 | addrw = kmemdup(addr, sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC); | 721 | addrw = kmemdup(addr, sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC); |
750 | if (addrw == NULL) { | 722 | if (addrw == NULL) { |
751 | spin_unlock_bh(&sctp_addr_wq_lock); | 723 | spin_unlock_bh(&net->sctp.addr_wq_lock); |
752 | return; | 724 | return; |
753 | } | 725 | } |
754 | addrw->state = cmd; | 726 | addrw->state = cmd; |
755 | list_add_tail(&addrw->list, &sctp_addr_waitq); | 727 | list_add_tail(&addrw->list, &net->sctp.addr_waitq); |
756 | SCTP_DEBUG_PRINTK_IPADDR("sctp_addr_wq_mgmt add new entry for cmd:%d ", | 728 | SCTP_DEBUG_PRINTK_IPADDR("sctp_addr_wq_mgmt add new entry for cmd:%d ", |
757 | " in wq %p\n", addrw->state, &addrw->a, &sctp_addr_waitq); | 729 | " in wq %p\n", addrw->state, &addrw->a, &net->sctp.addr_waitq); |
758 | 730 | ||
759 | if (!timer_pending(&sctp_addr_wq_timer)) { | 731 | if (!timer_pending(&net->sctp.addr_wq_timer)) { |
760 | timeo_val = jiffies; | 732 | timeo_val = jiffies; |
761 | timeo_val += msecs_to_jiffies(SCTP_ADDRESS_TICK_DELAY); | 733 | timeo_val += msecs_to_jiffies(SCTP_ADDRESS_TICK_DELAY); |
762 | mod_timer(&sctp_addr_wq_timer, timeo_val); | 734 | mod_timer(&net->sctp.addr_wq_timer, timeo_val); |
763 | } | 735 | } |
764 | spin_unlock_bh(&sctp_addr_wq_lock); | 736 | spin_unlock_bh(&net->sctp.addr_wq_lock); |
765 | } | 737 | } |
766 | 738 | ||
767 | /* Event handler for inet address addition/deletion events. | 739 | /* Event handler for inet address addition/deletion events. |
@@ -776,11 +748,9 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, | |||
776 | struct in_ifaddr *ifa = (struct in_ifaddr *)ptr; | 748 | struct in_ifaddr *ifa = (struct in_ifaddr *)ptr; |
777 | struct sctp_sockaddr_entry *addr = NULL; | 749 | struct sctp_sockaddr_entry *addr = NULL; |
778 | struct sctp_sockaddr_entry *temp; | 750 | struct sctp_sockaddr_entry *temp; |
751 | struct net *net = dev_net(ifa->ifa_dev->dev); | ||
779 | int found = 0; | 752 | int found = 0; |
780 | 753 | ||
781 | if (!net_eq(dev_net(ifa->ifa_dev->dev), &init_net)) | ||
782 | return NOTIFY_DONE; | ||
783 | |||
784 | switch (ev) { | 754 | switch (ev) { |
785 | case NETDEV_UP: | 755 | case NETDEV_UP: |
786 | addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC); | 756 | addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC); |
@@ -789,27 +759,27 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, | |||
789 | addr->a.v4.sin_port = 0; | 759 | addr->a.v4.sin_port = 0; |
790 | addr->a.v4.sin_addr.s_addr = ifa->ifa_local; | 760 | addr->a.v4.sin_addr.s_addr = ifa->ifa_local; |
791 | addr->valid = 1; | 761 | addr->valid = 1; |
792 | spin_lock_bh(&sctp_local_addr_lock); | 762 | spin_lock_bh(&net->sctp.local_addr_lock); |
793 | list_add_tail_rcu(&addr->list, &sctp_local_addr_list); | 763 | list_add_tail_rcu(&addr->list, &net->sctp.local_addr_list); |
794 | sctp_addr_wq_mgmt(addr, SCTP_ADDR_NEW); | 764 | sctp_addr_wq_mgmt(net, addr, SCTP_ADDR_NEW); |
795 | spin_unlock_bh(&sctp_local_addr_lock); | 765 | spin_unlock_bh(&net->sctp.local_addr_lock); |
796 | } | 766 | } |
797 | break; | 767 | break; |
798 | case NETDEV_DOWN: | 768 | case NETDEV_DOWN: |
799 | spin_lock_bh(&sctp_local_addr_lock); | 769 | spin_lock_bh(&net->sctp.local_addr_lock); |
800 | list_for_each_entry_safe(addr, temp, | 770 | list_for_each_entry_safe(addr, temp, |
801 | &sctp_local_addr_list, list) { | 771 | &net->sctp.local_addr_list, list) { |
802 | if (addr->a.sa.sa_family == AF_INET && | 772 | if (addr->a.sa.sa_family == AF_INET && |
803 | addr->a.v4.sin_addr.s_addr == | 773 | addr->a.v4.sin_addr.s_addr == |
804 | ifa->ifa_local) { | 774 | ifa->ifa_local) { |
805 | sctp_addr_wq_mgmt(addr, SCTP_ADDR_DEL); | 775 | sctp_addr_wq_mgmt(net, addr, SCTP_ADDR_DEL); |
806 | found = 1; | 776 | found = 1; |
807 | addr->valid = 0; | 777 | addr->valid = 0; |
808 | list_del_rcu(&addr->list); | 778 | list_del_rcu(&addr->list); |
809 | break; | 779 | break; |
810 | } | 780 | } |
811 | } | 781 | } |
812 | spin_unlock_bh(&sctp_local_addr_lock); | 782 | spin_unlock_bh(&net->sctp.local_addr_lock); |
813 | if (found) | 783 | if (found) |
814 | kfree_rcu(addr, rcu); | 784 | kfree_rcu(addr, rcu); |
815 | break; | 785 | break; |
@@ -822,7 +792,7 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev, | |||
822 | * Initialize the control inode/socket with a control endpoint data | 792 | * Initialize the control inode/socket with a control endpoint data |
823 | * structure. This endpoint is reserved exclusively for the OOTB processing. | 793 | * structure. This endpoint is reserved exclusively for the OOTB processing. |
824 | */ | 794 | */ |
825 | static int sctp_ctl_sock_init(void) | 795 | static int sctp_ctl_sock_init(struct net *net) |
826 | { | 796 | { |
827 | int err; | 797 | int err; |
828 | sa_family_t family = PF_INET; | 798 | sa_family_t family = PF_INET; |
@@ -830,14 +800,14 @@ static int sctp_ctl_sock_init(void) | |||
830 | if (sctp_get_pf_specific(PF_INET6)) | 800 | if (sctp_get_pf_specific(PF_INET6)) |
831 | family = PF_INET6; | 801 | family = PF_INET6; |
832 | 802 | ||
833 | err = inet_ctl_sock_create(&sctp_ctl_sock, family, | 803 | err = inet_ctl_sock_create(&net->sctp.ctl_sock, family, |
834 | SOCK_SEQPACKET, IPPROTO_SCTP, &init_net); | 804 | SOCK_SEQPACKET, IPPROTO_SCTP, net); |
835 | 805 | ||
836 | /* If IPv6 socket could not be created, try the IPv4 socket */ | 806 | /* If IPv6 socket could not be created, try the IPv4 socket */ |
837 | if (err < 0 && family == PF_INET6) | 807 | if (err < 0 && family == PF_INET6) |
838 | err = inet_ctl_sock_create(&sctp_ctl_sock, AF_INET, | 808 | err = inet_ctl_sock_create(&net->sctp.ctl_sock, AF_INET, |
839 | SOCK_SEQPACKET, IPPROTO_SCTP, | 809 | SOCK_SEQPACKET, IPPROTO_SCTP, |
840 | &init_net); | 810 | net); |
841 | 811 | ||
842 | if (err < 0) { | 812 | if (err < 0) { |
843 | pr_err("Failed to create the SCTP control socket\n"); | 813 | pr_err("Failed to create the SCTP control socket\n"); |
@@ -990,7 +960,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb, | |||
990 | inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? | 960 | inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? |
991 | IP_PMTUDISC_DO : IP_PMTUDISC_DONT; | 961 | IP_PMTUDISC_DO : IP_PMTUDISC_DONT; |
992 | 962 | ||
993 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); | 963 | SCTP_INC_STATS(sock_net(&inet->sk), SCTP_MIB_OUTSCTPPACKS); |
994 | return ip_queue_xmit(skb, &transport->fl); | 964 | return ip_queue_xmit(skb, &transport->fl); |
995 | } | 965 | } |
996 | 966 | ||
@@ -1063,6 +1033,7 @@ static const struct net_protocol sctp_protocol = { | |||
1063 | .handler = sctp_rcv, | 1033 | .handler = sctp_rcv, |
1064 | .err_handler = sctp_v4_err, | 1034 | .err_handler = sctp_v4_err, |
1065 | .no_policy = 1, | 1035 | .no_policy = 1, |
1036 | .netns_ok = 1, | ||
1066 | }; | 1037 | }; |
1067 | 1038 | ||
1068 | /* IPv4 address related functions. */ | 1039 | /* IPv4 address related functions. */ |
@@ -1130,16 +1101,16 @@ int sctp_register_pf(struct sctp_pf *pf, sa_family_t family) | |||
1130 | return 1; | 1101 | return 1; |
1131 | } | 1102 | } |
1132 | 1103 | ||
1133 | static inline int init_sctp_mibs(void) | 1104 | static inline int init_sctp_mibs(struct net *net) |
1134 | { | 1105 | { |
1135 | return snmp_mib_init((void __percpu **)sctp_statistics, | 1106 | return snmp_mib_init((void __percpu **)net->sctp.sctp_statistics, |
1136 | sizeof(struct sctp_mib), | 1107 | sizeof(struct sctp_mib), |
1137 | __alignof__(struct sctp_mib)); | 1108 | __alignof__(struct sctp_mib)); |
1138 | } | 1109 | } |
1139 | 1110 | ||
1140 | static inline void cleanup_sctp_mibs(void) | 1111 | static inline void cleanup_sctp_mibs(struct net *net) |
1141 | { | 1112 | { |
1142 | snmp_mib_free((void __percpu **)sctp_statistics); | 1113 | snmp_mib_free((void __percpu **)net->sctp.sctp_statistics); |
1143 | } | 1114 | } |
1144 | 1115 | ||
1145 | static void sctp_v4_pf_init(void) | 1116 | static void sctp_v4_pf_init(void) |
@@ -1194,6 +1165,143 @@ static void sctp_v4_del_protocol(void) | |||
1194 | unregister_inetaddr_notifier(&sctp_inetaddr_notifier); | 1165 | unregister_inetaddr_notifier(&sctp_inetaddr_notifier); |
1195 | } | 1166 | } |
1196 | 1167 | ||
1168 | static int sctp_net_init(struct net *net) | ||
1169 | { | ||
1170 | int status; | ||
1171 | |||
1172 | /* | ||
1173 | * 14. Suggested SCTP Protocol Parameter Values | ||
1174 | */ | ||
1175 | /* The following protocol parameters are RECOMMENDED: */ | ||
1176 | /* RTO.Initial - 3 seconds */ | ||
1177 | net->sctp.rto_initial = SCTP_RTO_INITIAL; | ||
1178 | /* RTO.Min - 1 second */ | ||
1179 | net->sctp.rto_min = SCTP_RTO_MIN; | ||
1180 | /* RTO.Max - 60 seconds */ | ||
1181 | net->sctp.rto_max = SCTP_RTO_MAX; | ||
1182 | /* RTO.Alpha - 1/8 */ | ||
1183 | net->sctp.rto_alpha = SCTP_RTO_ALPHA; | ||
1184 | /* RTO.Beta - 1/4 */ | ||
1185 | net->sctp.rto_beta = SCTP_RTO_BETA; | ||
1186 | |||
1187 | /* Valid.Cookie.Life - 60 seconds */ | ||
1188 | net->sctp.valid_cookie_life = SCTP_DEFAULT_COOKIE_LIFE; | ||
1189 | |||
1190 | /* Whether Cookie Preservative is enabled(1) or not(0) */ | ||
1191 | net->sctp.cookie_preserve_enable = 1; | ||
1192 | |||
1193 | /* Max.Burst - 4 */ | ||
1194 | net->sctp.max_burst = SCTP_DEFAULT_MAX_BURST; | ||
1195 | |||
1196 | /* Association.Max.Retrans - 10 attempts | ||
1197 | * Path.Max.Retrans - 5 attempts (per destination address) | ||
1198 | * Max.Init.Retransmits - 8 attempts | ||
1199 | */ | ||
1200 | net->sctp.max_retrans_association = 10; | ||
1201 | net->sctp.max_retrans_path = 5; | ||
1202 | net->sctp.max_retrans_init = 8; | ||
1203 | |||
1204 | /* Sendbuffer growth - do per-socket accounting */ | ||
1205 | net->sctp.sndbuf_policy = 0; | ||
1206 | |||
1207 | /* Rcvbuffer growth - do per-socket accounting */ | ||
1208 | net->sctp.rcvbuf_policy = 0; | ||
1209 | |||
1210 | /* HB.interval - 30 seconds */ | ||
1211 | net->sctp.hb_interval = SCTP_DEFAULT_TIMEOUT_HEARTBEAT; | ||
1212 | |||
1213 | /* delayed SACK timeout */ | ||
1214 | net->sctp.sack_timeout = SCTP_DEFAULT_TIMEOUT_SACK; | ||
1215 | |||
1216 | /* Disable ADDIP by default. */ | ||
1217 | net->sctp.addip_enable = 0; | ||
1218 | net->sctp.addip_noauth = 0; | ||
1219 | net->sctp.default_auto_asconf = 0; | ||
1220 | |||
1221 | /* Enable PR-SCTP by default. */ | ||
1222 | net->sctp.prsctp_enable = 1; | ||
1223 | |||
1224 | /* Disable AUTH by default. */ | ||
1225 | net->sctp.auth_enable = 0; | ||
1226 | |||
1227 | /* Set SCOPE policy to enabled */ | ||
1228 | net->sctp.scope_policy = SCTP_SCOPE_POLICY_ENABLE; | ||
1229 | |||
1230 | /* Set the default rwnd update threshold */ | ||
1231 | net->sctp.rwnd_upd_shift = SCTP_DEFAULT_RWND_SHIFT; | ||
1232 | |||
1233 | /* Initialize maximum autoclose timeout. */ | ||
1234 | net->sctp.max_autoclose = INT_MAX / HZ; | ||
1235 | |||
1236 | status = sctp_sysctl_net_register(net); | ||
1237 | if (status) | ||
1238 | goto err_sysctl_register; | ||
1239 | |||
1240 | /* Allocate and initialise sctp mibs. */ | ||
1241 | status = init_sctp_mibs(net); | ||
1242 | if (status) | ||
1243 | goto err_init_mibs; | ||
1244 | |||
1245 | /* Initialize proc fs directory. */ | ||
1246 | status = sctp_proc_init(net); | ||
1247 | if (status) | ||
1248 | goto err_init_proc; | ||
1249 | |||
1250 | sctp_dbg_objcnt_init(net); | ||
1251 | |||
1252 | /* Initialize the control inode/socket for handling OOTB packets. */ | ||
1253 | if ((status = sctp_ctl_sock_init(net))) { | ||
1254 | pr_err("Failed to initialize the SCTP control sock\n"); | ||
1255 | goto err_ctl_sock_init; | ||
1256 | } | ||
1257 | |||
1258 | /* Initialize the local address list. */ | ||
1259 | INIT_LIST_HEAD(&net->sctp.local_addr_list); | ||
1260 | spin_lock_init(&net->sctp.local_addr_lock); | ||
1261 | sctp_get_local_addr_list(net); | ||
1262 | |||
1263 | /* Initialize the address event list */ | ||
1264 | INIT_LIST_HEAD(&net->sctp.addr_waitq); | ||
1265 | INIT_LIST_HEAD(&net->sctp.auto_asconf_splist); | ||
1266 | spin_lock_init(&net->sctp.addr_wq_lock); | ||
1267 | net->sctp.addr_wq_timer.expires = 0; | ||
1268 | setup_timer(&net->sctp.addr_wq_timer, sctp_addr_wq_timeout_handler, | ||
1269 | (unsigned long)net); | ||
1270 | |||
1271 | return 0; | ||
1272 | |||
1273 | err_ctl_sock_init: | ||
1274 | sctp_dbg_objcnt_exit(net); | ||
1275 | sctp_proc_exit(net); | ||
1276 | err_init_proc: | ||
1277 | cleanup_sctp_mibs(net); | ||
1278 | err_init_mibs: | ||
1279 | sctp_sysctl_net_unregister(net); | ||
1280 | err_sysctl_register: | ||
1281 | return status; | ||
1282 | } | ||
1283 | |||
1284 | static void sctp_net_exit(struct net *net) | ||
1285 | { | ||
1286 | /* Free the local address list */ | ||
1287 | sctp_free_addr_wq(net); | ||
1288 | sctp_free_local_addr_list(net); | ||
1289 | |||
1290 | /* Free the control endpoint. */ | ||
1291 | inet_ctl_sock_destroy(net->sctp.ctl_sock); | ||
1292 | |||
1293 | sctp_dbg_objcnt_exit(net); | ||
1294 | |||
1295 | sctp_proc_exit(net); | ||
1296 | cleanup_sctp_mibs(net); | ||
1297 | sctp_sysctl_net_unregister(net); | ||
1298 | } | ||
1299 | |||
1300 | static struct pernet_operations sctp_net_ops = { | ||
1301 | .init = sctp_net_init, | ||
1302 | .exit = sctp_net_exit, | ||
1303 | }; | ||
1304 | |||
1197 | /* Initialize the universe into something sensible. */ | 1305 | /* Initialize the universe into something sensible. */ |
1198 | SCTP_STATIC __init int sctp_init(void) | 1306 | SCTP_STATIC __init int sctp_init(void) |
1199 | { | 1307 | { |
@@ -1224,62 +1332,9 @@ SCTP_STATIC __init int sctp_init(void) | |||
1224 | if (!sctp_chunk_cachep) | 1332 | if (!sctp_chunk_cachep) |
1225 | goto err_chunk_cachep; | 1333 | goto err_chunk_cachep; |
1226 | 1334 | ||
1227 | /* Allocate and initialise sctp mibs. */ | 1335 | status = percpu_counter_init(&sctp_sockets_allocated, 0); |
1228 | status = init_sctp_mibs(); | ||
1229 | if (status) | 1336 | if (status) |
1230 | goto err_init_mibs; | 1337 | goto err_percpu_counter_init; |
1231 | |||
1232 | /* Initialize proc fs directory. */ | ||
1233 | status = sctp_proc_init(); | ||
1234 | if (status) | ||
1235 | goto err_init_proc; | ||
1236 | |||
1237 | /* Initialize object count debugging. */ | ||
1238 | sctp_dbg_objcnt_init(); | ||
1239 | |||
1240 | /* | ||
1241 | * 14. Suggested SCTP Protocol Parameter Values | ||
1242 | */ | ||
1243 | /* The following protocol parameters are RECOMMENDED: */ | ||
1244 | /* RTO.Initial - 3 seconds */ | ||
1245 | sctp_rto_initial = SCTP_RTO_INITIAL; | ||
1246 | /* RTO.Min - 1 second */ | ||
1247 | sctp_rto_min = SCTP_RTO_MIN; | ||
1248 | /* RTO.Max - 60 seconds */ | ||
1249 | sctp_rto_max = SCTP_RTO_MAX; | ||
1250 | /* RTO.Alpha - 1/8 */ | ||
1251 | sctp_rto_alpha = SCTP_RTO_ALPHA; | ||
1252 | /* RTO.Beta - 1/4 */ | ||
1253 | sctp_rto_beta = SCTP_RTO_BETA; | ||
1254 | |||
1255 | /* Valid.Cookie.Life - 60 seconds */ | ||
1256 | sctp_valid_cookie_life = SCTP_DEFAULT_COOKIE_LIFE; | ||
1257 | |||
1258 | /* Whether Cookie Preservative is enabled(1) or not(0) */ | ||
1259 | sctp_cookie_preserve_enable = 1; | ||
1260 | |||
1261 | /* Max.Burst - 4 */ | ||
1262 | sctp_max_burst = SCTP_DEFAULT_MAX_BURST; | ||
1263 | |||
1264 | /* Association.Max.Retrans - 10 attempts | ||
1265 | * Path.Max.Retrans - 5 attempts (per destination address) | ||
1266 | * Max.Init.Retransmits - 8 attempts | ||
1267 | */ | ||
1268 | sctp_max_retrans_association = 10; | ||
1269 | sctp_max_retrans_path = 5; | ||
1270 | sctp_max_retrans_init = 8; | ||
1271 | |||
1272 | /* Sendbuffer growth - do per-socket accounting */ | ||
1273 | sctp_sndbuf_policy = 0; | ||
1274 | |||
1275 | /* Rcvbuffer growth - do per-socket accounting */ | ||
1276 | sctp_rcvbuf_policy = 0; | ||
1277 | |||
1278 | /* HB.interval - 30 seconds */ | ||
1279 | sctp_hb_interval = SCTP_DEFAULT_TIMEOUT_HEARTBEAT; | ||
1280 | |||
1281 | /* delayed SACK timeout */ | ||
1282 | sctp_sack_timeout = SCTP_DEFAULT_TIMEOUT_SACK; | ||
1283 | 1338 | ||
1284 | /* Implementation specific variables. */ | 1339 | /* Implementation specific variables. */ |
1285 | 1340 | ||
@@ -1287,9 +1342,6 @@ SCTP_STATIC __init int sctp_init(void) | |||
1287 | sctp_max_instreams = SCTP_DEFAULT_INSTREAMS; | 1342 | sctp_max_instreams = SCTP_DEFAULT_INSTREAMS; |
1288 | sctp_max_outstreams = SCTP_DEFAULT_OUTSTREAMS; | 1343 | sctp_max_outstreams = SCTP_DEFAULT_OUTSTREAMS; |
1289 | 1344 | ||
1290 | /* Initialize maximum autoclose timeout. */ | ||
1291 | sctp_max_autoclose = INT_MAX / HZ; | ||
1292 | |||
1293 | /* Initialize handle used for association ids. */ | 1345 | /* Initialize handle used for association ids. */ |
1294 | idr_init(&sctp_assocs_id); | 1346 | idr_init(&sctp_assocs_id); |
1295 | 1347 | ||
@@ -1376,41 +1428,12 @@ SCTP_STATIC __init int sctp_init(void) | |||
1376 | pr_info("Hash tables configured (established %d bind %d)\n", | 1428 | pr_info("Hash tables configured (established %d bind %d)\n", |
1377 | sctp_assoc_hashsize, sctp_port_hashsize); | 1429 | sctp_assoc_hashsize, sctp_port_hashsize); |
1378 | 1430 | ||
1379 | /* Disable ADDIP by default. */ | ||
1380 | sctp_addip_enable = 0; | ||
1381 | sctp_addip_noauth = 0; | ||
1382 | sctp_default_auto_asconf = 0; | ||
1383 | |||
1384 | /* Enable PR-SCTP by default. */ | ||
1385 | sctp_prsctp_enable = 1; | ||
1386 | |||
1387 | /* Disable AUTH by default. */ | ||
1388 | sctp_auth_enable = 0; | ||
1389 | |||
1390 | /* Set SCOPE policy to enabled */ | ||
1391 | sctp_scope_policy = SCTP_SCOPE_POLICY_ENABLE; | ||
1392 | |||
1393 | /* Set the default rwnd update threshold */ | ||
1394 | sctp_rwnd_upd_shift = SCTP_DEFAULT_RWND_SHIFT; | ||
1395 | |||
1396 | sctp_sysctl_register(); | 1431 | sctp_sysctl_register(); |
1397 | 1432 | ||
1398 | INIT_LIST_HEAD(&sctp_address_families); | 1433 | INIT_LIST_HEAD(&sctp_address_families); |
1399 | sctp_v4_pf_init(); | 1434 | sctp_v4_pf_init(); |
1400 | sctp_v6_pf_init(); | 1435 | sctp_v6_pf_init(); |
1401 | 1436 | ||
1402 | /* Initialize the local address list. */ | ||
1403 | INIT_LIST_HEAD(&sctp_local_addr_list); | ||
1404 | spin_lock_init(&sctp_local_addr_lock); | ||
1405 | sctp_get_local_addr_list(); | ||
1406 | |||
1407 | /* Initialize the address event list */ | ||
1408 | INIT_LIST_HEAD(&sctp_addr_waitq); | ||
1409 | INIT_LIST_HEAD(&sctp_auto_asconf_splist); | ||
1410 | spin_lock_init(&sctp_addr_wq_lock); | ||
1411 | sctp_addr_wq_timer.expires = 0; | ||
1412 | setup_timer(&sctp_addr_wq_timer, sctp_addr_wq_timeout_handler, 0); | ||
1413 | |||
1414 | status = sctp_v4_protosw_init(); | 1437 | status = sctp_v4_protosw_init(); |
1415 | 1438 | ||
1416 | if (status) | 1439 | if (status) |
@@ -1420,11 +1443,9 @@ SCTP_STATIC __init int sctp_init(void) | |||
1420 | if (status) | 1443 | if (status) |
1421 | goto err_v6_protosw_init; | 1444 | goto err_v6_protosw_init; |
1422 | 1445 | ||
1423 | /* Initialize the control inode/socket for handling OOTB packets. */ | 1446 | status = register_pernet_subsys(&sctp_net_ops); |
1424 | if ((status = sctp_ctl_sock_init())) { | 1447 | if (status) |
1425 | pr_err("Failed to initialize the SCTP control sock\n"); | 1448 | goto err_register_pernet_subsys; |
1426 | goto err_ctl_sock_init; | ||
1427 | } | ||
1428 | 1449 | ||
1429 | status = sctp_v4_add_protocol(); | 1450 | status = sctp_v4_add_protocol(); |
1430 | if (status) | 1451 | if (status) |
@@ -1441,13 +1462,12 @@ out: | |||
1441 | err_v6_add_protocol: | 1462 | err_v6_add_protocol: |
1442 | sctp_v4_del_protocol(); | 1463 | sctp_v4_del_protocol(); |
1443 | err_add_protocol: | 1464 | err_add_protocol: |
1444 | inet_ctl_sock_destroy(sctp_ctl_sock); | 1465 | unregister_pernet_subsys(&sctp_net_ops); |
1445 | err_ctl_sock_init: | 1466 | err_register_pernet_subsys: |
1446 | sctp_v6_protosw_exit(); | 1467 | sctp_v6_protosw_exit(); |
1447 | err_v6_protosw_init: | 1468 | err_v6_protosw_init: |
1448 | sctp_v4_protosw_exit(); | 1469 | sctp_v4_protosw_exit(); |
1449 | err_protosw_init: | 1470 | err_protosw_init: |
1450 | sctp_free_local_addr_list(); | ||
1451 | sctp_v4_pf_exit(); | 1471 | sctp_v4_pf_exit(); |
1452 | sctp_v6_pf_exit(); | 1472 | sctp_v6_pf_exit(); |
1453 | sctp_sysctl_unregister(); | 1473 | sctp_sysctl_unregister(); |
@@ -1461,11 +1481,8 @@ err_ehash_alloc: | |||
1461 | get_order(sctp_assoc_hashsize * | 1481 | get_order(sctp_assoc_hashsize * |
1462 | sizeof(struct sctp_hashbucket))); | 1482 | sizeof(struct sctp_hashbucket))); |
1463 | err_ahash_alloc: | 1483 | err_ahash_alloc: |
1464 | sctp_dbg_objcnt_exit(); | 1484 | percpu_counter_destroy(&sctp_sockets_allocated); |
1465 | sctp_proc_exit(); | 1485 | err_percpu_counter_init: |
1466 | err_init_proc: | ||
1467 | cleanup_sctp_mibs(); | ||
1468 | err_init_mibs: | ||
1469 | kmem_cache_destroy(sctp_chunk_cachep); | 1486 | kmem_cache_destroy(sctp_chunk_cachep); |
1470 | err_chunk_cachep: | 1487 | err_chunk_cachep: |
1471 | kmem_cache_destroy(sctp_bucket_cachep); | 1488 | kmem_cache_destroy(sctp_bucket_cachep); |
@@ -1482,18 +1499,13 @@ SCTP_STATIC __exit void sctp_exit(void) | |||
1482 | /* Unregister with inet6/inet layers. */ | 1499 | /* Unregister with inet6/inet layers. */ |
1483 | sctp_v6_del_protocol(); | 1500 | sctp_v6_del_protocol(); |
1484 | sctp_v4_del_protocol(); | 1501 | sctp_v4_del_protocol(); |
1485 | sctp_free_addr_wq(); | ||
1486 | 1502 | ||
1487 | /* Free the control endpoint. */ | 1503 | unregister_pernet_subsys(&sctp_net_ops); |
1488 | inet_ctl_sock_destroy(sctp_ctl_sock); | ||
1489 | 1504 | ||
1490 | /* Free protosw registrations */ | 1505 | /* Free protosw registrations */ |
1491 | sctp_v6_protosw_exit(); | 1506 | sctp_v6_protosw_exit(); |
1492 | sctp_v4_protosw_exit(); | 1507 | sctp_v4_protosw_exit(); |
1493 | 1508 | ||
1494 | /* Free the local address list. */ | ||
1495 | sctp_free_local_addr_list(); | ||
1496 | |||
1497 | /* Unregister with socket layer. */ | 1509 | /* Unregister with socket layer. */ |
1498 | sctp_v6_pf_exit(); | 1510 | sctp_v6_pf_exit(); |
1499 | sctp_v4_pf_exit(); | 1511 | sctp_v4_pf_exit(); |
@@ -1508,9 +1520,7 @@ SCTP_STATIC __exit void sctp_exit(void) | |||
1508 | get_order(sctp_port_hashsize * | 1520 | get_order(sctp_port_hashsize * |
1509 | sizeof(struct sctp_bind_hashbucket))); | 1521 | sizeof(struct sctp_bind_hashbucket))); |
1510 | 1522 | ||
1511 | sctp_dbg_objcnt_exit(); | 1523 | percpu_counter_destroy(&sctp_sockets_allocated); |
1512 | sctp_proc_exit(); | ||
1513 | cleanup_sctp_mibs(); | ||
1514 | 1524 | ||
1515 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ | 1525 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ |
1516 | 1526 | ||