aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-08-06 04:47:55 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-15 02:30:36 -0400
commitb01a24078fa3fc4f0f447d1306ce5adc495ead86 (patch)
tree6949f590c81e2c1ce193b1bdaec68a60e9842879
parentbb2db45b5495455ec7580315029184550709f4a2 (diff)
sctp: Make the mib per network namespace
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/netns/sctp.h3
-rw-r--r--include/net/sctp/sctp.h9
-rw-r--r--net/sctp/associola.c2
-rw-r--r--net/sctp/chunk.c2
-rw-r--r--net/sctp/endpointola.c2
-rw-r--r--net/sctp/input.c22
-rw-r--r--net/sctp/ipv6.c4
-rw-r--r--net/sctp/output.c2
-rw-r--r--net/sctp/outqueue.c18
-rw-r--r--net/sctp/proc.c5
-rw-r--r--net/sctp/protocol.c27
-rw-r--r--net/sctp/sm_statefuns.c163
-rw-r--r--net/sctp/ulpqueue.c18
13 files changed, 158 insertions, 119 deletions
diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h
index 9c20a82a77ec..06ccddf9566c 100644
--- a/include/net/netns/sctp.h
+++ b/include/net/netns/sctp.h
@@ -3,8 +3,11 @@
3 3
4struct sock; 4struct sock;
5struct proc_dir_entry; 5struct proc_dir_entry;
6struct sctp_mib;
6 7
7struct netns_sctp { 8struct netns_sctp {
9 DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics);
10
8#ifdef CONFIG_PROC_FS 11#ifdef CONFIG_PROC_FS
9 struct proc_dir_entry *proc_net_sctp; 12 struct proc_dir_entry *proc_net_sctp;
10#endif 13#endif
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index b49588a51d80..7dcd4dfd7c3f 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -221,11 +221,10 @@ extern struct kmem_cache *sctp_bucket_cachep __read_mostly;
221#define sctp_bh_unlock_sock(sk) bh_unlock_sock(sk) 221#define sctp_bh_unlock_sock(sk) bh_unlock_sock(sk)
222 222
223/* SCTP SNMP MIB stats handlers */ 223/* SCTP SNMP MIB stats handlers */
224DECLARE_SNMP_STAT(struct sctp_mib, sctp_statistics); 224#define SCTP_INC_STATS(net, field) SNMP_INC_STATS((net)->sctp.sctp_statistics, field)
225#define SCTP_INC_STATS(field) SNMP_INC_STATS(sctp_statistics, field) 225#define SCTP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->sctp.sctp_statistics, field)
226#define SCTP_INC_STATS_BH(field) SNMP_INC_STATS_BH(sctp_statistics, field) 226#define SCTP_INC_STATS_USER(net, field) SNMP_INC_STATS_USER((net)->sctp.sctp_statistics, field)
227#define SCTP_INC_STATS_USER(field) SNMP_INC_STATS_USER(sctp_statistics, field) 227#define SCTP_DEC_STATS(net, field) SNMP_DEC_STATS((net)->sctp.sctp_statistics, field)
228#define SCTP_DEC_STATS(field) SNMP_DEC_STATS(sctp_statistics, field)
229 228
230#endif /* !TEST_FRAME */ 229#endif /* !TEST_FRAME */
231 230
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index ed4930b31341..8a1f27a7a001 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -1150,7 +1150,7 @@ static void sctp_assoc_bh_rcv(struct work_struct *work)
1150 if (sctp_chunk_is_data(chunk)) 1150 if (sctp_chunk_is_data(chunk))
1151 asoc->peer.last_data_from = chunk->transport; 1151 asoc->peer.last_data_from = chunk->transport;
1152 else 1152 else
1153 SCTP_INC_STATS(SCTP_MIB_INCTRLCHUNKS); 1153 SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_INCTRLCHUNKS);
1154 1154
1155 if (chunk->transport) 1155 if (chunk->transport)
1156 chunk->transport->last_time_heard = jiffies; 1156 chunk->transport->last_time_heard = jiffies;
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c
index 6c8556459a75..7c2df9c33df3 100644
--- a/net/sctp/chunk.c
+++ b/net/sctp/chunk.c
@@ -257,7 +257,7 @@ struct sctp_datamsg *sctp_datamsg_from_user(struct sctp_association *asoc,
257 offset = 0; 257 offset = 0;
258 258
259 if ((whole > 1) || (whole && over)) 259 if ((whole > 1) || (whole && over))
260 SCTP_INC_STATS_USER(SCTP_MIB_FRAGUSRMSGS); 260 SCTP_INC_STATS_USER(sock_net(asoc->base.sk), SCTP_MIB_FRAGUSRMSGS);
261 261
262 /* Create chunks for all the full sized DATA chunks. */ 262 /* Create chunks for all the full sized DATA chunks. */
263 for (i=0, len=first_len; i < whole; i++) { 263 for (i=0, len=first_len; i < whole; i++) {
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 6b763939345b..3edca80ab3a1 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -478,7 +478,7 @@ normal:
478 if (asoc && sctp_chunk_is_data(chunk)) 478 if (asoc && sctp_chunk_is_data(chunk))
479 asoc->peer.last_data_from = chunk->transport; 479 asoc->peer.last_data_from = chunk->transport;
480 else 480 else
481 SCTP_INC_STATS(SCTP_MIB_INCTRLCHUNKS); 481 SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_INCTRLCHUNKS);
482 482
483 if (chunk->transport) 483 if (chunk->transport)
484 chunk->transport->last_time_heard = jiffies; 484 chunk->transport->last_time_heard = jiffies;
diff --git a/net/sctp/input.c b/net/sctp/input.c
index c9a0449bde53..530830151f04 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -83,7 +83,7 @@ static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb);
83 83
84 84
85/* Calculate the SCTP checksum of an SCTP packet. */ 85/* Calculate the SCTP checksum of an SCTP packet. */
86static inline int sctp_rcv_checksum(struct sk_buff *skb) 86static inline int sctp_rcv_checksum(struct net *net, struct sk_buff *skb)
87{ 87{
88 struct sctphdr *sh = sctp_hdr(skb); 88 struct sctphdr *sh = sctp_hdr(skb);
89 __le32 cmp = sh->checksum; 89 __le32 cmp = sh->checksum;
@@ -99,7 +99,7 @@ static inline int sctp_rcv_checksum(struct sk_buff *skb)
99 99
100 if (val != cmp) { 100 if (val != cmp) {
101 /* CRC failure, dump it. */ 101 /* CRC failure, dump it. */
102 SCTP_INC_STATS_BH(SCTP_MIB_CHECKSUMERRORS); 102 SCTP_INC_STATS_BH(net, SCTP_MIB_CHECKSUMERRORS);
103 return -1; 103 return -1;
104 } 104 }
105 return 0; 105 return 0;
@@ -137,7 +137,7 @@ int sctp_rcv(struct sk_buff *skb)
137 if (skb->pkt_type!=PACKET_HOST) 137 if (skb->pkt_type!=PACKET_HOST)
138 goto discard_it; 138 goto discard_it;
139 139
140 SCTP_INC_STATS_BH(SCTP_MIB_INSCTPPACKS); 140 SCTP_INC_STATS_BH(net, SCTP_MIB_INSCTPPACKS);
141 141
142 if (skb_linearize(skb)) 142 if (skb_linearize(skb))
143 goto discard_it; 143 goto discard_it;
@@ -149,7 +149,7 @@ int sctp_rcv(struct sk_buff *skb)
149 if (skb->len < sizeof(struct sctphdr)) 149 if (skb->len < sizeof(struct sctphdr))
150 goto discard_it; 150 goto discard_it;
151 if (!sctp_checksum_disable && !skb_csum_unnecessary(skb) && 151 if (!sctp_checksum_disable && !skb_csum_unnecessary(skb) &&
152 sctp_rcv_checksum(skb) < 0) 152 sctp_rcv_checksum(net, skb) < 0)
153 goto discard_it; 153 goto discard_it;
154 154
155 skb_pull(skb, sizeof(struct sctphdr)); 155 skb_pull(skb, sizeof(struct sctphdr));
@@ -220,7 +220,7 @@ int sctp_rcv(struct sk_buff *skb)
220 */ 220 */
221 if (!asoc) { 221 if (!asoc) {
222 if (sctp_rcv_ootb(skb)) { 222 if (sctp_rcv_ootb(skb)) {
223 SCTP_INC_STATS_BH(SCTP_MIB_OUTOFBLUES); 223 SCTP_INC_STATS_BH(net, SCTP_MIB_OUTOFBLUES);
224 goto discard_release; 224 goto discard_release;
225 } 225 }
226 } 226 }
@@ -276,9 +276,9 @@ int sctp_rcv(struct sk_buff *skb)
276 skb = NULL; /* sctp_chunk_free already freed the skb */ 276 skb = NULL; /* sctp_chunk_free already freed the skb */
277 goto discard_release; 277 goto discard_release;
278 } 278 }
279 SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_BACKLOG); 279 SCTP_INC_STATS_BH(net, SCTP_MIB_IN_PKT_BACKLOG);
280 } else { 280 } else {
281 SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_SOFTIRQ); 281 SCTP_INC_STATS_BH(net, SCTP_MIB_IN_PKT_SOFTIRQ);
282 sctp_inq_push(&chunk->rcvr->inqueue, chunk); 282 sctp_inq_push(&chunk->rcvr->inqueue, chunk);
283 } 283 }
284 284
@@ -293,7 +293,7 @@ int sctp_rcv(struct sk_buff *skb)
293 return 0; 293 return 0;
294 294
295discard_it: 295discard_it:
296 SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_DISCARDS); 296 SCTP_INC_STATS_BH(net, SCTP_MIB_IN_PKT_DISCARDS);
297 kfree_skb(skb); 297 kfree_skb(skb);
298 return 0; 298 return 0;
299 299
@@ -543,7 +543,7 @@ struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb,
543 * servers this needs to be solved differently. 543 * servers this needs to be solved differently.
544 */ 544 */
545 if (sock_owned_by_user(sk)) 545 if (sock_owned_by_user(sk))
546 NET_INC_STATS_BH(&init_net, LINUX_MIB_LOCKDROPPEDICMPS); 546 NET_INC_STATS_BH(net, LINUX_MIB_LOCKDROPPEDICMPS);
547 547
548 *app = asoc; 548 *app = asoc;
549 *tpp = transport; 549 *tpp = transport;
@@ -593,7 +593,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
593 struct net *net = dev_net(skb->dev); 593 struct net *net = dev_net(skb->dev);
594 594
595 if (skb->len < ihlen + 8) { 595 if (skb->len < ihlen + 8) {
596 ICMP_INC_STATS_BH(&init_net, ICMP_MIB_INERRORS); 596 ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS);
597 return; 597 return;
598 } 598 }
599 599
@@ -607,7 +607,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
607 skb->network_header = saveip; 607 skb->network_header = saveip;
608 skb->transport_header = savesctp; 608 skb->transport_header = savesctp;
609 if (!sk) { 609 if (!sk) {
610 ICMP_INC_STATS_BH(&init_net, ICMP_MIB_INERRORS); 610 ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS);
611 return; 611 return;
612 } 612 }
613 /* Warning: The sock lock is held. Remember to call 613 /* Warning: The sock lock is held. Remember to call
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index a18cda60e156..ea14cb445295 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -169,7 +169,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
169 skb->network_header = saveip; 169 skb->network_header = saveip;
170 skb->transport_header = savesctp; 170 skb->transport_header = savesctp;
171 if (!sk) { 171 if (!sk) {
172 ICMP6_INC_STATS_BH(dev_net(skb->dev), idev, ICMP6_MIB_INERRORS); 172 ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_INERRORS);
173 goto out; 173 goto out;
174 } 174 }
175 175
@@ -243,7 +243,7 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport)
243 __func__, skb, skb->len, 243 __func__, skb, skb->len,
244 &fl6.saddr, &fl6.daddr); 244 &fl6.saddr, &fl6.daddr);
245 245
246 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); 246 SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS);
247 247
248 if (!(transport->param_flags & SPP_PMTUD_ENABLE)) 248 if (!(transport->param_flags & SPP_PMTUD_ENABLE))
249 skb->local_df = 1; 249 skb->local_df = 1;
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 838e18b4d7ea..0c6359bb973c 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -597,7 +597,7 @@ out:
597 return err; 597 return err;
598no_route: 598no_route:
599 kfree_skb(nskb); 599 kfree_skb(nskb);
600 IP_INC_STATS_BH(&init_net, IPSTATS_MIB_OUTNOROUTES); 600 IP_INC_STATS_BH(sock_net(asoc->base.sk), IPSTATS_MIB_OUTNOROUTES);
601 601
602 /* FIXME: Returning the 'err' will effect all the associations 602 /* FIXME: Returning the 'err' will effect all the associations
603 * associated with a socket, although only one of the paths of the 603 * associated with a socket, although only one of the paths of the
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index e7aa177c9522..072bf6ae3c26 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -299,6 +299,7 @@ void sctp_outq_free(struct sctp_outq *q)
299/* Put a new chunk in an sctp_outq. */ 299/* Put a new chunk in an sctp_outq. */
300int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk) 300int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk)
301{ 301{
302 struct net *net = sock_net(q->asoc->base.sk);
302 int error = 0; 303 int error = 0;
303 304
304 SCTP_DEBUG_PRINTK("sctp_outq_tail(%p, %p[%s])\n", 305 SCTP_DEBUG_PRINTK("sctp_outq_tail(%p, %p[%s])\n",
@@ -337,15 +338,15 @@ int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk)
337 338
338 sctp_outq_tail_data(q, chunk); 339 sctp_outq_tail_data(q, chunk);
339 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) 340 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
340 SCTP_INC_STATS(SCTP_MIB_OUTUNORDERCHUNKS); 341 SCTP_INC_STATS(net, SCTP_MIB_OUTUNORDERCHUNKS);
341 else 342 else
342 SCTP_INC_STATS(SCTP_MIB_OUTORDERCHUNKS); 343 SCTP_INC_STATS(net, SCTP_MIB_OUTORDERCHUNKS);
343 q->empty = 0; 344 q->empty = 0;
344 break; 345 break;
345 } 346 }
346 } else { 347 } else {
347 list_add_tail(&chunk->list, &q->control_chunk_list); 348 list_add_tail(&chunk->list, &q->control_chunk_list);
348 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 349 SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
349 } 350 }
350 351
351 if (error < 0) 352 if (error < 0)
@@ -478,11 +479,12 @@ void sctp_retransmit_mark(struct sctp_outq *q,
478void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport, 479void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
479 sctp_retransmit_reason_t reason) 480 sctp_retransmit_reason_t reason)
480{ 481{
482 struct net *net = sock_net(q->asoc->base.sk);
481 int error = 0; 483 int error = 0;
482 484
483 switch(reason) { 485 switch(reason) {
484 case SCTP_RTXR_T3_RTX: 486 case SCTP_RTXR_T3_RTX:
485 SCTP_INC_STATS(SCTP_MIB_T3_RETRANSMITS); 487 SCTP_INC_STATS(net, SCTP_MIB_T3_RETRANSMITS);
486 sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_T3_RTX); 488 sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_T3_RTX);
487 /* Update the retran path if the T3-rtx timer has expired for 489 /* Update the retran path if the T3-rtx timer has expired for
488 * the current retran path. 490 * the current retran path.
@@ -493,15 +495,15 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
493 transport->asoc->unack_data; 495 transport->asoc->unack_data;
494 break; 496 break;
495 case SCTP_RTXR_FAST_RTX: 497 case SCTP_RTXR_FAST_RTX:
496 SCTP_INC_STATS(SCTP_MIB_FAST_RETRANSMITS); 498 SCTP_INC_STATS(net, SCTP_MIB_FAST_RETRANSMITS);
497 sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX); 499 sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX);
498 q->fast_rtx = 1; 500 q->fast_rtx = 1;
499 break; 501 break;
500 case SCTP_RTXR_PMTUD: 502 case SCTP_RTXR_PMTUD:
501 SCTP_INC_STATS(SCTP_MIB_PMTUD_RETRANSMITS); 503 SCTP_INC_STATS(net, SCTP_MIB_PMTUD_RETRANSMITS);
502 break; 504 break;
503 case SCTP_RTXR_T1_RTX: 505 case SCTP_RTXR_T1_RTX:
504 SCTP_INC_STATS(SCTP_MIB_T1_RETRANSMITS); 506 SCTP_INC_STATS(net, SCTP_MIB_T1_RETRANSMITS);
505 transport->asoc->init_retries++; 507 transport->asoc->init_retries++;
506 break; 508 break;
507 default: 509 default:
@@ -1914,6 +1916,6 @@ static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 ctsn)
1914 1916
1915 if (ftsn_chunk) { 1917 if (ftsn_chunk) {
1916 list_add_tail(&ftsn_chunk->list, &q->control_chunk_list); 1918 list_add_tail(&ftsn_chunk->list, &q->control_chunk_list);
1917 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 1919 SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_OUTCTRLCHUNKS);
1918 } 1920 }
1919} 1921}
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index dc79a3aa0382..3e62ee55228f 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -83,12 +83,9 @@ static int sctp_snmp_seq_show(struct seq_file *seq, void *v)
83 struct net *net = seq->private; 83 struct net *net = seq->private;
84 int i; 84 int i;
85 85
86 if (!net_eq(net, &init_net))
87 return 0;
88
89 for (i = 0; sctp_snmp_list[i].name != NULL; i++) 86 for (i = 0; sctp_snmp_list[i].name != NULL; i++)
90 seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name, 87 seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name,
91 snmp_fold_field((void __percpu **)sctp_statistics, 88 snmp_fold_field((void __percpu **)net->sctp.sctp_statistics,
92 sctp_snmp_list[i].entry)); 89 sctp_snmp_list[i].entry));
93 90
94 return 0; 91 return 0;
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 059c914c09f2..d58db315db85 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -69,7 +69,6 @@
69 69
70/* Global data structures. */ 70/* Global data structures. */
71struct sctp_globals sctp_globals __read_mostly; 71struct sctp_globals sctp_globals __read_mostly;
72DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics) __read_mostly;
73 72
74struct idr sctp_assocs_id; 73struct idr sctp_assocs_id;
75DEFINE_SPINLOCK(sctp_assocs_id_lock); 74DEFINE_SPINLOCK(sctp_assocs_id_lock);
@@ -961,7 +960,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
961 inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? 960 inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ?
962 IP_PMTUDISC_DO : IP_PMTUDISC_DONT; 961 IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
963 962
964 SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); 963 SCTP_INC_STATS(sock_net(&inet->sk), SCTP_MIB_OUTSCTPPACKS);
965 return ip_queue_xmit(skb, &transport->fl); 964 return ip_queue_xmit(skb, &transport->fl);
966} 965}
967 966
@@ -1102,16 +1101,16 @@ int sctp_register_pf(struct sctp_pf *pf, sa_family_t family)
1102 return 1; 1101 return 1;
1103} 1102}
1104 1103
1105static inline int init_sctp_mibs(void) 1104static inline int init_sctp_mibs(struct net *net)
1106{ 1105{
1107 return snmp_mib_init((void __percpu **)sctp_statistics, 1106 return snmp_mib_init((void __percpu **)net->sctp.sctp_statistics,
1108 sizeof(struct sctp_mib), 1107 sizeof(struct sctp_mib),
1109 __alignof__(struct sctp_mib)); 1108 __alignof__(struct sctp_mib));
1110} 1109}
1111 1110
1112static inline void cleanup_sctp_mibs(void) 1111static inline void cleanup_sctp_mibs(struct net *net)
1113{ 1112{
1114 snmp_mib_free((void __percpu **)sctp_statistics); 1113 snmp_mib_free((void __percpu **)net->sctp.sctp_statistics);
1115} 1114}
1116 1115
1117static void sctp_v4_pf_init(void) 1116static void sctp_v4_pf_init(void)
@@ -1170,6 +1169,11 @@ static int sctp_net_init(struct net *net)
1170{ 1169{
1171 int status; 1170 int status;
1172 1171
1172 /* Allocate and initialise sctp mibs. */
1173 status = init_sctp_mibs(net);
1174 if (status)
1175 goto err_init_mibs;
1176
1173 /* Initialize proc fs directory. */ 1177 /* Initialize proc fs directory. */
1174 status = sctp_proc_init(net); 1178 status = sctp_proc_init(net);
1175 if (status) 1179 if (status)
@@ -1202,6 +1206,8 @@ err_ctl_sock_init:
1202 sctp_dbg_objcnt_exit(net); 1206 sctp_dbg_objcnt_exit(net);
1203 sctp_proc_exit(net); 1207 sctp_proc_exit(net);
1204err_init_proc: 1208err_init_proc:
1209 cleanup_sctp_mibs(net);
1210err_init_mibs:
1205 return status; 1211 return status;
1206} 1212}
1207 1213
@@ -1217,6 +1223,7 @@ static void sctp_net_exit(struct net *net)
1217 sctp_dbg_objcnt_exit(net); 1223 sctp_dbg_objcnt_exit(net);
1218 1224
1219 sctp_proc_exit(net); 1225 sctp_proc_exit(net);
1226 cleanup_sctp_mibs(net);
1220} 1227}
1221 1228
1222static struct pernet_operations sctp_net_ops = { 1229static struct pernet_operations sctp_net_ops = {
@@ -1254,11 +1261,6 @@ SCTP_STATIC __init int sctp_init(void)
1254 if (!sctp_chunk_cachep) 1261 if (!sctp_chunk_cachep)
1255 goto err_chunk_cachep; 1262 goto err_chunk_cachep;
1256 1263
1257 /* Allocate and initialise sctp mibs. */
1258 status = init_sctp_mibs();
1259 if (status)
1260 goto err_init_mibs;
1261
1262 status = percpu_counter_init(&sctp_sockets_allocated, 0); 1264 status = percpu_counter_init(&sctp_sockets_allocated, 0);
1263 if (status) 1265 if (status)
1264 goto err_percpu_counter_init; 1266 goto err_percpu_counter_init;
@@ -1474,8 +1476,6 @@ err_ehash_alloc:
1474err_ahash_alloc: 1476err_ahash_alloc:
1475 percpu_counter_destroy(&sctp_sockets_allocated); 1477 percpu_counter_destroy(&sctp_sockets_allocated);
1476err_percpu_counter_init: 1478err_percpu_counter_init:
1477 cleanup_sctp_mibs();
1478err_init_mibs:
1479 kmem_cache_destroy(sctp_chunk_cachep); 1479 kmem_cache_destroy(sctp_chunk_cachep);
1480err_chunk_cachep: 1480err_chunk_cachep:
1481 kmem_cache_destroy(sctp_bucket_cachep); 1481 kmem_cache_destroy(sctp_bucket_cachep);
@@ -1514,7 +1514,6 @@ SCTP_STATIC __exit void sctp_exit(void)
1514 sizeof(struct sctp_bind_hashbucket))); 1514 sizeof(struct sctp_bind_hashbucket)));
1515 1515
1516 percpu_counter_destroy(&sctp_sockets_allocated); 1516 percpu_counter_destroy(&sctp_sockets_allocated);
1517 cleanup_sctp_mibs();
1518 1517
1519 rcu_barrier(); /* Wait for completion of call_rcu()'s */ 1518 rcu_barrier(); /* Wait for completion of call_rcu()'s */
1520 1519
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index f2daf615e8fe..bee5e2c288d8 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -213,6 +213,7 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep,
213{ 213{
214 struct sctp_chunk *chunk = arg; 214 struct sctp_chunk *chunk = arg;
215 struct sctp_ulpevent *ev; 215 struct sctp_ulpevent *ev;
216 struct net *net;
216 217
217 if (!sctp_vtag_verify_either(chunk, asoc)) 218 if (!sctp_vtag_verify_either(chunk, asoc))
218 return sctp_sf_pdiscard(ep, asoc, type, arg, commands); 219 return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -260,8 +261,9 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep,
260 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 261 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
261 SCTP_STATE(SCTP_STATE_CLOSED)); 262 SCTP_STATE(SCTP_STATE_CLOSED));
262 263
263 SCTP_INC_STATS(SCTP_MIB_SHUTDOWNS); 264 net = sock_net(asoc->base.sk);
264 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 265 SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS);
266 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
265 267
266 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); 268 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL());
267 269
@@ -322,7 +324,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep,
322 */ 324 */
323 net = sock_net(ep->base.sk); 325 net = sock_net(ep->base.sk);
324 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { 326 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) {
325 SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); 327 SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES);
326 return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); 328 return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);
327 } 329 }
328 330
@@ -369,7 +371,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep,
369 if (packet) { 371 if (packet) {
370 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, 372 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT,
371 SCTP_PACKET(packet)); 373 SCTP_PACKET(packet));
372 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 374 SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
373 return SCTP_DISPOSITION_CONSUME; 375 return SCTP_DISPOSITION_CONSUME;
374 } else { 376 } else {
375 return SCTP_DISPOSITION_NOMEM; 377 return SCTP_DISPOSITION_NOMEM;
@@ -540,7 +542,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep,
540 if (packet) { 542 if (packet) {
541 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, 543 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT,
542 SCTP_PACKET(packet)); 544 SCTP_PACKET(packet));
543 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 545 SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_OUTCTRLCHUNKS);
544 error = SCTP_ERROR_INV_PARAM; 546 error = SCTP_ERROR_INV_PARAM;
545 } 547 }
546 } 548 }
@@ -559,7 +561,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep,
559 if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) 561 if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc))
560 return sctp_sf_pdiscard(ep, asoc, type, arg, commands); 562 return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
561 563
562 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 564 SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_ABORTEDS);
563 return sctp_stop_t1_and_abort(commands, error, ECONNREFUSED, 565 return sctp_stop_t1_and_abort(commands, error, ECONNREFUSED,
564 asoc, chunk->transport); 566 asoc, chunk->transport);
565 } 567 }
@@ -656,7 +658,7 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
656 */ 658 */
657 net = sock_net(ep->base.sk); 659 net = sock_net(ep->base.sk);
658 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { 660 if (ep == sctp_sk(net->sctp.ctl_sock)->ep) {
659 SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); 661 SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES);
660 return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); 662 return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands);
661 } 663 }
662 664
@@ -809,8 +811,8 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep,
809 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc)); 811 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc));
810 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 812 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
811 SCTP_STATE(SCTP_STATE_ESTABLISHED)); 813 SCTP_STATE(SCTP_STATE_ESTABLISHED));
812 SCTP_INC_STATS(SCTP_MIB_CURRESTAB); 814 SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB);
813 SCTP_INC_STATS(SCTP_MIB_PASSIVEESTABS); 815 SCTP_INC_STATS(net, SCTP_MIB_PASSIVEESTABS);
814 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); 816 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL());
815 817
816 if (new_asoc->autoclose) 818 if (new_asoc->autoclose)
@@ -868,6 +870,7 @@ sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep,
868{ 870{
869 struct sctp_chunk *chunk = arg; 871 struct sctp_chunk *chunk = arg;
870 struct sctp_ulpevent *ev; 872 struct sctp_ulpevent *ev;
873 struct net *net;
871 874
872 if (!sctp_vtag_verify(chunk, asoc)) 875 if (!sctp_vtag_verify(chunk, asoc))
873 return sctp_sf_pdiscard(ep, asoc, type, arg, commands); 876 return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -897,8 +900,9 @@ sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep,
897 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); 900 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE));
898 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 901 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
899 SCTP_STATE(SCTP_STATE_ESTABLISHED)); 902 SCTP_STATE(SCTP_STATE_ESTABLISHED));
900 SCTP_INC_STATS(SCTP_MIB_CURRESTAB); 903 net = sock_net(ep->base.sk);
901 SCTP_INC_STATS(SCTP_MIB_ACTIVEESTABS); 904 SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB);
905 SCTP_INC_STATS(net, SCTP_MIB_ACTIVEESTABS);
902 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); 906 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL());
903 if (asoc->autoclose) 907 if (asoc->autoclose)
904 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, 908 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START,
@@ -972,13 +976,15 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep,
972 struct sctp_transport *transport = (struct sctp_transport *) arg; 976 struct sctp_transport *transport = (struct sctp_transport *) arg;
973 977
974 if (asoc->overall_error_count >= asoc->max_retrans) { 978 if (asoc->overall_error_count >= asoc->max_retrans) {
979 struct net *net;
975 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 980 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
976 SCTP_ERROR(ETIMEDOUT)); 981 SCTP_ERROR(ETIMEDOUT));
977 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 982 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
978 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 983 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
979 SCTP_PERR(SCTP_ERROR_NO_ERROR)); 984 SCTP_PERR(SCTP_ERROR_NO_ERROR));
980 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 985 net = sock_net(ep->base.sk);
981 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 986 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
987 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
982 return SCTP_DISPOSITION_DELETE_TCB; 988 return SCTP_DISPOSITION_DELETE_TCB;
983 } 989 }
984 990
@@ -1213,7 +1219,7 @@ static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa,
1213 goto out; 1219 goto out;
1214 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, SCTP_PACKET(pkt)); 1220 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, SCTP_PACKET(pkt));
1215 1221
1216 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 1222 SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
1217 1223
1218 /* Discard the rest of the inbound packet. */ 1224 /* Discard the rest of the inbound packet. */
1219 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL()); 1225 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL());
@@ -1427,7 +1433,7 @@ static sctp_disposition_t sctp_sf_do_unexpected_init(
1427 if (packet) { 1433 if (packet) {
1428 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, 1434 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT,
1429 SCTP_PACKET(packet)); 1435 SCTP_PACKET(packet));
1430 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 1436 SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_OUTCTRLCHUNKS);
1431 retval = SCTP_DISPOSITION_CONSUME; 1437 retval = SCTP_DISPOSITION_CONSUME;
1432 } else { 1438 } else {
1433 retval = SCTP_DISPOSITION_NOMEM; 1439 retval = SCTP_DISPOSITION_NOMEM;
@@ -1791,7 +1797,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep,
1791 sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc)); 1797 sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc));
1792 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 1798 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
1793 SCTP_STATE(SCTP_STATE_ESTABLISHED)); 1799 SCTP_STATE(SCTP_STATE_ESTABLISHED));
1794 SCTP_INC_STATS(SCTP_MIB_CURRESTAB); 1800 SCTP_INC_STATS(sock_net(new_asoc->base.sk), SCTP_MIB_CURRESTAB);
1795 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); 1801 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL());
1796 1802
1797 repl = sctp_make_cookie_ack(new_asoc, chunk); 1803 repl = sctp_make_cookie_ack(new_asoc, chunk);
@@ -1883,7 +1889,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_d(const struct sctp_endpoint *ep,
1883 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); 1889 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE));
1884 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 1890 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
1885 SCTP_STATE(SCTP_STATE_ESTABLISHED)); 1891 SCTP_STATE(SCTP_STATE_ESTABLISHED));
1886 SCTP_INC_STATS(SCTP_MIB_CURRESTAB); 1892 SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_CURRESTAB);
1887 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, 1893 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START,
1888 SCTP_NULL()); 1894 SCTP_NULL());
1889 1895
@@ -2417,6 +2423,7 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep,
2417 struct sctp_chunk *chunk = arg; 2423 struct sctp_chunk *chunk = arg;
2418 unsigned int len; 2424 unsigned int len;
2419 __be16 error = SCTP_ERROR_NO_ERROR; 2425 __be16 error = SCTP_ERROR_NO_ERROR;
2426 struct net *net;
2420 2427
2421 /* See if we have an error cause code in the chunk. */ 2428 /* See if we have an error cause code in the chunk. */
2422 len = ntohs(chunk->chunk_hdr->length); 2429 len = ntohs(chunk->chunk_hdr->length);
@@ -2433,8 +2440,9 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep,
2433 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET)); 2440 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET));
2434 /* ASSOC_FAILED will DELETE_TCB. */ 2441 /* ASSOC_FAILED will DELETE_TCB. */
2435 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_PERR(error)); 2442 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_PERR(error));
2436 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 2443 net = sock_net(ep->base.sk);
2437 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 2444 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
2445 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
2438 2446
2439 return SCTP_DISPOSITION_ABORT; 2447 return SCTP_DISPOSITION_ABORT;
2440} 2448}
@@ -2521,7 +2529,7 @@ static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
2521 SCTP_DEBUG_PRINTK("ABORT received (INIT).\n"); 2529 SCTP_DEBUG_PRINTK("ABORT received (INIT).\n");
2522 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 2530 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
2523 SCTP_STATE(SCTP_STATE_CLOSED)); 2531 SCTP_STATE(SCTP_STATE_CLOSED));
2524 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 2532 SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_ABORTEDS);
2525 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 2533 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
2526 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); 2534 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT));
2527 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(sk_err)); 2535 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(sk_err));
@@ -2904,11 +2912,11 @@ sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep,
2904 break; 2912 break;
2905 case SCTP_IERROR_HIGH_TSN: 2913 case SCTP_IERROR_HIGH_TSN:
2906 case SCTP_IERROR_BAD_STREAM: 2914 case SCTP_IERROR_BAD_STREAM:
2907 SCTP_INC_STATS(SCTP_MIB_IN_DATA_CHUNK_DISCARDS); 2915 SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_IN_DATA_CHUNK_DISCARDS);
2908 goto discard_noforce; 2916 goto discard_noforce;
2909 case SCTP_IERROR_DUP_TSN: 2917 case SCTP_IERROR_DUP_TSN:
2910 case SCTP_IERROR_IGNORE_TSN: 2918 case SCTP_IERROR_IGNORE_TSN:
2911 SCTP_INC_STATS(SCTP_MIB_IN_DATA_CHUNK_DISCARDS); 2919 SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_IN_DATA_CHUNK_DISCARDS);
2912 goto discard_force; 2920 goto discard_force;
2913 case SCTP_IERROR_NO_DATA: 2921 case SCTP_IERROR_NO_DATA:
2914 goto consume; 2922 goto consume;
@@ -3197,7 +3205,7 @@ static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep,
3197 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, 3205 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT,
3198 SCTP_PACKET(packet)); 3206 SCTP_PACKET(packet));
3199 3207
3200 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 3208 SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
3201 3209
3202 sctp_sf_pdiscard(ep, asoc, type, arg, commands); 3210 sctp_sf_pdiscard(ep, asoc, type, arg, commands);
3203 return SCTP_DISPOSITION_CONSUME; 3211 return SCTP_DISPOSITION_CONSUME;
@@ -3260,6 +3268,7 @@ sctp_disposition_t sctp_sf_do_9_2_final(const struct sctp_endpoint *ep,
3260 struct sctp_chunk *chunk = arg; 3268 struct sctp_chunk *chunk = arg;
3261 struct sctp_chunk *reply; 3269 struct sctp_chunk *reply;
3262 struct sctp_ulpevent *ev; 3270 struct sctp_ulpevent *ev;
3271 struct net *net;
3263 3272
3264 if (!sctp_vtag_verify(chunk, asoc)) 3273 if (!sctp_vtag_verify(chunk, asoc))
3265 return sctp_sf_pdiscard(ep, asoc, type, arg, commands); 3274 return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -3299,8 +3308,9 @@ sctp_disposition_t sctp_sf_do_9_2_final(const struct sctp_endpoint *ep,
3299 3308
3300 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 3309 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
3301 SCTP_STATE(SCTP_STATE_CLOSED)); 3310 SCTP_STATE(SCTP_STATE_CLOSED));
3302 SCTP_INC_STATS(SCTP_MIB_SHUTDOWNS); 3311 net = sock_net(asoc->base.sk);
3303 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 3312 SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS);
3313 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
3304 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply)); 3314 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply));
3305 3315
3306 /* ...and remove all record of the association. */ 3316 /* ...and remove all record of the association. */
@@ -3346,8 +3356,10 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep,
3346 __u8 *ch_end; 3356 __u8 *ch_end;
3347 int ootb_shut_ack = 0; 3357 int ootb_shut_ack = 0;
3348 int ootb_cookie_ack = 0; 3358 int ootb_cookie_ack = 0;
3359 struct net *net;
3349 3360
3350 SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); 3361 net = sock_net(asoc->base.sk);
3362 SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES);
3351 3363
3352 ch = (sctp_chunkhdr_t *) chunk->chunk_hdr; 3364 ch = (sctp_chunkhdr_t *) chunk->chunk_hdr;
3353 do { 3365 do {
@@ -3461,7 +3473,7 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep,
3461 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, 3473 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT,
3462 SCTP_PACKET(packet)); 3474 SCTP_PACKET(packet));
3463 3475
3464 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 3476 SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
3465 3477
3466 /* If the chunk length is invalid, we don't want to process 3478 /* If the chunk length is invalid, we don't want to process
3467 * the reset of the packet. 3479 * the reset of the packet.
@@ -3508,7 +3520,7 @@ sctp_disposition_t sctp_sf_do_8_5_1_E_sa(const struct sctp_endpoint *ep,
3508 * packet and the state function that handles OOTB SHUTDOWN_ACK is 3520 * packet and the state function that handles OOTB SHUTDOWN_ACK is
3509 * called with a NULL association. 3521 * called with a NULL association.
3510 */ 3522 */
3511 SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); 3523 SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_OUTOFBLUES);
3512 3524
3513 return sctp_sf_shut_8_4_5(ep, NULL, type, arg, commands); 3525 return sctp_sf_shut_8_4_5(ep, NULL, type, arg, commands);
3514} 3526}
@@ -3699,6 +3711,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
3699 */ 3711 */
3700 if (ADDIP_SERIAL_gte(rcvd_serial, sent_serial + 1) && 3712 if (ADDIP_SERIAL_gte(rcvd_serial, sent_serial + 1) &&
3701 !(asoc->addip_last_asconf)) { 3713 !(asoc->addip_last_asconf)) {
3714 struct net *net;
3702 abort = sctp_make_abort(asoc, asconf_ack, 3715 abort = sctp_make_abort(asoc, asconf_ack,
3703 sizeof(sctp_errhdr_t)); 3716 sizeof(sctp_errhdr_t));
3704 if (abort) { 3717 if (abort) {
@@ -3716,12 +3729,14 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
3716 SCTP_ERROR(ECONNABORTED)); 3729 SCTP_ERROR(ECONNABORTED));
3717 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 3730 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
3718 SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); 3731 SCTP_PERR(SCTP_ERROR_ASCONF_ACK));
3719 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 3732 net = sock_net(asoc->base.sk);
3720 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 3733 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
3734 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
3721 return SCTP_DISPOSITION_ABORT; 3735 return SCTP_DISPOSITION_ABORT;
3722 } 3736 }
3723 3737
3724 if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) { 3738 if ((rcvd_serial == sent_serial) && asoc->addip_last_asconf) {
3739 struct net *net;
3725 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 3740 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
3726 SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO)); 3741 SCTP_TO(SCTP_EVENT_TIMEOUT_T4_RTO));
3727 3742
@@ -3750,8 +3765,9 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep,
3750 SCTP_ERROR(ECONNABORTED)); 3765 SCTP_ERROR(ECONNABORTED));
3751 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 3766 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
3752 SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); 3767 SCTP_PERR(SCTP_ERROR_ASCONF_ACK));
3753 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 3768 net = sock_net(asoc->base.sk);
3754 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 3769 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
3770 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
3755 return SCTP_DISPOSITION_ABORT; 3771 return SCTP_DISPOSITION_ABORT;
3756 } 3772 }
3757 3773
@@ -4222,7 +4238,7 @@ sctp_disposition_t sctp_sf_pdiscard(const struct sctp_endpoint *ep,
4222 void *arg, 4238 void *arg,
4223 sctp_cmd_seq_t *commands) 4239 sctp_cmd_seq_t *commands)
4224{ 4240{
4225 SCTP_INC_STATS(SCTP_MIB_IN_PKT_DISCARDS); 4241 SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_IN_PKT_DISCARDS);
4226 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL()); 4242 sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL());
4227 4243
4228 return SCTP_DISPOSITION_CONSUME; 4244 return SCTP_DISPOSITION_CONSUME;
@@ -4315,7 +4331,7 @@ static sctp_disposition_t sctp_sf_abort_violation(
4315 } 4331 }
4316 4332
4317 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); 4333 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort));
4318 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 4334 SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
4319 4335
4320 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { 4336 if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) {
4321 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 4337 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
@@ -4329,7 +4345,7 @@ static sctp_disposition_t sctp_sf_abort_violation(
4329 SCTP_ERROR(ECONNABORTED)); 4345 SCTP_ERROR(ECONNABORTED));
4330 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4346 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4331 SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION)); 4347 SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION));
4332 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 4348 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
4333 } 4349 }
4334 } else { 4350 } else {
4335 packet = sctp_ootb_pkt_new(net, asoc, chunk); 4351 packet = sctp_ootb_pkt_new(net, asoc, chunk);
@@ -4347,10 +4363,10 @@ static sctp_disposition_t sctp_sf_abort_violation(
4347 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, 4363 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT,
4348 SCTP_PACKET(packet)); 4364 SCTP_PACKET(packet));
4349 4365
4350 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 4366 SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
4351 } 4367 }
4352 4368
4353 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 4369 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
4354 4370
4355discard: 4371discard:
4356 sctp_sf_pdiscard(ep, asoc, SCTP_ST_CHUNK(0), arg, commands); 4372 sctp_sf_pdiscard(ep, asoc, SCTP_ST_CHUNK(0), arg, commands);
@@ -4410,6 +4426,7 @@ static sctp_disposition_t sctp_sf_violation_paramlen(
4410 struct sctp_chunk *chunk = arg; 4426 struct sctp_chunk *chunk = arg;
4411 struct sctp_paramhdr *param = ext; 4427 struct sctp_paramhdr *param = ext;
4412 struct sctp_chunk *abort = NULL; 4428 struct sctp_chunk *abort = NULL;
4429 struct net *net;
4413 4430
4414 if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) 4431 if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc))
4415 goto discard; 4432 goto discard;
@@ -4419,15 +4436,16 @@ static sctp_disposition_t sctp_sf_violation_paramlen(
4419 if (!abort) 4436 if (!abort)
4420 goto nomem; 4437 goto nomem;
4421 4438
4439 net = sock_net(asoc->base.sk);
4422 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); 4440 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort));
4423 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 4441 SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
4424 4442
4425 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, 4443 sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
4426 SCTP_ERROR(ECONNABORTED)); 4444 SCTP_ERROR(ECONNABORTED));
4427 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4445 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4428 SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION)); 4446 SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION));
4429 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 4447 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
4430 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 4448 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
4431 4449
4432discard: 4450discard:
4433 sctp_sf_pdiscard(ep, asoc, SCTP_ST_CHUNK(0), arg, commands); 4451 sctp_sf_pdiscard(ep, asoc, SCTP_ST_CHUNK(0), arg, commands);
@@ -4757,6 +4775,7 @@ sctp_disposition_t sctp_sf_do_9_1_prm_abort(
4757 */ 4775 */
4758 struct sctp_chunk *abort = arg; 4776 struct sctp_chunk *abort = arg;
4759 sctp_disposition_t retval; 4777 sctp_disposition_t retval;
4778 struct net *net;
4760 4779
4761 retval = SCTP_DISPOSITION_CONSUME; 4780 retval = SCTP_DISPOSITION_CONSUME;
4762 4781
@@ -4772,8 +4791,9 @@ sctp_disposition_t sctp_sf_do_9_1_prm_abort(
4772 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 4791 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
4773 SCTP_PERR(SCTP_ERROR_USER_ABORT)); 4792 SCTP_PERR(SCTP_ERROR_USER_ABORT));
4774 4793
4775 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 4794 net = sock_net(asoc->base.sk);
4776 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 4795 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
4796 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
4777 4797
4778 return retval; 4798 return retval;
4779} 4799}
@@ -4824,13 +4844,15 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_shutdown(
4824 void *arg, 4844 void *arg,
4825 sctp_cmd_seq_t *commands) 4845 sctp_cmd_seq_t *commands)
4826{ 4846{
4847 struct net *net = sock_net(asoc->base.sk);
4848
4827 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 4849 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
4828 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); 4850 SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT));
4829 4851
4830 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 4852 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
4831 SCTP_STATE(SCTP_STATE_CLOSED)); 4853 SCTP_STATE(SCTP_STATE_CLOSED));
4832 4854
4833 SCTP_INC_STATS(SCTP_MIB_SHUTDOWNS); 4855 SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS);
4834 4856
4835 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); 4857 sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL());
4836 4858
@@ -4886,6 +4908,7 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_abort(
4886{ 4908{
4887 struct sctp_chunk *abort = arg; 4909 struct sctp_chunk *abort = arg;
4888 sctp_disposition_t retval; 4910 sctp_disposition_t retval;
4911 struct net *net = sock_net(asoc->base.sk);
4889 4912
4890 /* Stop T1-init timer */ 4913 /* Stop T1-init timer */
4891 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 4914 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
@@ -4897,7 +4920,7 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_abort(
4897 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, 4920 sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
4898 SCTP_STATE(SCTP_STATE_CLOSED)); 4921 SCTP_STATE(SCTP_STATE_CLOSED));
4899 4922
4900 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 4923 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
4901 4924
4902 /* Even if we can't send the ABORT due to low memory delete the 4925 /* Even if we can't send the ABORT due to low memory delete the
4903 * TCB. This is a departure from our typical NOMEM handling. 4926 * TCB. This is a departure from our typical NOMEM handling.
@@ -5318,8 +5341,9 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep,
5318 sctp_cmd_seq_t *commands) 5341 sctp_cmd_seq_t *commands)
5319{ 5342{
5320 struct sctp_transport *transport = arg; 5343 struct sctp_transport *transport = arg;
5344 struct net *net = sock_net(asoc->base.sk);
5321 5345
5322 SCTP_INC_STATS(SCTP_MIB_T3_RTX_EXPIREDS); 5346 SCTP_INC_STATS(net, SCTP_MIB_T3_RTX_EXPIREDS);
5323 5347
5324 if (asoc->overall_error_count >= asoc->max_retrans) { 5348 if (asoc->overall_error_count >= asoc->max_retrans) {
5325 if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { 5349 if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) {
@@ -5340,8 +5364,8 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep,
5340 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 5364 /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
5341 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 5365 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
5342 SCTP_PERR(SCTP_ERROR_NO_ERROR)); 5366 SCTP_PERR(SCTP_ERROR_NO_ERROR));
5343 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 5367 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
5344 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 5368 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
5345 return SCTP_DISPOSITION_DELETE_TCB; 5369 return SCTP_DISPOSITION_DELETE_TCB;
5346 } 5370 }
5347 } 5371 }
@@ -5403,7 +5427,8 @@ sctp_disposition_t sctp_sf_do_6_2_sack(const struct sctp_endpoint *ep,
5403 void *arg, 5427 void *arg,
5404 sctp_cmd_seq_t *commands) 5428 sctp_cmd_seq_t *commands)
5405{ 5429{
5406 SCTP_INC_STATS(SCTP_MIB_DELAY_SACK_EXPIREDS); 5430 struct net *net = sock_net(asoc->base.sk);
5431 SCTP_INC_STATS(net, SCTP_MIB_DELAY_SACK_EXPIREDS);
5407 sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_FORCE()); 5432 sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_FORCE());
5408 return SCTP_DISPOSITION_CONSUME; 5433 return SCTP_DISPOSITION_CONSUME;
5409} 5434}
@@ -5436,9 +5461,10 @@ sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep,
5436 struct sctp_chunk *repl = NULL; 5461 struct sctp_chunk *repl = NULL;
5437 struct sctp_bind_addr *bp; 5462 struct sctp_bind_addr *bp;
5438 int attempts = asoc->init_err_counter + 1; 5463 int attempts = asoc->init_err_counter + 1;
5464 struct net *net = sock_net(asoc->base.sk);
5439 5465
5440 SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n"); 5466 SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n");
5441 SCTP_INC_STATS(SCTP_MIB_T1_INIT_EXPIREDS); 5467 SCTP_INC_STATS(net, SCTP_MIB_T1_INIT_EXPIREDS);
5442 5468
5443 if (attempts <= asoc->max_init_attempts) { 5469 if (attempts <= asoc->max_init_attempts) {
5444 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; 5470 bp = (struct sctp_bind_addr *) &asoc->base.bind_addr;
@@ -5496,9 +5522,10 @@ sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep
5496{ 5522{
5497 struct sctp_chunk *repl = NULL; 5523 struct sctp_chunk *repl = NULL;
5498 int attempts = asoc->init_err_counter + 1; 5524 int attempts = asoc->init_err_counter + 1;
5525 struct net *net = sock_net(asoc->base.sk);
5499 5526
5500 SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n"); 5527 SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n");
5501 SCTP_INC_STATS(SCTP_MIB_T1_COOKIE_EXPIREDS); 5528 SCTP_INC_STATS(net, SCTP_MIB_T1_COOKIE_EXPIREDS);
5502 5529
5503 if (attempts <= asoc->max_init_attempts) { 5530 if (attempts <= asoc->max_init_attempts) {
5504 repl = sctp_make_cookie_echo(asoc, NULL); 5531 repl = sctp_make_cookie_echo(asoc, NULL);
@@ -5543,9 +5570,10 @@ sctp_disposition_t sctp_sf_t2_timer_expire(const struct sctp_endpoint *ep,
5543 sctp_cmd_seq_t *commands) 5570 sctp_cmd_seq_t *commands)
5544{ 5571{
5545 struct sctp_chunk *reply = NULL; 5572 struct sctp_chunk *reply = NULL;
5573 struct net *net = sock_net(asoc->base.sk);
5546 5574
5547 SCTP_DEBUG_PRINTK("Timer T2 expired.\n"); 5575 SCTP_DEBUG_PRINTK("Timer T2 expired.\n");
5548 SCTP_INC_STATS(SCTP_MIB_T2_SHUTDOWN_EXPIREDS); 5576 SCTP_INC_STATS(net, SCTP_MIB_T2_SHUTDOWN_EXPIREDS);
5549 5577
5550 ((struct sctp_association *)asoc)->shutdown_retries++; 5578 ((struct sctp_association *)asoc)->shutdown_retries++;
5551 5579
@@ -5555,8 +5583,8 @@ sctp_disposition_t sctp_sf_t2_timer_expire(const struct sctp_endpoint *ep,
5555 /* Note: CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ 5583 /* Note: CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */
5556 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 5584 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
5557 SCTP_PERR(SCTP_ERROR_NO_ERROR)); 5585 SCTP_PERR(SCTP_ERROR_NO_ERROR));
5558 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 5586 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
5559 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 5587 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
5560 return SCTP_DISPOSITION_DELETE_TCB; 5588 return SCTP_DISPOSITION_DELETE_TCB;
5561 } 5589 }
5562 5590
@@ -5613,8 +5641,9 @@ sctp_disposition_t sctp_sf_t4_timer_expire(
5613{ 5641{
5614 struct sctp_chunk *chunk = asoc->addip_last_asconf; 5642 struct sctp_chunk *chunk = asoc->addip_last_asconf;
5615 struct sctp_transport *transport = chunk->transport; 5643 struct sctp_transport *transport = chunk->transport;
5644 struct net *net = sock_net(asoc->base.sk);
5616 5645
5617 SCTP_INC_STATS(SCTP_MIB_T4_RTO_EXPIREDS); 5646 SCTP_INC_STATS(net, SCTP_MIB_T4_RTO_EXPIREDS);
5618 5647
5619 /* ADDIP 4.1 B1) Increment the error counters and perform path failure 5648 /* ADDIP 4.1 B1) Increment the error counters and perform path failure
5620 * detection on the appropriate destination address as defined in 5649 * detection on the appropriate destination address as defined in
@@ -5639,8 +5668,8 @@ sctp_disposition_t sctp_sf_t4_timer_expire(
5639 SCTP_ERROR(ETIMEDOUT)); 5668 SCTP_ERROR(ETIMEDOUT));
5640 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 5669 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
5641 SCTP_PERR(SCTP_ERROR_NO_ERROR)); 5670 SCTP_PERR(SCTP_ERROR_NO_ERROR));
5642 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 5671 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
5643 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 5672 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
5644 return SCTP_DISPOSITION_ABORT; 5673 return SCTP_DISPOSITION_ABORT;
5645 } 5674 }
5646 5675
@@ -5682,9 +5711,10 @@ sctp_disposition_t sctp_sf_t5_timer_expire(const struct sctp_endpoint *ep,
5682 sctp_cmd_seq_t *commands) 5711 sctp_cmd_seq_t *commands)
5683{ 5712{
5684 struct sctp_chunk *reply = NULL; 5713 struct sctp_chunk *reply = NULL;
5714 struct net *net = sock_net(asoc->base.sk);
5685 5715
5686 SCTP_DEBUG_PRINTK("Timer T5 expired.\n"); 5716 SCTP_DEBUG_PRINTK("Timer T5 expired.\n");
5687 SCTP_INC_STATS(SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS); 5717 SCTP_INC_STATS(net, SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS);
5688 5718
5689 reply = sctp_make_abort(asoc, NULL, 0); 5719 reply = sctp_make_abort(asoc, NULL, 0);
5690 if (!reply) 5720 if (!reply)
@@ -5696,8 +5726,8 @@ sctp_disposition_t sctp_sf_t5_timer_expire(const struct sctp_endpoint *ep,
5696 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 5726 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
5697 SCTP_PERR(SCTP_ERROR_NO_ERROR)); 5727 SCTP_PERR(SCTP_ERROR_NO_ERROR));
5698 5728
5699 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 5729 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
5700 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 5730 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
5701 5731
5702 return SCTP_DISPOSITION_DELETE_TCB; 5732 return SCTP_DISPOSITION_DELETE_TCB;
5703nomem: 5733nomem:
@@ -5716,9 +5746,10 @@ sctp_disposition_t sctp_sf_autoclose_timer_expire(
5716 void *arg, 5746 void *arg,
5717 sctp_cmd_seq_t *commands) 5747 sctp_cmd_seq_t *commands)
5718{ 5748{
5749 struct net *net = sock_net(asoc->base.sk);
5719 int disposition; 5750 int disposition;
5720 5751
5721 SCTP_INC_STATS(SCTP_MIB_AUTOCLOSE_EXPIREDS); 5752 SCTP_INC_STATS(net, SCTP_MIB_AUTOCLOSE_EXPIREDS);
5722 5753
5723 /* From 9.2 Shutdown of an Association 5754 /* From 9.2 Shutdown of an Association
5724 * Upon receipt of the SHUTDOWN primitive from its upper 5755 * Upon receipt of the SHUTDOWN primitive from its upper
@@ -5976,7 +6007,7 @@ static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep,
5976 sctp_packet_append_chunk(packet, err_chunk); 6007 sctp_packet_append_chunk(packet, err_chunk);
5977 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, 6008 sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT,
5978 SCTP_PACKET(packet)); 6009 SCTP_PACKET(packet));
5979 SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); 6010 SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS);
5980 } else 6011 } else
5981 sctp_chunk_free (err_chunk); 6012 sctp_chunk_free (err_chunk);
5982 } 6013 }
@@ -5996,6 +6027,7 @@ static int sctp_eat_data(const struct sctp_association *asoc,
5996 __u32 tsn; 6027 __u32 tsn;
5997 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; 6028 struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map;
5998 struct sock *sk = asoc->base.sk; 6029 struct sock *sk = asoc->base.sk;
6030 struct net *net;
5999 u16 ssn; 6031 u16 ssn;
6000 u16 sid; 6032 u16 sid;
6001 u8 ordered = 0; 6033 u8 ordered = 0;
@@ -6112,6 +6144,7 @@ static int sctp_eat_data(const struct sctp_association *asoc,
6112 * No User Data: This error cause is returned to the originator of a 6144 * No User Data: This error cause is returned to the originator of a
6113 * DATA chunk if a received DATA chunk has no user data. 6145 * DATA chunk if a received DATA chunk has no user data.
6114 */ 6146 */
6147 net = sock_net(sk);
6115 if (unlikely(0 == datalen)) { 6148 if (unlikely(0 == datalen)) {
6116 err = sctp_make_abort_no_data(asoc, chunk, tsn); 6149 err = sctp_make_abort_no_data(asoc, chunk, tsn);
6117 if (err) { 6150 if (err) {
@@ -6126,8 +6159,8 @@ static int sctp_eat_data(const struct sctp_association *asoc,
6126 SCTP_ERROR(ECONNABORTED)); 6159 SCTP_ERROR(ECONNABORTED));
6127 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, 6160 sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED,
6128 SCTP_PERR(SCTP_ERROR_NO_DATA)); 6161 SCTP_PERR(SCTP_ERROR_NO_DATA));
6129 SCTP_INC_STATS(SCTP_MIB_ABORTEDS); 6162 SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS);
6130 SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); 6163 SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB);
6131 return SCTP_IERROR_NO_DATA; 6164 return SCTP_IERROR_NO_DATA;
6132 } 6165 }
6133 6166
@@ -6137,9 +6170,9 @@ static int sctp_eat_data(const struct sctp_association *asoc,
6137 * if we renege and the chunk arrives again. 6170 * if we renege and the chunk arrives again.
6138 */ 6171 */
6139 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) 6172 if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
6140 SCTP_INC_STATS(SCTP_MIB_INUNORDERCHUNKS); 6173 SCTP_INC_STATS(net, SCTP_MIB_INUNORDERCHUNKS);
6141 else { 6174 else {
6142 SCTP_INC_STATS(SCTP_MIB_INORDERCHUNKS); 6175 SCTP_INC_STATS(net, SCTP_MIB_INORDERCHUNKS);
6143 ordered = 1; 6176 ordered = 1;
6144 } 6177 }
6145 6178
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c
index f5a6a4f4faf7..360d8697b95c 100644
--- a/net/sctp/ulpqueue.c
+++ b/net/sctp/ulpqueue.c
@@ -326,7 +326,9 @@ static void sctp_ulpq_store_reasm(struct sctp_ulpq *ulpq,
326 * payload was fragmented on the way and ip had to reassemble them. 326 * payload was fragmented on the way and ip had to reassemble them.
327 * We add the rest of skb's to the first skb's fraglist. 327 * We add the rest of skb's to the first skb's fraglist.
328 */ 328 */
329static struct sctp_ulpevent *sctp_make_reassembled_event(struct sk_buff_head *queue, struct sk_buff *f_frag, struct sk_buff *l_frag) 329static struct sctp_ulpevent *sctp_make_reassembled_event(struct net *net,
330 struct sk_buff_head *queue, struct sk_buff *f_frag,
331 struct sk_buff *l_frag)
330{ 332{
331 struct sk_buff *pos; 333 struct sk_buff *pos;
332 struct sk_buff *new = NULL; 334 struct sk_buff *new = NULL;
@@ -394,7 +396,7 @@ static struct sctp_ulpevent *sctp_make_reassembled_event(struct sk_buff_head *qu
394 } 396 }
395 397
396 event = sctp_skb2event(f_frag); 398 event = sctp_skb2event(f_frag);
397 SCTP_INC_STATS(SCTP_MIB_REASMUSRMSGS); 399 SCTP_INC_STATS(net, SCTP_MIB_REASMUSRMSGS);
398 400
399 return event; 401 return event;
400} 402}
@@ -493,7 +495,8 @@ static struct sctp_ulpevent *sctp_ulpq_retrieve_reassembled(struct sctp_ulpq *ul
493 cevent = sctp_skb2event(pd_first); 495 cevent = sctp_skb2event(pd_first);
494 pd_point = sctp_sk(asoc->base.sk)->pd_point; 496 pd_point = sctp_sk(asoc->base.sk)->pd_point;
495 if (pd_point && pd_point <= pd_len) { 497 if (pd_point && pd_point <= pd_len) {
496 retval = sctp_make_reassembled_event(&ulpq->reasm, 498 retval = sctp_make_reassembled_event(sock_net(asoc->base.sk),
499 &ulpq->reasm,
497 pd_first, 500 pd_first,
498 pd_last); 501 pd_last);
499 if (retval) 502 if (retval)
@@ -503,7 +506,8 @@ static struct sctp_ulpevent *sctp_ulpq_retrieve_reassembled(struct sctp_ulpq *ul
503done: 506done:
504 return retval; 507 return retval;
505found: 508found:
506 retval = sctp_make_reassembled_event(&ulpq->reasm, first_frag, pos); 509 retval = sctp_make_reassembled_event(sock_net(ulpq->asoc->base.sk),
510 &ulpq->reasm, first_frag, pos);
507 if (retval) 511 if (retval)
508 retval->msg_flags |= MSG_EOR; 512 retval->msg_flags |= MSG_EOR;
509 goto done; 513 goto done;
@@ -563,7 +567,8 @@ static struct sctp_ulpevent *sctp_ulpq_retrieve_partial(struct sctp_ulpq *ulpq)
563 * further. 567 * further.
564 */ 568 */
565done: 569done:
566 retval = sctp_make_reassembled_event(&ulpq->reasm, first_frag, last_frag); 570 retval = sctp_make_reassembled_event(sock_net(ulpq->asoc->base.sk),
571 &ulpq->reasm, first_frag, last_frag);
567 if (retval && is_last) 572 if (retval && is_last)
568 retval->msg_flags |= MSG_EOR; 573 retval->msg_flags |= MSG_EOR;
569 574
@@ -655,7 +660,8 @@ static struct sctp_ulpevent *sctp_ulpq_retrieve_first(struct sctp_ulpq *ulpq)
655 * further. 660 * further.
656 */ 661 */
657done: 662done:
658 retval = sctp_make_reassembled_event(&ulpq->reasm, first_frag, last_frag); 663 retval = sctp_make_reassembled_event(sock_net(ulpq->asoc->base.sk),
664 &ulpq->reasm, first_frag, last_frag);
659 return retval; 665 return retval;
660} 666}
661 667