diff options
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/associola.c | 25 | ||||
-rw-r--r-- | net/sctp/auth.c | 20 | ||||
-rw-r--r-- | net/sctp/bind_addr.c | 20 | ||||
-rw-r--r-- | net/sctp/chunk.c | 2 | ||||
-rw-r--r-- | net/sctp/endpointola.c | 25 | ||||
-rw-r--r-- | net/sctp/input.c | 115 | ||||
-rw-r--r-- | net/sctp/ipv6.c | 36 | ||||
-rw-r--r-- | net/sctp/objcnt.c | 8 | ||||
-rw-r--r-- | net/sctp/output.c | 2 | ||||
-rw-r--r-- | net/sctp/outqueue.c | 28 | ||||
-rw-r--r-- | net/sctp/primitive.c | 4 | ||||
-rw-r--r-- | net/sctp/proc.c | 55 | ||||
-rw-r--r-- | net/sctp/protocol.c | 454 | ||||
-rw-r--r-- | net/sctp/sm_make_chunk.c | 61 | ||||
-rw-r--r-- | net/sctp/sm_sideeffect.c | 26 | ||||
-rw-r--r-- | net/sctp/sm_statefuns.c | 725 | ||||
-rw-r--r-- | net/sctp/sm_statetable.c | 17 | ||||
-rw-r--r-- | net/sctp/socket.c | 119 | ||||
-rw-r--r-- | net/sctp/sysctl.c | 198 | ||||
-rw-r--r-- | net/sctp/transport.c | 23 | ||||
-rw-r--r-- | net/sctp/ulpqueue.c | 18 |
21 files changed, 1119 insertions, 862 deletions
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index ebaef3ed6065..b1ef3bc301a5 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -82,6 +82,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
82 | sctp_scope_t scope, | 82 | sctp_scope_t scope, |
83 | gfp_t gfp) | 83 | gfp_t gfp) |
84 | { | 84 | { |
85 | struct net *net = sock_net(sk); | ||
85 | struct sctp_sock *sp; | 86 | struct sctp_sock *sp; |
86 | int i; | 87 | int i; |
87 | sctp_paramhdr_t *p; | 88 | sctp_paramhdr_t *p; |
@@ -124,7 +125,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
124 | * socket values. | 125 | * socket values. |
125 | */ | 126 | */ |
126 | asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt; | 127 | asoc->max_retrans = sp->assocparams.sasoc_asocmaxrxt; |
127 | asoc->pf_retrans = sctp_pf_retrans; | 128 | asoc->pf_retrans = net->sctp.pf_retrans; |
128 | 129 | ||
129 | asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial); | 130 | asoc->rto_initial = msecs_to_jiffies(sp->rtoinfo.srto_initial); |
130 | asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max); | 131 | asoc->rto_max = msecs_to_jiffies(sp->rtoinfo.srto_max); |
@@ -175,7 +176,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
175 | asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0; | 176 | asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0; |
176 | asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay; | 177 | asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay; |
177 | asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = | 178 | asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = |
178 | min_t(unsigned long, sp->autoclose, sctp_max_autoclose) * HZ; | 179 | min_t(unsigned long, sp->autoclose, net->sctp.max_autoclose) * HZ; |
179 | 180 | ||
180 | /* Initializes the timers */ | 181 | /* Initializes the timers */ |
181 | for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i) | 182 | for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i) |
@@ -281,7 +282,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
281 | * and will revert old behavior. | 282 | * and will revert old behavior. |
282 | */ | 283 | */ |
283 | asoc->peer.asconf_capable = 0; | 284 | asoc->peer.asconf_capable = 0; |
284 | if (sctp_addip_noauth) | 285 | if (net->sctp.addip_noauth) |
285 | asoc->peer.asconf_capable = 1; | 286 | asoc->peer.asconf_capable = 1; |
286 | asoc->asconf_addr_del_pending = NULL; | 287 | asoc->asconf_addr_del_pending = NULL; |
287 | asoc->src_out_of_asoc_ok = 0; | 288 | asoc->src_out_of_asoc_ok = 0; |
@@ -641,6 +642,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, | |||
641 | const gfp_t gfp, | 642 | const gfp_t gfp, |
642 | const int peer_state) | 643 | const int peer_state) |
643 | { | 644 | { |
645 | struct net *net = sock_net(asoc->base.sk); | ||
644 | struct sctp_transport *peer; | 646 | struct sctp_transport *peer; |
645 | struct sctp_sock *sp; | 647 | struct sctp_sock *sp; |
646 | unsigned short port; | 648 | unsigned short port; |
@@ -674,7 +676,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, | |||
674 | return peer; | 676 | return peer; |
675 | } | 677 | } |
676 | 678 | ||
677 | peer = sctp_transport_new(addr, gfp); | 679 | peer = sctp_transport_new(net, addr, gfp); |
678 | if (!peer) | 680 | if (!peer) |
679 | return NULL; | 681 | return NULL; |
680 | 682 | ||
@@ -1089,13 +1091,15 @@ out: | |||
1089 | 1091 | ||
1090 | /* Is this the association we are looking for? */ | 1092 | /* Is this the association we are looking for? */ |
1091 | struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc, | 1093 | struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc, |
1094 | struct net *net, | ||
1092 | const union sctp_addr *laddr, | 1095 | const union sctp_addr *laddr, |
1093 | const union sctp_addr *paddr) | 1096 | const union sctp_addr *paddr) |
1094 | { | 1097 | { |
1095 | struct sctp_transport *transport; | 1098 | struct sctp_transport *transport; |
1096 | 1099 | ||
1097 | if ((htons(asoc->base.bind_addr.port) == laddr->v4.sin_port) && | 1100 | if ((htons(asoc->base.bind_addr.port) == laddr->v4.sin_port) && |
1098 | (htons(asoc->peer.port) == paddr->v4.sin_port)) { | 1101 | (htons(asoc->peer.port) == paddr->v4.sin_port) && |
1102 | net_eq(sock_net(asoc->base.sk), net)) { | ||
1099 | transport = sctp_assoc_lookup_paddr(asoc, paddr); | 1103 | transport = sctp_assoc_lookup_paddr(asoc, paddr); |
1100 | if (!transport) | 1104 | if (!transport) |
1101 | goto out; | 1105 | goto out; |
@@ -1116,6 +1120,7 @@ static void sctp_assoc_bh_rcv(struct work_struct *work) | |||
1116 | struct sctp_association *asoc = | 1120 | struct sctp_association *asoc = |
1117 | container_of(work, struct sctp_association, | 1121 | container_of(work, struct sctp_association, |
1118 | base.inqueue.immediate); | 1122 | base.inqueue.immediate); |
1123 | struct net *net = sock_net(asoc->base.sk); | ||
1119 | struct sctp_endpoint *ep; | 1124 | struct sctp_endpoint *ep; |
1120 | struct sctp_chunk *chunk; | 1125 | struct sctp_chunk *chunk; |
1121 | struct sctp_inq *inqueue; | 1126 | struct sctp_inq *inqueue; |
@@ -1148,13 +1153,13 @@ static void sctp_assoc_bh_rcv(struct work_struct *work) | |||
1148 | if (sctp_chunk_is_data(chunk)) | 1153 | if (sctp_chunk_is_data(chunk)) |
1149 | asoc->peer.last_data_from = chunk->transport; | 1154 | asoc->peer.last_data_from = chunk->transport; |
1150 | else | 1155 | else |
1151 | SCTP_INC_STATS(SCTP_MIB_INCTRLCHUNKS); | 1156 | SCTP_INC_STATS(net, SCTP_MIB_INCTRLCHUNKS); |
1152 | 1157 | ||
1153 | if (chunk->transport) | 1158 | if (chunk->transport) |
1154 | chunk->transport->last_time_heard = jiffies; | 1159 | chunk->transport->last_time_heard = jiffies; |
1155 | 1160 | ||
1156 | /* Run through the state machine. */ | 1161 | /* Run through the state machine. */ |
1157 | error = sctp_do_sm(SCTP_EVENT_T_CHUNK, subtype, | 1162 | error = sctp_do_sm(net, SCTP_EVENT_T_CHUNK, subtype, |
1158 | state, ep, asoc, chunk, GFP_ATOMIC); | 1163 | state, ep, asoc, chunk, GFP_ATOMIC); |
1159 | 1164 | ||
1160 | /* Check to see if the association is freed in response to | 1165 | /* Check to see if the association is freed in response to |
@@ -1414,6 +1419,7 @@ void sctp_assoc_sync_pmtu(struct sock *sk, struct sctp_association *asoc) | |||
1414 | /* Should we send a SACK to update our peer? */ | 1419 | /* Should we send a SACK to update our peer? */ |
1415 | static inline int sctp_peer_needs_update(struct sctp_association *asoc) | 1420 | static inline int sctp_peer_needs_update(struct sctp_association *asoc) |
1416 | { | 1421 | { |
1422 | struct net *net = sock_net(asoc->base.sk); | ||
1417 | switch (asoc->state) { | 1423 | switch (asoc->state) { |
1418 | case SCTP_STATE_ESTABLISHED: | 1424 | case SCTP_STATE_ESTABLISHED: |
1419 | case SCTP_STATE_SHUTDOWN_PENDING: | 1425 | case SCTP_STATE_SHUTDOWN_PENDING: |
@@ -1421,7 +1427,7 @@ static inline int sctp_peer_needs_update(struct sctp_association *asoc) | |||
1421 | case SCTP_STATE_SHUTDOWN_SENT: | 1427 | case SCTP_STATE_SHUTDOWN_SENT: |
1422 | if ((asoc->rwnd > asoc->a_rwnd) && | 1428 | if ((asoc->rwnd > asoc->a_rwnd) && |
1423 | ((asoc->rwnd - asoc->a_rwnd) >= max_t(__u32, | 1429 | ((asoc->rwnd - asoc->a_rwnd) >= max_t(__u32, |
1424 | (asoc->base.sk->sk_rcvbuf >> sctp_rwnd_upd_shift), | 1430 | (asoc->base.sk->sk_rcvbuf >> net->sctp.rwnd_upd_shift), |
1425 | asoc->pathmtu))) | 1431 | asoc->pathmtu))) |
1426 | return 1; | 1432 | return 1; |
1427 | break; | 1433 | break; |
@@ -1542,7 +1548,8 @@ int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, | |||
1542 | if (asoc->peer.ipv6_address) | 1548 | if (asoc->peer.ipv6_address) |
1543 | flags |= SCTP_ADDR6_PEERSUPP; | 1549 | flags |= SCTP_ADDR6_PEERSUPP; |
1544 | 1550 | ||
1545 | return sctp_bind_addr_copy(&asoc->base.bind_addr, | 1551 | return sctp_bind_addr_copy(sock_net(asoc->base.sk), |
1552 | &asoc->base.bind_addr, | ||
1546 | &asoc->ep->base.bind_addr, | 1553 | &asoc->ep->base.bind_addr, |
1547 | scope, gfp, flags); | 1554 | scope, gfp, flags); |
1548 | } | 1555 | } |
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index bf812048cf6f..159b9bc5d633 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c | |||
@@ -392,13 +392,14 @@ nomem: | |||
392 | */ | 392 | */ |
393 | int sctp_auth_asoc_init_active_key(struct sctp_association *asoc, gfp_t gfp) | 393 | int sctp_auth_asoc_init_active_key(struct sctp_association *asoc, gfp_t gfp) |
394 | { | 394 | { |
395 | struct net *net = sock_net(asoc->base.sk); | ||
395 | struct sctp_auth_bytes *secret; | 396 | struct sctp_auth_bytes *secret; |
396 | struct sctp_shared_key *ep_key; | 397 | struct sctp_shared_key *ep_key; |
397 | 398 | ||
398 | /* If we don't support AUTH, or peer is not capable | 399 | /* If we don't support AUTH, or peer is not capable |
399 | * we don't need to do anything. | 400 | * we don't need to do anything. |
400 | */ | 401 | */ |
401 | if (!sctp_auth_enable || !asoc->peer.auth_capable) | 402 | if (!net->sctp.auth_enable || !asoc->peer.auth_capable) |
402 | return 0; | 403 | return 0; |
403 | 404 | ||
404 | /* If the key_id is non-zero and we couldn't find an | 405 | /* If the key_id is non-zero and we couldn't find an |
@@ -445,11 +446,12 @@ struct sctp_shared_key *sctp_auth_get_shkey( | |||
445 | */ | 446 | */ |
446 | int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) | 447 | int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) |
447 | { | 448 | { |
449 | struct net *net = sock_net(ep->base.sk); | ||
448 | struct crypto_hash *tfm = NULL; | 450 | struct crypto_hash *tfm = NULL; |
449 | __u16 id; | 451 | __u16 id; |
450 | 452 | ||
451 | /* if the transforms are already allocted, we are done */ | 453 | /* if the transforms are already allocted, we are done */ |
452 | if (!sctp_auth_enable) { | 454 | if (!net->sctp.auth_enable) { |
453 | ep->auth_hmacs = NULL; | 455 | ep->auth_hmacs = NULL; |
454 | return 0; | 456 | return 0; |
455 | } | 457 | } |
@@ -674,7 +676,12 @@ static int __sctp_auth_cid(sctp_cid_t chunk, struct sctp_chunks_param *param) | |||
674 | /* Check if peer requested that this chunk is authenticated */ | 676 | /* Check if peer requested that this chunk is authenticated */ |
675 | int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc) | 677 | int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc) |
676 | { | 678 | { |
677 | if (!sctp_auth_enable || !asoc || !asoc->peer.auth_capable) | 679 | struct net *net; |
680 | if (!asoc) | ||
681 | return 0; | ||
682 | |||
683 | net = sock_net(asoc->base.sk); | ||
684 | if (!net->sctp.auth_enable || !asoc->peer.auth_capable) | ||
678 | return 0; | 685 | return 0; |
679 | 686 | ||
680 | return __sctp_auth_cid(chunk, asoc->peer.peer_chunks); | 687 | return __sctp_auth_cid(chunk, asoc->peer.peer_chunks); |
@@ -683,7 +690,12 @@ int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc) | |||
683 | /* Check if we requested that peer authenticate this chunk. */ | 690 | /* Check if we requested that peer authenticate this chunk. */ |
684 | int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc) | 691 | int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc) |
685 | { | 692 | { |
686 | if (!sctp_auth_enable || !asoc) | 693 | struct net *net; |
694 | if (!asoc) | ||
695 | return 0; | ||
696 | |||
697 | net = sock_net(asoc->base.sk); | ||
698 | if (!net->sctp.auth_enable) | ||
687 | return 0; | 699 | return 0; |
688 | 700 | ||
689 | return __sctp_auth_cid(chunk, | 701 | return __sctp_auth_cid(chunk, |
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c index 4ece451c8d27..d886b3bf84f5 100644 --- a/net/sctp/bind_addr.c +++ b/net/sctp/bind_addr.c | |||
@@ -52,8 +52,8 @@ | |||
52 | #include <net/sctp/sm.h> | 52 | #include <net/sctp/sm.h> |
53 | 53 | ||
54 | /* Forward declarations for internal helpers. */ | 54 | /* Forward declarations for internal helpers. */ |
55 | static int sctp_copy_one_addr(struct sctp_bind_addr *, union sctp_addr *, | 55 | static int sctp_copy_one_addr(struct net *, struct sctp_bind_addr *, |
56 | sctp_scope_t scope, gfp_t gfp, | 56 | union sctp_addr *, sctp_scope_t scope, gfp_t gfp, |
57 | int flags); | 57 | int flags); |
58 | static void sctp_bind_addr_clean(struct sctp_bind_addr *); | 58 | static void sctp_bind_addr_clean(struct sctp_bind_addr *); |
59 | 59 | ||
@@ -62,7 +62,7 @@ static void sctp_bind_addr_clean(struct sctp_bind_addr *); | |||
62 | /* Copy 'src' to 'dest' taking 'scope' into account. Omit addresses | 62 | /* Copy 'src' to 'dest' taking 'scope' into account. Omit addresses |
63 | * in 'src' which have a broader scope than 'scope'. | 63 | * in 'src' which have a broader scope than 'scope'. |
64 | */ | 64 | */ |
65 | int sctp_bind_addr_copy(struct sctp_bind_addr *dest, | 65 | int sctp_bind_addr_copy(struct net *net, struct sctp_bind_addr *dest, |
66 | const struct sctp_bind_addr *src, | 66 | const struct sctp_bind_addr *src, |
67 | sctp_scope_t scope, gfp_t gfp, | 67 | sctp_scope_t scope, gfp_t gfp, |
68 | int flags) | 68 | int flags) |
@@ -75,7 +75,7 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest, | |||
75 | 75 | ||
76 | /* Extract the addresses which are relevant for this scope. */ | 76 | /* Extract the addresses which are relevant for this scope. */ |
77 | list_for_each_entry(addr, &src->address_list, list) { | 77 | list_for_each_entry(addr, &src->address_list, list) { |
78 | error = sctp_copy_one_addr(dest, &addr->a, scope, | 78 | error = sctp_copy_one_addr(net, dest, &addr->a, scope, |
79 | gfp, flags); | 79 | gfp, flags); |
80 | if (error < 0) | 80 | if (error < 0) |
81 | goto out; | 81 | goto out; |
@@ -87,7 +87,7 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest, | |||
87 | */ | 87 | */ |
88 | if (list_empty(&dest->address_list) && (SCTP_SCOPE_GLOBAL == scope)) { | 88 | if (list_empty(&dest->address_list) && (SCTP_SCOPE_GLOBAL == scope)) { |
89 | list_for_each_entry(addr, &src->address_list, list) { | 89 | list_for_each_entry(addr, &src->address_list, list) { |
90 | error = sctp_copy_one_addr(dest, &addr->a, | 90 | error = sctp_copy_one_addr(net, dest, &addr->a, |
91 | SCTP_SCOPE_LINK, gfp, | 91 | SCTP_SCOPE_LINK, gfp, |
92 | flags); | 92 | flags); |
93 | if (error < 0) | 93 | if (error < 0) |
@@ -448,7 +448,7 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, | |||
448 | } | 448 | } |
449 | 449 | ||
450 | /* Copy out addresses from the global local address list. */ | 450 | /* Copy out addresses from the global local address list. */ |
451 | static int sctp_copy_one_addr(struct sctp_bind_addr *dest, | 451 | static int sctp_copy_one_addr(struct net *net, struct sctp_bind_addr *dest, |
452 | union sctp_addr *addr, | 452 | union sctp_addr *addr, |
453 | sctp_scope_t scope, gfp_t gfp, | 453 | sctp_scope_t scope, gfp_t gfp, |
454 | int flags) | 454 | int flags) |
@@ -456,8 +456,8 @@ static int sctp_copy_one_addr(struct sctp_bind_addr *dest, | |||
456 | int error = 0; | 456 | int error = 0; |
457 | 457 | ||
458 | if (sctp_is_any(NULL, addr)) { | 458 | if (sctp_is_any(NULL, addr)) { |
459 | error = sctp_copy_local_addr_list(dest, scope, gfp, flags); | 459 | error = sctp_copy_local_addr_list(net, dest, scope, gfp, flags); |
460 | } else if (sctp_in_scope(addr, scope)) { | 460 | } else if (sctp_in_scope(net, addr, scope)) { |
461 | /* Now that the address is in scope, check to see if | 461 | /* Now that the address is in scope, check to see if |
462 | * the address type is supported by local sock as | 462 | * the address type is supported by local sock as |
463 | * well as the remote peer. | 463 | * well as the remote peer. |
@@ -494,7 +494,7 @@ int sctp_is_any(struct sock *sk, const union sctp_addr *addr) | |||
494 | } | 494 | } |
495 | 495 | ||
496 | /* Is 'addr' valid for 'scope'? */ | 496 | /* Is 'addr' valid for 'scope'? */ |
497 | int sctp_in_scope(const union sctp_addr *addr, sctp_scope_t scope) | 497 | int sctp_in_scope(struct net *net, const union sctp_addr *addr, sctp_scope_t scope) |
498 | { | 498 | { |
499 | sctp_scope_t addr_scope = sctp_scope(addr); | 499 | sctp_scope_t addr_scope = sctp_scope(addr); |
500 | 500 | ||
@@ -512,7 +512,7 @@ int sctp_in_scope(const union sctp_addr *addr, sctp_scope_t scope) | |||
512 | * Address scoping can be selectively controlled via sysctl | 512 | * Address scoping can be selectively controlled via sysctl |
513 | * option | 513 | * option |
514 | */ | 514 | */ |
515 | switch (sctp_scope_policy) { | 515 | switch (net->sctp.scope_policy) { |
516 | case SCTP_SCOPE_POLICY_DISABLE: | 516 | case SCTP_SCOPE_POLICY_DISABLE: |
517 | return 1; | 517 | return 1; |
518 | case SCTP_SCOPE_POLICY_ENABLE: | 518 | case SCTP_SCOPE_POLICY_ENABLE: |
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 68a385d7c3bd..1859e2bc83d1 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c | |||
@@ -65,6 +65,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
65 | struct sock *sk, | 65 | struct sock *sk, |
66 | gfp_t gfp) | 66 | gfp_t gfp) |
67 | { | 67 | { |
68 | struct net *net = sock_net(sk); | ||
68 | struct sctp_hmac_algo_param *auth_hmacs = NULL; | 69 | struct sctp_hmac_algo_param *auth_hmacs = NULL; |
69 | struct sctp_chunks_param *auth_chunks = NULL; | 70 | struct sctp_chunks_param *auth_chunks = NULL; |
70 | struct sctp_shared_key *null_key; | 71 | struct sctp_shared_key *null_key; |
@@ -74,7 +75,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
74 | if (!ep->digest) | 75 | if (!ep->digest) |
75 | return NULL; | 76 | return NULL; |
76 | 77 | ||
77 | if (sctp_auth_enable) { | 78 | if (net->sctp.auth_enable) { |
78 | /* Allocate space for HMACS and CHUNKS authentication | 79 | /* Allocate space for HMACS and CHUNKS authentication |
79 | * variables. There are arrays that we encode directly | 80 | * variables. There are arrays that we encode directly |
80 | * into parameters to make the rest of the operations easier. | 81 | * into parameters to make the rest of the operations easier. |
@@ -106,7 +107,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
106 | /* If the Add-IP functionality is enabled, we must | 107 | /* If the Add-IP functionality is enabled, we must |
107 | * authenticate, ASCONF and ASCONF-ACK chunks | 108 | * authenticate, ASCONF and ASCONF-ACK chunks |
108 | */ | 109 | */ |
109 | if (sctp_addip_enable) { | 110 | if (net->sctp.addip_enable) { |
110 | auth_chunks->chunks[0] = SCTP_CID_ASCONF; | 111 | auth_chunks->chunks[0] = SCTP_CID_ASCONF; |
111 | auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK; | 112 | auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK; |
112 | auth_chunks->param_hdr.length = | 113 | auth_chunks->param_hdr.length = |
@@ -140,14 +141,14 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
140 | INIT_LIST_HEAD(&ep->asocs); | 141 | INIT_LIST_HEAD(&ep->asocs); |
141 | 142 | ||
142 | /* Use SCTP specific send buffer space queues. */ | 143 | /* Use SCTP specific send buffer space queues. */ |
143 | ep->sndbuf_policy = sctp_sndbuf_policy; | 144 | ep->sndbuf_policy = net->sctp.sndbuf_policy; |
144 | 145 | ||
145 | sk->sk_data_ready = sctp_data_ready; | 146 | sk->sk_data_ready = sctp_data_ready; |
146 | sk->sk_write_space = sctp_write_space; | 147 | sk->sk_write_space = sctp_write_space; |
147 | sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); | 148 | sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); |
148 | 149 | ||
149 | /* Get the receive buffer policy for this endpoint */ | 150 | /* Get the receive buffer policy for this endpoint */ |
150 | ep->rcvbuf_policy = sctp_rcvbuf_policy; | 151 | ep->rcvbuf_policy = net->sctp.rcvbuf_policy; |
151 | 152 | ||
152 | /* Initialize the secret key used with cookie. */ | 153 | /* Initialize the secret key used with cookie. */ |
153 | get_random_bytes(&ep->secret_key[0], SCTP_SECRET_SIZE); | 154 | get_random_bytes(&ep->secret_key[0], SCTP_SECRET_SIZE); |
@@ -302,11 +303,13 @@ void sctp_endpoint_put(struct sctp_endpoint *ep) | |||
302 | 303 | ||
303 | /* Is this the endpoint we are looking for? */ | 304 | /* Is this the endpoint we are looking for? */ |
304 | struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep, | 305 | struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep, |
306 | struct net *net, | ||
305 | const union sctp_addr *laddr) | 307 | const union sctp_addr *laddr) |
306 | { | 308 | { |
307 | struct sctp_endpoint *retval = NULL; | 309 | struct sctp_endpoint *retval = NULL; |
308 | 310 | ||
309 | if (htons(ep->base.bind_addr.port) == laddr->v4.sin_port) { | 311 | if ((htons(ep->base.bind_addr.port) == laddr->v4.sin_port) && |
312 | net_eq(sock_net(ep->base.sk), net)) { | ||
310 | if (sctp_bind_addr_match(&ep->base.bind_addr, laddr, | 313 | if (sctp_bind_addr_match(&ep->base.bind_addr, laddr, |
311 | sctp_sk(ep->base.sk))) | 314 | sctp_sk(ep->base.sk))) |
312 | retval = ep; | 315 | retval = ep; |
@@ -343,7 +346,8 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( | |||
343 | 346 | ||
344 | rport = ntohs(paddr->v4.sin_port); | 347 | rport = ntohs(paddr->v4.sin_port); |
345 | 348 | ||
346 | hash = sctp_assoc_hashfn(ep->base.bind_addr.port, rport); | 349 | hash = sctp_assoc_hashfn(sock_net(ep->base.sk), ep->base.bind_addr.port, |
350 | rport); | ||
347 | head = &sctp_assoc_hashtable[hash]; | 351 | head = &sctp_assoc_hashtable[hash]; |
348 | read_lock(&head->lock); | 352 | read_lock(&head->lock); |
349 | sctp_for_each_hentry(epb, node, &head->chain) { | 353 | sctp_for_each_hentry(epb, node, &head->chain) { |
@@ -386,13 +390,14 @@ int sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep, | |||
386 | { | 390 | { |
387 | struct sctp_sockaddr_entry *addr; | 391 | struct sctp_sockaddr_entry *addr; |
388 | struct sctp_bind_addr *bp; | 392 | struct sctp_bind_addr *bp; |
393 | struct net *net = sock_net(ep->base.sk); | ||
389 | 394 | ||
390 | bp = &ep->base.bind_addr; | 395 | bp = &ep->base.bind_addr; |
391 | /* This function is called with the socket lock held, | 396 | /* This function is called with the socket lock held, |
392 | * so the address_list can not change. | 397 | * so the address_list can not change. |
393 | */ | 398 | */ |
394 | list_for_each_entry(addr, &bp->address_list, list) { | 399 | list_for_each_entry(addr, &bp->address_list, list) { |
395 | if (sctp_has_association(&addr->a, paddr)) | 400 | if (sctp_has_association(net, &addr->a, paddr)) |
396 | return 1; | 401 | return 1; |
397 | } | 402 | } |
398 | 403 | ||
@@ -409,6 +414,7 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work) | |||
409 | base.inqueue.immediate); | 414 | base.inqueue.immediate); |
410 | struct sctp_association *asoc; | 415 | struct sctp_association *asoc; |
411 | struct sock *sk; | 416 | struct sock *sk; |
417 | struct net *net; | ||
412 | struct sctp_transport *transport; | 418 | struct sctp_transport *transport; |
413 | struct sctp_chunk *chunk; | 419 | struct sctp_chunk *chunk; |
414 | struct sctp_inq *inqueue; | 420 | struct sctp_inq *inqueue; |
@@ -423,6 +429,7 @@ static void sctp_endpoint_bh_rcv(struct work_struct *work) | |||
423 | asoc = NULL; | 429 | asoc = NULL; |
424 | inqueue = &ep->base.inqueue; | 430 | inqueue = &ep->base.inqueue; |
425 | sk = ep->base.sk; | 431 | sk = ep->base.sk; |
432 | net = sock_net(sk); | ||
426 | 433 | ||
427 | while (NULL != (chunk = sctp_inq_pop(inqueue))) { | 434 | while (NULL != (chunk = sctp_inq_pop(inqueue))) { |
428 | subtype = SCTP_ST_CHUNK(chunk->chunk_hdr->type); | 435 | subtype = SCTP_ST_CHUNK(chunk->chunk_hdr->type); |
@@ -474,12 +481,12 @@ normal: | |||
474 | if (asoc && sctp_chunk_is_data(chunk)) | 481 | if (asoc && sctp_chunk_is_data(chunk)) |
475 | asoc->peer.last_data_from = chunk->transport; | 482 | asoc->peer.last_data_from = chunk->transport; |
476 | else | 483 | else |
477 | SCTP_INC_STATS(SCTP_MIB_INCTRLCHUNKS); | 484 | SCTP_INC_STATS(sock_net(ep->base.sk), SCTP_MIB_INCTRLCHUNKS); |
478 | 485 | ||
479 | if (chunk->transport) | 486 | if (chunk->transport) |
480 | chunk->transport->last_time_heard = jiffies; | 487 | chunk->transport->last_time_heard = jiffies; |
481 | 488 | ||
482 | error = sctp_do_sm(SCTP_EVENT_T_CHUNK, subtype, state, | 489 | error = sctp_do_sm(net, SCTP_EVENT_T_CHUNK, subtype, state, |
483 | ep, asoc, chunk, GFP_ATOMIC); | 490 | ep, asoc, chunk, GFP_ATOMIC); |
484 | 491 | ||
485 | if (error && chunk) | 492 | if (error && chunk) |
diff --git a/net/sctp/input.c b/net/sctp/input.c index e64d5210ed13..25dfe7380479 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c | |||
@@ -66,12 +66,15 @@ | |||
66 | 66 | ||
67 | /* Forward declarations for internal helpers. */ | 67 | /* Forward declarations for internal helpers. */ |
68 | static int sctp_rcv_ootb(struct sk_buff *); | 68 | static int sctp_rcv_ootb(struct sk_buff *); |
69 | static struct sctp_association *__sctp_rcv_lookup(struct sk_buff *skb, | 69 | static struct sctp_association *__sctp_rcv_lookup(struct net *net, |
70 | struct sk_buff *skb, | ||
70 | const union sctp_addr *laddr, | 71 | const union sctp_addr *laddr, |
71 | const union sctp_addr *paddr, | 72 | const union sctp_addr *paddr, |
72 | struct sctp_transport **transportp); | 73 | struct sctp_transport **transportp); |
73 | static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr); | 74 | static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net, |
75 | const union sctp_addr *laddr); | ||
74 | static struct sctp_association *__sctp_lookup_association( | 76 | static struct sctp_association *__sctp_lookup_association( |
77 | struct net *net, | ||
75 | const union sctp_addr *local, | 78 | const union sctp_addr *local, |
76 | const union sctp_addr *peer, | 79 | const union sctp_addr *peer, |
77 | struct sctp_transport **pt); | 80 | struct sctp_transport **pt); |
@@ -80,7 +83,7 @@ static int sctp_add_backlog(struct sock *sk, struct sk_buff *skb); | |||
80 | 83 | ||
81 | 84 | ||
82 | /* Calculate the SCTP checksum of an SCTP packet. */ | 85 | /* Calculate the SCTP checksum of an SCTP packet. */ |
83 | static inline int sctp_rcv_checksum(struct sk_buff *skb) | 86 | static inline int sctp_rcv_checksum(struct net *net, struct sk_buff *skb) |
84 | { | 87 | { |
85 | struct sctphdr *sh = sctp_hdr(skb); | 88 | struct sctphdr *sh = sctp_hdr(skb); |
86 | __le32 cmp = sh->checksum; | 89 | __le32 cmp = sh->checksum; |
@@ -96,7 +99,7 @@ static inline int sctp_rcv_checksum(struct sk_buff *skb) | |||
96 | 99 | ||
97 | if (val != cmp) { | 100 | if (val != cmp) { |
98 | /* CRC failure, dump it. */ | 101 | /* CRC failure, dump it. */ |
99 | SCTP_INC_STATS_BH(SCTP_MIB_CHECKSUMERRORS); | 102 | SCTP_INC_STATS_BH(net, SCTP_MIB_CHECKSUMERRORS); |
100 | return -1; | 103 | return -1; |
101 | } | 104 | } |
102 | return 0; | 105 | return 0; |
@@ -129,11 +132,12 @@ int sctp_rcv(struct sk_buff *skb) | |||
129 | union sctp_addr dest; | 132 | union sctp_addr dest; |
130 | int family; | 133 | int family; |
131 | struct sctp_af *af; | 134 | struct sctp_af *af; |
135 | struct net *net = dev_net(skb->dev); | ||
132 | 136 | ||
133 | if (skb->pkt_type!=PACKET_HOST) | 137 | if (skb->pkt_type!=PACKET_HOST) |
134 | goto discard_it; | 138 | goto discard_it; |
135 | 139 | ||
136 | SCTP_INC_STATS_BH(SCTP_MIB_INSCTPPACKS); | 140 | SCTP_INC_STATS_BH(net, SCTP_MIB_INSCTPPACKS); |
137 | 141 | ||
138 | if (skb_linearize(skb)) | 142 | if (skb_linearize(skb)) |
139 | goto discard_it; | 143 | goto discard_it; |
@@ -145,7 +149,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
145 | if (skb->len < sizeof(struct sctphdr)) | 149 | if (skb->len < sizeof(struct sctphdr)) |
146 | goto discard_it; | 150 | goto discard_it; |
147 | if (!sctp_checksum_disable && !skb_csum_unnecessary(skb) && | 151 | if (!sctp_checksum_disable && !skb_csum_unnecessary(skb) && |
148 | sctp_rcv_checksum(skb) < 0) | 152 | sctp_rcv_checksum(net, skb) < 0) |
149 | goto discard_it; | 153 | goto discard_it; |
150 | 154 | ||
151 | skb_pull(skb, sizeof(struct sctphdr)); | 155 | skb_pull(skb, sizeof(struct sctphdr)); |
@@ -178,10 +182,10 @@ int sctp_rcv(struct sk_buff *skb) | |||
178 | !af->addr_valid(&dest, NULL, skb)) | 182 | !af->addr_valid(&dest, NULL, skb)) |
179 | goto discard_it; | 183 | goto discard_it; |
180 | 184 | ||
181 | asoc = __sctp_rcv_lookup(skb, &src, &dest, &transport); | 185 | asoc = __sctp_rcv_lookup(net, skb, &src, &dest, &transport); |
182 | 186 | ||
183 | if (!asoc) | 187 | if (!asoc) |
184 | ep = __sctp_rcv_lookup_endpoint(&dest); | 188 | ep = __sctp_rcv_lookup_endpoint(net, &dest); |
185 | 189 | ||
186 | /* Retrieve the common input handling substructure. */ | 190 | /* Retrieve the common input handling substructure. */ |
187 | rcvr = asoc ? &asoc->base : &ep->base; | 191 | rcvr = asoc ? &asoc->base : &ep->base; |
@@ -200,7 +204,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
200 | sctp_endpoint_put(ep); | 204 | sctp_endpoint_put(ep); |
201 | ep = NULL; | 205 | ep = NULL; |
202 | } | 206 | } |
203 | sk = sctp_get_ctl_sock(); | 207 | sk = net->sctp.ctl_sock; |
204 | ep = sctp_sk(sk)->ep; | 208 | ep = sctp_sk(sk)->ep; |
205 | sctp_endpoint_hold(ep); | 209 | sctp_endpoint_hold(ep); |
206 | rcvr = &ep->base; | 210 | rcvr = &ep->base; |
@@ -216,7 +220,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
216 | */ | 220 | */ |
217 | if (!asoc) { | 221 | if (!asoc) { |
218 | if (sctp_rcv_ootb(skb)) { | 222 | if (sctp_rcv_ootb(skb)) { |
219 | SCTP_INC_STATS_BH(SCTP_MIB_OUTOFBLUES); | 223 | SCTP_INC_STATS_BH(net, SCTP_MIB_OUTOFBLUES); |
220 | goto discard_release; | 224 | goto discard_release; |
221 | } | 225 | } |
222 | } | 226 | } |
@@ -272,9 +276,9 @@ int sctp_rcv(struct sk_buff *skb) | |||
272 | skb = NULL; /* sctp_chunk_free already freed the skb */ | 276 | skb = NULL; /* sctp_chunk_free already freed the skb */ |
273 | goto discard_release; | 277 | goto discard_release; |
274 | } | 278 | } |
275 | SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_BACKLOG); | 279 | SCTP_INC_STATS_BH(net, SCTP_MIB_IN_PKT_BACKLOG); |
276 | } else { | 280 | } else { |
277 | SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_SOFTIRQ); | 281 | SCTP_INC_STATS_BH(net, SCTP_MIB_IN_PKT_SOFTIRQ); |
278 | sctp_inq_push(&chunk->rcvr->inqueue, chunk); | 282 | sctp_inq_push(&chunk->rcvr->inqueue, chunk); |
279 | } | 283 | } |
280 | 284 | ||
@@ -289,7 +293,7 @@ int sctp_rcv(struct sk_buff *skb) | |||
289 | return 0; | 293 | return 0; |
290 | 294 | ||
291 | discard_it: | 295 | discard_it: |
292 | SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_DISCARDS); | 296 | SCTP_INC_STATS_BH(net, SCTP_MIB_IN_PKT_DISCARDS); |
293 | kfree_skb(skb); | 297 | kfree_skb(skb); |
294 | return 0; | 298 | return 0; |
295 | 299 | ||
@@ -462,11 +466,13 @@ void sctp_icmp_proto_unreachable(struct sock *sk, | |||
462 | } | 466 | } |
463 | 467 | ||
464 | } else { | 468 | } else { |
469 | struct net *net = sock_net(sk); | ||
470 | |||
465 | if (timer_pending(&t->proto_unreach_timer) && | 471 | if (timer_pending(&t->proto_unreach_timer) && |
466 | del_timer(&t->proto_unreach_timer)) | 472 | del_timer(&t->proto_unreach_timer)) |
467 | sctp_association_put(asoc); | 473 | sctp_association_put(asoc); |
468 | 474 | ||
469 | sctp_do_sm(SCTP_EVENT_T_OTHER, | 475 | sctp_do_sm(net, SCTP_EVENT_T_OTHER, |
470 | SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH), | 476 | SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH), |
471 | asoc->state, asoc->ep, asoc, t, | 477 | asoc->state, asoc->ep, asoc, t, |
472 | GFP_ATOMIC); | 478 | GFP_ATOMIC); |
@@ -474,7 +480,7 @@ void sctp_icmp_proto_unreachable(struct sock *sk, | |||
474 | } | 480 | } |
475 | 481 | ||
476 | /* Common lookup code for icmp/icmpv6 error handler. */ | 482 | /* Common lookup code for icmp/icmpv6 error handler. */ |
477 | struct sock *sctp_err_lookup(int family, struct sk_buff *skb, | 483 | struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *skb, |
478 | struct sctphdr *sctphdr, | 484 | struct sctphdr *sctphdr, |
479 | struct sctp_association **app, | 485 | struct sctp_association **app, |
480 | struct sctp_transport **tpp) | 486 | struct sctp_transport **tpp) |
@@ -503,7 +509,7 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb, | |||
503 | /* Look for an association that matches the incoming ICMP error | 509 | /* Look for an association that matches the incoming ICMP error |
504 | * packet. | 510 | * packet. |
505 | */ | 511 | */ |
506 | asoc = __sctp_lookup_association(&saddr, &daddr, &transport); | 512 | asoc = __sctp_lookup_association(net, &saddr, &daddr, &transport); |
507 | if (!asoc) | 513 | if (!asoc) |
508 | return NULL; | 514 | return NULL; |
509 | 515 | ||
@@ -539,7 +545,7 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb, | |||
539 | * servers this needs to be solved differently. | 545 | * servers this needs to be solved differently. |
540 | */ | 546 | */ |
541 | if (sock_owned_by_user(sk)) | 547 | if (sock_owned_by_user(sk)) |
542 | NET_INC_STATS_BH(&init_net, LINUX_MIB_LOCKDROPPEDICMPS); | 548 | NET_INC_STATS_BH(net, LINUX_MIB_LOCKDROPPEDICMPS); |
543 | 549 | ||
544 | *app = asoc; | 550 | *app = asoc; |
545 | *tpp = transport; | 551 | *tpp = transport; |
@@ -586,9 +592,10 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) | |||
586 | struct inet_sock *inet; | 592 | struct inet_sock *inet; |
587 | sk_buff_data_t saveip, savesctp; | 593 | sk_buff_data_t saveip, savesctp; |
588 | int err; | 594 | int err; |
595 | struct net *net = dev_net(skb->dev); | ||
589 | 596 | ||
590 | if (skb->len < ihlen + 8) { | 597 | if (skb->len < ihlen + 8) { |
591 | ICMP_INC_STATS_BH(&init_net, ICMP_MIB_INERRORS); | 598 | ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS); |
592 | return; | 599 | return; |
593 | } | 600 | } |
594 | 601 | ||
@@ -597,12 +604,12 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info) | |||
597 | savesctp = skb->transport_header; | 604 | savesctp = skb->transport_header; |
598 | skb_reset_network_header(skb); | 605 | skb_reset_network_header(skb); |
599 | skb_set_transport_header(skb, ihlen); | 606 | skb_set_transport_header(skb, ihlen); |
600 | sk = sctp_err_lookup(AF_INET, skb, sctp_hdr(skb), &asoc, &transport); | 607 | sk = sctp_err_lookup(net, AF_INET, skb, sctp_hdr(skb), &asoc, &transport); |
601 | /* Put back, the original values. */ | 608 | /* Put back, the original values. */ |
602 | skb->network_header = saveip; | 609 | skb->network_header = saveip; |
603 | skb->transport_header = savesctp; | 610 | skb->transport_header = savesctp; |
604 | if (!sk) { | 611 | if (!sk) { |
605 | ICMP_INC_STATS_BH(&init_net, ICMP_MIB_INERRORS); | 612 | ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS); |
606 | return; | 613 | return; |
607 | } | 614 | } |
608 | /* Warning: The sock lock is held. Remember to call | 615 | /* Warning: The sock lock is held. Remember to call |
@@ -723,12 +730,13 @@ discard: | |||
723 | /* Insert endpoint into the hash table. */ | 730 | /* Insert endpoint into the hash table. */ |
724 | static void __sctp_hash_endpoint(struct sctp_endpoint *ep) | 731 | static void __sctp_hash_endpoint(struct sctp_endpoint *ep) |
725 | { | 732 | { |
733 | struct net *net = sock_net(ep->base.sk); | ||
726 | struct sctp_ep_common *epb; | 734 | struct sctp_ep_common *epb; |
727 | struct sctp_hashbucket *head; | 735 | struct sctp_hashbucket *head; |
728 | 736 | ||
729 | epb = &ep->base; | 737 | epb = &ep->base; |
730 | 738 | ||
731 | epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); | 739 | epb->hashent = sctp_ep_hashfn(net, epb->bind_addr.port); |
732 | head = &sctp_ep_hashtable[epb->hashent]; | 740 | head = &sctp_ep_hashtable[epb->hashent]; |
733 | 741 | ||
734 | sctp_write_lock(&head->lock); | 742 | sctp_write_lock(&head->lock); |
@@ -747,12 +755,13 @@ void sctp_hash_endpoint(struct sctp_endpoint *ep) | |||
747 | /* Remove endpoint from the hash table. */ | 755 | /* Remove endpoint from the hash table. */ |
748 | static void __sctp_unhash_endpoint(struct sctp_endpoint *ep) | 756 | static void __sctp_unhash_endpoint(struct sctp_endpoint *ep) |
749 | { | 757 | { |
758 | struct net *net = sock_net(ep->base.sk); | ||
750 | struct sctp_hashbucket *head; | 759 | struct sctp_hashbucket *head; |
751 | struct sctp_ep_common *epb; | 760 | struct sctp_ep_common *epb; |
752 | 761 | ||
753 | epb = &ep->base; | 762 | epb = &ep->base; |
754 | 763 | ||
755 | epb->hashent = sctp_ep_hashfn(epb->bind_addr.port); | 764 | epb->hashent = sctp_ep_hashfn(net, epb->bind_addr.port); |
756 | 765 | ||
757 | head = &sctp_ep_hashtable[epb->hashent]; | 766 | head = &sctp_ep_hashtable[epb->hashent]; |
758 | 767 | ||
@@ -770,7 +779,8 @@ void sctp_unhash_endpoint(struct sctp_endpoint *ep) | |||
770 | } | 779 | } |
771 | 780 | ||
772 | /* Look up an endpoint. */ | 781 | /* Look up an endpoint. */ |
773 | static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr) | 782 | static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net, |
783 | const union sctp_addr *laddr) | ||
774 | { | 784 | { |
775 | struct sctp_hashbucket *head; | 785 | struct sctp_hashbucket *head; |
776 | struct sctp_ep_common *epb; | 786 | struct sctp_ep_common *epb; |
@@ -778,16 +788,16 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *l | |||
778 | struct hlist_node *node; | 788 | struct hlist_node *node; |
779 | int hash; | 789 | int hash; |
780 | 790 | ||
781 | hash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port)); | 791 | hash = sctp_ep_hashfn(net, ntohs(laddr->v4.sin_port)); |
782 | head = &sctp_ep_hashtable[hash]; | 792 | head = &sctp_ep_hashtable[hash]; |
783 | read_lock(&head->lock); | 793 | read_lock(&head->lock); |
784 | sctp_for_each_hentry(epb, node, &head->chain) { | 794 | sctp_for_each_hentry(epb, node, &head->chain) { |
785 | ep = sctp_ep(epb); | 795 | ep = sctp_ep(epb); |
786 | if (sctp_endpoint_is_match(ep, laddr)) | 796 | if (sctp_endpoint_is_match(ep, net, laddr)) |
787 | goto hit; | 797 | goto hit; |
788 | } | 798 | } |
789 | 799 | ||
790 | ep = sctp_sk((sctp_get_ctl_sock()))->ep; | 800 | ep = sctp_sk(net->sctp.ctl_sock)->ep; |
791 | 801 | ||
792 | hit: | 802 | hit: |
793 | sctp_endpoint_hold(ep); | 803 | sctp_endpoint_hold(ep); |
@@ -798,13 +808,15 @@ hit: | |||
798 | /* Insert association into the hash table. */ | 808 | /* Insert association into the hash table. */ |
799 | static void __sctp_hash_established(struct sctp_association *asoc) | 809 | static void __sctp_hash_established(struct sctp_association *asoc) |
800 | { | 810 | { |
811 | struct net *net = sock_net(asoc->base.sk); | ||
801 | struct sctp_ep_common *epb; | 812 | struct sctp_ep_common *epb; |
802 | struct sctp_hashbucket *head; | 813 | struct sctp_hashbucket *head; |
803 | 814 | ||
804 | epb = &asoc->base; | 815 | epb = &asoc->base; |
805 | 816 | ||
806 | /* Calculate which chain this entry will belong to. */ | 817 | /* Calculate which chain this entry will belong to. */ |
807 | epb->hashent = sctp_assoc_hashfn(epb->bind_addr.port, asoc->peer.port); | 818 | epb->hashent = sctp_assoc_hashfn(net, epb->bind_addr.port, |
819 | asoc->peer.port); | ||
808 | 820 | ||
809 | head = &sctp_assoc_hashtable[epb->hashent]; | 821 | head = &sctp_assoc_hashtable[epb->hashent]; |
810 | 822 | ||
@@ -827,12 +839,13 @@ void sctp_hash_established(struct sctp_association *asoc) | |||
827 | /* Remove association from the hash table. */ | 839 | /* Remove association from the hash table. */ |
828 | static void __sctp_unhash_established(struct sctp_association *asoc) | 840 | static void __sctp_unhash_established(struct sctp_association *asoc) |
829 | { | 841 | { |
842 | struct net *net = sock_net(asoc->base.sk); | ||
830 | struct sctp_hashbucket *head; | 843 | struct sctp_hashbucket *head; |
831 | struct sctp_ep_common *epb; | 844 | struct sctp_ep_common *epb; |
832 | 845 | ||
833 | epb = &asoc->base; | 846 | epb = &asoc->base; |
834 | 847 | ||
835 | epb->hashent = sctp_assoc_hashfn(epb->bind_addr.port, | 848 | epb->hashent = sctp_assoc_hashfn(net, epb->bind_addr.port, |
836 | asoc->peer.port); | 849 | asoc->peer.port); |
837 | 850 | ||
838 | head = &sctp_assoc_hashtable[epb->hashent]; | 851 | head = &sctp_assoc_hashtable[epb->hashent]; |
@@ -855,6 +868,7 @@ void sctp_unhash_established(struct sctp_association *asoc) | |||
855 | 868 | ||
856 | /* Look up an association. */ | 869 | /* Look up an association. */ |
857 | static struct sctp_association *__sctp_lookup_association( | 870 | static struct sctp_association *__sctp_lookup_association( |
871 | struct net *net, | ||
858 | const union sctp_addr *local, | 872 | const union sctp_addr *local, |
859 | const union sctp_addr *peer, | 873 | const union sctp_addr *peer, |
860 | struct sctp_transport **pt) | 874 | struct sctp_transport **pt) |
@@ -869,12 +883,13 @@ static struct sctp_association *__sctp_lookup_association( | |||
869 | /* Optimize here for direct hit, only listening connections can | 883 | /* Optimize here for direct hit, only listening connections can |
870 | * have wildcards anyways. | 884 | * have wildcards anyways. |
871 | */ | 885 | */ |
872 | hash = sctp_assoc_hashfn(ntohs(local->v4.sin_port), ntohs(peer->v4.sin_port)); | 886 | hash = sctp_assoc_hashfn(net, ntohs(local->v4.sin_port), |
887 | ntohs(peer->v4.sin_port)); | ||
873 | head = &sctp_assoc_hashtable[hash]; | 888 | head = &sctp_assoc_hashtable[hash]; |
874 | read_lock(&head->lock); | 889 | read_lock(&head->lock); |
875 | sctp_for_each_hentry(epb, node, &head->chain) { | 890 | sctp_for_each_hentry(epb, node, &head->chain) { |
876 | asoc = sctp_assoc(epb); | 891 | asoc = sctp_assoc(epb); |
877 | transport = sctp_assoc_is_match(asoc, local, peer); | 892 | transport = sctp_assoc_is_match(asoc, net, local, peer); |
878 | if (transport) | 893 | if (transport) |
879 | goto hit; | 894 | goto hit; |
880 | } | 895 | } |
@@ -892,27 +907,29 @@ hit: | |||
892 | 907 | ||
893 | /* Look up an association. BH-safe. */ | 908 | /* Look up an association. BH-safe. */ |
894 | SCTP_STATIC | 909 | SCTP_STATIC |
895 | struct sctp_association *sctp_lookup_association(const union sctp_addr *laddr, | 910 | struct sctp_association *sctp_lookup_association(struct net *net, |
911 | const union sctp_addr *laddr, | ||
896 | const union sctp_addr *paddr, | 912 | const union sctp_addr *paddr, |
897 | struct sctp_transport **transportp) | 913 | struct sctp_transport **transportp) |
898 | { | 914 | { |
899 | struct sctp_association *asoc; | 915 | struct sctp_association *asoc; |
900 | 916 | ||
901 | sctp_local_bh_disable(); | 917 | sctp_local_bh_disable(); |
902 | asoc = __sctp_lookup_association(laddr, paddr, transportp); | 918 | asoc = __sctp_lookup_association(net, laddr, paddr, transportp); |
903 | sctp_local_bh_enable(); | 919 | sctp_local_bh_enable(); |
904 | 920 | ||
905 | return asoc; | 921 | return asoc; |
906 | } | 922 | } |
907 | 923 | ||
908 | /* Is there an association matching the given local and peer addresses? */ | 924 | /* Is there an association matching the given local and peer addresses? */ |
909 | int sctp_has_association(const union sctp_addr *laddr, | 925 | int sctp_has_association(struct net *net, |
926 | const union sctp_addr *laddr, | ||
910 | const union sctp_addr *paddr) | 927 | const union sctp_addr *paddr) |
911 | { | 928 | { |
912 | struct sctp_association *asoc; | 929 | struct sctp_association *asoc; |
913 | struct sctp_transport *transport; | 930 | struct sctp_transport *transport; |
914 | 931 | ||
915 | if ((asoc = sctp_lookup_association(laddr, paddr, &transport))) { | 932 | if ((asoc = sctp_lookup_association(net, laddr, paddr, &transport))) { |
916 | sctp_association_put(asoc); | 933 | sctp_association_put(asoc); |
917 | return 1; | 934 | return 1; |
918 | } | 935 | } |
@@ -938,7 +955,8 @@ int sctp_has_association(const union sctp_addr *laddr, | |||
938 | * in certain circumstances. | 955 | * in certain circumstances. |
939 | * | 956 | * |
940 | */ | 957 | */ |
941 | static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb, | 958 | static struct sctp_association *__sctp_rcv_init_lookup(struct net *net, |
959 | struct sk_buff *skb, | ||
942 | const union sctp_addr *laddr, struct sctp_transport **transportp) | 960 | const union sctp_addr *laddr, struct sctp_transport **transportp) |
943 | { | 961 | { |
944 | struct sctp_association *asoc; | 962 | struct sctp_association *asoc; |
@@ -978,7 +996,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb, | |||
978 | 996 | ||
979 | af->from_addr_param(paddr, params.addr, sh->source, 0); | 997 | af->from_addr_param(paddr, params.addr, sh->source, 0); |
980 | 998 | ||
981 | asoc = __sctp_lookup_association(laddr, paddr, &transport); | 999 | asoc = __sctp_lookup_association(net, laddr, paddr, &transport); |
982 | if (asoc) | 1000 | if (asoc) |
983 | return asoc; | 1001 | return asoc; |
984 | } | 1002 | } |
@@ -1001,6 +1019,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb, | |||
1001 | * subsequent ASCONF Chunks. If found, proceed to rule D4. | 1019 | * subsequent ASCONF Chunks. If found, proceed to rule D4. |
1002 | */ | 1020 | */ |
1003 | static struct sctp_association *__sctp_rcv_asconf_lookup( | 1021 | static struct sctp_association *__sctp_rcv_asconf_lookup( |
1022 | struct net *net, | ||
1004 | sctp_chunkhdr_t *ch, | 1023 | sctp_chunkhdr_t *ch, |
1005 | const union sctp_addr *laddr, | 1024 | const union sctp_addr *laddr, |
1006 | __be16 peer_port, | 1025 | __be16 peer_port, |
@@ -1020,7 +1039,7 @@ static struct sctp_association *__sctp_rcv_asconf_lookup( | |||
1020 | 1039 | ||
1021 | af->from_addr_param(&paddr, param, peer_port, 0); | 1040 | af->from_addr_param(&paddr, param, peer_port, 0); |
1022 | 1041 | ||
1023 | return __sctp_lookup_association(laddr, &paddr, transportp); | 1042 | return __sctp_lookup_association(net, laddr, &paddr, transportp); |
1024 | } | 1043 | } |
1025 | 1044 | ||
1026 | 1045 | ||
@@ -1033,7 +1052,8 @@ static struct sctp_association *__sctp_rcv_asconf_lookup( | |||
1033 | * This means that any chunks that can help us identify the association need | 1052 | * This means that any chunks that can help us identify the association need |
1034 | * to be looked at to find this association. | 1053 | * to be looked at to find this association. |
1035 | */ | 1054 | */ |
1036 | static struct sctp_association *__sctp_rcv_walk_lookup(struct sk_buff *skb, | 1055 | static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net, |
1056 | struct sk_buff *skb, | ||
1037 | const union sctp_addr *laddr, | 1057 | const union sctp_addr *laddr, |
1038 | struct sctp_transport **transportp) | 1058 | struct sctp_transport **transportp) |
1039 | { | 1059 | { |
@@ -1074,8 +1094,9 @@ static struct sctp_association *__sctp_rcv_walk_lookup(struct sk_buff *skb, | |||
1074 | break; | 1094 | break; |
1075 | 1095 | ||
1076 | case SCTP_CID_ASCONF: | 1096 | case SCTP_CID_ASCONF: |
1077 | if (have_auth || sctp_addip_noauth) | 1097 | if (have_auth || net->sctp.addip_noauth) |
1078 | asoc = __sctp_rcv_asconf_lookup(ch, laddr, | 1098 | asoc = __sctp_rcv_asconf_lookup( |
1099 | net, ch, laddr, | ||
1079 | sctp_hdr(skb)->source, | 1100 | sctp_hdr(skb)->source, |
1080 | transportp); | 1101 | transportp); |
1081 | default: | 1102 | default: |
@@ -1098,7 +1119,8 @@ static struct sctp_association *__sctp_rcv_walk_lookup(struct sk_buff *skb, | |||
1098 | * include looking inside of INIT/INIT-ACK chunks or after the AUTH | 1119 | * include looking inside of INIT/INIT-ACK chunks or after the AUTH |
1099 | * chunks. | 1120 | * chunks. |
1100 | */ | 1121 | */ |
1101 | static struct sctp_association *__sctp_rcv_lookup_harder(struct sk_buff *skb, | 1122 | static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net, |
1123 | struct sk_buff *skb, | ||
1102 | const union sctp_addr *laddr, | 1124 | const union sctp_addr *laddr, |
1103 | struct sctp_transport **transportp) | 1125 | struct sctp_transport **transportp) |
1104 | { | 1126 | { |
@@ -1118,11 +1140,11 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct sk_buff *skb, | |||
1118 | switch (ch->type) { | 1140 | switch (ch->type) { |
1119 | case SCTP_CID_INIT: | 1141 | case SCTP_CID_INIT: |
1120 | case SCTP_CID_INIT_ACK: | 1142 | case SCTP_CID_INIT_ACK: |
1121 | return __sctp_rcv_init_lookup(skb, laddr, transportp); | 1143 | return __sctp_rcv_init_lookup(net, skb, laddr, transportp); |
1122 | break; | 1144 | break; |
1123 | 1145 | ||
1124 | default: | 1146 | default: |
1125 | return __sctp_rcv_walk_lookup(skb, laddr, transportp); | 1147 | return __sctp_rcv_walk_lookup(net, skb, laddr, transportp); |
1126 | break; | 1148 | break; |
1127 | } | 1149 | } |
1128 | 1150 | ||
@@ -1131,21 +1153,22 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct sk_buff *skb, | |||
1131 | } | 1153 | } |
1132 | 1154 | ||
1133 | /* Lookup an association for an inbound skb. */ | 1155 | /* Lookup an association for an inbound skb. */ |
1134 | static struct sctp_association *__sctp_rcv_lookup(struct sk_buff *skb, | 1156 | static struct sctp_association *__sctp_rcv_lookup(struct net *net, |
1157 | struct sk_buff *skb, | ||
1135 | const union sctp_addr *paddr, | 1158 | const union sctp_addr *paddr, |
1136 | const union sctp_addr *laddr, | 1159 | const union sctp_addr *laddr, |
1137 | struct sctp_transport **transportp) | 1160 | struct sctp_transport **transportp) |
1138 | { | 1161 | { |
1139 | struct sctp_association *asoc; | 1162 | struct sctp_association *asoc; |
1140 | 1163 | ||
1141 | asoc = __sctp_lookup_association(laddr, paddr, transportp); | 1164 | asoc = __sctp_lookup_association(net, laddr, paddr, transportp); |
1142 | 1165 | ||
1143 | /* Further lookup for INIT/INIT-ACK packets. | 1166 | /* Further lookup for INIT/INIT-ACK packets. |
1144 | * SCTP Implementors Guide, 2.18 Handling of address | 1167 | * SCTP Implementors Guide, 2.18 Handling of address |
1145 | * parameters within the INIT or INIT-ACK. | 1168 | * parameters within the INIT or INIT-ACK. |
1146 | */ | 1169 | */ |
1147 | if (!asoc) | 1170 | if (!asoc) |
1148 | asoc = __sctp_rcv_lookup_harder(skb, laddr, transportp); | 1171 | asoc = __sctp_rcv_lookup_harder(net, skb, laddr, transportp); |
1149 | 1172 | ||
1150 | return asoc; | 1173 | return asoc; |
1151 | } | 1174 | } |
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index ed7139ea7978..ea14cb445295 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -99,6 +99,7 @@ static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev, | |||
99 | struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr; | 99 | struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr; |
100 | struct sctp_sockaddr_entry *addr = NULL; | 100 | struct sctp_sockaddr_entry *addr = NULL; |
101 | struct sctp_sockaddr_entry *temp; | 101 | struct sctp_sockaddr_entry *temp; |
102 | struct net *net = dev_net(ifa->idev->dev); | ||
102 | int found = 0; | 103 | int found = 0; |
103 | 104 | ||
104 | switch (ev) { | 105 | switch (ev) { |
@@ -110,27 +111,27 @@ static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev, | |||
110 | addr->a.v6.sin6_addr = ifa->addr; | 111 | addr->a.v6.sin6_addr = ifa->addr; |
111 | addr->a.v6.sin6_scope_id = ifa->idev->dev->ifindex; | 112 | addr->a.v6.sin6_scope_id = ifa->idev->dev->ifindex; |
112 | addr->valid = 1; | 113 | addr->valid = 1; |
113 | spin_lock_bh(&sctp_local_addr_lock); | 114 | spin_lock_bh(&net->sctp.local_addr_lock); |
114 | list_add_tail_rcu(&addr->list, &sctp_local_addr_list); | 115 | list_add_tail_rcu(&addr->list, &net->sctp.local_addr_list); |
115 | sctp_addr_wq_mgmt(addr, SCTP_ADDR_NEW); | 116 | sctp_addr_wq_mgmt(net, addr, SCTP_ADDR_NEW); |
116 | spin_unlock_bh(&sctp_local_addr_lock); | 117 | spin_unlock_bh(&net->sctp.local_addr_lock); |
117 | } | 118 | } |
118 | break; | 119 | break; |
119 | case NETDEV_DOWN: | 120 | case NETDEV_DOWN: |
120 | spin_lock_bh(&sctp_local_addr_lock); | 121 | spin_lock_bh(&net->sctp.local_addr_lock); |
121 | list_for_each_entry_safe(addr, temp, | 122 | list_for_each_entry_safe(addr, temp, |
122 | &sctp_local_addr_list, list) { | 123 | &net->sctp.local_addr_list, list) { |
123 | if (addr->a.sa.sa_family == AF_INET6 && | 124 | if (addr->a.sa.sa_family == AF_INET6 && |
124 | ipv6_addr_equal(&addr->a.v6.sin6_addr, | 125 | ipv6_addr_equal(&addr->a.v6.sin6_addr, |
125 | &ifa->addr)) { | 126 | &ifa->addr)) { |
126 | sctp_addr_wq_mgmt(addr, SCTP_ADDR_DEL); | 127 | sctp_addr_wq_mgmt(net, addr, SCTP_ADDR_DEL); |
127 | found = 1; | 128 | found = 1; |
128 | addr->valid = 0; | 129 | addr->valid = 0; |
129 | list_del_rcu(&addr->list); | 130 | list_del_rcu(&addr->list); |
130 | break; | 131 | break; |
131 | } | 132 | } |
132 | } | 133 | } |
133 | spin_unlock_bh(&sctp_local_addr_lock); | 134 | spin_unlock_bh(&net->sctp.local_addr_lock); |
134 | if (found) | 135 | if (found) |
135 | kfree_rcu(addr, rcu); | 136 | kfree_rcu(addr, rcu); |
136 | break; | 137 | break; |
@@ -154,6 +155,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
154 | struct ipv6_pinfo *np; | 155 | struct ipv6_pinfo *np; |
155 | sk_buff_data_t saveip, savesctp; | 156 | sk_buff_data_t saveip, savesctp; |
156 | int err; | 157 | int err; |
158 | struct net *net = dev_net(skb->dev); | ||
157 | 159 | ||
158 | idev = in6_dev_get(skb->dev); | 160 | idev = in6_dev_get(skb->dev); |
159 | 161 | ||
@@ -162,12 +164,12 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
162 | savesctp = skb->transport_header; | 164 | savesctp = skb->transport_header; |
163 | skb_reset_network_header(skb); | 165 | skb_reset_network_header(skb); |
164 | skb_set_transport_header(skb, offset); | 166 | skb_set_transport_header(skb, offset); |
165 | sk = sctp_err_lookup(AF_INET6, skb, sctp_hdr(skb), &asoc, &transport); | 167 | sk = sctp_err_lookup(net, AF_INET6, skb, sctp_hdr(skb), &asoc, &transport); |
166 | /* Put back, the original pointers. */ | 168 | /* Put back, the original pointers. */ |
167 | skb->network_header = saveip; | 169 | skb->network_header = saveip; |
168 | skb->transport_header = savesctp; | 170 | skb->transport_header = savesctp; |
169 | if (!sk) { | 171 | if (!sk) { |
170 | ICMP6_INC_STATS_BH(dev_net(skb->dev), idev, ICMP6_MIB_INERRORS); | 172 | ICMP6_INC_STATS_BH(net, idev, ICMP6_MIB_INERRORS); |
171 | goto out; | 173 | goto out; |
172 | } | 174 | } |
173 | 175 | ||
@@ -241,7 +243,7 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport) | |||
241 | __func__, skb, skb->len, | 243 | __func__, skb, skb->len, |
242 | &fl6.saddr, &fl6.daddr); | 244 | &fl6.saddr, &fl6.daddr); |
243 | 245 | ||
244 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); | 246 | SCTP_INC_STATS(sock_net(sk), SCTP_MIB_OUTSCTPPACKS); |
245 | 247 | ||
246 | if (!(transport->param_flags & SPP_PMTUD_ENABLE)) | 248 | if (!(transport->param_flags & SPP_PMTUD_ENABLE)) |
247 | skb->local_df = 1; | 249 | skb->local_df = 1; |
@@ -580,7 +582,7 @@ static int sctp_v6_available(union sctp_addr *addr, struct sctp_sock *sp) | |||
580 | if (!(type & IPV6_ADDR_UNICAST)) | 582 | if (!(type & IPV6_ADDR_UNICAST)) |
581 | return 0; | 583 | return 0; |
582 | 584 | ||
583 | return ipv6_chk_addr(&init_net, in6, NULL, 0); | 585 | return ipv6_chk_addr(sock_net(&sp->inet.sk), in6, NULL, 0); |
584 | } | 586 | } |
585 | 587 | ||
586 | /* This function checks if the address is a valid address to be used for | 588 | /* This function checks if the address is a valid address to be used for |
@@ -857,14 +859,14 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr) | |||
857 | struct net_device *dev; | 859 | struct net_device *dev; |
858 | 860 | ||
859 | if (type & IPV6_ADDR_LINKLOCAL) { | 861 | if (type & IPV6_ADDR_LINKLOCAL) { |
862 | struct net *net; | ||
860 | if (!addr->v6.sin6_scope_id) | 863 | if (!addr->v6.sin6_scope_id) |
861 | return 0; | 864 | return 0; |
865 | net = sock_net(&opt->inet.sk); | ||
862 | rcu_read_lock(); | 866 | rcu_read_lock(); |
863 | dev = dev_get_by_index_rcu(&init_net, | 867 | dev = dev_get_by_index_rcu(net, addr->v6.sin6_scope_id); |
864 | addr->v6.sin6_scope_id); | ||
865 | if (!dev || | 868 | if (!dev || |
866 | !ipv6_chk_addr(&init_net, &addr->v6.sin6_addr, | 869 | !ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0)) { |
867 | dev, 0)) { | ||
868 | rcu_read_unlock(); | 870 | rcu_read_unlock(); |
869 | return 0; | 871 | return 0; |
870 | } | 872 | } |
@@ -897,7 +899,7 @@ static int sctp_inet6_send_verify(struct sctp_sock *opt, union sctp_addr *addr) | |||
897 | if (!addr->v6.sin6_scope_id) | 899 | if (!addr->v6.sin6_scope_id) |
898 | return 0; | 900 | return 0; |
899 | rcu_read_lock(); | 901 | rcu_read_lock(); |
900 | dev = dev_get_by_index_rcu(&init_net, | 902 | dev = dev_get_by_index_rcu(sock_net(&opt->inet.sk), |
901 | addr->v6.sin6_scope_id); | 903 | addr->v6.sin6_scope_id); |
902 | rcu_read_unlock(); | 904 | rcu_read_unlock(); |
903 | if (!dev) | 905 | if (!dev) |
diff --git a/net/sctp/objcnt.c b/net/sctp/objcnt.c index 8ef8e7d9eb61..fe012c44f8df 100644 --- a/net/sctp/objcnt.c +++ b/net/sctp/objcnt.c | |||
@@ -129,20 +129,20 @@ static const struct file_operations sctp_objcnt_ops = { | |||
129 | }; | 129 | }; |
130 | 130 | ||
131 | /* Initialize the objcount in the proc filesystem. */ | 131 | /* Initialize the objcount in the proc filesystem. */ |
132 | void sctp_dbg_objcnt_init(void) | 132 | void sctp_dbg_objcnt_init(struct net *net) |
133 | { | 133 | { |
134 | struct proc_dir_entry *ent; | 134 | struct proc_dir_entry *ent; |
135 | 135 | ||
136 | ent = proc_create("sctp_dbg_objcnt", 0, | 136 | ent = proc_create("sctp_dbg_objcnt", 0, |
137 | proc_net_sctp, &sctp_objcnt_ops); | 137 | net->sctp.proc_net_sctp, &sctp_objcnt_ops); |
138 | if (!ent) | 138 | if (!ent) |
139 | pr_warn("sctp_dbg_objcnt: Unable to create /proc entry.\n"); | 139 | pr_warn("sctp_dbg_objcnt: Unable to create /proc entry.\n"); |
140 | } | 140 | } |
141 | 141 | ||
142 | /* Cleanup the objcount entry in the proc filesystem. */ | 142 | /* Cleanup the objcount entry in the proc filesystem. */ |
143 | void sctp_dbg_objcnt_exit(void) | 143 | void sctp_dbg_objcnt_exit(struct net *net) |
144 | { | 144 | { |
145 | remove_proc_entry("sctp_dbg_objcnt", proc_net_sctp); | 145 | remove_proc_entry("sctp_dbg_objcnt", net->sctp.proc_net_sctp); |
146 | } | 146 | } |
147 | 147 | ||
148 | 148 | ||
diff --git a/net/sctp/output.c b/net/sctp/output.c index be50aa234dcd..4e90188bf489 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c | |||
@@ -616,7 +616,7 @@ out: | |||
616 | return err; | 616 | return err; |
617 | no_route: | 617 | no_route: |
618 | kfree_skb(nskb); | 618 | kfree_skb(nskb); |
619 | IP_INC_STATS_BH(&init_net, IPSTATS_MIB_OUTNOROUTES); | 619 | IP_INC_STATS_BH(sock_net(asoc->base.sk), IPSTATS_MIB_OUTNOROUTES); |
620 | 620 | ||
621 | /* FIXME: Returning the 'err' will effect all the associations | 621 | /* FIXME: Returning the 'err' will effect all the associations |
622 | * associated with a socket, although only one of the paths of the | 622 | * 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..d16632e1503a 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. */ |
300 | int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk) | 300 | int 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, | |||
478 | void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport, | 479 | void 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: |
@@ -589,9 +591,8 @@ static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt, | |||
589 | * next chunk. | 591 | * next chunk. |
590 | */ | 592 | */ |
591 | if (chunk->tsn_gap_acked) { | 593 | if (chunk->tsn_gap_acked) { |
592 | list_del(&chunk->transmitted_list); | 594 | list_move_tail(&chunk->transmitted_list, |
593 | list_add_tail(&chunk->transmitted_list, | 595 | &transport->transmitted); |
594 | &transport->transmitted); | ||
595 | continue; | 596 | continue; |
596 | } | 597 | } |
597 | 598 | ||
@@ -655,9 +656,8 @@ redo: | |||
655 | /* The append was successful, so add this chunk to | 656 | /* The append was successful, so add this chunk to |
656 | * the transmitted list. | 657 | * the transmitted list. |
657 | */ | 658 | */ |
658 | list_del(&chunk->transmitted_list); | 659 | list_move_tail(&chunk->transmitted_list, |
659 | list_add_tail(&chunk->transmitted_list, | 660 | &transport->transmitted); |
660 | &transport->transmitted); | ||
661 | 661 | ||
662 | /* Mark the chunk as ineligible for fast retransmit | 662 | /* Mark the chunk as ineligible for fast retransmit |
663 | * after it is retransmitted. | 663 | * after it is retransmitted. |
@@ -1914,6 +1914,6 @@ static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 ctsn) | |||
1914 | 1914 | ||
1915 | if (ftsn_chunk) { | 1915 | if (ftsn_chunk) { |
1916 | list_add_tail(&ftsn_chunk->list, &q->control_chunk_list); | 1916 | list_add_tail(&ftsn_chunk->list, &q->control_chunk_list); |
1917 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 1917 | SCTP_INC_STATS(sock_net(asoc->base.sk), SCTP_MIB_OUTCTRLCHUNKS); |
1918 | } | 1918 | } |
1919 | } | 1919 | } |
diff --git a/net/sctp/primitive.c b/net/sctp/primitive.c index 534c7eae9d15..794bb14decde 100644 --- a/net/sctp/primitive.c +++ b/net/sctp/primitive.c | |||
@@ -57,7 +57,7 @@ | |||
57 | 57 | ||
58 | #define DECLARE_PRIMITIVE(name) \ | 58 | #define DECLARE_PRIMITIVE(name) \ |
59 | /* This is called in the code as sctp_primitive_ ## name. */ \ | 59 | /* This is called in the code as sctp_primitive_ ## name. */ \ |
60 | int sctp_primitive_ ## name(struct sctp_association *asoc, \ | 60 | int sctp_primitive_ ## name(struct net *net, struct sctp_association *asoc, \ |
61 | void *arg) { \ | 61 | void *arg) { \ |
62 | int error = 0; \ | 62 | int error = 0; \ |
63 | sctp_event_t event_type; sctp_subtype_t subtype; \ | 63 | sctp_event_t event_type; sctp_subtype_t subtype; \ |
@@ -69,7 +69,7 @@ int sctp_primitive_ ## name(struct sctp_association *asoc, \ | |||
69 | state = asoc ? asoc->state : SCTP_STATE_CLOSED; \ | 69 | state = asoc ? asoc->state : SCTP_STATE_CLOSED; \ |
70 | ep = asoc ? asoc->ep : NULL; \ | 70 | ep = asoc ? asoc->ep : NULL; \ |
71 | \ | 71 | \ |
72 | error = sctp_do_sm(event_type, subtype, state, ep, asoc, \ | 72 | error = sctp_do_sm(net, event_type, subtype, state, ep, asoc, \ |
73 | arg, GFP_KERNEL); \ | 73 | arg, GFP_KERNEL); \ |
74 | return error; \ | 74 | return error; \ |
75 | } | 75 | } |
diff --git a/net/sctp/proc.c b/net/sctp/proc.c index dc12febc977a..c3bea269faf4 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c | |||
@@ -80,11 +80,12 @@ static const struct snmp_mib sctp_snmp_list[] = { | |||
80 | /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ | 80 | /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ |
81 | static int sctp_snmp_seq_show(struct seq_file *seq, void *v) | 81 | static int sctp_snmp_seq_show(struct seq_file *seq, void *v) |
82 | { | 82 | { |
83 | struct net *net = seq->private; | ||
83 | int i; | 84 | int i; |
84 | 85 | ||
85 | for (i = 0; sctp_snmp_list[i].name != NULL; i++) | 86 | for (i = 0; sctp_snmp_list[i].name != NULL; i++) |
86 | 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, |
87 | snmp_fold_field((void __percpu **)sctp_statistics, | 88 | snmp_fold_field((void __percpu **)net->sctp.sctp_statistics, |
88 | sctp_snmp_list[i].entry)); | 89 | sctp_snmp_list[i].entry)); |
89 | 90 | ||
90 | return 0; | 91 | return 0; |
@@ -93,7 +94,7 @@ static int sctp_snmp_seq_show(struct seq_file *seq, void *v) | |||
93 | /* Initialize the seq file operations for 'snmp' object. */ | 94 | /* Initialize the seq file operations for 'snmp' object. */ |
94 | static int sctp_snmp_seq_open(struct inode *inode, struct file *file) | 95 | static int sctp_snmp_seq_open(struct inode *inode, struct file *file) |
95 | { | 96 | { |
96 | return single_open(file, sctp_snmp_seq_show, NULL); | 97 | return single_open_net(inode, file, sctp_snmp_seq_show); |
97 | } | 98 | } |
98 | 99 | ||
99 | static const struct file_operations sctp_snmp_seq_fops = { | 100 | static const struct file_operations sctp_snmp_seq_fops = { |
@@ -105,11 +106,12 @@ static const struct file_operations sctp_snmp_seq_fops = { | |||
105 | }; | 106 | }; |
106 | 107 | ||
107 | /* Set up the proc fs entry for 'snmp' object. */ | 108 | /* Set up the proc fs entry for 'snmp' object. */ |
108 | int __init sctp_snmp_proc_init(void) | 109 | int __net_init sctp_snmp_proc_init(struct net *net) |
109 | { | 110 | { |
110 | struct proc_dir_entry *p; | 111 | struct proc_dir_entry *p; |
111 | 112 | ||
112 | p = proc_create("snmp", S_IRUGO, proc_net_sctp, &sctp_snmp_seq_fops); | 113 | p = proc_create("snmp", S_IRUGO, net->sctp.proc_net_sctp, |
114 | &sctp_snmp_seq_fops); | ||
113 | if (!p) | 115 | if (!p) |
114 | return -ENOMEM; | 116 | return -ENOMEM; |
115 | 117 | ||
@@ -117,9 +119,9 @@ int __init sctp_snmp_proc_init(void) | |||
117 | } | 119 | } |
118 | 120 | ||
119 | /* Cleanup the proc fs entry for 'snmp' object. */ | 121 | /* Cleanup the proc fs entry for 'snmp' object. */ |
120 | void sctp_snmp_proc_exit(void) | 122 | void sctp_snmp_proc_exit(struct net *net) |
121 | { | 123 | { |
122 | remove_proc_entry("snmp", proc_net_sctp); | 124 | remove_proc_entry("snmp", net->sctp.proc_net_sctp); |
123 | } | 125 | } |
124 | 126 | ||
125 | /* Dump local addresses of an association/endpoint. */ | 127 | /* Dump local addresses of an association/endpoint. */ |
@@ -213,6 +215,8 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v) | |||
213 | sctp_for_each_hentry(epb, node, &head->chain) { | 215 | sctp_for_each_hentry(epb, node, &head->chain) { |
214 | ep = sctp_ep(epb); | 216 | ep = sctp_ep(epb); |
215 | sk = epb->sk; | 217 | sk = epb->sk; |
218 | if (!net_eq(sock_net(sk), seq_file_net(seq))) | ||
219 | continue; | ||
216 | seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk, | 220 | seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk, |
217 | sctp_sk(sk)->type, sk->sk_state, hash, | 221 | sctp_sk(sk)->type, sk->sk_state, hash, |
218 | epb->bind_addr.port, | 222 | epb->bind_addr.port, |
@@ -239,7 +243,8 @@ static const struct seq_operations sctp_eps_ops = { | |||
239 | /* Initialize the seq file operations for 'eps' object. */ | 243 | /* Initialize the seq file operations for 'eps' object. */ |
240 | static int sctp_eps_seq_open(struct inode *inode, struct file *file) | 244 | static int sctp_eps_seq_open(struct inode *inode, struct file *file) |
241 | { | 245 | { |
242 | return seq_open(file, &sctp_eps_ops); | 246 | return seq_open_net(inode, file, &sctp_eps_ops, |
247 | sizeof(struct seq_net_private)); | ||
243 | } | 248 | } |
244 | 249 | ||
245 | static const struct file_operations sctp_eps_seq_fops = { | 250 | static const struct file_operations sctp_eps_seq_fops = { |
@@ -250,11 +255,12 @@ static const struct file_operations sctp_eps_seq_fops = { | |||
250 | }; | 255 | }; |
251 | 256 | ||
252 | /* Set up the proc fs entry for 'eps' object. */ | 257 | /* Set up the proc fs entry for 'eps' object. */ |
253 | int __init sctp_eps_proc_init(void) | 258 | int __net_init sctp_eps_proc_init(struct net *net) |
254 | { | 259 | { |
255 | struct proc_dir_entry *p; | 260 | struct proc_dir_entry *p; |
256 | 261 | ||
257 | p = proc_create("eps", S_IRUGO, proc_net_sctp, &sctp_eps_seq_fops); | 262 | p = proc_create("eps", S_IRUGO, net->sctp.proc_net_sctp, |
263 | &sctp_eps_seq_fops); | ||
258 | if (!p) | 264 | if (!p) |
259 | return -ENOMEM; | 265 | return -ENOMEM; |
260 | 266 | ||
@@ -262,9 +268,9 @@ int __init sctp_eps_proc_init(void) | |||
262 | } | 268 | } |
263 | 269 | ||
264 | /* Cleanup the proc fs entry for 'eps' object. */ | 270 | /* Cleanup the proc fs entry for 'eps' object. */ |
265 | void sctp_eps_proc_exit(void) | 271 | void sctp_eps_proc_exit(struct net *net) |
266 | { | 272 | { |
267 | remove_proc_entry("eps", proc_net_sctp); | 273 | remove_proc_entry("eps", net->sctp.proc_net_sctp); |
268 | } | 274 | } |
269 | 275 | ||
270 | 276 | ||
@@ -317,6 +323,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v) | |||
317 | sctp_for_each_hentry(epb, node, &head->chain) { | 323 | sctp_for_each_hentry(epb, node, &head->chain) { |
318 | assoc = sctp_assoc(epb); | 324 | assoc = sctp_assoc(epb); |
319 | sk = epb->sk; | 325 | sk = epb->sk; |
326 | if (!net_eq(sock_net(sk), seq_file_net(seq))) | ||
327 | continue; | ||
320 | seq_printf(seq, | 328 | seq_printf(seq, |
321 | "%8pK %8pK %-3d %-3d %-2d %-4d " | 329 | "%8pK %8pK %-3d %-3d %-2d %-4d " |
322 | "%4d %8d %8d %7d %5lu %-5d %5d ", | 330 | "%4d %8d %8d %7d %5lu %-5d %5d ", |
@@ -356,7 +364,8 @@ static const struct seq_operations sctp_assoc_ops = { | |||
356 | /* Initialize the seq file operations for 'assocs' object. */ | 364 | /* Initialize the seq file operations for 'assocs' object. */ |
357 | static int sctp_assocs_seq_open(struct inode *inode, struct file *file) | 365 | static int sctp_assocs_seq_open(struct inode *inode, struct file *file) |
358 | { | 366 | { |
359 | return seq_open(file, &sctp_assoc_ops); | 367 | return seq_open_net(inode, file, &sctp_assoc_ops, |
368 | sizeof(struct seq_net_private)); | ||
360 | } | 369 | } |
361 | 370 | ||
362 | static const struct file_operations sctp_assocs_seq_fops = { | 371 | static const struct file_operations sctp_assocs_seq_fops = { |
@@ -367,11 +376,11 @@ static const struct file_operations sctp_assocs_seq_fops = { | |||
367 | }; | 376 | }; |
368 | 377 | ||
369 | /* Set up the proc fs entry for 'assocs' object. */ | 378 | /* Set up the proc fs entry for 'assocs' object. */ |
370 | int __init sctp_assocs_proc_init(void) | 379 | int __net_init sctp_assocs_proc_init(struct net *net) |
371 | { | 380 | { |
372 | struct proc_dir_entry *p; | 381 | struct proc_dir_entry *p; |
373 | 382 | ||
374 | p = proc_create("assocs", S_IRUGO, proc_net_sctp, | 383 | p = proc_create("assocs", S_IRUGO, net->sctp.proc_net_sctp, |
375 | &sctp_assocs_seq_fops); | 384 | &sctp_assocs_seq_fops); |
376 | if (!p) | 385 | if (!p) |
377 | return -ENOMEM; | 386 | return -ENOMEM; |
@@ -380,9 +389,9 @@ int __init sctp_assocs_proc_init(void) | |||
380 | } | 389 | } |
381 | 390 | ||
382 | /* Cleanup the proc fs entry for 'assocs' object. */ | 391 | /* Cleanup the proc fs entry for 'assocs' object. */ |
383 | void sctp_assocs_proc_exit(void) | 392 | void sctp_assocs_proc_exit(struct net *net) |
384 | { | 393 | { |
385 | remove_proc_entry("assocs", proc_net_sctp); | 394 | remove_proc_entry("assocs", net->sctp.proc_net_sctp); |
386 | } | 395 | } |
387 | 396 | ||
388 | static void *sctp_remaddr_seq_start(struct seq_file *seq, loff_t *pos) | 397 | static void *sctp_remaddr_seq_start(struct seq_file *seq, loff_t *pos) |
@@ -428,6 +437,8 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) | |||
428 | sctp_local_bh_disable(); | 437 | sctp_local_bh_disable(); |
429 | read_lock(&head->lock); | 438 | read_lock(&head->lock); |
430 | sctp_for_each_hentry(epb, node, &head->chain) { | 439 | sctp_for_each_hentry(epb, node, &head->chain) { |
440 | if (!net_eq(sock_net(epb->sk), seq_file_net(seq))) | ||
441 | continue; | ||
431 | assoc = sctp_assoc(epb); | 442 | assoc = sctp_assoc(epb); |
432 | list_for_each_entry(tsp, &assoc->peer.transport_addr_list, | 443 | list_for_each_entry(tsp, &assoc->peer.transport_addr_list, |
433 | transports) { | 444 | transports) { |
@@ -491,14 +502,15 @@ static const struct seq_operations sctp_remaddr_ops = { | |||
491 | }; | 502 | }; |
492 | 503 | ||
493 | /* Cleanup the proc fs entry for 'remaddr' object. */ | 504 | /* Cleanup the proc fs entry for 'remaddr' object. */ |
494 | void sctp_remaddr_proc_exit(void) | 505 | void sctp_remaddr_proc_exit(struct net *net) |
495 | { | 506 | { |
496 | remove_proc_entry("remaddr", proc_net_sctp); | 507 | remove_proc_entry("remaddr", net->sctp.proc_net_sctp); |
497 | } | 508 | } |
498 | 509 | ||
499 | static int sctp_remaddr_seq_open(struct inode *inode, struct file *file) | 510 | static int sctp_remaddr_seq_open(struct inode *inode, struct file *file) |
500 | { | 511 | { |
501 | return seq_open(file, &sctp_remaddr_ops); | 512 | return seq_open_net(inode, file, &sctp_remaddr_ops, |
513 | sizeof(struct seq_net_private)); | ||
502 | } | 514 | } |
503 | 515 | ||
504 | static const struct file_operations sctp_remaddr_seq_fops = { | 516 | static const struct file_operations sctp_remaddr_seq_fops = { |
@@ -508,11 +520,12 @@ static const struct file_operations sctp_remaddr_seq_fops = { | |||
508 | .release = seq_release, | 520 | .release = seq_release, |
509 | }; | 521 | }; |
510 | 522 | ||
511 | int __init sctp_remaddr_proc_init(void) | 523 | int __net_init sctp_remaddr_proc_init(struct net *net) |
512 | { | 524 | { |
513 | struct proc_dir_entry *p; | 525 | struct proc_dir_entry *p; |
514 | 526 | ||
515 | p = proc_create("remaddr", S_IRUGO, proc_net_sctp, &sctp_remaddr_seq_fops); | 527 | p = proc_create("remaddr", S_IRUGO, net->sctp.proc_net_sctp, |
528 | &sctp_remaddr_seq_fops); | ||
516 | if (!p) | 529 | if (!p) |
517 | return -ENOMEM; | 530 | return -ENOMEM; |
518 | return 0; | 531 | return 0; |
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 | ||
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 479a70ef6ff8..fbe1636309a7 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -198,6 +198,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | |||
198 | const struct sctp_bind_addr *bp, | 198 | const struct sctp_bind_addr *bp, |
199 | gfp_t gfp, int vparam_len) | 199 | gfp_t gfp, int vparam_len) |
200 | { | 200 | { |
201 | struct net *net = sock_net(asoc->base.sk); | ||
201 | sctp_inithdr_t init; | 202 | sctp_inithdr_t init; |
202 | union sctp_params addrs; | 203 | union sctp_params addrs; |
203 | size_t chunksize; | 204 | size_t chunksize; |
@@ -237,7 +238,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | |||
237 | chunksize += WORD_ROUND(SCTP_SAT_LEN(num_types)); | 238 | chunksize += WORD_ROUND(SCTP_SAT_LEN(num_types)); |
238 | chunksize += sizeof(ecap_param); | 239 | chunksize += sizeof(ecap_param); |
239 | 240 | ||
240 | if (sctp_prsctp_enable) | 241 | if (net->sctp.prsctp_enable) |
241 | chunksize += sizeof(prsctp_param); | 242 | chunksize += sizeof(prsctp_param); |
242 | 243 | ||
243 | /* ADDIP: Section 4.2.7: | 244 | /* ADDIP: Section 4.2.7: |
@@ -245,7 +246,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | |||
245 | * the ASCONF,the ASCONF-ACK, and the AUTH chunks in its INIT and | 246 | * the ASCONF,the ASCONF-ACK, and the AUTH chunks in its INIT and |
246 | * INIT-ACK parameters. | 247 | * INIT-ACK parameters. |
247 | */ | 248 | */ |
248 | if (sctp_addip_enable) { | 249 | if (net->sctp.addip_enable) { |
249 | extensions[num_ext] = SCTP_CID_ASCONF; | 250 | extensions[num_ext] = SCTP_CID_ASCONF; |
250 | extensions[num_ext+1] = SCTP_CID_ASCONF_ACK; | 251 | extensions[num_ext+1] = SCTP_CID_ASCONF_ACK; |
251 | num_ext += 2; | 252 | num_ext += 2; |
@@ -257,7 +258,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | |||
257 | chunksize += vparam_len; | 258 | chunksize += vparam_len; |
258 | 259 | ||
259 | /* Account for AUTH related parameters */ | 260 | /* Account for AUTH related parameters */ |
260 | if (sctp_auth_enable) { | 261 | if (net->sctp.auth_enable) { |
261 | /* Add random parameter length*/ | 262 | /* Add random parameter length*/ |
262 | chunksize += sizeof(asoc->c.auth_random); | 263 | chunksize += sizeof(asoc->c.auth_random); |
263 | 264 | ||
@@ -331,7 +332,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | |||
331 | sctp_addto_param(retval, num_ext, extensions); | 332 | sctp_addto_param(retval, num_ext, extensions); |
332 | } | 333 | } |
333 | 334 | ||
334 | if (sctp_prsctp_enable) | 335 | if (net->sctp.prsctp_enable) |
335 | sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); | 336 | sctp_addto_chunk(retval, sizeof(prsctp_param), &prsctp_param); |
336 | 337 | ||
337 | if (sp->adaptation_ind) { | 338 | if (sp->adaptation_ind) { |
@@ -342,7 +343,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | |||
342 | } | 343 | } |
343 | 344 | ||
344 | /* Add SCTP-AUTH chunks to the parameter list */ | 345 | /* Add SCTP-AUTH chunks to the parameter list */ |
345 | if (sctp_auth_enable) { | 346 | if (net->sctp.auth_enable) { |
346 | sctp_addto_chunk(retval, sizeof(asoc->c.auth_random), | 347 | sctp_addto_chunk(retval, sizeof(asoc->c.auth_random), |
347 | asoc->c.auth_random); | 348 | asoc->c.auth_random); |
348 | if (auth_hmacs) | 349 | if (auth_hmacs) |
@@ -1940,7 +1941,7 @@ static int sctp_process_hn_param(const struct sctp_association *asoc, | |||
1940 | return 0; | 1941 | return 0; |
1941 | } | 1942 | } |
1942 | 1943 | ||
1943 | static int sctp_verify_ext_param(union sctp_params param) | 1944 | static int sctp_verify_ext_param(struct net *net, union sctp_params param) |
1944 | { | 1945 | { |
1945 | __u16 num_ext = ntohs(param.p->length) - sizeof(sctp_paramhdr_t); | 1946 | __u16 num_ext = ntohs(param.p->length) - sizeof(sctp_paramhdr_t); |
1946 | int have_auth = 0; | 1947 | int have_auth = 0; |
@@ -1964,10 +1965,10 @@ static int sctp_verify_ext_param(union sctp_params param) | |||
1964 | * only if ADD-IP is turned on and we are not backward-compatible | 1965 | * only if ADD-IP is turned on and we are not backward-compatible |
1965 | * mode. | 1966 | * mode. |
1966 | */ | 1967 | */ |
1967 | if (sctp_addip_noauth) | 1968 | if (net->sctp.addip_noauth) |
1968 | return 1; | 1969 | return 1; |
1969 | 1970 | ||
1970 | if (sctp_addip_enable && !have_auth && have_asconf) | 1971 | if (net->sctp.addip_enable && !have_auth && have_asconf) |
1971 | return 0; | 1972 | return 0; |
1972 | 1973 | ||
1973 | return 1; | 1974 | return 1; |
@@ -1976,13 +1977,14 @@ static int sctp_verify_ext_param(union sctp_params param) | |||
1976 | static void sctp_process_ext_param(struct sctp_association *asoc, | 1977 | static void sctp_process_ext_param(struct sctp_association *asoc, |
1977 | union sctp_params param) | 1978 | union sctp_params param) |
1978 | { | 1979 | { |
1980 | struct net *net = sock_net(asoc->base.sk); | ||
1979 | __u16 num_ext = ntohs(param.p->length) - sizeof(sctp_paramhdr_t); | 1981 | __u16 num_ext = ntohs(param.p->length) - sizeof(sctp_paramhdr_t); |
1980 | int i; | 1982 | int i; |
1981 | 1983 | ||
1982 | for (i = 0; i < num_ext; i++) { | 1984 | for (i = 0; i < num_ext; i++) { |
1983 | switch (param.ext->chunks[i]) { | 1985 | switch (param.ext->chunks[i]) { |
1984 | case SCTP_CID_FWD_TSN: | 1986 | case SCTP_CID_FWD_TSN: |
1985 | if (sctp_prsctp_enable && | 1987 | if (net->sctp.prsctp_enable && |
1986 | !asoc->peer.prsctp_capable) | 1988 | !asoc->peer.prsctp_capable) |
1987 | asoc->peer.prsctp_capable = 1; | 1989 | asoc->peer.prsctp_capable = 1; |
1988 | break; | 1990 | break; |
@@ -1990,12 +1992,12 @@ static void sctp_process_ext_param(struct sctp_association *asoc, | |||
1990 | /* if the peer reports AUTH, assume that he | 1992 | /* if the peer reports AUTH, assume that he |
1991 | * supports AUTH. | 1993 | * supports AUTH. |
1992 | */ | 1994 | */ |
1993 | if (sctp_auth_enable) | 1995 | if (net->sctp.auth_enable) |
1994 | asoc->peer.auth_capable = 1; | 1996 | asoc->peer.auth_capable = 1; |
1995 | break; | 1997 | break; |
1996 | case SCTP_CID_ASCONF: | 1998 | case SCTP_CID_ASCONF: |
1997 | case SCTP_CID_ASCONF_ACK: | 1999 | case SCTP_CID_ASCONF_ACK: |
1998 | if (sctp_addip_enable) | 2000 | if (net->sctp.addip_enable) |
1999 | asoc->peer.asconf_capable = 1; | 2001 | asoc->peer.asconf_capable = 1; |
2000 | break; | 2002 | break; |
2001 | default: | 2003 | default: |
@@ -2081,7 +2083,8 @@ static sctp_ierror_t sctp_process_unk_param(const struct sctp_association *asoc, | |||
2081 | * SCTP_IERROR_ERROR - stop processing, trigger an ERROR | 2083 | * SCTP_IERROR_ERROR - stop processing, trigger an ERROR |
2082 | * SCTP_IERROR_NO_ERROR - continue with the chunk | 2084 | * SCTP_IERROR_NO_ERROR - continue with the chunk |
2083 | */ | 2085 | */ |
2084 | static sctp_ierror_t sctp_verify_param(const struct sctp_association *asoc, | 2086 | static sctp_ierror_t sctp_verify_param(struct net *net, |
2087 | const struct sctp_association *asoc, | ||
2085 | union sctp_params param, | 2088 | union sctp_params param, |
2086 | sctp_cid_t cid, | 2089 | sctp_cid_t cid, |
2087 | struct sctp_chunk *chunk, | 2090 | struct sctp_chunk *chunk, |
@@ -2110,12 +2113,12 @@ static sctp_ierror_t sctp_verify_param(const struct sctp_association *asoc, | |||
2110 | break; | 2113 | break; |
2111 | 2114 | ||
2112 | case SCTP_PARAM_SUPPORTED_EXT: | 2115 | case SCTP_PARAM_SUPPORTED_EXT: |
2113 | if (!sctp_verify_ext_param(param)) | 2116 | if (!sctp_verify_ext_param(net, param)) |
2114 | return SCTP_IERROR_ABORT; | 2117 | return SCTP_IERROR_ABORT; |
2115 | break; | 2118 | break; |
2116 | 2119 | ||
2117 | case SCTP_PARAM_SET_PRIMARY: | 2120 | case SCTP_PARAM_SET_PRIMARY: |
2118 | if (sctp_addip_enable) | 2121 | if (net->sctp.addip_enable) |
2119 | break; | 2122 | break; |
2120 | goto fallthrough; | 2123 | goto fallthrough; |
2121 | 2124 | ||
@@ -2126,12 +2129,12 @@ static sctp_ierror_t sctp_verify_param(const struct sctp_association *asoc, | |||
2126 | break; | 2129 | break; |
2127 | 2130 | ||
2128 | case SCTP_PARAM_FWD_TSN_SUPPORT: | 2131 | case SCTP_PARAM_FWD_TSN_SUPPORT: |
2129 | if (sctp_prsctp_enable) | 2132 | if (net->sctp.prsctp_enable) |
2130 | break; | 2133 | break; |
2131 | goto fallthrough; | 2134 | goto fallthrough; |
2132 | 2135 | ||
2133 | case SCTP_PARAM_RANDOM: | 2136 | case SCTP_PARAM_RANDOM: |
2134 | if (!sctp_auth_enable) | 2137 | if (!net->sctp.auth_enable) |
2135 | goto fallthrough; | 2138 | goto fallthrough; |
2136 | 2139 | ||
2137 | /* SCTP-AUTH: Secion 6.1 | 2140 | /* SCTP-AUTH: Secion 6.1 |
@@ -2148,7 +2151,7 @@ static sctp_ierror_t sctp_verify_param(const struct sctp_association *asoc, | |||
2148 | break; | 2151 | break; |
2149 | 2152 | ||
2150 | case SCTP_PARAM_CHUNKS: | 2153 | case SCTP_PARAM_CHUNKS: |
2151 | if (!sctp_auth_enable) | 2154 | if (!net->sctp.auth_enable) |
2152 | goto fallthrough; | 2155 | goto fallthrough; |
2153 | 2156 | ||
2154 | /* SCTP-AUTH: Section 3.2 | 2157 | /* SCTP-AUTH: Section 3.2 |
@@ -2164,7 +2167,7 @@ static sctp_ierror_t sctp_verify_param(const struct sctp_association *asoc, | |||
2164 | break; | 2167 | break; |
2165 | 2168 | ||
2166 | case SCTP_PARAM_HMAC_ALGO: | 2169 | case SCTP_PARAM_HMAC_ALGO: |
2167 | if (!sctp_auth_enable) | 2170 | if (!net->sctp.auth_enable) |
2168 | goto fallthrough; | 2171 | goto fallthrough; |
2169 | 2172 | ||
2170 | hmacs = (struct sctp_hmac_algo_param *)param.p; | 2173 | hmacs = (struct sctp_hmac_algo_param *)param.p; |
@@ -2198,7 +2201,7 @@ fallthrough: | |||
2198 | } | 2201 | } |
2199 | 2202 | ||
2200 | /* Verify the INIT packet before we process it. */ | 2203 | /* Verify the INIT packet before we process it. */ |
2201 | int sctp_verify_init(const struct sctp_association *asoc, | 2204 | int sctp_verify_init(struct net *net, const struct sctp_association *asoc, |
2202 | sctp_cid_t cid, | 2205 | sctp_cid_t cid, |
2203 | sctp_init_chunk_t *peer_init, | 2206 | sctp_init_chunk_t *peer_init, |
2204 | struct sctp_chunk *chunk, | 2207 | struct sctp_chunk *chunk, |
@@ -2245,7 +2248,7 @@ int sctp_verify_init(const struct sctp_association *asoc, | |||
2245 | /* Verify all the variable length parameters */ | 2248 | /* Verify all the variable length parameters */ |
2246 | sctp_walk_params(param, peer_init, init_hdr.params) { | 2249 | sctp_walk_params(param, peer_init, init_hdr.params) { |
2247 | 2250 | ||
2248 | result = sctp_verify_param(asoc, param, cid, chunk, errp); | 2251 | result = sctp_verify_param(net, asoc, param, cid, chunk, errp); |
2249 | switch (result) { | 2252 | switch (result) { |
2250 | case SCTP_IERROR_ABORT: | 2253 | case SCTP_IERROR_ABORT: |
2251 | case SCTP_IERROR_NOMEM: | 2254 | case SCTP_IERROR_NOMEM: |
@@ -2270,6 +2273,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, | |||
2270 | const union sctp_addr *peer_addr, | 2273 | const union sctp_addr *peer_addr, |
2271 | sctp_init_chunk_t *peer_init, gfp_t gfp) | 2274 | sctp_init_chunk_t *peer_init, gfp_t gfp) |
2272 | { | 2275 | { |
2276 | struct net *net = sock_net(asoc->base.sk); | ||
2273 | union sctp_params param; | 2277 | union sctp_params param; |
2274 | struct sctp_transport *transport; | 2278 | struct sctp_transport *transport; |
2275 | struct list_head *pos, *temp; | 2279 | struct list_head *pos, *temp; |
@@ -2326,7 +2330,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, | |||
2326 | * also give us an option to silently ignore the packet, which | 2330 | * also give us an option to silently ignore the packet, which |
2327 | * is what we'll do here. | 2331 | * is what we'll do here. |
2328 | */ | 2332 | */ |
2329 | if (!sctp_addip_noauth && | 2333 | if (!net->sctp.addip_noauth && |
2330 | (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) { | 2334 | (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) { |
2331 | asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP | | 2335 | asoc->peer.addip_disabled_mask |= (SCTP_PARAM_ADD_IP | |
2332 | SCTP_PARAM_DEL_IP | | 2336 | SCTP_PARAM_DEL_IP | |
@@ -2466,6 +2470,7 @@ static int sctp_process_param(struct sctp_association *asoc, | |||
2466 | const union sctp_addr *peer_addr, | 2470 | const union sctp_addr *peer_addr, |
2467 | gfp_t gfp) | 2471 | gfp_t gfp) |
2468 | { | 2472 | { |
2473 | struct net *net = sock_net(asoc->base.sk); | ||
2469 | union sctp_addr addr; | 2474 | union sctp_addr addr; |
2470 | int i; | 2475 | int i; |
2471 | __u16 sat; | 2476 | __u16 sat; |
@@ -2494,13 +2499,13 @@ do_addr_param: | |||
2494 | af = sctp_get_af_specific(param_type2af(param.p->type)); | 2499 | af = sctp_get_af_specific(param_type2af(param.p->type)); |
2495 | af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0); | 2500 | af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0); |
2496 | scope = sctp_scope(peer_addr); | 2501 | scope = sctp_scope(peer_addr); |
2497 | if (sctp_in_scope(&addr, scope)) | 2502 | if (sctp_in_scope(net, &addr, scope)) |
2498 | if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED)) | 2503 | if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED)) |
2499 | return 0; | 2504 | return 0; |
2500 | break; | 2505 | break; |
2501 | 2506 | ||
2502 | case SCTP_PARAM_COOKIE_PRESERVATIVE: | 2507 | case SCTP_PARAM_COOKIE_PRESERVATIVE: |
2503 | if (!sctp_cookie_preserve_enable) | 2508 | if (!net->sctp.cookie_preserve_enable) |
2504 | break; | 2509 | break; |
2505 | 2510 | ||
2506 | stale = ntohl(param.life->lifespan_increment); | 2511 | stale = ntohl(param.life->lifespan_increment); |
@@ -2580,7 +2585,7 @@ do_addr_param: | |||
2580 | break; | 2585 | break; |
2581 | 2586 | ||
2582 | case SCTP_PARAM_SET_PRIMARY: | 2587 | case SCTP_PARAM_SET_PRIMARY: |
2583 | if (!sctp_addip_enable) | 2588 | if (!net->sctp.addip_enable) |
2584 | goto fall_through; | 2589 | goto fall_through; |
2585 | 2590 | ||
2586 | addr_param = param.v + sizeof(sctp_addip_param_t); | 2591 | addr_param = param.v + sizeof(sctp_addip_param_t); |
@@ -2607,7 +2612,7 @@ do_addr_param: | |||
2607 | break; | 2612 | break; |
2608 | 2613 | ||
2609 | case SCTP_PARAM_FWD_TSN_SUPPORT: | 2614 | case SCTP_PARAM_FWD_TSN_SUPPORT: |
2610 | if (sctp_prsctp_enable) { | 2615 | if (net->sctp.prsctp_enable) { |
2611 | asoc->peer.prsctp_capable = 1; | 2616 | asoc->peer.prsctp_capable = 1; |
2612 | break; | 2617 | break; |
2613 | } | 2618 | } |
@@ -2615,7 +2620,7 @@ do_addr_param: | |||
2615 | goto fall_through; | 2620 | goto fall_through; |
2616 | 2621 | ||
2617 | case SCTP_PARAM_RANDOM: | 2622 | case SCTP_PARAM_RANDOM: |
2618 | if (!sctp_auth_enable) | 2623 | if (!net->sctp.auth_enable) |
2619 | goto fall_through; | 2624 | goto fall_through; |
2620 | 2625 | ||
2621 | /* Save peer's random parameter */ | 2626 | /* Save peer's random parameter */ |
@@ -2628,7 +2633,7 @@ do_addr_param: | |||
2628 | break; | 2633 | break; |
2629 | 2634 | ||
2630 | case SCTP_PARAM_HMAC_ALGO: | 2635 | case SCTP_PARAM_HMAC_ALGO: |
2631 | if (!sctp_auth_enable) | 2636 | if (!net->sctp.auth_enable) |
2632 | goto fall_through; | 2637 | goto fall_through; |
2633 | 2638 | ||
2634 | /* Save peer's HMAC list */ | 2639 | /* Save peer's HMAC list */ |
@@ -2644,7 +2649,7 @@ do_addr_param: | |||
2644 | break; | 2649 | break; |
2645 | 2650 | ||
2646 | case SCTP_PARAM_CHUNKS: | 2651 | case SCTP_PARAM_CHUNKS: |
2647 | if (!sctp_auth_enable) | 2652 | if (!net->sctp.auth_enable) |
2648 | goto fall_through; | 2653 | goto fall_through; |
2649 | 2654 | ||
2650 | asoc->peer.peer_chunks = kmemdup(param.p, | 2655 | asoc->peer.peer_chunks = kmemdup(param.p, |
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index fe99628e1257..bcfebb91559d 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c | |||
@@ -251,6 +251,7 @@ void sctp_generate_t3_rtx_event(unsigned long peer) | |||
251 | int error; | 251 | int error; |
252 | struct sctp_transport *transport = (struct sctp_transport *) peer; | 252 | struct sctp_transport *transport = (struct sctp_transport *) peer; |
253 | struct sctp_association *asoc = transport->asoc; | 253 | struct sctp_association *asoc = transport->asoc; |
254 | struct net *net = sock_net(asoc->base.sk); | ||
254 | 255 | ||
255 | /* Check whether a task is in the sock. */ | 256 | /* Check whether a task is in the sock. */ |
256 | 257 | ||
@@ -271,7 +272,7 @@ void sctp_generate_t3_rtx_event(unsigned long peer) | |||
271 | goto out_unlock; | 272 | goto out_unlock; |
272 | 273 | ||
273 | /* Run through the state machine. */ | 274 | /* Run through the state machine. */ |
274 | error = sctp_do_sm(SCTP_EVENT_T_TIMEOUT, | 275 | error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT, |
275 | SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX), | 276 | SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_T3_RTX), |
276 | asoc->state, | 277 | asoc->state, |
277 | asoc->ep, asoc, | 278 | asoc->ep, asoc, |
@@ -291,6 +292,7 @@ out_unlock: | |||
291 | static void sctp_generate_timeout_event(struct sctp_association *asoc, | 292 | static void sctp_generate_timeout_event(struct sctp_association *asoc, |
292 | sctp_event_timeout_t timeout_type) | 293 | sctp_event_timeout_t timeout_type) |
293 | { | 294 | { |
295 | struct net *net = sock_net(asoc->base.sk); | ||
294 | int error = 0; | 296 | int error = 0; |
295 | 297 | ||
296 | sctp_bh_lock_sock(asoc->base.sk); | 298 | sctp_bh_lock_sock(asoc->base.sk); |
@@ -312,7 +314,7 @@ static void sctp_generate_timeout_event(struct sctp_association *asoc, | |||
312 | goto out_unlock; | 314 | goto out_unlock; |
313 | 315 | ||
314 | /* Run through the state machine. */ | 316 | /* Run through the state machine. */ |
315 | error = sctp_do_sm(SCTP_EVENT_T_TIMEOUT, | 317 | error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT, |
316 | SCTP_ST_TIMEOUT(timeout_type), | 318 | SCTP_ST_TIMEOUT(timeout_type), |
317 | asoc->state, asoc->ep, asoc, | 319 | asoc->state, asoc->ep, asoc, |
318 | (void *)timeout_type, GFP_ATOMIC); | 320 | (void *)timeout_type, GFP_ATOMIC); |
@@ -371,6 +373,7 @@ void sctp_generate_heartbeat_event(unsigned long data) | |||
371 | int error = 0; | 373 | int error = 0; |
372 | struct sctp_transport *transport = (struct sctp_transport *) data; | 374 | struct sctp_transport *transport = (struct sctp_transport *) data; |
373 | struct sctp_association *asoc = transport->asoc; | 375 | struct sctp_association *asoc = transport->asoc; |
376 | struct net *net = sock_net(asoc->base.sk); | ||
374 | 377 | ||
375 | sctp_bh_lock_sock(asoc->base.sk); | 378 | sctp_bh_lock_sock(asoc->base.sk); |
376 | if (sock_owned_by_user(asoc->base.sk)) { | 379 | if (sock_owned_by_user(asoc->base.sk)) { |
@@ -388,7 +391,7 @@ void sctp_generate_heartbeat_event(unsigned long data) | |||
388 | if (transport->dead) | 391 | if (transport->dead) |
389 | goto out_unlock; | 392 | goto out_unlock; |
390 | 393 | ||
391 | error = sctp_do_sm(SCTP_EVENT_T_TIMEOUT, | 394 | error = sctp_do_sm(net, SCTP_EVENT_T_TIMEOUT, |
392 | SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_HEARTBEAT), | 395 | SCTP_ST_TIMEOUT(SCTP_EVENT_TIMEOUT_HEARTBEAT), |
393 | asoc->state, asoc->ep, asoc, | 396 | asoc->state, asoc->ep, asoc, |
394 | transport, GFP_ATOMIC); | 397 | transport, GFP_ATOMIC); |
@@ -408,6 +411,7 @@ void sctp_generate_proto_unreach_event(unsigned long data) | |||
408 | { | 411 | { |
409 | struct sctp_transport *transport = (struct sctp_transport *) data; | 412 | struct sctp_transport *transport = (struct sctp_transport *) data; |
410 | struct sctp_association *asoc = transport->asoc; | 413 | struct sctp_association *asoc = transport->asoc; |
414 | struct net *net = sock_net(asoc->base.sk); | ||
411 | 415 | ||
412 | sctp_bh_lock_sock(asoc->base.sk); | 416 | sctp_bh_lock_sock(asoc->base.sk); |
413 | if (sock_owned_by_user(asoc->base.sk)) { | 417 | if (sock_owned_by_user(asoc->base.sk)) { |
@@ -426,7 +430,7 @@ void sctp_generate_proto_unreach_event(unsigned long data) | |||
426 | if (asoc->base.dead) | 430 | if (asoc->base.dead) |
427 | goto out_unlock; | 431 | goto out_unlock; |
428 | 432 | ||
429 | sctp_do_sm(SCTP_EVENT_T_OTHER, | 433 | sctp_do_sm(net, SCTP_EVENT_T_OTHER, |
430 | SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH), | 434 | SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH), |
431 | asoc->state, asoc->ep, asoc, transport, GFP_ATOMIC); | 435 | asoc->state, asoc->ep, asoc, transport, GFP_ATOMIC); |
432 | 436 | ||
@@ -753,8 +757,10 @@ static int sctp_cmd_process_sack(sctp_cmd_seq_t *cmds, | |||
753 | int err = 0; | 757 | int err = 0; |
754 | 758 | ||
755 | if (sctp_outq_sack(&asoc->outqueue, sackh)) { | 759 | if (sctp_outq_sack(&asoc->outqueue, sackh)) { |
760 | struct net *net = sock_net(asoc->base.sk); | ||
761 | |||
756 | /* There are no more TSNs awaiting SACK. */ | 762 | /* There are no more TSNs awaiting SACK. */ |
757 | err = sctp_do_sm(SCTP_EVENT_T_OTHER, | 763 | err = sctp_do_sm(net, SCTP_EVENT_T_OTHER, |
758 | SCTP_ST_OTHER(SCTP_EVENT_NO_PENDING_TSN), | 764 | SCTP_ST_OTHER(SCTP_EVENT_NO_PENDING_TSN), |
759 | asoc->state, asoc->ep, asoc, NULL, | 765 | asoc->state, asoc->ep, asoc, NULL, |
760 | GFP_ATOMIC); | 766 | GFP_ATOMIC); |
@@ -1042,6 +1048,8 @@ static int sctp_cmd_send_msg(struct sctp_association *asoc, | |||
1042 | */ | 1048 | */ |
1043 | static void sctp_cmd_send_asconf(struct sctp_association *asoc) | 1049 | static void sctp_cmd_send_asconf(struct sctp_association *asoc) |
1044 | { | 1050 | { |
1051 | struct net *net = sock_net(asoc->base.sk); | ||
1052 | |||
1045 | /* Send the next asconf chunk from the addip chunk | 1053 | /* Send the next asconf chunk from the addip chunk |
1046 | * queue. | 1054 | * queue. |
1047 | */ | 1055 | */ |
@@ -1053,7 +1061,7 @@ static void sctp_cmd_send_asconf(struct sctp_association *asoc) | |||
1053 | 1061 | ||
1054 | /* Hold the chunk until an ASCONF_ACK is received. */ | 1062 | /* Hold the chunk until an ASCONF_ACK is received. */ |
1055 | sctp_chunk_hold(asconf); | 1063 | sctp_chunk_hold(asconf); |
1056 | if (sctp_primitive_ASCONF(asoc, asconf)) | 1064 | if (sctp_primitive_ASCONF(net, asoc, asconf)) |
1057 | sctp_chunk_free(asconf); | 1065 | sctp_chunk_free(asconf); |
1058 | else | 1066 | else |
1059 | asoc->addip_last_asconf = asconf; | 1067 | asoc->addip_last_asconf = asconf; |
@@ -1089,7 +1097,7 @@ static void sctp_cmd_send_asconf(struct sctp_association *asoc) | |||
1089 | * If you want to understand all of lksctp, this is a | 1097 | * If you want to understand all of lksctp, this is a |
1090 | * good place to start. | 1098 | * good place to start. |
1091 | */ | 1099 | */ |
1092 | int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype, | 1100 | int sctp_do_sm(struct net *net, sctp_event_t event_type, sctp_subtype_t subtype, |
1093 | sctp_state_t state, | 1101 | sctp_state_t state, |
1094 | struct sctp_endpoint *ep, | 1102 | struct sctp_endpoint *ep, |
1095 | struct sctp_association *asoc, | 1103 | struct sctp_association *asoc, |
@@ -1110,12 +1118,12 @@ int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype, | |||
1110 | /* Look up the state function, run it, and then process the | 1118 | /* Look up the state function, run it, and then process the |
1111 | * side effects. These three steps are the heart of lksctp. | 1119 | * side effects. These three steps are the heart of lksctp. |
1112 | */ | 1120 | */ |
1113 | state_fn = sctp_sm_lookup_event(event_type, state, subtype); | 1121 | state_fn = sctp_sm_lookup_event(net, event_type, state, subtype); |
1114 | 1122 | ||
1115 | sctp_init_cmd_seq(&commands); | 1123 | sctp_init_cmd_seq(&commands); |
1116 | 1124 | ||
1117 | DEBUG_PRE; | 1125 | DEBUG_PRE; |
1118 | status = (*state_fn->fn)(ep, asoc, subtype, event_arg, &commands); | 1126 | status = (*state_fn->fn)(net, ep, asoc, subtype, event_arg, &commands); |
1119 | DEBUG_POST; | 1127 | DEBUG_POST; |
1120 | 1128 | ||
1121 | error = sctp_side_effects(event_type, subtype, state, | 1129 | error = sctp_side_effects(event_type, subtype, state, |
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 9fca10357350..094813b6c3c3 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
@@ -66,7 +66,8 @@ | |||
66 | #include <net/sctp/sm.h> | 66 | #include <net/sctp/sm.h> |
67 | #include <net/sctp/structs.h> | 67 | #include <net/sctp/structs.h> |
68 | 68 | ||
69 | static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | 69 | static struct sctp_packet *sctp_abort_pkt_new(struct net *net, |
70 | const struct sctp_endpoint *ep, | ||
70 | const struct sctp_association *asoc, | 71 | const struct sctp_association *asoc, |
71 | struct sctp_chunk *chunk, | 72 | struct sctp_chunk *chunk, |
72 | const void *payload, | 73 | const void *payload, |
@@ -74,36 +75,43 @@ static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | |||
74 | static int sctp_eat_data(const struct sctp_association *asoc, | 75 | static int sctp_eat_data(const struct sctp_association *asoc, |
75 | struct sctp_chunk *chunk, | 76 | struct sctp_chunk *chunk, |
76 | sctp_cmd_seq_t *commands); | 77 | sctp_cmd_seq_t *commands); |
77 | static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc, | 78 | static struct sctp_packet *sctp_ootb_pkt_new(struct net *net, |
79 | const struct sctp_association *asoc, | ||
78 | const struct sctp_chunk *chunk); | 80 | const struct sctp_chunk *chunk); |
79 | static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, | 81 | static void sctp_send_stale_cookie_err(struct net *net, |
82 | const struct sctp_endpoint *ep, | ||
80 | const struct sctp_association *asoc, | 83 | const struct sctp_association *asoc, |
81 | const struct sctp_chunk *chunk, | 84 | const struct sctp_chunk *chunk, |
82 | sctp_cmd_seq_t *commands, | 85 | sctp_cmd_seq_t *commands, |
83 | struct sctp_chunk *err_chunk); | 86 | struct sctp_chunk *err_chunk); |
84 | static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep, | 87 | static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net, |
88 | const struct sctp_endpoint *ep, | ||
85 | const struct sctp_association *asoc, | 89 | const struct sctp_association *asoc, |
86 | const sctp_subtype_t type, | 90 | const sctp_subtype_t type, |
87 | void *arg, | 91 | void *arg, |
88 | sctp_cmd_seq_t *commands); | 92 | sctp_cmd_seq_t *commands); |
89 | static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | 93 | static sctp_disposition_t sctp_sf_shut_8_4_5(struct net *net, |
94 | const struct sctp_endpoint *ep, | ||
90 | const struct sctp_association *asoc, | 95 | const struct sctp_association *asoc, |
91 | const sctp_subtype_t type, | 96 | const sctp_subtype_t type, |
92 | void *arg, | 97 | void *arg, |
93 | sctp_cmd_seq_t *commands); | 98 | sctp_cmd_seq_t *commands); |
94 | static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | 99 | static sctp_disposition_t sctp_sf_tabort_8_4_8(struct net *net, |
100 | const struct sctp_endpoint *ep, | ||
95 | const struct sctp_association *asoc, | 101 | const struct sctp_association *asoc, |
96 | const sctp_subtype_t type, | 102 | const sctp_subtype_t type, |
97 | void *arg, | 103 | void *arg, |
98 | sctp_cmd_seq_t *commands); | 104 | sctp_cmd_seq_t *commands); |
99 | static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk); | 105 | static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk); |
100 | 106 | ||
101 | static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, | 107 | static sctp_disposition_t sctp_stop_t1_and_abort(struct net *net, |
108 | sctp_cmd_seq_t *commands, | ||
102 | __be16 error, int sk_err, | 109 | __be16 error, int sk_err, |
103 | const struct sctp_association *asoc, | 110 | const struct sctp_association *asoc, |
104 | struct sctp_transport *transport); | 111 | struct sctp_transport *transport); |
105 | 112 | ||
106 | static sctp_disposition_t sctp_sf_abort_violation( | 113 | static sctp_disposition_t sctp_sf_abort_violation( |
114 | struct net *net, | ||
107 | const struct sctp_endpoint *ep, | 115 | const struct sctp_endpoint *ep, |
108 | const struct sctp_association *asoc, | 116 | const struct sctp_association *asoc, |
109 | void *arg, | 117 | void *arg, |
@@ -112,6 +120,7 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
112 | const size_t paylen); | 120 | const size_t paylen); |
113 | 121 | ||
114 | static sctp_disposition_t sctp_sf_violation_chunklen( | 122 | static sctp_disposition_t sctp_sf_violation_chunklen( |
123 | struct net *net, | ||
115 | const struct sctp_endpoint *ep, | 124 | const struct sctp_endpoint *ep, |
116 | const struct sctp_association *asoc, | 125 | const struct sctp_association *asoc, |
117 | const sctp_subtype_t type, | 126 | const sctp_subtype_t type, |
@@ -119,6 +128,7 @@ static sctp_disposition_t sctp_sf_violation_chunklen( | |||
119 | sctp_cmd_seq_t *commands); | 128 | sctp_cmd_seq_t *commands); |
120 | 129 | ||
121 | static sctp_disposition_t sctp_sf_violation_paramlen( | 130 | static sctp_disposition_t sctp_sf_violation_paramlen( |
131 | struct net *net, | ||
122 | const struct sctp_endpoint *ep, | 132 | const struct sctp_endpoint *ep, |
123 | const struct sctp_association *asoc, | 133 | const struct sctp_association *asoc, |
124 | const sctp_subtype_t type, | 134 | const sctp_subtype_t type, |
@@ -126,6 +136,7 @@ static sctp_disposition_t sctp_sf_violation_paramlen( | |||
126 | sctp_cmd_seq_t *commands); | 136 | sctp_cmd_seq_t *commands); |
127 | 137 | ||
128 | static sctp_disposition_t sctp_sf_violation_ctsn( | 138 | static sctp_disposition_t sctp_sf_violation_ctsn( |
139 | struct net *net, | ||
129 | const struct sctp_endpoint *ep, | 140 | const struct sctp_endpoint *ep, |
130 | const struct sctp_association *asoc, | 141 | const struct sctp_association *asoc, |
131 | const sctp_subtype_t type, | 142 | const sctp_subtype_t type, |
@@ -133,18 +144,21 @@ static sctp_disposition_t sctp_sf_violation_ctsn( | |||
133 | sctp_cmd_seq_t *commands); | 144 | sctp_cmd_seq_t *commands); |
134 | 145 | ||
135 | static sctp_disposition_t sctp_sf_violation_chunk( | 146 | static sctp_disposition_t sctp_sf_violation_chunk( |
147 | struct net *net, | ||
136 | const struct sctp_endpoint *ep, | 148 | const struct sctp_endpoint *ep, |
137 | const struct sctp_association *asoc, | 149 | const struct sctp_association *asoc, |
138 | const sctp_subtype_t type, | 150 | const sctp_subtype_t type, |
139 | void *arg, | 151 | void *arg, |
140 | sctp_cmd_seq_t *commands); | 152 | sctp_cmd_seq_t *commands); |
141 | 153 | ||
142 | static sctp_ierror_t sctp_sf_authenticate(const struct sctp_endpoint *ep, | 154 | static sctp_ierror_t sctp_sf_authenticate(struct net *net, |
155 | const struct sctp_endpoint *ep, | ||
143 | const struct sctp_association *asoc, | 156 | const struct sctp_association *asoc, |
144 | const sctp_subtype_t type, | 157 | const sctp_subtype_t type, |
145 | struct sctp_chunk *chunk); | 158 | struct sctp_chunk *chunk); |
146 | 159 | ||
147 | static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | 160 | static sctp_disposition_t __sctp_sf_do_9_1_abort(struct net *net, |
161 | const struct sctp_endpoint *ep, | ||
148 | const struct sctp_association *asoc, | 162 | const struct sctp_association *asoc, |
149 | const sctp_subtype_t type, | 163 | const sctp_subtype_t type, |
150 | void *arg, | 164 | void *arg, |
@@ -204,7 +218,8 @@ sctp_chunk_length_valid(struct sctp_chunk *chunk, | |||
204 | * | 218 | * |
205 | * The return value is the disposition of the chunk. | 219 | * The return value is the disposition of the chunk. |
206 | */ | 220 | */ |
207 | sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | 221 | sctp_disposition_t sctp_sf_do_4_C(struct net *net, |
222 | const struct sctp_endpoint *ep, | ||
208 | const struct sctp_association *asoc, | 223 | const struct sctp_association *asoc, |
209 | const sctp_subtype_t type, | 224 | const sctp_subtype_t type, |
210 | void *arg, | 225 | void *arg, |
@@ -214,7 +229,7 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | |||
214 | struct sctp_ulpevent *ev; | 229 | struct sctp_ulpevent *ev; |
215 | 230 | ||
216 | if (!sctp_vtag_verify_either(chunk, asoc)) | 231 | if (!sctp_vtag_verify_either(chunk, asoc)) |
217 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 232 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
218 | 233 | ||
219 | /* RFC 2960 6.10 Bundling | 234 | /* RFC 2960 6.10 Bundling |
220 | * | 235 | * |
@@ -222,11 +237,11 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | |||
222 | * SHUTDOWN COMPLETE with any other chunks. | 237 | * SHUTDOWN COMPLETE with any other chunks. |
223 | */ | 238 | */ |
224 | if (!chunk->singleton) | 239 | if (!chunk->singleton) |
225 | return sctp_sf_violation_chunk(ep, asoc, type, arg, commands); | 240 | return sctp_sf_violation_chunk(net, ep, asoc, type, arg, commands); |
226 | 241 | ||
227 | /* Make sure that the SHUTDOWN_COMPLETE chunk has a valid length. */ | 242 | /* Make sure that the SHUTDOWN_COMPLETE chunk has a valid length. */ |
228 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 243 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
229 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 244 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
230 | commands); | 245 | commands); |
231 | 246 | ||
232 | /* RFC 2960 10.2 SCTP-to-ULP | 247 | /* RFC 2960 10.2 SCTP-to-ULP |
@@ -259,8 +274,8 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | |||
259 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 274 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
260 | SCTP_STATE(SCTP_STATE_CLOSED)); | 275 | SCTP_STATE(SCTP_STATE_CLOSED)); |
261 | 276 | ||
262 | SCTP_INC_STATS(SCTP_MIB_SHUTDOWNS); | 277 | SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS); |
263 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 278 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
264 | 279 | ||
265 | sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); | 280 | sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); |
266 | 281 | ||
@@ -289,7 +304,8 @@ sctp_disposition_t sctp_sf_do_4_C(const struct sctp_endpoint *ep, | |||
289 | * | 304 | * |
290 | * The return value is the disposition of the chunk. | 305 | * The return value is the disposition of the chunk. |
291 | */ | 306 | */ |
292 | sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | 307 | sctp_disposition_t sctp_sf_do_5_1B_init(struct net *net, |
308 | const struct sctp_endpoint *ep, | ||
293 | const struct sctp_association *asoc, | 309 | const struct sctp_association *asoc, |
294 | const sctp_subtype_t type, | 310 | const sctp_subtype_t type, |
295 | void *arg, | 311 | void *arg, |
@@ -313,21 +329,21 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
313 | * with an INIT chunk that is bundled with other chunks. | 329 | * with an INIT chunk that is bundled with other chunks. |
314 | */ | 330 | */ |
315 | if (!chunk->singleton) | 331 | if (!chunk->singleton) |
316 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 332 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
317 | 333 | ||
318 | /* If the packet is an OOTB packet which is temporarily on the | 334 | /* If the packet is an OOTB packet which is temporarily on the |
319 | * control endpoint, respond with an ABORT. | 335 | * control endpoint, respond with an ABORT. |
320 | */ | 336 | */ |
321 | if (ep == sctp_sk((sctp_get_ctl_sock()))->ep) { | 337 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { |
322 | SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); | 338 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); |
323 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 339 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
324 | } | 340 | } |
325 | 341 | ||
326 | /* 3.1 A packet containing an INIT chunk MUST have a zero Verification | 342 | /* 3.1 A packet containing an INIT chunk MUST have a zero Verification |
327 | * Tag. | 343 | * Tag. |
328 | */ | 344 | */ |
329 | if (chunk->sctp_hdr->vtag != 0) | 345 | if (chunk->sctp_hdr->vtag != 0) |
330 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 346 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
331 | 347 | ||
332 | /* Make sure that the INIT chunk has a valid length. | 348 | /* Make sure that the INIT chunk has a valid length. |
333 | * Normally, this would cause an ABORT with a Protocol Violation | 349 | * Normally, this would cause an ABORT with a Protocol Violation |
@@ -335,7 +351,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
335 | * just discard the packet. | 351 | * just discard the packet. |
336 | */ | 352 | */ |
337 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) | 353 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) |
338 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 354 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
339 | 355 | ||
340 | /* If the INIT is coming toward a closing socket, we'll send back | 356 | /* If the INIT is coming toward a closing socket, we'll send back |
341 | * and ABORT. Essentially, this catches the race of INIT being | 357 | * and ABORT. Essentially, this catches the race of INIT being |
@@ -344,18 +360,18 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
344 | * can treat this OOTB | 360 | * can treat this OOTB |
345 | */ | 361 | */ |
346 | if (sctp_sstate(ep->base.sk, CLOSING)) | 362 | if (sctp_sstate(ep->base.sk, CLOSING)) |
347 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 363 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
348 | 364 | ||
349 | /* Verify the INIT chunk before processing it. */ | 365 | /* Verify the INIT chunk before processing it. */ |
350 | err_chunk = NULL; | 366 | err_chunk = NULL; |
351 | if (!sctp_verify_init(asoc, chunk->chunk_hdr->type, | 367 | if (!sctp_verify_init(net, asoc, chunk->chunk_hdr->type, |
352 | (sctp_init_chunk_t *)chunk->chunk_hdr, chunk, | 368 | (sctp_init_chunk_t *)chunk->chunk_hdr, chunk, |
353 | &err_chunk)) { | 369 | &err_chunk)) { |
354 | /* This chunk contains fatal error. It is to be discarded. | 370 | /* This chunk contains fatal error. It is to be discarded. |
355 | * Send an ABORT, with causes if there is any. | 371 | * Send an ABORT, with causes if there is any. |
356 | */ | 372 | */ |
357 | if (err_chunk) { | 373 | if (err_chunk) { |
358 | packet = sctp_abort_pkt_new(ep, asoc, arg, | 374 | packet = sctp_abort_pkt_new(net, ep, asoc, arg, |
359 | (__u8 *)(err_chunk->chunk_hdr) + | 375 | (__u8 *)(err_chunk->chunk_hdr) + |
360 | sizeof(sctp_chunkhdr_t), | 376 | sizeof(sctp_chunkhdr_t), |
361 | ntohs(err_chunk->chunk_hdr->length) - | 377 | ntohs(err_chunk->chunk_hdr->length) - |
@@ -366,13 +382,13 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
366 | if (packet) { | 382 | if (packet) { |
367 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, | 383 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, |
368 | SCTP_PACKET(packet)); | 384 | SCTP_PACKET(packet)); |
369 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 385 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
370 | return SCTP_DISPOSITION_CONSUME; | 386 | return SCTP_DISPOSITION_CONSUME; |
371 | } else { | 387 | } else { |
372 | return SCTP_DISPOSITION_NOMEM; | 388 | return SCTP_DISPOSITION_NOMEM; |
373 | } | 389 | } |
374 | } else { | 390 | } else { |
375 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, | 391 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, |
376 | commands); | 392 | commands); |
377 | } | 393 | } |
378 | } | 394 | } |
@@ -484,7 +500,8 @@ nomem: | |||
484 | * | 500 | * |
485 | * The return value is the disposition of the chunk. | 501 | * The return value is the disposition of the chunk. |
486 | */ | 502 | */ |
487 | sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | 503 | sctp_disposition_t sctp_sf_do_5_1C_ack(struct net *net, |
504 | const struct sctp_endpoint *ep, | ||
488 | const struct sctp_association *asoc, | 505 | const struct sctp_association *asoc, |
489 | const sctp_subtype_t type, | 506 | const sctp_subtype_t type, |
490 | void *arg, | 507 | void *arg, |
@@ -496,25 +513,25 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
496 | struct sctp_packet *packet; | 513 | struct sctp_packet *packet; |
497 | 514 | ||
498 | if (!sctp_vtag_verify(chunk, asoc)) | 515 | if (!sctp_vtag_verify(chunk, asoc)) |
499 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 516 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
500 | 517 | ||
501 | /* 6.10 Bundling | 518 | /* 6.10 Bundling |
502 | * An endpoint MUST NOT bundle INIT, INIT ACK or | 519 | * An endpoint MUST NOT bundle INIT, INIT ACK or |
503 | * SHUTDOWN COMPLETE with any other chunks. | 520 | * SHUTDOWN COMPLETE with any other chunks. |
504 | */ | 521 | */ |
505 | if (!chunk->singleton) | 522 | if (!chunk->singleton) |
506 | return sctp_sf_violation_chunk(ep, asoc, type, arg, commands); | 523 | return sctp_sf_violation_chunk(net, ep, asoc, type, arg, commands); |
507 | 524 | ||
508 | /* Make sure that the INIT-ACK chunk has a valid length */ | 525 | /* Make sure that the INIT-ACK chunk has a valid length */ |
509 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_initack_chunk_t))) | 526 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_initack_chunk_t))) |
510 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 527 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
511 | commands); | 528 | commands); |
512 | /* Grab the INIT header. */ | 529 | /* Grab the INIT header. */ |
513 | chunk->subh.init_hdr = (sctp_inithdr_t *) chunk->skb->data; | 530 | chunk->subh.init_hdr = (sctp_inithdr_t *) chunk->skb->data; |
514 | 531 | ||
515 | /* Verify the INIT chunk before processing it. */ | 532 | /* Verify the INIT chunk before processing it. */ |
516 | err_chunk = NULL; | 533 | err_chunk = NULL; |
517 | if (!sctp_verify_init(asoc, chunk->chunk_hdr->type, | 534 | if (!sctp_verify_init(net, asoc, chunk->chunk_hdr->type, |
518 | (sctp_init_chunk_t *)chunk->chunk_hdr, chunk, | 535 | (sctp_init_chunk_t *)chunk->chunk_hdr, chunk, |
519 | &err_chunk)) { | 536 | &err_chunk)) { |
520 | 537 | ||
@@ -526,7 +543,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
526 | * the association. | 543 | * the association. |
527 | */ | 544 | */ |
528 | if (err_chunk) { | 545 | if (err_chunk) { |
529 | packet = sctp_abort_pkt_new(ep, asoc, arg, | 546 | packet = sctp_abort_pkt_new(net, ep, asoc, arg, |
530 | (__u8 *)(err_chunk->chunk_hdr) + | 547 | (__u8 *)(err_chunk->chunk_hdr) + |
531 | sizeof(sctp_chunkhdr_t), | 548 | sizeof(sctp_chunkhdr_t), |
532 | ntohs(err_chunk->chunk_hdr->length) - | 549 | ntohs(err_chunk->chunk_hdr->length) - |
@@ -537,7 +554,7 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
537 | if (packet) { | 554 | if (packet) { |
538 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, | 555 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, |
539 | SCTP_PACKET(packet)); | 556 | SCTP_PACKET(packet)); |
540 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 557 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
541 | error = SCTP_ERROR_INV_PARAM; | 558 | error = SCTP_ERROR_INV_PARAM; |
542 | } | 559 | } |
543 | } | 560 | } |
@@ -554,10 +571,10 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
554 | * was malformed. | 571 | * was malformed. |
555 | */ | 572 | */ |
556 | if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) | 573 | if (sctp_auth_recv_cid(SCTP_CID_ABORT, asoc)) |
557 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 574 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
558 | 575 | ||
559 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 576 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
560 | return sctp_stop_t1_and_abort(commands, error, ECONNREFUSED, | 577 | return sctp_stop_t1_and_abort(net, commands, error, ECONNREFUSED, |
561 | asoc, chunk->transport); | 578 | asoc, chunk->transport); |
562 | } | 579 | } |
563 | 580 | ||
@@ -633,7 +650,8 @@ sctp_disposition_t sctp_sf_do_5_1C_ack(const struct sctp_endpoint *ep, | |||
633 | * | 650 | * |
634 | * The return value is the disposition of the chunk. | 651 | * The return value is the disposition of the chunk. |
635 | */ | 652 | */ |
636 | sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | 653 | sctp_disposition_t sctp_sf_do_5_1D_ce(struct net *net, |
654 | const struct sctp_endpoint *ep, | ||
637 | const struct sctp_association *asoc, | 655 | const struct sctp_association *asoc, |
638 | const sctp_subtype_t type, void *arg, | 656 | const sctp_subtype_t type, void *arg, |
639 | sctp_cmd_seq_t *commands) | 657 | sctp_cmd_seq_t *commands) |
@@ -650,9 +668,9 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
650 | /* If the packet is an OOTB packet which is temporarily on the | 668 | /* If the packet is an OOTB packet which is temporarily on the |
651 | * control endpoint, respond with an ABORT. | 669 | * control endpoint, respond with an ABORT. |
652 | */ | 670 | */ |
653 | if (ep == sctp_sk((sctp_get_ctl_sock()))->ep) { | 671 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { |
654 | SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); | 672 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); |
655 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 673 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
656 | } | 674 | } |
657 | 675 | ||
658 | /* Make sure that the COOKIE_ECHO chunk has a valid length. | 676 | /* Make sure that the COOKIE_ECHO chunk has a valid length. |
@@ -661,7 +679,7 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
661 | * in sctp_unpack_cookie(). | 679 | * in sctp_unpack_cookie(). |
662 | */ | 680 | */ |
663 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 681 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
664 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 682 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
665 | 683 | ||
666 | /* If the endpoint is not listening or if the number of associations | 684 | /* If the endpoint is not listening or if the number of associations |
667 | * on the TCP-style socket exceed the max backlog, respond with an | 685 | * on the TCP-style socket exceed the max backlog, respond with an |
@@ -670,7 +688,7 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
670 | sk = ep->base.sk; | 688 | sk = ep->base.sk; |
671 | if (!sctp_sstate(sk, LISTENING) || | 689 | if (!sctp_sstate(sk, LISTENING) || |
672 | (sctp_style(sk, TCP) && sk_acceptq_is_full(sk))) | 690 | (sctp_style(sk, TCP) && sk_acceptq_is_full(sk))) |
673 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 691 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
674 | 692 | ||
675 | /* "Decode" the chunk. We have no optional parameters so we | 693 | /* "Decode" the chunk. We have no optional parameters so we |
676 | * are in good shape. | 694 | * are in good shape. |
@@ -703,13 +721,13 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
703 | goto nomem; | 721 | goto nomem; |
704 | 722 | ||
705 | case -SCTP_IERROR_STALE_COOKIE: | 723 | case -SCTP_IERROR_STALE_COOKIE: |
706 | sctp_send_stale_cookie_err(ep, asoc, chunk, commands, | 724 | sctp_send_stale_cookie_err(net, ep, asoc, chunk, commands, |
707 | err_chk_p); | 725 | err_chk_p); |
708 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 726 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
709 | 727 | ||
710 | case -SCTP_IERROR_BAD_SIG: | 728 | case -SCTP_IERROR_BAD_SIG: |
711 | default: | 729 | default: |
712 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 730 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
713 | } | 731 | } |
714 | } | 732 | } |
715 | 733 | ||
@@ -756,14 +774,14 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
756 | skb_pull(chunk->auth_chunk, sizeof(sctp_chunkhdr_t)); | 774 | skb_pull(chunk->auth_chunk, sizeof(sctp_chunkhdr_t)); |
757 | auth.transport = chunk->transport; | 775 | auth.transport = chunk->transport; |
758 | 776 | ||
759 | ret = sctp_sf_authenticate(ep, new_asoc, type, &auth); | 777 | ret = sctp_sf_authenticate(net, ep, new_asoc, type, &auth); |
760 | 778 | ||
761 | /* We can now safely free the auth_chunk clone */ | 779 | /* We can now safely free the auth_chunk clone */ |
762 | kfree_skb(chunk->auth_chunk); | 780 | kfree_skb(chunk->auth_chunk); |
763 | 781 | ||
764 | if (ret != SCTP_IERROR_NO_ERROR) { | 782 | if (ret != SCTP_IERROR_NO_ERROR) { |
765 | sctp_association_free(new_asoc); | 783 | sctp_association_free(new_asoc); |
766 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 784 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
767 | } | 785 | } |
768 | } | 786 | } |
769 | 787 | ||
@@ -804,8 +822,8 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
804 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc)); | 822 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(new_asoc)); |
805 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 823 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
806 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); | 824 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); |
807 | SCTP_INC_STATS(SCTP_MIB_CURRESTAB); | 825 | SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); |
808 | SCTP_INC_STATS(SCTP_MIB_PASSIVEESTABS); | 826 | SCTP_INC_STATS(net, SCTP_MIB_PASSIVEESTABS); |
809 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); | 827 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); |
810 | 828 | ||
811 | if (new_asoc->autoclose) | 829 | if (new_asoc->autoclose) |
@@ -856,7 +874,8 @@ nomem: | |||
856 | * | 874 | * |
857 | * The return value is the disposition of the chunk. | 875 | * The return value is the disposition of the chunk. |
858 | */ | 876 | */ |
859 | sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep, | 877 | sctp_disposition_t sctp_sf_do_5_1E_ca(struct net *net, |
878 | const struct sctp_endpoint *ep, | ||
860 | const struct sctp_association *asoc, | 879 | const struct sctp_association *asoc, |
861 | const sctp_subtype_t type, void *arg, | 880 | const sctp_subtype_t type, void *arg, |
862 | sctp_cmd_seq_t *commands) | 881 | sctp_cmd_seq_t *commands) |
@@ -865,13 +884,13 @@ sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep, | |||
865 | struct sctp_ulpevent *ev; | 884 | struct sctp_ulpevent *ev; |
866 | 885 | ||
867 | if (!sctp_vtag_verify(chunk, asoc)) | 886 | if (!sctp_vtag_verify(chunk, asoc)) |
868 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 887 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
869 | 888 | ||
870 | /* Verify that the chunk length for the COOKIE-ACK is OK. | 889 | /* Verify that the chunk length for the COOKIE-ACK is OK. |
871 | * If we don't do this, any bundled chunks may be junked. | 890 | * If we don't do this, any bundled chunks may be junked. |
872 | */ | 891 | */ |
873 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 892 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
874 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 893 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
875 | commands); | 894 | commands); |
876 | 895 | ||
877 | /* Reset init error count upon receipt of COOKIE-ACK, | 896 | /* Reset init error count upon receipt of COOKIE-ACK, |
@@ -892,8 +911,8 @@ sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep, | |||
892 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); | 911 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); |
893 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 912 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
894 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); | 913 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); |
895 | SCTP_INC_STATS(SCTP_MIB_CURRESTAB); | 914 | SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); |
896 | SCTP_INC_STATS(SCTP_MIB_ACTIVEESTABS); | 915 | SCTP_INC_STATS(net, SCTP_MIB_ACTIVEESTABS); |
897 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); | 916 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); |
898 | if (asoc->autoclose) | 917 | if (asoc->autoclose) |
899 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, | 918 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, |
@@ -958,7 +977,8 @@ static sctp_disposition_t sctp_sf_heartbeat(const struct sctp_endpoint *ep, | |||
958 | } | 977 | } |
959 | 978 | ||
960 | /* Generate a HEARTBEAT packet on the given transport. */ | 979 | /* Generate a HEARTBEAT packet on the given transport. */ |
961 | sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep, | 980 | sctp_disposition_t sctp_sf_sendbeat_8_3(struct net *net, |
981 | const struct sctp_endpoint *ep, | ||
962 | const struct sctp_association *asoc, | 982 | const struct sctp_association *asoc, |
963 | const sctp_subtype_t type, | 983 | const sctp_subtype_t type, |
964 | void *arg, | 984 | void *arg, |
@@ -972,8 +992,8 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep, | |||
972 | /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ | 992 | /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ |
973 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 993 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
974 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); | 994 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); |
975 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 995 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
976 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 996 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
977 | return SCTP_DISPOSITION_DELETE_TCB; | 997 | return SCTP_DISPOSITION_DELETE_TCB; |
978 | } | 998 | } |
979 | 999 | ||
@@ -1028,7 +1048,8 @@ sctp_disposition_t sctp_sf_sendbeat_8_3(const struct sctp_endpoint *ep, | |||
1028 | * | 1048 | * |
1029 | * The return value is the disposition of the chunk. | 1049 | * The return value is the disposition of the chunk. |
1030 | */ | 1050 | */ |
1031 | sctp_disposition_t sctp_sf_beat_8_3(const struct sctp_endpoint *ep, | 1051 | sctp_disposition_t sctp_sf_beat_8_3(struct net *net, |
1052 | const struct sctp_endpoint *ep, | ||
1032 | const struct sctp_association *asoc, | 1053 | const struct sctp_association *asoc, |
1033 | const sctp_subtype_t type, | 1054 | const sctp_subtype_t type, |
1034 | void *arg, | 1055 | void *arg, |
@@ -1039,11 +1060,11 @@ sctp_disposition_t sctp_sf_beat_8_3(const struct sctp_endpoint *ep, | |||
1039 | size_t paylen = 0; | 1060 | size_t paylen = 0; |
1040 | 1061 | ||
1041 | if (!sctp_vtag_verify(chunk, asoc)) | 1062 | if (!sctp_vtag_verify(chunk, asoc)) |
1042 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 1063 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
1043 | 1064 | ||
1044 | /* Make sure that the HEARTBEAT chunk has a valid length. */ | 1065 | /* Make sure that the HEARTBEAT chunk has a valid length. */ |
1045 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_heartbeat_chunk_t))) | 1066 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_heartbeat_chunk_t))) |
1046 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 1067 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
1047 | commands); | 1068 | commands); |
1048 | 1069 | ||
1049 | /* 8.3 The receiver of the HEARTBEAT should immediately | 1070 | /* 8.3 The receiver of the HEARTBEAT should immediately |
@@ -1095,7 +1116,8 @@ nomem: | |||
1095 | * | 1116 | * |
1096 | * The return value is the disposition of the chunk. | 1117 | * The return value is the disposition of the chunk. |
1097 | */ | 1118 | */ |
1098 | sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep, | 1119 | sctp_disposition_t sctp_sf_backbeat_8_3(struct net *net, |
1120 | const struct sctp_endpoint *ep, | ||
1099 | const struct sctp_association *asoc, | 1121 | const struct sctp_association *asoc, |
1100 | const sctp_subtype_t type, | 1122 | const sctp_subtype_t type, |
1101 | void *arg, | 1123 | void *arg, |
@@ -1108,12 +1130,12 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep, | |||
1108 | unsigned long max_interval; | 1130 | unsigned long max_interval; |
1109 | 1131 | ||
1110 | if (!sctp_vtag_verify(chunk, asoc)) | 1132 | if (!sctp_vtag_verify(chunk, asoc)) |
1111 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 1133 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
1112 | 1134 | ||
1113 | /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ | 1135 | /* Make sure that the HEARTBEAT-ACK chunk has a valid length. */ |
1114 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t) + | 1136 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t) + |
1115 | sizeof(sctp_sender_hb_info_t))) | 1137 | sizeof(sctp_sender_hb_info_t))) |
1116 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 1138 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
1117 | commands); | 1139 | commands); |
1118 | 1140 | ||
1119 | hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data; | 1141 | hbinfo = (sctp_sender_hb_info_t *) chunk->skb->data; |
@@ -1171,7 +1193,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep, | |||
1171 | /* Helper function to send out an abort for the restart | 1193 | /* Helper function to send out an abort for the restart |
1172 | * condition. | 1194 | * condition. |
1173 | */ | 1195 | */ |
1174 | static int sctp_sf_send_restart_abort(union sctp_addr *ssa, | 1196 | static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa, |
1175 | struct sctp_chunk *init, | 1197 | struct sctp_chunk *init, |
1176 | sctp_cmd_seq_t *commands) | 1198 | sctp_cmd_seq_t *commands) |
1177 | { | 1199 | { |
@@ -1197,18 +1219,18 @@ static int sctp_sf_send_restart_abort(union sctp_addr *ssa, | |||
1197 | errhdr->length = htons(len); | 1219 | errhdr->length = htons(len); |
1198 | 1220 | ||
1199 | /* Assign to the control socket. */ | 1221 | /* Assign to the control socket. */ |
1200 | ep = sctp_sk((sctp_get_ctl_sock()))->ep; | 1222 | ep = sctp_sk(net->sctp.ctl_sock)->ep; |
1201 | 1223 | ||
1202 | /* Association is NULL since this may be a restart attack and we | 1224 | /* Association is NULL since this may be a restart attack and we |
1203 | * want to send back the attacker's vtag. | 1225 | * want to send back the attacker's vtag. |
1204 | */ | 1226 | */ |
1205 | pkt = sctp_abort_pkt_new(ep, NULL, init, errhdr, len); | 1227 | pkt = sctp_abort_pkt_new(net, ep, NULL, init, errhdr, len); |
1206 | 1228 | ||
1207 | if (!pkt) | 1229 | if (!pkt) |
1208 | goto out; | 1230 | goto out; |
1209 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, SCTP_PACKET(pkt)); | 1231 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, SCTP_PACKET(pkt)); |
1210 | 1232 | ||
1211 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 1233 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
1212 | 1234 | ||
1213 | /* Discard the rest of the inbound packet. */ | 1235 | /* Discard the rest of the inbound packet. */ |
1214 | sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL()); | 1236 | sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL()); |
@@ -1240,6 +1262,7 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc, | |||
1240 | struct sctp_chunk *init, | 1262 | struct sctp_chunk *init, |
1241 | sctp_cmd_seq_t *commands) | 1263 | sctp_cmd_seq_t *commands) |
1242 | { | 1264 | { |
1265 | struct net *net = sock_net(new_asoc->base.sk); | ||
1243 | struct sctp_transport *new_addr; | 1266 | struct sctp_transport *new_addr; |
1244 | int ret = 1; | 1267 | int ret = 1; |
1245 | 1268 | ||
@@ -1258,7 +1281,7 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc, | |||
1258 | transports) { | 1281 | transports) { |
1259 | if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, | 1282 | if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, |
1260 | &new_addr->ipaddr)) { | 1283 | &new_addr->ipaddr)) { |
1261 | sctp_sf_send_restart_abort(&new_addr->ipaddr, init, | 1284 | sctp_sf_send_restart_abort(net, &new_addr->ipaddr, init, |
1262 | commands); | 1285 | commands); |
1263 | ret = 0; | 1286 | ret = 0; |
1264 | break; | 1287 | break; |
@@ -1358,6 +1381,7 @@ static char sctp_tietags_compare(struct sctp_association *new_asoc, | |||
1358 | * chunk handling. | 1381 | * chunk handling. |
1359 | */ | 1382 | */ |
1360 | static sctp_disposition_t sctp_sf_do_unexpected_init( | 1383 | static sctp_disposition_t sctp_sf_do_unexpected_init( |
1384 | struct net *net, | ||
1361 | const struct sctp_endpoint *ep, | 1385 | const struct sctp_endpoint *ep, |
1362 | const struct sctp_association *asoc, | 1386 | const struct sctp_association *asoc, |
1363 | const sctp_subtype_t type, | 1387 | const sctp_subtype_t type, |
@@ -1382,20 +1406,20 @@ static sctp_disposition_t sctp_sf_do_unexpected_init( | |||
1382 | * with an INIT chunk that is bundled with other chunks. | 1406 | * with an INIT chunk that is bundled with other chunks. |
1383 | */ | 1407 | */ |
1384 | if (!chunk->singleton) | 1408 | if (!chunk->singleton) |
1385 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 1409 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
1386 | 1410 | ||
1387 | /* 3.1 A packet containing an INIT chunk MUST have a zero Verification | 1411 | /* 3.1 A packet containing an INIT chunk MUST have a zero Verification |
1388 | * Tag. | 1412 | * Tag. |
1389 | */ | 1413 | */ |
1390 | if (chunk->sctp_hdr->vtag != 0) | 1414 | if (chunk->sctp_hdr->vtag != 0) |
1391 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 1415 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
1392 | 1416 | ||
1393 | /* Make sure that the INIT chunk has a valid length. | 1417 | /* Make sure that the INIT chunk has a valid length. |
1394 | * In this case, we generate a protocol violation since we have | 1418 | * In this case, we generate a protocol violation since we have |
1395 | * an association established. | 1419 | * an association established. |
1396 | */ | 1420 | */ |
1397 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) | 1421 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_init_chunk_t))) |
1398 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 1422 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
1399 | commands); | 1423 | commands); |
1400 | /* Grab the INIT header. */ | 1424 | /* Grab the INIT header. */ |
1401 | chunk->subh.init_hdr = (sctp_inithdr_t *) chunk->skb->data; | 1425 | chunk->subh.init_hdr = (sctp_inithdr_t *) chunk->skb->data; |
@@ -1405,14 +1429,14 @@ static sctp_disposition_t sctp_sf_do_unexpected_init( | |||
1405 | 1429 | ||
1406 | /* Verify the INIT chunk before processing it. */ | 1430 | /* Verify the INIT chunk before processing it. */ |
1407 | err_chunk = NULL; | 1431 | err_chunk = NULL; |
1408 | if (!sctp_verify_init(asoc, chunk->chunk_hdr->type, | 1432 | if (!sctp_verify_init(net, asoc, chunk->chunk_hdr->type, |
1409 | (sctp_init_chunk_t *)chunk->chunk_hdr, chunk, | 1433 | (sctp_init_chunk_t *)chunk->chunk_hdr, chunk, |
1410 | &err_chunk)) { | 1434 | &err_chunk)) { |
1411 | /* This chunk contains fatal error. It is to be discarded. | 1435 | /* This chunk contains fatal error. It is to be discarded. |
1412 | * Send an ABORT, with causes if there is any. | 1436 | * Send an ABORT, with causes if there is any. |
1413 | */ | 1437 | */ |
1414 | if (err_chunk) { | 1438 | if (err_chunk) { |
1415 | packet = sctp_abort_pkt_new(ep, asoc, arg, | 1439 | packet = sctp_abort_pkt_new(net, ep, asoc, arg, |
1416 | (__u8 *)(err_chunk->chunk_hdr) + | 1440 | (__u8 *)(err_chunk->chunk_hdr) + |
1417 | sizeof(sctp_chunkhdr_t), | 1441 | sizeof(sctp_chunkhdr_t), |
1418 | ntohs(err_chunk->chunk_hdr->length) - | 1442 | ntohs(err_chunk->chunk_hdr->length) - |
@@ -1421,14 +1445,14 @@ static sctp_disposition_t sctp_sf_do_unexpected_init( | |||
1421 | if (packet) { | 1445 | if (packet) { |
1422 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, | 1446 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, |
1423 | SCTP_PACKET(packet)); | 1447 | SCTP_PACKET(packet)); |
1424 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 1448 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
1425 | retval = SCTP_DISPOSITION_CONSUME; | 1449 | retval = SCTP_DISPOSITION_CONSUME; |
1426 | } else { | 1450 | } else { |
1427 | retval = SCTP_DISPOSITION_NOMEM; | 1451 | retval = SCTP_DISPOSITION_NOMEM; |
1428 | } | 1452 | } |
1429 | goto cleanup; | 1453 | goto cleanup; |
1430 | } else { | 1454 | } else { |
1431 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, | 1455 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, |
1432 | commands); | 1456 | commands); |
1433 | } | 1457 | } |
1434 | } | 1458 | } |
@@ -1570,7 +1594,8 @@ cleanup: | |||
1570 | * | 1594 | * |
1571 | * The return value is the disposition of the chunk. | 1595 | * The return value is the disposition of the chunk. |
1572 | */ | 1596 | */ |
1573 | sctp_disposition_t sctp_sf_do_5_2_1_siminit(const struct sctp_endpoint *ep, | 1597 | sctp_disposition_t sctp_sf_do_5_2_1_siminit(struct net *net, |
1598 | const struct sctp_endpoint *ep, | ||
1574 | const struct sctp_association *asoc, | 1599 | const struct sctp_association *asoc, |
1575 | const sctp_subtype_t type, | 1600 | const sctp_subtype_t type, |
1576 | void *arg, | 1601 | void *arg, |
@@ -1579,7 +1604,7 @@ sctp_disposition_t sctp_sf_do_5_2_1_siminit(const struct sctp_endpoint *ep, | |||
1579 | /* Call helper to do the real work for both simulataneous and | 1604 | /* Call helper to do the real work for both simulataneous and |
1580 | * duplicate INIT chunk handling. | 1605 | * duplicate INIT chunk handling. |
1581 | */ | 1606 | */ |
1582 | return sctp_sf_do_unexpected_init(ep, asoc, type, arg, commands); | 1607 | return sctp_sf_do_unexpected_init(net, ep, asoc, type, arg, commands); |
1583 | } | 1608 | } |
1584 | 1609 | ||
1585 | /* | 1610 | /* |
@@ -1623,7 +1648,8 @@ sctp_disposition_t sctp_sf_do_5_2_1_siminit(const struct sctp_endpoint *ep, | |||
1623 | * | 1648 | * |
1624 | * The return value is the disposition of the chunk. | 1649 | * The return value is the disposition of the chunk. |
1625 | */ | 1650 | */ |
1626 | sctp_disposition_t sctp_sf_do_5_2_2_dupinit(const struct sctp_endpoint *ep, | 1651 | sctp_disposition_t sctp_sf_do_5_2_2_dupinit(struct net *net, |
1652 | const struct sctp_endpoint *ep, | ||
1627 | const struct sctp_association *asoc, | 1653 | const struct sctp_association *asoc, |
1628 | const sctp_subtype_t type, | 1654 | const sctp_subtype_t type, |
1629 | void *arg, | 1655 | void *arg, |
@@ -1632,7 +1658,7 @@ sctp_disposition_t sctp_sf_do_5_2_2_dupinit(const struct sctp_endpoint *ep, | |||
1632 | /* Call helper to do the real work for both simulataneous and | 1658 | /* Call helper to do the real work for both simulataneous and |
1633 | * duplicate INIT chunk handling. | 1659 | * duplicate INIT chunk handling. |
1634 | */ | 1660 | */ |
1635 | return sctp_sf_do_unexpected_init(ep, asoc, type, arg, commands); | 1661 | return sctp_sf_do_unexpected_init(net, ep, asoc, type, arg, commands); |
1636 | } | 1662 | } |
1637 | 1663 | ||
1638 | 1664 | ||
@@ -1645,7 +1671,8 @@ sctp_disposition_t sctp_sf_do_5_2_2_dupinit(const struct sctp_endpoint *ep, | |||
1645 | * An unexpected INIT ACK usually indicates the processing of an old or | 1671 | * An unexpected INIT ACK usually indicates the processing of an old or |
1646 | * duplicated INIT chunk. | 1672 | * duplicated INIT chunk. |
1647 | */ | 1673 | */ |
1648 | sctp_disposition_t sctp_sf_do_5_2_3_initack(const struct sctp_endpoint *ep, | 1674 | sctp_disposition_t sctp_sf_do_5_2_3_initack(struct net *net, |
1675 | const struct sctp_endpoint *ep, | ||
1649 | const struct sctp_association *asoc, | 1676 | const struct sctp_association *asoc, |
1650 | const sctp_subtype_t type, | 1677 | const sctp_subtype_t type, |
1651 | void *arg, sctp_cmd_seq_t *commands) | 1678 | void *arg, sctp_cmd_seq_t *commands) |
@@ -1653,10 +1680,10 @@ sctp_disposition_t sctp_sf_do_5_2_3_initack(const struct sctp_endpoint *ep, | |||
1653 | /* Per the above section, we'll discard the chunk if we have an | 1680 | /* Per the above section, we'll discard the chunk if we have an |
1654 | * endpoint. If this is an OOTB INIT-ACK, treat it as such. | 1681 | * endpoint. If this is an OOTB INIT-ACK, treat it as such. |
1655 | */ | 1682 | */ |
1656 | if (ep == sctp_sk((sctp_get_ctl_sock()))->ep) | 1683 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) |
1657 | return sctp_sf_ootb(ep, asoc, type, arg, commands); | 1684 | return sctp_sf_ootb(net, ep, asoc, type, arg, commands); |
1658 | else | 1685 | else |
1659 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 1686 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
1660 | } | 1687 | } |
1661 | 1688 | ||
1662 | /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A') | 1689 | /* Unexpected COOKIE-ECHO handler for peer restart (Table 2, action 'A') |
@@ -1664,7 +1691,8 @@ sctp_disposition_t sctp_sf_do_5_2_3_initack(const struct sctp_endpoint *ep, | |||
1664 | * Section 5.2.4 | 1691 | * Section 5.2.4 |
1665 | * A) In this case, the peer may have restarted. | 1692 | * A) In this case, the peer may have restarted. |
1666 | */ | 1693 | */ |
1667 | static sctp_disposition_t sctp_sf_do_dupcook_a(const struct sctp_endpoint *ep, | 1694 | static sctp_disposition_t sctp_sf_do_dupcook_a(struct net *net, |
1695 | const struct sctp_endpoint *ep, | ||
1668 | const struct sctp_association *asoc, | 1696 | const struct sctp_association *asoc, |
1669 | struct sctp_chunk *chunk, | 1697 | struct sctp_chunk *chunk, |
1670 | sctp_cmd_seq_t *commands, | 1698 | sctp_cmd_seq_t *commands, |
@@ -1700,7 +1728,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_a(const struct sctp_endpoint *ep, | |||
1700 | * its peer. | 1728 | * its peer. |
1701 | */ | 1729 | */ |
1702 | if (sctp_state(asoc, SHUTDOWN_ACK_SENT)) { | 1730 | if (sctp_state(asoc, SHUTDOWN_ACK_SENT)) { |
1703 | disposition = sctp_sf_do_9_2_reshutack(ep, asoc, | 1731 | disposition = sctp_sf_do_9_2_reshutack(net, ep, asoc, |
1704 | SCTP_ST_CHUNK(chunk->chunk_hdr->type), | 1732 | SCTP_ST_CHUNK(chunk->chunk_hdr->type), |
1705 | chunk, commands); | 1733 | chunk, commands); |
1706 | if (SCTP_DISPOSITION_NOMEM == disposition) | 1734 | if (SCTP_DISPOSITION_NOMEM == disposition) |
@@ -1763,7 +1791,8 @@ nomem: | |||
1763 | * after responding to the local endpoint's INIT | 1791 | * after responding to the local endpoint's INIT |
1764 | */ | 1792 | */ |
1765 | /* This case represents an initialization collision. */ | 1793 | /* This case represents an initialization collision. */ |
1766 | static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep, | 1794 | static sctp_disposition_t sctp_sf_do_dupcook_b(struct net *net, |
1795 | const struct sctp_endpoint *ep, | ||
1767 | const struct sctp_association *asoc, | 1796 | const struct sctp_association *asoc, |
1768 | struct sctp_chunk *chunk, | 1797 | struct sctp_chunk *chunk, |
1769 | sctp_cmd_seq_t *commands, | 1798 | sctp_cmd_seq_t *commands, |
@@ -1784,7 +1813,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_b(const struct sctp_endpoint *ep, | |||
1784 | sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc)); | 1813 | sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc)); |
1785 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 1814 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
1786 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); | 1815 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); |
1787 | SCTP_INC_STATS(SCTP_MIB_CURRESTAB); | 1816 | SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); |
1788 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); | 1817 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); |
1789 | 1818 | ||
1790 | repl = sctp_make_cookie_ack(new_asoc, chunk); | 1819 | repl = sctp_make_cookie_ack(new_asoc, chunk); |
@@ -1833,7 +1862,8 @@ nomem: | |||
1833 | * but a new tag of its own. | 1862 | * but a new tag of its own. |
1834 | */ | 1863 | */ |
1835 | /* This case represents an initialization collision. */ | 1864 | /* This case represents an initialization collision. */ |
1836 | static sctp_disposition_t sctp_sf_do_dupcook_c(const struct sctp_endpoint *ep, | 1865 | static sctp_disposition_t sctp_sf_do_dupcook_c(struct net *net, |
1866 | const struct sctp_endpoint *ep, | ||
1837 | const struct sctp_association *asoc, | 1867 | const struct sctp_association *asoc, |
1838 | struct sctp_chunk *chunk, | 1868 | struct sctp_chunk *chunk, |
1839 | sctp_cmd_seq_t *commands, | 1869 | sctp_cmd_seq_t *commands, |
@@ -1854,7 +1884,8 @@ static sctp_disposition_t sctp_sf_do_dupcook_c(const struct sctp_endpoint *ep, | |||
1854 | * enter the ESTABLISHED state, if it has not already done so. | 1884 | * enter the ESTABLISHED state, if it has not already done so. |
1855 | */ | 1885 | */ |
1856 | /* This case represents an initialization collision. */ | 1886 | /* This case represents an initialization collision. */ |
1857 | static sctp_disposition_t sctp_sf_do_dupcook_d(const struct sctp_endpoint *ep, | 1887 | static sctp_disposition_t sctp_sf_do_dupcook_d(struct net *net, |
1888 | const struct sctp_endpoint *ep, | ||
1858 | const struct sctp_association *asoc, | 1889 | const struct sctp_association *asoc, |
1859 | struct sctp_chunk *chunk, | 1890 | struct sctp_chunk *chunk, |
1860 | sctp_cmd_seq_t *commands, | 1891 | sctp_cmd_seq_t *commands, |
@@ -1876,7 +1907,7 @@ static sctp_disposition_t sctp_sf_do_dupcook_d(const struct sctp_endpoint *ep, | |||
1876 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); | 1907 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); |
1877 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 1908 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
1878 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); | 1909 | SCTP_STATE(SCTP_STATE_ESTABLISHED)); |
1879 | SCTP_INC_STATS(SCTP_MIB_CURRESTAB); | 1910 | SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); |
1880 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, | 1911 | sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, |
1881 | SCTP_NULL()); | 1912 | SCTP_NULL()); |
1882 | 1913 | ||
@@ -1948,7 +1979,8 @@ nomem: | |||
1948 | * | 1979 | * |
1949 | * The return value is the disposition of the chunk. | 1980 | * The return value is the disposition of the chunk. |
1950 | */ | 1981 | */ |
1951 | sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep, | 1982 | sctp_disposition_t sctp_sf_do_5_2_4_dupcook(struct net *net, |
1983 | const struct sctp_endpoint *ep, | ||
1952 | const struct sctp_association *asoc, | 1984 | const struct sctp_association *asoc, |
1953 | const sctp_subtype_t type, | 1985 | const sctp_subtype_t type, |
1954 | void *arg, | 1986 | void *arg, |
@@ -1967,7 +1999,7 @@ sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep, | |||
1967 | * done later. | 1999 | * done later. |
1968 | */ | 2000 | */ |
1969 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 2001 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
1970 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2002 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
1971 | commands); | 2003 | commands); |
1972 | 2004 | ||
1973 | /* "Decode" the chunk. We have no optional parameters so we | 2005 | /* "Decode" the chunk. We have no optional parameters so we |
@@ -2001,12 +2033,12 @@ sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep, | |||
2001 | goto nomem; | 2033 | goto nomem; |
2002 | 2034 | ||
2003 | case -SCTP_IERROR_STALE_COOKIE: | 2035 | case -SCTP_IERROR_STALE_COOKIE: |
2004 | sctp_send_stale_cookie_err(ep, asoc, chunk, commands, | 2036 | sctp_send_stale_cookie_err(net, ep, asoc, chunk, commands, |
2005 | err_chk_p); | 2037 | err_chk_p); |
2006 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2038 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2007 | case -SCTP_IERROR_BAD_SIG: | 2039 | case -SCTP_IERROR_BAD_SIG: |
2008 | default: | 2040 | default: |
2009 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2041 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2010 | } | 2042 | } |
2011 | } | 2043 | } |
2012 | 2044 | ||
@@ -2017,27 +2049,27 @@ sctp_disposition_t sctp_sf_do_5_2_4_dupcook(const struct sctp_endpoint *ep, | |||
2017 | 2049 | ||
2018 | switch (action) { | 2050 | switch (action) { |
2019 | case 'A': /* Association restart. */ | 2051 | case 'A': /* Association restart. */ |
2020 | retval = sctp_sf_do_dupcook_a(ep, asoc, chunk, commands, | 2052 | retval = sctp_sf_do_dupcook_a(net, ep, asoc, chunk, commands, |
2021 | new_asoc); | 2053 | new_asoc); |
2022 | break; | 2054 | break; |
2023 | 2055 | ||
2024 | case 'B': /* Collision case B. */ | 2056 | case 'B': /* Collision case B. */ |
2025 | retval = sctp_sf_do_dupcook_b(ep, asoc, chunk, commands, | 2057 | retval = sctp_sf_do_dupcook_b(net, ep, asoc, chunk, commands, |
2026 | new_asoc); | 2058 | new_asoc); |
2027 | break; | 2059 | break; |
2028 | 2060 | ||
2029 | case 'C': /* Collision case C. */ | 2061 | case 'C': /* Collision case C. */ |
2030 | retval = sctp_sf_do_dupcook_c(ep, asoc, chunk, commands, | 2062 | retval = sctp_sf_do_dupcook_c(net, ep, asoc, chunk, commands, |
2031 | new_asoc); | 2063 | new_asoc); |
2032 | break; | 2064 | break; |
2033 | 2065 | ||
2034 | case 'D': /* Collision case D. */ | 2066 | case 'D': /* Collision case D. */ |
2035 | retval = sctp_sf_do_dupcook_d(ep, asoc, chunk, commands, | 2067 | retval = sctp_sf_do_dupcook_d(net, ep, asoc, chunk, commands, |
2036 | new_asoc); | 2068 | new_asoc); |
2037 | break; | 2069 | break; |
2038 | 2070 | ||
2039 | default: /* Discard packet for all others. */ | 2071 | default: /* Discard packet for all others. */ |
2040 | retval = sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2072 | retval = sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2041 | break; | 2073 | break; |
2042 | } | 2074 | } |
2043 | 2075 | ||
@@ -2063,6 +2095,7 @@ nomem: | |||
2063 | * See sctp_sf_do_9_1_abort(). | 2095 | * See sctp_sf_do_9_1_abort(). |
2064 | */ | 2096 | */ |
2065 | sctp_disposition_t sctp_sf_shutdown_pending_abort( | 2097 | sctp_disposition_t sctp_sf_shutdown_pending_abort( |
2098 | struct net *net, | ||
2066 | const struct sctp_endpoint *ep, | 2099 | const struct sctp_endpoint *ep, |
2067 | const struct sctp_association *asoc, | 2100 | const struct sctp_association *asoc, |
2068 | const sctp_subtype_t type, | 2101 | const sctp_subtype_t type, |
@@ -2072,7 +2105,7 @@ sctp_disposition_t sctp_sf_shutdown_pending_abort( | |||
2072 | struct sctp_chunk *chunk = arg; | 2105 | struct sctp_chunk *chunk = arg; |
2073 | 2106 | ||
2074 | if (!sctp_vtag_verify_either(chunk, asoc)) | 2107 | if (!sctp_vtag_verify_either(chunk, asoc)) |
2075 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2108 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2076 | 2109 | ||
2077 | /* Make sure that the ABORT chunk has a valid length. | 2110 | /* Make sure that the ABORT chunk has a valid length. |
2078 | * Since this is an ABORT chunk, we have to discard it | 2111 | * Since this is an ABORT chunk, we have to discard it |
@@ -2085,7 +2118,7 @@ sctp_disposition_t sctp_sf_shutdown_pending_abort( | |||
2085 | * packet. | 2118 | * packet. |
2086 | */ | 2119 | */ |
2087 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) | 2120 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) |
2088 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2121 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2089 | 2122 | ||
2090 | /* ADD-IP: Special case for ABORT chunks | 2123 | /* ADD-IP: Special case for ABORT chunks |
2091 | * F4) One special consideration is that ABORT Chunks arriving | 2124 | * F4) One special consideration is that ABORT Chunks arriving |
@@ -2094,9 +2127,9 @@ sctp_disposition_t sctp_sf_shutdown_pending_abort( | |||
2094 | */ | 2127 | */ |
2095 | if (SCTP_ADDR_DEL == | 2128 | if (SCTP_ADDR_DEL == |
2096 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) | 2129 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) |
2097 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 2130 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
2098 | 2131 | ||
2099 | return __sctp_sf_do_9_1_abort(ep, asoc, type, arg, commands); | 2132 | return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands); |
2100 | } | 2133 | } |
2101 | 2134 | ||
2102 | /* | 2135 | /* |
@@ -2104,7 +2137,8 @@ sctp_disposition_t sctp_sf_shutdown_pending_abort( | |||
2104 | * | 2137 | * |
2105 | * See sctp_sf_do_9_1_abort(). | 2138 | * See sctp_sf_do_9_1_abort(). |
2106 | */ | 2139 | */ |
2107 | sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | 2140 | sctp_disposition_t sctp_sf_shutdown_sent_abort(struct net *net, |
2141 | const struct sctp_endpoint *ep, | ||
2108 | const struct sctp_association *asoc, | 2142 | const struct sctp_association *asoc, |
2109 | const sctp_subtype_t type, | 2143 | const sctp_subtype_t type, |
2110 | void *arg, | 2144 | void *arg, |
@@ -2113,7 +2147,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2113 | struct sctp_chunk *chunk = arg; | 2147 | struct sctp_chunk *chunk = arg; |
2114 | 2148 | ||
2115 | if (!sctp_vtag_verify_either(chunk, asoc)) | 2149 | if (!sctp_vtag_verify_either(chunk, asoc)) |
2116 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2150 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2117 | 2151 | ||
2118 | /* Make sure that the ABORT chunk has a valid length. | 2152 | /* Make sure that the ABORT chunk has a valid length. |
2119 | * Since this is an ABORT chunk, we have to discard it | 2153 | * Since this is an ABORT chunk, we have to discard it |
@@ -2126,7 +2160,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2126 | * packet. | 2160 | * packet. |
2127 | */ | 2161 | */ |
2128 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) | 2162 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) |
2129 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2163 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2130 | 2164 | ||
2131 | /* ADD-IP: Special case for ABORT chunks | 2165 | /* ADD-IP: Special case for ABORT chunks |
2132 | * F4) One special consideration is that ABORT Chunks arriving | 2166 | * F4) One special consideration is that ABORT Chunks arriving |
@@ -2135,7 +2169,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2135 | */ | 2169 | */ |
2136 | if (SCTP_ADDR_DEL == | 2170 | if (SCTP_ADDR_DEL == |
2137 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) | 2171 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) |
2138 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 2172 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
2139 | 2173 | ||
2140 | /* Stop the T2-shutdown timer. */ | 2174 | /* Stop the T2-shutdown timer. */ |
2141 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 2175 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
@@ -2145,7 +2179,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2145 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 2179 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
2146 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); | 2180 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); |
2147 | 2181 | ||
2148 | return __sctp_sf_do_9_1_abort(ep, asoc, type, arg, commands); | 2182 | return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands); |
2149 | } | 2183 | } |
2150 | 2184 | ||
2151 | /* | 2185 | /* |
@@ -2154,6 +2188,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_abort(const struct sctp_endpoint *ep, | |||
2154 | * See sctp_sf_do_9_1_abort(). | 2188 | * See sctp_sf_do_9_1_abort(). |
2155 | */ | 2189 | */ |
2156 | sctp_disposition_t sctp_sf_shutdown_ack_sent_abort( | 2190 | sctp_disposition_t sctp_sf_shutdown_ack_sent_abort( |
2191 | struct net *net, | ||
2157 | const struct sctp_endpoint *ep, | 2192 | const struct sctp_endpoint *ep, |
2158 | const struct sctp_association *asoc, | 2193 | const struct sctp_association *asoc, |
2159 | const sctp_subtype_t type, | 2194 | const sctp_subtype_t type, |
@@ -2163,7 +2198,7 @@ sctp_disposition_t sctp_sf_shutdown_ack_sent_abort( | |||
2163 | /* The same T2 timer, so we should be able to use | 2198 | /* The same T2 timer, so we should be able to use |
2164 | * common function with the SHUTDOWN-SENT state. | 2199 | * common function with the SHUTDOWN-SENT state. |
2165 | */ | 2200 | */ |
2166 | return sctp_sf_shutdown_sent_abort(ep, asoc, type, arg, commands); | 2201 | return sctp_sf_shutdown_sent_abort(net, ep, asoc, type, arg, commands); |
2167 | } | 2202 | } |
2168 | 2203 | ||
2169 | /* | 2204 | /* |
@@ -2180,7 +2215,8 @@ sctp_disposition_t sctp_sf_shutdown_ack_sent_abort( | |||
2180 | * | 2215 | * |
2181 | * The return value is the disposition of the chunk. | 2216 | * The return value is the disposition of the chunk. |
2182 | */ | 2217 | */ |
2183 | sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | 2218 | sctp_disposition_t sctp_sf_cookie_echoed_err(struct net *net, |
2219 | const struct sctp_endpoint *ep, | ||
2184 | const struct sctp_association *asoc, | 2220 | const struct sctp_association *asoc, |
2185 | const sctp_subtype_t type, | 2221 | const sctp_subtype_t type, |
2186 | void *arg, | 2222 | void *arg, |
@@ -2190,13 +2226,13 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | |||
2190 | sctp_errhdr_t *err; | 2226 | sctp_errhdr_t *err; |
2191 | 2227 | ||
2192 | if (!sctp_vtag_verify(chunk, asoc)) | 2228 | if (!sctp_vtag_verify(chunk, asoc)) |
2193 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2229 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2194 | 2230 | ||
2195 | /* Make sure that the ERROR chunk has a valid length. | 2231 | /* Make sure that the ERROR chunk has a valid length. |
2196 | * The parameter walking depends on this as well. | 2232 | * The parameter walking depends on this as well. |
2197 | */ | 2233 | */ |
2198 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) | 2234 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) |
2199 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2235 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2200 | commands); | 2236 | commands); |
2201 | 2237 | ||
2202 | /* Process the error here */ | 2238 | /* Process the error here */ |
@@ -2206,7 +2242,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | |||
2206 | */ | 2242 | */ |
2207 | sctp_walk_errors(err, chunk->chunk_hdr) { | 2243 | sctp_walk_errors(err, chunk->chunk_hdr) { |
2208 | if (SCTP_ERROR_STALE_COOKIE == err->cause) | 2244 | if (SCTP_ERROR_STALE_COOKIE == err->cause) |
2209 | return sctp_sf_do_5_2_6_stale(ep, asoc, type, | 2245 | return sctp_sf_do_5_2_6_stale(net, ep, asoc, type, |
2210 | arg, commands); | 2246 | arg, commands); |
2211 | } | 2247 | } |
2212 | 2248 | ||
@@ -2215,7 +2251,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | |||
2215 | * we are discarding the packet, there should be no adverse | 2251 | * we are discarding the packet, there should be no adverse |
2216 | * affects. | 2252 | * affects. |
2217 | */ | 2253 | */ |
2218 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2254 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2219 | } | 2255 | } |
2220 | 2256 | ||
2221 | /* | 2257 | /* |
@@ -2243,7 +2279,8 @@ sctp_disposition_t sctp_sf_cookie_echoed_err(const struct sctp_endpoint *ep, | |||
2243 | * | 2279 | * |
2244 | * The return value is the disposition of the chunk. | 2280 | * The return value is the disposition of the chunk. |
2245 | */ | 2281 | */ |
2246 | static sctp_disposition_t sctp_sf_do_5_2_6_stale(const struct sctp_endpoint *ep, | 2282 | static sctp_disposition_t sctp_sf_do_5_2_6_stale(struct net *net, |
2283 | const struct sctp_endpoint *ep, | ||
2247 | const struct sctp_association *asoc, | 2284 | const struct sctp_association *asoc, |
2248 | const sctp_subtype_t type, | 2285 | const sctp_subtype_t type, |
2249 | void *arg, | 2286 | void *arg, |
@@ -2365,7 +2402,8 @@ nomem: | |||
2365 | * | 2402 | * |
2366 | * The return value is the disposition of the chunk. | 2403 | * The return value is the disposition of the chunk. |
2367 | */ | 2404 | */ |
2368 | sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | 2405 | sctp_disposition_t sctp_sf_do_9_1_abort(struct net *net, |
2406 | const struct sctp_endpoint *ep, | ||
2369 | const struct sctp_association *asoc, | 2407 | const struct sctp_association *asoc, |
2370 | const sctp_subtype_t type, | 2408 | const sctp_subtype_t type, |
2371 | void *arg, | 2409 | void *arg, |
@@ -2374,7 +2412,7 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2374 | struct sctp_chunk *chunk = arg; | 2412 | struct sctp_chunk *chunk = arg; |
2375 | 2413 | ||
2376 | if (!sctp_vtag_verify_either(chunk, asoc)) | 2414 | if (!sctp_vtag_verify_either(chunk, asoc)) |
2377 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2415 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2378 | 2416 | ||
2379 | /* Make sure that the ABORT chunk has a valid length. | 2417 | /* Make sure that the ABORT chunk has a valid length. |
2380 | * Since this is an ABORT chunk, we have to discard it | 2418 | * Since this is an ABORT chunk, we have to discard it |
@@ -2387,7 +2425,7 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2387 | * packet. | 2425 | * packet. |
2388 | */ | 2426 | */ |
2389 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) | 2427 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) |
2390 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2428 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2391 | 2429 | ||
2392 | /* ADD-IP: Special case for ABORT chunks | 2430 | /* ADD-IP: Special case for ABORT chunks |
2393 | * F4) One special consideration is that ABORT Chunks arriving | 2431 | * F4) One special consideration is that ABORT Chunks arriving |
@@ -2396,12 +2434,13 @@ sctp_disposition_t sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2396 | */ | 2434 | */ |
2397 | if (SCTP_ADDR_DEL == | 2435 | if (SCTP_ADDR_DEL == |
2398 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) | 2436 | sctp_bind_addr_state(&asoc->base.bind_addr, &chunk->dest)) |
2399 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 2437 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
2400 | 2438 | ||
2401 | return __sctp_sf_do_9_1_abort(ep, asoc, type, arg, commands); | 2439 | return __sctp_sf_do_9_1_abort(net, ep, asoc, type, arg, commands); |
2402 | } | 2440 | } |
2403 | 2441 | ||
2404 | static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | 2442 | static sctp_disposition_t __sctp_sf_do_9_1_abort(struct net *net, |
2443 | const struct sctp_endpoint *ep, | ||
2405 | const struct sctp_association *asoc, | 2444 | const struct sctp_association *asoc, |
2406 | const sctp_subtype_t type, | 2445 | const sctp_subtype_t type, |
2407 | void *arg, | 2446 | void *arg, |
@@ -2418,7 +2457,7 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2418 | sctp_errhdr_t *err; | 2457 | sctp_errhdr_t *err; |
2419 | sctp_walk_errors(err, chunk->chunk_hdr); | 2458 | sctp_walk_errors(err, chunk->chunk_hdr); |
2420 | if ((void *)err != (void *)chunk->chunk_end) | 2459 | if ((void *)err != (void *)chunk->chunk_end) |
2421 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2460 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2422 | 2461 | ||
2423 | error = ((sctp_errhdr_t *)chunk->skb->data)->cause; | 2462 | error = ((sctp_errhdr_t *)chunk->skb->data)->cause; |
2424 | } | 2463 | } |
@@ -2426,8 +2465,8 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2426 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET)); | 2465 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(ECONNRESET)); |
2427 | /* ASSOC_FAILED will DELETE_TCB. */ | 2466 | /* ASSOC_FAILED will DELETE_TCB. */ |
2428 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_PERR(error)); | 2467 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, SCTP_PERR(error)); |
2429 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 2468 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
2430 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 2469 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
2431 | 2470 | ||
2432 | return SCTP_DISPOSITION_ABORT; | 2471 | return SCTP_DISPOSITION_ABORT; |
2433 | } | 2472 | } |
@@ -2437,7 +2476,8 @@ static sctp_disposition_t __sctp_sf_do_9_1_abort(const struct sctp_endpoint *ep, | |||
2437 | * | 2476 | * |
2438 | * See sctp_sf_do_9_1_abort() above. | 2477 | * See sctp_sf_do_9_1_abort() above. |
2439 | */ | 2478 | */ |
2440 | sctp_disposition_t sctp_sf_cookie_wait_abort(const struct sctp_endpoint *ep, | 2479 | sctp_disposition_t sctp_sf_cookie_wait_abort(struct net *net, |
2480 | const struct sctp_endpoint *ep, | ||
2441 | const struct sctp_association *asoc, | 2481 | const struct sctp_association *asoc, |
2442 | const sctp_subtype_t type, | 2482 | const sctp_subtype_t type, |
2443 | void *arg, | 2483 | void *arg, |
@@ -2448,7 +2488,7 @@ sctp_disposition_t sctp_sf_cookie_wait_abort(const struct sctp_endpoint *ep, | |||
2448 | __be16 error = SCTP_ERROR_NO_ERROR; | 2488 | __be16 error = SCTP_ERROR_NO_ERROR; |
2449 | 2489 | ||
2450 | if (!sctp_vtag_verify_either(chunk, asoc)) | 2490 | if (!sctp_vtag_verify_either(chunk, asoc)) |
2451 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2491 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2452 | 2492 | ||
2453 | /* Make sure that the ABORT chunk has a valid length. | 2493 | /* Make sure that the ABORT chunk has a valid length. |
2454 | * Since this is an ABORT chunk, we have to discard it | 2494 | * Since this is an ABORT chunk, we have to discard it |
@@ -2461,27 +2501,28 @@ sctp_disposition_t sctp_sf_cookie_wait_abort(const struct sctp_endpoint *ep, | |||
2461 | * packet. | 2501 | * packet. |
2462 | */ | 2502 | */ |
2463 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) | 2503 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_abort_chunk_t))) |
2464 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2504 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2465 | 2505 | ||
2466 | /* See if we have an error cause code in the chunk. */ | 2506 | /* See if we have an error cause code in the chunk. */ |
2467 | len = ntohs(chunk->chunk_hdr->length); | 2507 | len = ntohs(chunk->chunk_hdr->length); |
2468 | if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) | 2508 | if (len >= sizeof(struct sctp_chunkhdr) + sizeof(struct sctp_errhdr)) |
2469 | error = ((sctp_errhdr_t *)chunk->skb->data)->cause; | 2509 | error = ((sctp_errhdr_t *)chunk->skb->data)->cause; |
2470 | 2510 | ||
2471 | return sctp_stop_t1_and_abort(commands, error, ECONNREFUSED, asoc, | 2511 | return sctp_stop_t1_and_abort(net, commands, error, ECONNREFUSED, asoc, |
2472 | chunk->transport); | 2512 | chunk->transport); |
2473 | } | 2513 | } |
2474 | 2514 | ||
2475 | /* | 2515 | /* |
2476 | * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state) | 2516 | * Process an incoming ICMP as an ABORT. (COOKIE-WAIT state) |
2477 | */ | 2517 | */ |
2478 | sctp_disposition_t sctp_sf_cookie_wait_icmp_abort(const struct sctp_endpoint *ep, | 2518 | sctp_disposition_t sctp_sf_cookie_wait_icmp_abort(struct net *net, |
2519 | const struct sctp_endpoint *ep, | ||
2479 | const struct sctp_association *asoc, | 2520 | const struct sctp_association *asoc, |
2480 | const sctp_subtype_t type, | 2521 | const sctp_subtype_t type, |
2481 | void *arg, | 2522 | void *arg, |
2482 | sctp_cmd_seq_t *commands) | 2523 | sctp_cmd_seq_t *commands) |
2483 | { | 2524 | { |
2484 | return sctp_stop_t1_and_abort(commands, SCTP_ERROR_NO_ERROR, | 2525 | return sctp_stop_t1_and_abort(net, commands, SCTP_ERROR_NO_ERROR, |
2485 | ENOPROTOOPT, asoc, | 2526 | ENOPROTOOPT, asoc, |
2486 | (struct sctp_transport *)arg); | 2527 | (struct sctp_transport *)arg); |
2487 | } | 2528 | } |
@@ -2489,7 +2530,8 @@ sctp_disposition_t sctp_sf_cookie_wait_icmp_abort(const struct sctp_endpoint *ep | |||
2489 | /* | 2530 | /* |
2490 | * Process an ABORT. (COOKIE-ECHOED state) | 2531 | * Process an ABORT. (COOKIE-ECHOED state) |
2491 | */ | 2532 | */ |
2492 | sctp_disposition_t sctp_sf_cookie_echoed_abort(const struct sctp_endpoint *ep, | 2533 | sctp_disposition_t sctp_sf_cookie_echoed_abort(struct net *net, |
2534 | const struct sctp_endpoint *ep, | ||
2493 | const struct sctp_association *asoc, | 2535 | const struct sctp_association *asoc, |
2494 | const sctp_subtype_t type, | 2536 | const sctp_subtype_t type, |
2495 | void *arg, | 2537 | void *arg, |
@@ -2498,7 +2540,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_abort(const struct sctp_endpoint *ep, | |||
2498 | /* There is a single T1 timer, so we should be able to use | 2540 | /* There is a single T1 timer, so we should be able to use |
2499 | * common function with the COOKIE-WAIT state. | 2541 | * common function with the COOKIE-WAIT state. |
2500 | */ | 2542 | */ |
2501 | return sctp_sf_cookie_wait_abort(ep, asoc, type, arg, commands); | 2543 | return sctp_sf_cookie_wait_abort(net, ep, asoc, type, arg, commands); |
2502 | } | 2544 | } |
2503 | 2545 | ||
2504 | /* | 2546 | /* |
@@ -2506,7 +2548,8 @@ sctp_disposition_t sctp_sf_cookie_echoed_abort(const struct sctp_endpoint *ep, | |||
2506 | * | 2548 | * |
2507 | * This is common code called by several sctp_sf_*_abort() functions above. | 2549 | * This is common code called by several sctp_sf_*_abort() functions above. |
2508 | */ | 2550 | */ |
2509 | static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, | 2551 | static sctp_disposition_t sctp_stop_t1_and_abort(struct net *net, |
2552 | sctp_cmd_seq_t *commands, | ||
2510 | __be16 error, int sk_err, | 2553 | __be16 error, int sk_err, |
2511 | const struct sctp_association *asoc, | 2554 | const struct sctp_association *asoc, |
2512 | struct sctp_transport *transport) | 2555 | struct sctp_transport *transport) |
@@ -2514,7 +2557,7 @@ static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, | |||
2514 | SCTP_DEBUG_PRINTK("ABORT received (INIT).\n"); | 2557 | SCTP_DEBUG_PRINTK("ABORT received (INIT).\n"); |
2515 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 2558 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
2516 | SCTP_STATE(SCTP_STATE_CLOSED)); | 2559 | SCTP_STATE(SCTP_STATE_CLOSED)); |
2517 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 2560 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
2518 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 2561 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
2519 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); | 2562 | SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); |
2520 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(sk_err)); | 2563 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, SCTP_ERROR(sk_err)); |
@@ -2557,7 +2600,8 @@ static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands, | |||
2557 | * | 2600 | * |
2558 | * The return value is the disposition of the chunk. | 2601 | * The return value is the disposition of the chunk. |
2559 | */ | 2602 | */ |
2560 | sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | 2603 | sctp_disposition_t sctp_sf_do_9_2_shutdown(struct net *net, |
2604 | const struct sctp_endpoint *ep, | ||
2561 | const struct sctp_association *asoc, | 2605 | const struct sctp_association *asoc, |
2562 | const sctp_subtype_t type, | 2606 | const sctp_subtype_t type, |
2563 | void *arg, | 2607 | void *arg, |
@@ -2570,12 +2614,12 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | |||
2570 | __u32 ctsn; | 2614 | __u32 ctsn; |
2571 | 2615 | ||
2572 | if (!sctp_vtag_verify(chunk, asoc)) | 2616 | if (!sctp_vtag_verify(chunk, asoc)) |
2573 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2617 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2574 | 2618 | ||
2575 | /* Make sure that the SHUTDOWN chunk has a valid length. */ | 2619 | /* Make sure that the SHUTDOWN chunk has a valid length. */ |
2576 | if (!sctp_chunk_length_valid(chunk, | 2620 | if (!sctp_chunk_length_valid(chunk, |
2577 | sizeof(struct sctp_shutdown_chunk_t))) | 2621 | sizeof(struct sctp_shutdown_chunk_t))) |
2578 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2622 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2579 | commands); | 2623 | commands); |
2580 | 2624 | ||
2581 | /* Convert the elaborate header. */ | 2625 | /* Convert the elaborate header. */ |
@@ -2595,7 +2639,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | |||
2595 | * sender with an ABORT. | 2639 | * sender with an ABORT. |
2596 | */ | 2640 | */ |
2597 | if (!TSN_lt(ctsn, asoc->next_tsn)) | 2641 | if (!TSN_lt(ctsn, asoc->next_tsn)) |
2598 | return sctp_sf_violation_ctsn(ep, asoc, type, arg, commands); | 2642 | return sctp_sf_violation_ctsn(net, ep, asoc, type, arg, commands); |
2599 | 2643 | ||
2600 | /* API 5.3.1.5 SCTP_SHUTDOWN_EVENT | 2644 | /* API 5.3.1.5 SCTP_SHUTDOWN_EVENT |
2601 | * When a peer sends a SHUTDOWN, SCTP delivers this notification to | 2645 | * When a peer sends a SHUTDOWN, SCTP delivers this notification to |
@@ -2619,7 +2663,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | |||
2619 | disposition = SCTP_DISPOSITION_CONSUME; | 2663 | disposition = SCTP_DISPOSITION_CONSUME; |
2620 | 2664 | ||
2621 | if (sctp_outq_is_empty(&asoc->outqueue)) { | 2665 | if (sctp_outq_is_empty(&asoc->outqueue)) { |
2622 | disposition = sctp_sf_do_9_2_shutdown_ack(ep, asoc, type, | 2666 | disposition = sctp_sf_do_9_2_shutdown_ack(net, ep, asoc, type, |
2623 | arg, commands); | 2667 | arg, commands); |
2624 | } | 2668 | } |
2625 | 2669 | ||
@@ -2645,7 +2689,8 @@ out: | |||
2645 | * The Cumulative TSN Ack of the received SHUTDOWN chunk | 2689 | * The Cumulative TSN Ack of the received SHUTDOWN chunk |
2646 | * MUST be processed. | 2690 | * MUST be processed. |
2647 | */ | 2691 | */ |
2648 | sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(const struct sctp_endpoint *ep, | 2692 | sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(struct net *net, |
2693 | const struct sctp_endpoint *ep, | ||
2649 | const struct sctp_association *asoc, | 2694 | const struct sctp_association *asoc, |
2650 | const sctp_subtype_t type, | 2695 | const sctp_subtype_t type, |
2651 | void *arg, | 2696 | void *arg, |
@@ -2656,12 +2701,12 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(const struct sctp_endpoint *ep, | |||
2656 | __u32 ctsn; | 2701 | __u32 ctsn; |
2657 | 2702 | ||
2658 | if (!sctp_vtag_verify(chunk, asoc)) | 2703 | if (!sctp_vtag_verify(chunk, asoc)) |
2659 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2704 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2660 | 2705 | ||
2661 | /* Make sure that the SHUTDOWN chunk has a valid length. */ | 2706 | /* Make sure that the SHUTDOWN chunk has a valid length. */ |
2662 | if (!sctp_chunk_length_valid(chunk, | 2707 | if (!sctp_chunk_length_valid(chunk, |
2663 | sizeof(struct sctp_shutdown_chunk_t))) | 2708 | sizeof(struct sctp_shutdown_chunk_t))) |
2664 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2709 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2665 | commands); | 2710 | commands); |
2666 | 2711 | ||
2667 | sdh = (sctp_shutdownhdr_t *)chunk->skb->data; | 2712 | sdh = (sctp_shutdownhdr_t *)chunk->skb->data; |
@@ -2678,7 +2723,7 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(const struct sctp_endpoint *ep, | |||
2678 | * sender with an ABORT. | 2723 | * sender with an ABORT. |
2679 | */ | 2724 | */ |
2680 | if (!TSN_lt(ctsn, asoc->next_tsn)) | 2725 | if (!TSN_lt(ctsn, asoc->next_tsn)) |
2681 | return sctp_sf_violation_ctsn(ep, asoc, type, arg, commands); | 2726 | return sctp_sf_violation_ctsn(net, ep, asoc, type, arg, commands); |
2682 | 2727 | ||
2683 | /* verify, by checking the Cumulative TSN Ack field of the | 2728 | /* verify, by checking the Cumulative TSN Ack field of the |
2684 | * chunk, that all its outstanding DATA chunks have been | 2729 | * chunk, that all its outstanding DATA chunks have been |
@@ -2697,7 +2742,8 @@ sctp_disposition_t sctp_sf_do_9_2_shut_ctsn(const struct sctp_endpoint *ep, | |||
2697 | * that belong to this association, it should discard the INIT chunk and | 2742 | * that belong to this association, it should discard the INIT chunk and |
2698 | * retransmit the SHUTDOWN ACK chunk. | 2743 | * retransmit the SHUTDOWN ACK chunk. |
2699 | */ | 2744 | */ |
2700 | sctp_disposition_t sctp_sf_do_9_2_reshutack(const struct sctp_endpoint *ep, | 2745 | sctp_disposition_t sctp_sf_do_9_2_reshutack(struct net *net, |
2746 | const struct sctp_endpoint *ep, | ||
2701 | const struct sctp_association *asoc, | 2747 | const struct sctp_association *asoc, |
2702 | const sctp_subtype_t type, | 2748 | const sctp_subtype_t type, |
2703 | void *arg, | 2749 | void *arg, |
@@ -2708,7 +2754,7 @@ sctp_disposition_t sctp_sf_do_9_2_reshutack(const struct sctp_endpoint *ep, | |||
2708 | 2754 | ||
2709 | /* Make sure that the chunk has a valid length */ | 2755 | /* Make sure that the chunk has a valid length */ |
2710 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 2756 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
2711 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2757 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2712 | commands); | 2758 | commands); |
2713 | 2759 | ||
2714 | /* Since we are not going to really process this INIT, there | 2760 | /* Since we are not going to really process this INIT, there |
@@ -2760,7 +2806,8 @@ nomem: | |||
2760 | * | 2806 | * |
2761 | * The return value is the disposition of the chunk. | 2807 | * The return value is the disposition of the chunk. |
2762 | */ | 2808 | */ |
2763 | sctp_disposition_t sctp_sf_do_ecn_cwr(const struct sctp_endpoint *ep, | 2809 | sctp_disposition_t sctp_sf_do_ecn_cwr(struct net *net, |
2810 | const struct sctp_endpoint *ep, | ||
2764 | const struct sctp_association *asoc, | 2811 | const struct sctp_association *asoc, |
2765 | const sctp_subtype_t type, | 2812 | const sctp_subtype_t type, |
2766 | void *arg, | 2813 | void *arg, |
@@ -2771,10 +2818,10 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(const struct sctp_endpoint *ep, | |||
2771 | u32 lowest_tsn; | 2818 | u32 lowest_tsn; |
2772 | 2819 | ||
2773 | if (!sctp_vtag_verify(chunk, asoc)) | 2820 | if (!sctp_vtag_verify(chunk, asoc)) |
2774 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2821 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2775 | 2822 | ||
2776 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) | 2823 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) |
2777 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2824 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2778 | commands); | 2825 | commands); |
2779 | 2826 | ||
2780 | cwr = (sctp_cwrhdr_t *) chunk->skb->data; | 2827 | cwr = (sctp_cwrhdr_t *) chunk->skb->data; |
@@ -2815,7 +2862,8 @@ sctp_disposition_t sctp_sf_do_ecn_cwr(const struct sctp_endpoint *ep, | |||
2815 | * | 2862 | * |
2816 | * The return value is the disposition of the chunk. | 2863 | * The return value is the disposition of the chunk. |
2817 | */ | 2864 | */ |
2818 | sctp_disposition_t sctp_sf_do_ecne(const struct sctp_endpoint *ep, | 2865 | sctp_disposition_t sctp_sf_do_ecne(struct net *net, |
2866 | const struct sctp_endpoint *ep, | ||
2819 | const struct sctp_association *asoc, | 2867 | const struct sctp_association *asoc, |
2820 | const sctp_subtype_t type, | 2868 | const sctp_subtype_t type, |
2821 | void *arg, | 2869 | void *arg, |
@@ -2825,10 +2873,10 @@ sctp_disposition_t sctp_sf_do_ecne(const struct sctp_endpoint *ep, | |||
2825 | struct sctp_chunk *chunk = arg; | 2873 | struct sctp_chunk *chunk = arg; |
2826 | 2874 | ||
2827 | if (!sctp_vtag_verify(chunk, asoc)) | 2875 | if (!sctp_vtag_verify(chunk, asoc)) |
2828 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2876 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2829 | 2877 | ||
2830 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) | 2878 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_ecne_chunk_t))) |
2831 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2879 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2832 | commands); | 2880 | commands); |
2833 | 2881 | ||
2834 | ecne = (sctp_ecnehdr_t *) chunk->skb->data; | 2882 | ecne = (sctp_ecnehdr_t *) chunk->skb->data; |
@@ -2871,7 +2919,8 @@ sctp_disposition_t sctp_sf_do_ecne(const struct sctp_endpoint *ep, | |||
2871 | * | 2919 | * |
2872 | * The return value is the disposition of the chunk. | 2920 | * The return value is the disposition of the chunk. |
2873 | */ | 2921 | */ |
2874 | sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep, | 2922 | sctp_disposition_t sctp_sf_eat_data_6_2(struct net *net, |
2923 | const struct sctp_endpoint *ep, | ||
2875 | const struct sctp_association *asoc, | 2924 | const struct sctp_association *asoc, |
2876 | const sctp_subtype_t type, | 2925 | const sctp_subtype_t type, |
2877 | void *arg, | 2926 | void *arg, |
@@ -2884,11 +2933,11 @@ sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep, | |||
2884 | if (!sctp_vtag_verify(chunk, asoc)) { | 2933 | if (!sctp_vtag_verify(chunk, asoc)) { |
2885 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 2934 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
2886 | SCTP_NULL()); | 2935 | SCTP_NULL()); |
2887 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 2936 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
2888 | } | 2937 | } |
2889 | 2938 | ||
2890 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_data_chunk_t))) | 2939 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_data_chunk_t))) |
2891 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 2940 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
2892 | commands); | 2941 | commands); |
2893 | 2942 | ||
2894 | error = sctp_eat_data(asoc, chunk, commands ); | 2943 | error = sctp_eat_data(asoc, chunk, commands ); |
@@ -2897,16 +2946,16 @@ sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep, | |||
2897 | break; | 2946 | break; |
2898 | case SCTP_IERROR_HIGH_TSN: | 2947 | case SCTP_IERROR_HIGH_TSN: |
2899 | case SCTP_IERROR_BAD_STREAM: | 2948 | case SCTP_IERROR_BAD_STREAM: |
2900 | SCTP_INC_STATS(SCTP_MIB_IN_DATA_CHUNK_DISCARDS); | 2949 | SCTP_INC_STATS(net, SCTP_MIB_IN_DATA_CHUNK_DISCARDS); |
2901 | goto discard_noforce; | 2950 | goto discard_noforce; |
2902 | case SCTP_IERROR_DUP_TSN: | 2951 | case SCTP_IERROR_DUP_TSN: |
2903 | case SCTP_IERROR_IGNORE_TSN: | 2952 | case SCTP_IERROR_IGNORE_TSN: |
2904 | SCTP_INC_STATS(SCTP_MIB_IN_DATA_CHUNK_DISCARDS); | 2953 | SCTP_INC_STATS(net, SCTP_MIB_IN_DATA_CHUNK_DISCARDS); |
2905 | goto discard_force; | 2954 | goto discard_force; |
2906 | case SCTP_IERROR_NO_DATA: | 2955 | case SCTP_IERROR_NO_DATA: |
2907 | goto consume; | 2956 | goto consume; |
2908 | case SCTP_IERROR_PROTO_VIOLATION: | 2957 | case SCTP_IERROR_PROTO_VIOLATION: |
2909 | return sctp_sf_abort_violation(ep, asoc, chunk, commands, | 2958 | return sctp_sf_abort_violation(net, ep, asoc, chunk, commands, |
2910 | (u8 *)chunk->subh.data_hdr, sizeof(sctp_datahdr_t)); | 2959 | (u8 *)chunk->subh.data_hdr, sizeof(sctp_datahdr_t)); |
2911 | default: | 2960 | default: |
2912 | BUG(); | 2961 | BUG(); |
@@ -2992,7 +3041,8 @@ consume: | |||
2992 | * | 3041 | * |
2993 | * The return value is the disposition of the chunk. | 3042 | * The return value is the disposition of the chunk. |
2994 | */ | 3043 | */ |
2995 | sctp_disposition_t sctp_sf_eat_data_fast_4_4(const struct sctp_endpoint *ep, | 3044 | sctp_disposition_t sctp_sf_eat_data_fast_4_4(struct net *net, |
3045 | const struct sctp_endpoint *ep, | ||
2996 | const struct sctp_association *asoc, | 3046 | const struct sctp_association *asoc, |
2997 | const sctp_subtype_t type, | 3047 | const sctp_subtype_t type, |
2998 | void *arg, | 3048 | void *arg, |
@@ -3004,11 +3054,11 @@ sctp_disposition_t sctp_sf_eat_data_fast_4_4(const struct sctp_endpoint *ep, | |||
3004 | if (!sctp_vtag_verify(chunk, asoc)) { | 3054 | if (!sctp_vtag_verify(chunk, asoc)) { |
3005 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3055 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3006 | SCTP_NULL()); | 3056 | SCTP_NULL()); |
3007 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3057 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3008 | } | 3058 | } |
3009 | 3059 | ||
3010 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_data_chunk_t))) | 3060 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_data_chunk_t))) |
3011 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3061 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3012 | commands); | 3062 | commands); |
3013 | 3063 | ||
3014 | error = sctp_eat_data(asoc, chunk, commands ); | 3064 | error = sctp_eat_data(asoc, chunk, commands ); |
@@ -3022,7 +3072,7 @@ sctp_disposition_t sctp_sf_eat_data_fast_4_4(const struct sctp_endpoint *ep, | |||
3022 | case SCTP_IERROR_NO_DATA: | 3072 | case SCTP_IERROR_NO_DATA: |
3023 | goto consume; | 3073 | goto consume; |
3024 | case SCTP_IERROR_PROTO_VIOLATION: | 3074 | case SCTP_IERROR_PROTO_VIOLATION: |
3025 | return sctp_sf_abort_violation(ep, asoc, chunk, commands, | 3075 | return sctp_sf_abort_violation(net, ep, asoc, chunk, commands, |
3026 | (u8 *)chunk->subh.data_hdr, sizeof(sctp_datahdr_t)); | 3076 | (u8 *)chunk->subh.data_hdr, sizeof(sctp_datahdr_t)); |
3027 | default: | 3077 | default: |
3028 | BUG(); | 3078 | BUG(); |
@@ -3082,7 +3132,8 @@ consume: | |||
3082 | * | 3132 | * |
3083 | * The return value is the disposition of the chunk. | 3133 | * The return value is the disposition of the chunk. |
3084 | */ | 3134 | */ |
3085 | sctp_disposition_t sctp_sf_eat_sack_6_2(const struct sctp_endpoint *ep, | 3135 | sctp_disposition_t sctp_sf_eat_sack_6_2(struct net *net, |
3136 | const struct sctp_endpoint *ep, | ||
3086 | const struct sctp_association *asoc, | 3137 | const struct sctp_association *asoc, |
3087 | const sctp_subtype_t type, | 3138 | const sctp_subtype_t type, |
3088 | void *arg, | 3139 | void *arg, |
@@ -3093,18 +3144,18 @@ sctp_disposition_t sctp_sf_eat_sack_6_2(const struct sctp_endpoint *ep, | |||
3093 | __u32 ctsn; | 3144 | __u32 ctsn; |
3094 | 3145 | ||
3095 | if (!sctp_vtag_verify(chunk, asoc)) | 3146 | if (!sctp_vtag_verify(chunk, asoc)) |
3096 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3147 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3097 | 3148 | ||
3098 | /* Make sure that the SACK chunk has a valid length. */ | 3149 | /* Make sure that the SACK chunk has a valid length. */ |
3099 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_sack_chunk_t))) | 3150 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_sack_chunk_t))) |
3100 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3151 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3101 | commands); | 3152 | commands); |
3102 | 3153 | ||
3103 | /* Pull the SACK chunk from the data buffer */ | 3154 | /* Pull the SACK chunk from the data buffer */ |
3104 | sackh = sctp_sm_pull_sack(chunk); | 3155 | sackh = sctp_sm_pull_sack(chunk); |
3105 | /* Was this a bogus SACK? */ | 3156 | /* Was this a bogus SACK? */ |
3106 | if (!sackh) | 3157 | if (!sackh) |
3107 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3158 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3108 | chunk->subh.sack_hdr = sackh; | 3159 | chunk->subh.sack_hdr = sackh; |
3109 | ctsn = ntohl(sackh->cum_tsn_ack); | 3160 | ctsn = ntohl(sackh->cum_tsn_ack); |
3110 | 3161 | ||
@@ -3125,7 +3176,7 @@ sctp_disposition_t sctp_sf_eat_sack_6_2(const struct sctp_endpoint *ep, | |||
3125 | * sender with an ABORT. | 3176 | * sender with an ABORT. |
3126 | */ | 3177 | */ |
3127 | if (!TSN_lt(ctsn, asoc->next_tsn)) | 3178 | if (!TSN_lt(ctsn, asoc->next_tsn)) |
3128 | return sctp_sf_violation_ctsn(ep, asoc, type, arg, commands); | 3179 | return sctp_sf_violation_ctsn(net, ep, asoc, type, arg, commands); |
3129 | 3180 | ||
3130 | /* Return this SACK for further processing. */ | 3181 | /* Return this SACK for further processing. */ |
3131 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK, SCTP_SACKH(sackh)); | 3182 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK, SCTP_SACKH(sackh)); |
@@ -3154,7 +3205,8 @@ sctp_disposition_t sctp_sf_eat_sack_6_2(const struct sctp_endpoint *ep, | |||
3154 | * | 3205 | * |
3155 | * The return value is the disposition of the chunk. | 3206 | * The return value is the disposition of the chunk. |
3156 | */ | 3207 | */ |
3157 | static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | 3208 | static sctp_disposition_t sctp_sf_tabort_8_4_8(struct net *net, |
3209 | const struct sctp_endpoint *ep, | ||
3158 | const struct sctp_association *asoc, | 3210 | const struct sctp_association *asoc, |
3159 | const sctp_subtype_t type, | 3211 | const sctp_subtype_t type, |
3160 | void *arg, | 3212 | void *arg, |
@@ -3164,7 +3216,7 @@ static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | |||
3164 | struct sctp_chunk *chunk = arg; | 3216 | struct sctp_chunk *chunk = arg; |
3165 | struct sctp_chunk *abort; | 3217 | struct sctp_chunk *abort; |
3166 | 3218 | ||
3167 | packet = sctp_ootb_pkt_new(asoc, chunk); | 3219 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
3168 | 3220 | ||
3169 | if (packet) { | 3221 | if (packet) { |
3170 | /* Make an ABORT. The T bit will be set if the asoc | 3222 | /* Make an ABORT. The T bit will be set if the asoc |
@@ -3188,9 +3240,9 @@ static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | |||
3188 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, | 3240 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, |
3189 | SCTP_PACKET(packet)); | 3241 | SCTP_PACKET(packet)); |
3190 | 3242 | ||
3191 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 3243 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
3192 | 3244 | ||
3193 | sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3245 | sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3194 | return SCTP_DISPOSITION_CONSUME; | 3246 | return SCTP_DISPOSITION_CONSUME; |
3195 | } | 3247 | } |
3196 | 3248 | ||
@@ -3205,7 +3257,8 @@ static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | |||
3205 | * | 3257 | * |
3206 | * The return value is the disposition of the chunk. | 3258 | * The return value is the disposition of the chunk. |
3207 | */ | 3259 | */ |
3208 | sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep, | 3260 | sctp_disposition_t sctp_sf_operr_notify(struct net *net, |
3261 | const struct sctp_endpoint *ep, | ||
3209 | const struct sctp_association *asoc, | 3262 | const struct sctp_association *asoc, |
3210 | const sctp_subtype_t type, | 3263 | const sctp_subtype_t type, |
3211 | void *arg, | 3264 | void *arg, |
@@ -3215,15 +3268,15 @@ sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep, | |||
3215 | sctp_errhdr_t *err; | 3268 | sctp_errhdr_t *err; |
3216 | 3269 | ||
3217 | if (!sctp_vtag_verify(chunk, asoc)) | 3270 | if (!sctp_vtag_verify(chunk, asoc)) |
3218 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3271 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3219 | 3272 | ||
3220 | /* Make sure that the ERROR chunk has a valid length. */ | 3273 | /* Make sure that the ERROR chunk has a valid length. */ |
3221 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) | 3274 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_operr_chunk_t))) |
3222 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3275 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3223 | commands); | 3276 | commands); |
3224 | sctp_walk_errors(err, chunk->chunk_hdr); | 3277 | sctp_walk_errors(err, chunk->chunk_hdr); |
3225 | if ((void *)err != (void *)chunk->chunk_end) | 3278 | if ((void *)err != (void *)chunk->chunk_end) |
3226 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, | 3279 | return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, |
3227 | (void *)err, commands); | 3280 | (void *)err, commands); |
3228 | 3281 | ||
3229 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR, | 3282 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_OPERR, |
@@ -3242,7 +3295,8 @@ sctp_disposition_t sctp_sf_operr_notify(const struct sctp_endpoint *ep, | |||
3242 | * | 3295 | * |
3243 | * The return value is the disposition. | 3296 | * The return value is the disposition. |
3244 | */ | 3297 | */ |
3245 | sctp_disposition_t sctp_sf_do_9_2_final(const struct sctp_endpoint *ep, | 3298 | sctp_disposition_t sctp_sf_do_9_2_final(struct net *net, |
3299 | const struct sctp_endpoint *ep, | ||
3246 | const struct sctp_association *asoc, | 3300 | const struct sctp_association *asoc, |
3247 | const sctp_subtype_t type, | 3301 | const sctp_subtype_t type, |
3248 | void *arg, | 3302 | void *arg, |
@@ -3253,11 +3307,11 @@ sctp_disposition_t sctp_sf_do_9_2_final(const struct sctp_endpoint *ep, | |||
3253 | struct sctp_ulpevent *ev; | 3307 | struct sctp_ulpevent *ev; |
3254 | 3308 | ||
3255 | if (!sctp_vtag_verify(chunk, asoc)) | 3309 | if (!sctp_vtag_verify(chunk, asoc)) |
3256 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3310 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3257 | 3311 | ||
3258 | /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ | 3312 | /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ |
3259 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 3313 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
3260 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3314 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3261 | commands); | 3315 | commands); |
3262 | /* 10.2 H) SHUTDOWN COMPLETE notification | 3316 | /* 10.2 H) SHUTDOWN COMPLETE notification |
3263 | * | 3317 | * |
@@ -3290,8 +3344,8 @@ sctp_disposition_t sctp_sf_do_9_2_final(const struct sctp_endpoint *ep, | |||
3290 | 3344 | ||
3291 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 3345 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
3292 | SCTP_STATE(SCTP_STATE_CLOSED)); | 3346 | SCTP_STATE(SCTP_STATE_CLOSED)); |
3293 | SCTP_INC_STATS(SCTP_MIB_SHUTDOWNS); | 3347 | SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS); |
3294 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 3348 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
3295 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply)); | 3349 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(reply)); |
3296 | 3350 | ||
3297 | /* ...and remove all record of the association. */ | 3351 | /* ...and remove all record of the association. */ |
@@ -3324,7 +3378,8 @@ nomem: | |||
3324 | * receiver of the OOTB packet shall discard the OOTB packet and take | 3378 | * receiver of the OOTB packet shall discard the OOTB packet and take |
3325 | * no further action. | 3379 | * no further action. |
3326 | */ | 3380 | */ |
3327 | sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | 3381 | sctp_disposition_t sctp_sf_ootb(struct net *net, |
3382 | const struct sctp_endpoint *ep, | ||
3328 | const struct sctp_association *asoc, | 3383 | const struct sctp_association *asoc, |
3329 | const sctp_subtype_t type, | 3384 | const sctp_subtype_t type, |
3330 | void *arg, | 3385 | void *arg, |
@@ -3338,13 +3393,13 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | |||
3338 | int ootb_shut_ack = 0; | 3393 | int ootb_shut_ack = 0; |
3339 | int ootb_cookie_ack = 0; | 3394 | int ootb_cookie_ack = 0; |
3340 | 3395 | ||
3341 | SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); | 3396 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); |
3342 | 3397 | ||
3343 | ch = (sctp_chunkhdr_t *) chunk->chunk_hdr; | 3398 | ch = (sctp_chunkhdr_t *) chunk->chunk_hdr; |
3344 | do { | 3399 | do { |
3345 | /* Report violation if the chunk is less then minimal */ | 3400 | /* Report violation if the chunk is less then minimal */ |
3346 | if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t)) | 3401 | if (ntohs(ch->length) < sizeof(sctp_chunkhdr_t)) |
3347 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3402 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3348 | commands); | 3403 | commands); |
3349 | 3404 | ||
3350 | /* Now that we know we at least have a chunk header, | 3405 | /* Now that we know we at least have a chunk header, |
@@ -3359,7 +3414,7 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | |||
3359 | * sending an ABORT of its own. | 3414 | * sending an ABORT of its own. |
3360 | */ | 3415 | */ |
3361 | if (SCTP_CID_ABORT == ch->type) | 3416 | if (SCTP_CID_ABORT == ch->type) |
3362 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3417 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3363 | 3418 | ||
3364 | /* RFC 8.4, 7) If the packet contains a "Stale cookie" ERROR | 3419 | /* RFC 8.4, 7) If the packet contains a "Stale cookie" ERROR |
3365 | * or a COOKIE ACK the SCTP Packet should be silently | 3420 | * or a COOKIE ACK the SCTP Packet should be silently |
@@ -3381,18 +3436,18 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | |||
3381 | /* Report violation if chunk len overflows */ | 3436 | /* Report violation if chunk len overflows */ |
3382 | ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length)); | 3437 | ch_end = ((__u8 *)ch) + WORD_ROUND(ntohs(ch->length)); |
3383 | if (ch_end > skb_tail_pointer(skb)) | 3438 | if (ch_end > skb_tail_pointer(skb)) |
3384 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3439 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3385 | commands); | 3440 | commands); |
3386 | 3441 | ||
3387 | ch = (sctp_chunkhdr_t *) ch_end; | 3442 | ch = (sctp_chunkhdr_t *) ch_end; |
3388 | } while (ch_end < skb_tail_pointer(skb)); | 3443 | } while (ch_end < skb_tail_pointer(skb)); |
3389 | 3444 | ||
3390 | if (ootb_shut_ack) | 3445 | if (ootb_shut_ack) |
3391 | return sctp_sf_shut_8_4_5(ep, asoc, type, arg, commands); | 3446 | return sctp_sf_shut_8_4_5(net, ep, asoc, type, arg, commands); |
3392 | else if (ootb_cookie_ack) | 3447 | else if (ootb_cookie_ack) |
3393 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3448 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3394 | else | 3449 | else |
3395 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 3450 | return sctp_sf_tabort_8_4_8(net, ep, asoc, type, arg, commands); |
3396 | } | 3451 | } |
3397 | 3452 | ||
3398 | /* | 3453 | /* |
@@ -3416,7 +3471,8 @@ sctp_disposition_t sctp_sf_ootb(const struct sctp_endpoint *ep, | |||
3416 | * | 3471 | * |
3417 | * The return value is the disposition of the chunk. | 3472 | * The return value is the disposition of the chunk. |
3418 | */ | 3473 | */ |
3419 | static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | 3474 | static sctp_disposition_t sctp_sf_shut_8_4_5(struct net *net, |
3475 | const struct sctp_endpoint *ep, | ||
3420 | const struct sctp_association *asoc, | 3476 | const struct sctp_association *asoc, |
3421 | const sctp_subtype_t type, | 3477 | const sctp_subtype_t type, |
3422 | void *arg, | 3478 | void *arg, |
@@ -3426,7 +3482,7 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | |||
3426 | struct sctp_chunk *chunk = arg; | 3482 | struct sctp_chunk *chunk = arg; |
3427 | struct sctp_chunk *shut; | 3483 | struct sctp_chunk *shut; |
3428 | 3484 | ||
3429 | packet = sctp_ootb_pkt_new(asoc, chunk); | 3485 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
3430 | 3486 | ||
3431 | if (packet) { | 3487 | if (packet) { |
3432 | /* Make an SHUTDOWN_COMPLETE. | 3488 | /* Make an SHUTDOWN_COMPLETE. |
@@ -3450,19 +3506,19 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | |||
3450 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, | 3506 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, |
3451 | SCTP_PACKET(packet)); | 3507 | SCTP_PACKET(packet)); |
3452 | 3508 | ||
3453 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 3509 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
3454 | 3510 | ||
3455 | /* If the chunk length is invalid, we don't want to process | 3511 | /* If the chunk length is invalid, we don't want to process |
3456 | * the reset of the packet. | 3512 | * the reset of the packet. |
3457 | */ | 3513 | */ |
3458 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 3514 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
3459 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3515 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3460 | 3516 | ||
3461 | /* We need to discard the rest of the packet to prevent | 3517 | /* We need to discard the rest of the packet to prevent |
3462 | * potential bomming attacks from additional bundled chunks. | 3518 | * potential bomming attacks from additional bundled chunks. |
3463 | * This is documented in SCTP Threats ID. | 3519 | * This is documented in SCTP Threats ID. |
3464 | */ | 3520 | */ |
3465 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3521 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3466 | } | 3522 | } |
3467 | 3523 | ||
3468 | return SCTP_DISPOSITION_NOMEM; | 3524 | return SCTP_DISPOSITION_NOMEM; |
@@ -3479,7 +3535,8 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | |||
3479 | * chunks. --piggy ] | 3535 | * chunks. --piggy ] |
3480 | * | 3536 | * |
3481 | */ | 3537 | */ |
3482 | sctp_disposition_t sctp_sf_do_8_5_1_E_sa(const struct sctp_endpoint *ep, | 3538 | sctp_disposition_t sctp_sf_do_8_5_1_E_sa(struct net *net, |
3539 | const struct sctp_endpoint *ep, | ||
3483 | const struct sctp_association *asoc, | 3540 | const struct sctp_association *asoc, |
3484 | const sctp_subtype_t type, | 3541 | const sctp_subtype_t type, |
3485 | void *arg, | 3542 | void *arg, |
@@ -3489,7 +3546,7 @@ sctp_disposition_t sctp_sf_do_8_5_1_E_sa(const struct sctp_endpoint *ep, | |||
3489 | 3546 | ||
3490 | /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ | 3547 | /* Make sure that the SHUTDOWN_ACK chunk has a valid length. */ |
3491 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 3548 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
3492 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3549 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3493 | commands); | 3550 | commands); |
3494 | 3551 | ||
3495 | /* Although we do have an association in this case, it corresponds | 3552 | /* Although we do have an association in this case, it corresponds |
@@ -3497,13 +3554,14 @@ sctp_disposition_t sctp_sf_do_8_5_1_E_sa(const struct sctp_endpoint *ep, | |||
3497 | * packet and the state function that handles OOTB SHUTDOWN_ACK is | 3554 | * packet and the state function that handles OOTB SHUTDOWN_ACK is |
3498 | * called with a NULL association. | 3555 | * called with a NULL association. |
3499 | */ | 3556 | */ |
3500 | SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); | 3557 | SCTP_INC_STATS(net, SCTP_MIB_OUTOFBLUES); |
3501 | 3558 | ||
3502 | return sctp_sf_shut_8_4_5(ep, NULL, type, arg, commands); | 3559 | return sctp_sf_shut_8_4_5(net, ep, NULL, type, arg, commands); |
3503 | } | 3560 | } |
3504 | 3561 | ||
3505 | /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. */ | 3562 | /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. */ |
3506 | sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | 3563 | sctp_disposition_t sctp_sf_do_asconf(struct net *net, |
3564 | const struct sctp_endpoint *ep, | ||
3507 | const struct sctp_association *asoc, | 3565 | const struct sctp_association *asoc, |
3508 | const sctp_subtype_t type, void *arg, | 3566 | const sctp_subtype_t type, void *arg, |
3509 | sctp_cmd_seq_t *commands) | 3567 | sctp_cmd_seq_t *commands) |
@@ -3519,7 +3577,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3519 | if (!sctp_vtag_verify(chunk, asoc)) { | 3577 | if (!sctp_vtag_verify(chunk, asoc)) { |
3520 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3578 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3521 | SCTP_NULL()); | 3579 | SCTP_NULL()); |
3522 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3580 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3523 | } | 3581 | } |
3524 | 3582 | ||
3525 | /* ADD-IP: Section 4.1.1 | 3583 | /* ADD-IP: Section 4.1.1 |
@@ -3528,12 +3586,12 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3528 | * is received unauthenticated it MUST be silently discarded as | 3586 | * is received unauthenticated it MUST be silently discarded as |
3529 | * described in [I-D.ietf-tsvwg-sctp-auth]. | 3587 | * described in [I-D.ietf-tsvwg-sctp-auth]. |
3530 | */ | 3588 | */ |
3531 | if (!sctp_addip_noauth && !chunk->auth) | 3589 | if (!net->sctp.addip_noauth && !chunk->auth) |
3532 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 3590 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
3533 | 3591 | ||
3534 | /* Make sure that the ASCONF ADDIP chunk has a valid length. */ | 3592 | /* Make sure that the ASCONF ADDIP chunk has a valid length. */ |
3535 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_addip_chunk_t))) | 3593 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_addip_chunk_t))) |
3536 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3594 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3537 | commands); | 3595 | commands); |
3538 | 3596 | ||
3539 | hdr = (sctp_addiphdr_t *)chunk->skb->data; | 3597 | hdr = (sctp_addiphdr_t *)chunk->skb->data; |
@@ -3542,7 +3600,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3542 | addr_param = (union sctp_addr_param *)hdr->params; | 3600 | addr_param = (union sctp_addr_param *)hdr->params; |
3543 | length = ntohs(addr_param->p.length); | 3601 | length = ntohs(addr_param->p.length); |
3544 | if (length < sizeof(sctp_paramhdr_t)) | 3602 | if (length < sizeof(sctp_paramhdr_t)) |
3545 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, | 3603 | return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, |
3546 | (void *)addr_param, commands); | 3604 | (void *)addr_param, commands); |
3547 | 3605 | ||
3548 | /* Verify the ASCONF chunk before processing it. */ | 3606 | /* Verify the ASCONF chunk before processing it. */ |
@@ -3550,7 +3608,7 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3550 | (sctp_paramhdr_t *)((void *)addr_param + length), | 3608 | (sctp_paramhdr_t *)((void *)addr_param + length), |
3551 | (void *)chunk->chunk_end, | 3609 | (void *)chunk->chunk_end, |
3552 | &err_param)) | 3610 | &err_param)) |
3553 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, | 3611 | return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, |
3554 | (void *)err_param, commands); | 3612 | (void *)err_param, commands); |
3555 | 3613 | ||
3556 | /* ADDIP 5.2 E1) Compare the value of the serial number to the value | 3614 | /* ADDIP 5.2 E1) Compare the value of the serial number to the value |
@@ -3630,7 +3688,8 @@ sctp_disposition_t sctp_sf_do_asconf(const struct sctp_endpoint *ep, | |||
3630 | * When building TLV parameters for the ASCONF Chunk that will add or | 3688 | * When building TLV parameters for the ASCONF Chunk that will add or |
3631 | * delete IP addresses the D0 to D13 rules should be applied: | 3689 | * delete IP addresses the D0 to D13 rules should be applied: |
3632 | */ | 3690 | */ |
3633 | sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | 3691 | sctp_disposition_t sctp_sf_do_asconf_ack(struct net *net, |
3692 | const struct sctp_endpoint *ep, | ||
3634 | const struct sctp_association *asoc, | 3693 | const struct sctp_association *asoc, |
3635 | const sctp_subtype_t type, void *arg, | 3694 | const sctp_subtype_t type, void *arg, |
3636 | sctp_cmd_seq_t *commands) | 3695 | sctp_cmd_seq_t *commands) |
@@ -3645,7 +3704,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3645 | if (!sctp_vtag_verify(asconf_ack, asoc)) { | 3704 | if (!sctp_vtag_verify(asconf_ack, asoc)) { |
3646 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3705 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3647 | SCTP_NULL()); | 3706 | SCTP_NULL()); |
3648 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3707 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3649 | } | 3708 | } |
3650 | 3709 | ||
3651 | /* ADD-IP, Section 4.1.2: | 3710 | /* ADD-IP, Section 4.1.2: |
@@ -3654,12 +3713,12 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3654 | * is received unauthenticated it MUST be silently discarded as | 3713 | * is received unauthenticated it MUST be silently discarded as |
3655 | * described in [I-D.ietf-tsvwg-sctp-auth]. | 3714 | * described in [I-D.ietf-tsvwg-sctp-auth]. |
3656 | */ | 3715 | */ |
3657 | if (!sctp_addip_noauth && !asconf_ack->auth) | 3716 | if (!net->sctp.addip_noauth && !asconf_ack->auth) |
3658 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 3717 | return sctp_sf_discard_chunk(net, ep, asoc, type, arg, commands); |
3659 | 3718 | ||
3660 | /* Make sure that the ADDIP chunk has a valid length. */ | 3719 | /* Make sure that the ADDIP chunk has a valid length. */ |
3661 | if (!sctp_chunk_length_valid(asconf_ack, sizeof(sctp_addip_chunk_t))) | 3720 | if (!sctp_chunk_length_valid(asconf_ack, sizeof(sctp_addip_chunk_t))) |
3662 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3721 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3663 | commands); | 3722 | commands); |
3664 | 3723 | ||
3665 | addip_hdr = (sctp_addiphdr_t *)asconf_ack->skb->data; | 3724 | addip_hdr = (sctp_addiphdr_t *)asconf_ack->skb->data; |
@@ -3670,7 +3729,7 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3670 | (sctp_paramhdr_t *)addip_hdr->params, | 3729 | (sctp_paramhdr_t *)addip_hdr->params, |
3671 | (void *)asconf_ack->chunk_end, | 3730 | (void *)asconf_ack->chunk_end, |
3672 | &err_param)) | 3731 | &err_param)) |
3673 | return sctp_sf_violation_paramlen(ep, asoc, type, arg, | 3732 | return sctp_sf_violation_paramlen(net, ep, asoc, type, arg, |
3674 | (void *)err_param, commands); | 3733 | (void *)err_param, commands); |
3675 | 3734 | ||
3676 | if (last_asconf) { | 3735 | if (last_asconf) { |
@@ -3705,8 +3764,8 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3705 | SCTP_ERROR(ECONNABORTED)); | 3764 | SCTP_ERROR(ECONNABORTED)); |
3706 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 3765 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
3707 | SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); | 3766 | SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); |
3708 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 3767 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
3709 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 3768 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
3710 | return SCTP_DISPOSITION_ABORT; | 3769 | return SCTP_DISPOSITION_ABORT; |
3711 | } | 3770 | } |
3712 | 3771 | ||
@@ -3739,8 +3798,8 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3739 | SCTP_ERROR(ECONNABORTED)); | 3798 | SCTP_ERROR(ECONNABORTED)); |
3740 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 3799 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
3741 | SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); | 3800 | SCTP_PERR(SCTP_ERROR_ASCONF_ACK)); |
3742 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 3801 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
3743 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 3802 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
3744 | return SCTP_DISPOSITION_ABORT; | 3803 | return SCTP_DISPOSITION_ABORT; |
3745 | } | 3804 | } |
3746 | 3805 | ||
@@ -3761,7 +3820,8 @@ sctp_disposition_t sctp_sf_do_asconf_ack(const struct sctp_endpoint *ep, | |||
3761 | * | 3820 | * |
3762 | * The return value is the disposition of the chunk. | 3821 | * The return value is the disposition of the chunk. |
3763 | */ | 3822 | */ |
3764 | sctp_disposition_t sctp_sf_eat_fwd_tsn(const struct sctp_endpoint *ep, | 3823 | sctp_disposition_t sctp_sf_eat_fwd_tsn(struct net *net, |
3824 | const struct sctp_endpoint *ep, | ||
3765 | const struct sctp_association *asoc, | 3825 | const struct sctp_association *asoc, |
3766 | const sctp_subtype_t type, | 3826 | const sctp_subtype_t type, |
3767 | void *arg, | 3827 | void *arg, |
@@ -3776,12 +3836,12 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn(const struct sctp_endpoint *ep, | |||
3776 | if (!sctp_vtag_verify(chunk, asoc)) { | 3836 | if (!sctp_vtag_verify(chunk, asoc)) { |
3777 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3837 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3778 | SCTP_NULL()); | 3838 | SCTP_NULL()); |
3779 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3839 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3780 | } | 3840 | } |
3781 | 3841 | ||
3782 | /* Make sure that the FORWARD_TSN chunk has valid length. */ | 3842 | /* Make sure that the FORWARD_TSN chunk has valid length. */ |
3783 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_fwdtsn_chunk))) | 3843 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_fwdtsn_chunk))) |
3784 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3844 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3785 | commands); | 3845 | commands); |
3786 | 3846 | ||
3787 | fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; | 3847 | fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; |
@@ -3828,6 +3888,7 @@ discard_noforce: | |||
3828 | } | 3888 | } |
3829 | 3889 | ||
3830 | sctp_disposition_t sctp_sf_eat_fwd_tsn_fast( | 3890 | sctp_disposition_t sctp_sf_eat_fwd_tsn_fast( |
3891 | struct net *net, | ||
3831 | const struct sctp_endpoint *ep, | 3892 | const struct sctp_endpoint *ep, |
3832 | const struct sctp_association *asoc, | 3893 | const struct sctp_association *asoc, |
3833 | const sctp_subtype_t type, | 3894 | const sctp_subtype_t type, |
@@ -3843,12 +3904,12 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn_fast( | |||
3843 | if (!sctp_vtag_verify(chunk, asoc)) { | 3904 | if (!sctp_vtag_verify(chunk, asoc)) { |
3844 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 3905 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
3845 | SCTP_NULL()); | 3906 | SCTP_NULL()); |
3846 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 3907 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
3847 | } | 3908 | } |
3848 | 3909 | ||
3849 | /* Make sure that the FORWARD_TSN chunk has a valid length. */ | 3910 | /* Make sure that the FORWARD_TSN chunk has a valid length. */ |
3850 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_fwdtsn_chunk))) | 3911 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_fwdtsn_chunk))) |
3851 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 3912 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
3852 | commands); | 3913 | commands); |
3853 | 3914 | ||
3854 | fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; | 3915 | fwdtsn_hdr = (struct sctp_fwdtsn_hdr *)chunk->skb->data; |
@@ -3915,7 +3976,8 @@ gen_shutdown: | |||
3915 | * | 3976 | * |
3916 | * The return value is the disposition of the chunk. | 3977 | * The return value is the disposition of the chunk. |
3917 | */ | 3978 | */ |
3918 | static sctp_ierror_t sctp_sf_authenticate(const struct sctp_endpoint *ep, | 3979 | static sctp_ierror_t sctp_sf_authenticate(struct net *net, |
3980 | const struct sctp_endpoint *ep, | ||
3919 | const struct sctp_association *asoc, | 3981 | const struct sctp_association *asoc, |
3920 | const sctp_subtype_t type, | 3982 | const sctp_subtype_t type, |
3921 | struct sctp_chunk *chunk) | 3983 | struct sctp_chunk *chunk) |
@@ -3988,7 +4050,8 @@ nomem: | |||
3988 | return SCTP_IERROR_NOMEM; | 4050 | return SCTP_IERROR_NOMEM; |
3989 | } | 4051 | } |
3990 | 4052 | ||
3991 | sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep, | 4053 | sctp_disposition_t sctp_sf_eat_auth(struct net *net, |
4054 | const struct sctp_endpoint *ep, | ||
3992 | const struct sctp_association *asoc, | 4055 | const struct sctp_association *asoc, |
3993 | const sctp_subtype_t type, | 4056 | const sctp_subtype_t type, |
3994 | void *arg, | 4057 | void *arg, |
@@ -4001,21 +4064,21 @@ sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep, | |||
4001 | 4064 | ||
4002 | /* Make sure that the peer has AUTH capable */ | 4065 | /* Make sure that the peer has AUTH capable */ |
4003 | if (!asoc->peer.auth_capable) | 4066 | if (!asoc->peer.auth_capable) |
4004 | return sctp_sf_unk_chunk(ep, asoc, type, arg, commands); | 4067 | return sctp_sf_unk_chunk(net, ep, asoc, type, arg, commands); |
4005 | 4068 | ||
4006 | if (!sctp_vtag_verify(chunk, asoc)) { | 4069 | if (!sctp_vtag_verify(chunk, asoc)) { |
4007 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, | 4070 | sctp_add_cmd_sf(commands, SCTP_CMD_REPORT_BAD_TAG, |
4008 | SCTP_NULL()); | 4071 | SCTP_NULL()); |
4009 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4072 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4010 | } | 4073 | } |
4011 | 4074 | ||
4012 | /* Make sure that the AUTH chunk has valid length. */ | 4075 | /* Make sure that the AUTH chunk has valid length. */ |
4013 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_auth_chunk))) | 4076 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_auth_chunk))) |
4014 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4077 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4015 | commands); | 4078 | commands); |
4016 | 4079 | ||
4017 | auth_hdr = (struct sctp_authhdr *)chunk->skb->data; | 4080 | auth_hdr = (struct sctp_authhdr *)chunk->skb->data; |
4018 | error = sctp_sf_authenticate(ep, asoc, type, chunk); | 4081 | error = sctp_sf_authenticate(net, ep, asoc, type, chunk); |
4019 | switch (error) { | 4082 | switch (error) { |
4020 | case SCTP_IERROR_AUTH_BAD_HMAC: | 4083 | case SCTP_IERROR_AUTH_BAD_HMAC: |
4021 | /* Generate the ERROR chunk and discard the rest | 4084 | /* Generate the ERROR chunk and discard the rest |
@@ -4032,10 +4095,10 @@ sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep, | |||
4032 | /* Fall Through */ | 4095 | /* Fall Through */ |
4033 | case SCTP_IERROR_AUTH_BAD_KEYID: | 4096 | case SCTP_IERROR_AUTH_BAD_KEYID: |
4034 | case SCTP_IERROR_BAD_SIG: | 4097 | case SCTP_IERROR_BAD_SIG: |
4035 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4098 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4036 | 4099 | ||
4037 | case SCTP_IERROR_PROTO_VIOLATION: | 4100 | case SCTP_IERROR_PROTO_VIOLATION: |
4038 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4101 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4039 | commands); | 4102 | commands); |
4040 | 4103 | ||
4041 | case SCTP_IERROR_NOMEM: | 4104 | case SCTP_IERROR_NOMEM: |
@@ -4084,7 +4147,8 @@ sctp_disposition_t sctp_sf_eat_auth(const struct sctp_endpoint *ep, | |||
4084 | * | 4147 | * |
4085 | * The return value is the disposition of the chunk. | 4148 | * The return value is the disposition of the chunk. |
4086 | */ | 4149 | */ |
4087 | sctp_disposition_t sctp_sf_unk_chunk(const struct sctp_endpoint *ep, | 4150 | sctp_disposition_t sctp_sf_unk_chunk(struct net *net, |
4151 | const struct sctp_endpoint *ep, | ||
4088 | const struct sctp_association *asoc, | 4152 | const struct sctp_association *asoc, |
4089 | const sctp_subtype_t type, | 4153 | const sctp_subtype_t type, |
4090 | void *arg, | 4154 | void *arg, |
@@ -4097,20 +4161,20 @@ sctp_disposition_t sctp_sf_unk_chunk(const struct sctp_endpoint *ep, | |||
4097 | SCTP_DEBUG_PRINTK("Processing the unknown chunk id %d.\n", type.chunk); | 4161 | SCTP_DEBUG_PRINTK("Processing the unknown chunk id %d.\n", type.chunk); |
4098 | 4162 | ||
4099 | if (!sctp_vtag_verify(unk_chunk, asoc)) | 4163 | if (!sctp_vtag_verify(unk_chunk, asoc)) |
4100 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4164 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4101 | 4165 | ||
4102 | /* Make sure that the chunk has a valid length. | 4166 | /* Make sure that the chunk has a valid length. |
4103 | * Since we don't know the chunk type, we use a general | 4167 | * Since we don't know the chunk type, we use a general |
4104 | * chunkhdr structure to make a comparison. | 4168 | * chunkhdr structure to make a comparison. |
4105 | */ | 4169 | */ |
4106 | if (!sctp_chunk_length_valid(unk_chunk, sizeof(sctp_chunkhdr_t))) | 4170 | if (!sctp_chunk_length_valid(unk_chunk, sizeof(sctp_chunkhdr_t))) |
4107 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4171 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4108 | commands); | 4172 | commands); |
4109 | 4173 | ||
4110 | switch (type.chunk & SCTP_CID_ACTION_MASK) { | 4174 | switch (type.chunk & SCTP_CID_ACTION_MASK) { |
4111 | case SCTP_CID_ACTION_DISCARD: | 4175 | case SCTP_CID_ACTION_DISCARD: |
4112 | /* Discard the packet. */ | 4176 | /* Discard the packet. */ |
4113 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4177 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4114 | break; | 4178 | break; |
4115 | case SCTP_CID_ACTION_DISCARD_ERR: | 4179 | case SCTP_CID_ACTION_DISCARD_ERR: |
4116 | /* Generate an ERROR chunk as response. */ | 4180 | /* Generate an ERROR chunk as response. */ |
@@ -4125,7 +4189,7 @@ sctp_disposition_t sctp_sf_unk_chunk(const struct sctp_endpoint *ep, | |||
4125 | } | 4189 | } |
4126 | 4190 | ||
4127 | /* Discard the packet. */ | 4191 | /* Discard the packet. */ |
4128 | sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 4192 | sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
4129 | return SCTP_DISPOSITION_CONSUME; | 4193 | return SCTP_DISPOSITION_CONSUME; |
4130 | break; | 4194 | break; |
4131 | case SCTP_CID_ACTION_SKIP: | 4195 | case SCTP_CID_ACTION_SKIP: |
@@ -4167,7 +4231,8 @@ sctp_disposition_t sctp_sf_unk_chunk(const struct sctp_endpoint *ep, | |||
4167 | * | 4231 | * |
4168 | * The return value is the disposition of the chunk. | 4232 | * The return value is the disposition of the chunk. |
4169 | */ | 4233 | */ |
4170 | sctp_disposition_t sctp_sf_discard_chunk(const struct sctp_endpoint *ep, | 4234 | sctp_disposition_t sctp_sf_discard_chunk(struct net *net, |
4235 | const struct sctp_endpoint *ep, | ||
4171 | const struct sctp_association *asoc, | 4236 | const struct sctp_association *asoc, |
4172 | const sctp_subtype_t type, | 4237 | const sctp_subtype_t type, |
4173 | void *arg, | 4238 | void *arg, |
@@ -4180,7 +4245,7 @@ sctp_disposition_t sctp_sf_discard_chunk(const struct sctp_endpoint *ep, | |||
4180 | * chunkhdr structure to make a comparison. | 4245 | * chunkhdr structure to make a comparison. |
4181 | */ | 4246 | */ |
4182 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 4247 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
4183 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4248 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4184 | commands); | 4249 | commands); |
4185 | 4250 | ||
4186 | SCTP_DEBUG_PRINTK("Chunk %d is discarded\n", type.chunk); | 4251 | SCTP_DEBUG_PRINTK("Chunk %d is discarded\n", type.chunk); |
@@ -4205,13 +4270,14 @@ sctp_disposition_t sctp_sf_discard_chunk(const struct sctp_endpoint *ep, | |||
4205 | * | 4270 | * |
4206 | * The return value is the disposition of the chunk. | 4271 | * The return value is the disposition of the chunk. |
4207 | */ | 4272 | */ |
4208 | sctp_disposition_t sctp_sf_pdiscard(const struct sctp_endpoint *ep, | 4273 | sctp_disposition_t sctp_sf_pdiscard(struct net *net, |
4274 | const struct sctp_endpoint *ep, | ||
4209 | const struct sctp_association *asoc, | 4275 | const struct sctp_association *asoc, |
4210 | const sctp_subtype_t type, | 4276 | const sctp_subtype_t type, |
4211 | void *arg, | 4277 | void *arg, |
4212 | sctp_cmd_seq_t *commands) | 4278 | sctp_cmd_seq_t *commands) |
4213 | { | 4279 | { |
4214 | SCTP_INC_STATS(SCTP_MIB_IN_PKT_DISCARDS); | 4280 | SCTP_INC_STATS(net, SCTP_MIB_IN_PKT_DISCARDS); |
4215 | sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL()); | 4281 | sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL()); |
4216 | 4282 | ||
4217 | return SCTP_DISPOSITION_CONSUME; | 4283 | return SCTP_DISPOSITION_CONSUME; |
@@ -4232,7 +4298,8 @@ sctp_disposition_t sctp_sf_pdiscard(const struct sctp_endpoint *ep, | |||
4232 | * We simply tag the chunk as a violation. The state machine will log | 4298 | * We simply tag the chunk as a violation. The state machine will log |
4233 | * the violation and continue. | 4299 | * the violation and continue. |
4234 | */ | 4300 | */ |
4235 | sctp_disposition_t sctp_sf_violation(const struct sctp_endpoint *ep, | 4301 | sctp_disposition_t sctp_sf_violation(struct net *net, |
4302 | const struct sctp_endpoint *ep, | ||
4236 | const struct sctp_association *asoc, | 4303 | const struct sctp_association *asoc, |
4237 | const sctp_subtype_t type, | 4304 | const sctp_subtype_t type, |
4238 | void *arg, | 4305 | void *arg, |
@@ -4242,7 +4309,7 @@ sctp_disposition_t sctp_sf_violation(const struct sctp_endpoint *ep, | |||
4242 | 4309 | ||
4243 | /* Make sure that the chunk has a valid length. */ | 4310 | /* Make sure that the chunk has a valid length. */ |
4244 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) | 4311 | if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) |
4245 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 4312 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
4246 | commands); | 4313 | commands); |
4247 | 4314 | ||
4248 | return SCTP_DISPOSITION_VIOLATION; | 4315 | return SCTP_DISPOSITION_VIOLATION; |
@@ -4252,6 +4319,7 @@ sctp_disposition_t sctp_sf_violation(const struct sctp_endpoint *ep, | |||
4252 | * Common function to handle a protocol violation. | 4319 | * Common function to handle a protocol violation. |
4253 | */ | 4320 | */ |
4254 | static sctp_disposition_t sctp_sf_abort_violation( | 4321 | static sctp_disposition_t sctp_sf_abort_violation( |
4322 | struct net *net, | ||
4255 | const struct sctp_endpoint *ep, | 4323 | const struct sctp_endpoint *ep, |
4256 | const struct sctp_association *asoc, | 4324 | const struct sctp_association *asoc, |
4257 | void *arg, | 4325 | void *arg, |
@@ -4302,7 +4370,7 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
4302 | } | 4370 | } |
4303 | 4371 | ||
4304 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); | 4372 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); |
4305 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 4373 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
4306 | 4374 | ||
4307 | if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { | 4375 | if (asoc->state <= SCTP_STATE_COOKIE_ECHOED) { |
4308 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 4376 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
@@ -4316,10 +4384,10 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
4316 | SCTP_ERROR(ECONNABORTED)); | 4384 | SCTP_ERROR(ECONNABORTED)); |
4317 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 4385 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
4318 | SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION)); | 4386 | SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION)); |
4319 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 4387 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
4320 | } | 4388 | } |
4321 | } else { | 4389 | } else { |
4322 | packet = sctp_ootb_pkt_new(asoc, chunk); | 4390 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
4323 | 4391 | ||
4324 | if (!packet) | 4392 | if (!packet) |
4325 | goto nomem_pkt; | 4393 | goto nomem_pkt; |
@@ -4334,13 +4402,13 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
4334 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, | 4402 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, |
4335 | SCTP_PACKET(packet)); | 4403 | SCTP_PACKET(packet)); |
4336 | 4404 | ||
4337 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 4405 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
4338 | } | 4406 | } |
4339 | 4407 | ||
4340 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 4408 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
4341 | 4409 | ||
4342 | discard: | 4410 | discard: |
4343 | sctp_sf_pdiscard(ep, asoc, SCTP_ST_CHUNK(0), arg, commands); | 4411 | sctp_sf_pdiscard(net, ep, asoc, SCTP_ST_CHUNK(0), arg, commands); |
4344 | return SCTP_DISPOSITION_ABORT; | 4412 | return SCTP_DISPOSITION_ABORT; |
4345 | 4413 | ||
4346 | nomem_pkt: | 4414 | nomem_pkt: |
@@ -4369,6 +4437,7 @@ nomem: | |||
4369 | * Generate an ABORT chunk and terminate the association. | 4437 | * Generate an ABORT chunk and terminate the association. |
4370 | */ | 4438 | */ |
4371 | static sctp_disposition_t sctp_sf_violation_chunklen( | 4439 | static sctp_disposition_t sctp_sf_violation_chunklen( |
4440 | struct net *net, | ||
4372 | const struct sctp_endpoint *ep, | 4441 | const struct sctp_endpoint *ep, |
4373 | const struct sctp_association *asoc, | 4442 | const struct sctp_association *asoc, |
4374 | const sctp_subtype_t type, | 4443 | const sctp_subtype_t type, |
@@ -4377,7 +4446,7 @@ static sctp_disposition_t sctp_sf_violation_chunklen( | |||
4377 | { | 4446 | { |
4378 | static const char err_str[]="The following chunk had invalid length:"; | 4447 | static const char err_str[]="The following chunk had invalid length:"; |
4379 | 4448 | ||
4380 | return sctp_sf_abort_violation(ep, asoc, arg, commands, err_str, | 4449 | return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, |
4381 | sizeof(err_str)); | 4450 | sizeof(err_str)); |
4382 | } | 4451 | } |
4383 | 4452 | ||
@@ -4388,6 +4457,7 @@ static sctp_disposition_t sctp_sf_violation_chunklen( | |||
4388 | * the length is considered as invalid. | 4457 | * the length is considered as invalid. |
4389 | */ | 4458 | */ |
4390 | static sctp_disposition_t sctp_sf_violation_paramlen( | 4459 | static sctp_disposition_t sctp_sf_violation_paramlen( |
4460 | struct net *net, | ||
4391 | const struct sctp_endpoint *ep, | 4461 | const struct sctp_endpoint *ep, |
4392 | const struct sctp_association *asoc, | 4462 | const struct sctp_association *asoc, |
4393 | const sctp_subtype_t type, | 4463 | const sctp_subtype_t type, |
@@ -4407,17 +4477,17 @@ static sctp_disposition_t sctp_sf_violation_paramlen( | |||
4407 | goto nomem; | 4477 | goto nomem; |
4408 | 4478 | ||
4409 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); | 4479 | sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(abort)); |
4410 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 4480 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
4411 | 4481 | ||
4412 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, | 4482 | sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR, |
4413 | SCTP_ERROR(ECONNABORTED)); | 4483 | SCTP_ERROR(ECONNABORTED)); |
4414 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 4484 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
4415 | SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION)); | 4485 | SCTP_PERR(SCTP_ERROR_PROTO_VIOLATION)); |
4416 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 4486 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
4417 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 4487 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
4418 | 4488 | ||
4419 | discard: | 4489 | discard: |
4420 | sctp_sf_pdiscard(ep, asoc, SCTP_ST_CHUNK(0), arg, commands); | 4490 | sctp_sf_pdiscard(net, ep, asoc, SCTP_ST_CHUNK(0), arg, commands); |
4421 | return SCTP_DISPOSITION_ABORT; | 4491 | return SCTP_DISPOSITION_ABORT; |
4422 | nomem: | 4492 | nomem: |
4423 | return SCTP_DISPOSITION_NOMEM; | 4493 | return SCTP_DISPOSITION_NOMEM; |
@@ -4430,6 +4500,7 @@ nomem: | |||
4430 | * error code. | 4500 | * error code. |
4431 | */ | 4501 | */ |
4432 | static sctp_disposition_t sctp_sf_violation_ctsn( | 4502 | static sctp_disposition_t sctp_sf_violation_ctsn( |
4503 | struct net *net, | ||
4433 | const struct sctp_endpoint *ep, | 4504 | const struct sctp_endpoint *ep, |
4434 | const struct sctp_association *asoc, | 4505 | const struct sctp_association *asoc, |
4435 | const sctp_subtype_t type, | 4506 | const sctp_subtype_t type, |
@@ -4438,7 +4509,7 @@ static sctp_disposition_t sctp_sf_violation_ctsn( | |||
4438 | { | 4509 | { |
4439 | static const char err_str[]="The cumulative tsn ack beyond the max tsn currently sent:"; | 4510 | static const char err_str[]="The cumulative tsn ack beyond the max tsn currently sent:"; |
4440 | 4511 | ||
4441 | return sctp_sf_abort_violation(ep, asoc, arg, commands, err_str, | 4512 | return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, |
4442 | sizeof(err_str)); | 4513 | sizeof(err_str)); |
4443 | } | 4514 | } |
4444 | 4515 | ||
@@ -4449,6 +4520,7 @@ static sctp_disposition_t sctp_sf_violation_ctsn( | |||
4449 | * on the path and we may not want to continue this communication. | 4520 | * on the path and we may not want to continue this communication. |
4450 | */ | 4521 | */ |
4451 | static sctp_disposition_t sctp_sf_violation_chunk( | 4522 | static sctp_disposition_t sctp_sf_violation_chunk( |
4523 | struct net *net, | ||
4452 | const struct sctp_endpoint *ep, | 4524 | const struct sctp_endpoint *ep, |
4453 | const struct sctp_association *asoc, | 4525 | const struct sctp_association *asoc, |
4454 | const sctp_subtype_t type, | 4526 | const sctp_subtype_t type, |
@@ -4458,9 +4530,9 @@ static sctp_disposition_t sctp_sf_violation_chunk( | |||
4458 | static const char err_str[]="The following chunk violates protocol:"; | 4530 | static const char err_str[]="The following chunk violates protocol:"; |
4459 | 4531 | ||
4460 | if (!asoc) | 4532 | if (!asoc) |
4461 | return sctp_sf_violation(ep, asoc, type, arg, commands); | 4533 | return sctp_sf_violation(net, ep, asoc, type, arg, commands); |
4462 | 4534 | ||
4463 | return sctp_sf_abort_violation(ep, asoc, arg, commands, err_str, | 4535 | return sctp_sf_abort_violation(net, ep, asoc, arg, commands, err_str, |
4464 | sizeof(err_str)); | 4536 | sizeof(err_str)); |
4465 | } | 4537 | } |
4466 | /*************************************************************************** | 4538 | /*************************************************************************** |
@@ -4523,7 +4595,8 @@ static sctp_disposition_t sctp_sf_violation_chunk( | |||
4523 | * | 4595 | * |
4524 | * The return value is a disposition. | 4596 | * The return value is a disposition. |
4525 | */ | 4597 | */ |
4526 | sctp_disposition_t sctp_sf_do_prm_asoc(const struct sctp_endpoint *ep, | 4598 | sctp_disposition_t sctp_sf_do_prm_asoc(struct net *net, |
4599 | const struct sctp_endpoint *ep, | ||
4527 | const struct sctp_association *asoc, | 4600 | const struct sctp_association *asoc, |
4528 | const sctp_subtype_t type, | 4601 | const sctp_subtype_t type, |
4529 | void *arg, | 4602 | void *arg, |
@@ -4634,7 +4707,8 @@ nomem: | |||
4634 | * | 4707 | * |
4635 | * The return value is the disposition. | 4708 | * The return value is the disposition. |
4636 | */ | 4709 | */ |
4637 | sctp_disposition_t sctp_sf_do_prm_send(const struct sctp_endpoint *ep, | 4710 | sctp_disposition_t sctp_sf_do_prm_send(struct net *net, |
4711 | const struct sctp_endpoint *ep, | ||
4638 | const struct sctp_association *asoc, | 4712 | const struct sctp_association *asoc, |
4639 | const sctp_subtype_t type, | 4713 | const sctp_subtype_t type, |
4640 | void *arg, | 4714 | void *arg, |
@@ -4673,6 +4747,7 @@ sctp_disposition_t sctp_sf_do_prm_send(const struct sctp_endpoint *ep, | |||
4673 | * The return value is the disposition. | 4747 | * The return value is the disposition. |
4674 | */ | 4748 | */ |
4675 | sctp_disposition_t sctp_sf_do_9_2_prm_shutdown( | 4749 | sctp_disposition_t sctp_sf_do_9_2_prm_shutdown( |
4750 | struct net *net, | ||
4676 | const struct sctp_endpoint *ep, | 4751 | const struct sctp_endpoint *ep, |
4677 | const struct sctp_association *asoc, | 4752 | const struct sctp_association *asoc, |
4678 | const sctp_subtype_t type, | 4753 | const sctp_subtype_t type, |
@@ -4694,7 +4769,7 @@ sctp_disposition_t sctp_sf_do_9_2_prm_shutdown( | |||
4694 | 4769 | ||
4695 | disposition = SCTP_DISPOSITION_CONSUME; | 4770 | disposition = SCTP_DISPOSITION_CONSUME; |
4696 | if (sctp_outq_is_empty(&asoc->outqueue)) { | 4771 | if (sctp_outq_is_empty(&asoc->outqueue)) { |
4697 | disposition = sctp_sf_do_9_2_start_shutdown(ep, asoc, type, | 4772 | disposition = sctp_sf_do_9_2_start_shutdown(net, ep, asoc, type, |
4698 | arg, commands); | 4773 | arg, commands); |
4699 | } | 4774 | } |
4700 | return disposition; | 4775 | return disposition; |
@@ -4728,6 +4803,7 @@ sctp_disposition_t sctp_sf_do_9_2_prm_shutdown( | |||
4728 | * The return value is the disposition. | 4803 | * The return value is the disposition. |
4729 | */ | 4804 | */ |
4730 | sctp_disposition_t sctp_sf_do_9_1_prm_abort( | 4805 | sctp_disposition_t sctp_sf_do_9_1_prm_abort( |
4806 | struct net *net, | ||
4731 | const struct sctp_endpoint *ep, | 4807 | const struct sctp_endpoint *ep, |
4732 | const struct sctp_association *asoc, | 4808 | const struct sctp_association *asoc, |
4733 | const sctp_subtype_t type, | 4809 | const sctp_subtype_t type, |
@@ -4759,14 +4835,15 @@ sctp_disposition_t sctp_sf_do_9_1_prm_abort( | |||
4759 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 4835 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
4760 | SCTP_PERR(SCTP_ERROR_USER_ABORT)); | 4836 | SCTP_PERR(SCTP_ERROR_USER_ABORT)); |
4761 | 4837 | ||
4762 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 4838 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
4763 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 4839 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
4764 | 4840 | ||
4765 | return retval; | 4841 | return retval; |
4766 | } | 4842 | } |
4767 | 4843 | ||
4768 | /* We tried an illegal operation on an association which is closed. */ | 4844 | /* We tried an illegal operation on an association which is closed. */ |
4769 | sctp_disposition_t sctp_sf_error_closed(const struct sctp_endpoint *ep, | 4845 | sctp_disposition_t sctp_sf_error_closed(struct net *net, |
4846 | const struct sctp_endpoint *ep, | ||
4770 | const struct sctp_association *asoc, | 4847 | const struct sctp_association *asoc, |
4771 | const sctp_subtype_t type, | 4848 | const sctp_subtype_t type, |
4772 | void *arg, | 4849 | void *arg, |
@@ -4779,7 +4856,8 @@ sctp_disposition_t sctp_sf_error_closed(const struct sctp_endpoint *ep, | |||
4779 | /* We tried an illegal operation on an association which is shutting | 4856 | /* We tried an illegal operation on an association which is shutting |
4780 | * down. | 4857 | * down. |
4781 | */ | 4858 | */ |
4782 | sctp_disposition_t sctp_sf_error_shutdown(const struct sctp_endpoint *ep, | 4859 | sctp_disposition_t sctp_sf_error_shutdown(struct net *net, |
4860 | const struct sctp_endpoint *ep, | ||
4783 | const struct sctp_association *asoc, | 4861 | const struct sctp_association *asoc, |
4784 | const sctp_subtype_t type, | 4862 | const sctp_subtype_t type, |
4785 | void *arg, | 4863 | void *arg, |
@@ -4805,6 +4883,7 @@ sctp_disposition_t sctp_sf_error_shutdown(const struct sctp_endpoint *ep, | |||
4805 | * (timers) | 4883 | * (timers) |
4806 | */ | 4884 | */ |
4807 | sctp_disposition_t sctp_sf_cookie_wait_prm_shutdown( | 4885 | sctp_disposition_t sctp_sf_cookie_wait_prm_shutdown( |
4886 | struct net *net, | ||
4808 | const struct sctp_endpoint *ep, | 4887 | const struct sctp_endpoint *ep, |
4809 | const struct sctp_association *asoc, | 4888 | const struct sctp_association *asoc, |
4810 | const sctp_subtype_t type, | 4889 | const sctp_subtype_t type, |
@@ -4817,7 +4896,7 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_shutdown( | |||
4817 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 4896 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
4818 | SCTP_STATE(SCTP_STATE_CLOSED)); | 4897 | SCTP_STATE(SCTP_STATE_CLOSED)); |
4819 | 4898 | ||
4820 | SCTP_INC_STATS(SCTP_MIB_SHUTDOWNS); | 4899 | SCTP_INC_STATS(net, SCTP_MIB_SHUTDOWNS); |
4821 | 4900 | ||
4822 | sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); | 4901 | sctp_add_cmd_sf(commands, SCTP_CMD_DELETE_TCB, SCTP_NULL()); |
4823 | 4902 | ||
@@ -4839,6 +4918,7 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_shutdown( | |||
4839 | * (timers) | 4918 | * (timers) |
4840 | */ | 4919 | */ |
4841 | sctp_disposition_t sctp_sf_cookie_echoed_prm_shutdown( | 4920 | sctp_disposition_t sctp_sf_cookie_echoed_prm_shutdown( |
4921 | struct net *net, | ||
4842 | const struct sctp_endpoint *ep, | 4922 | const struct sctp_endpoint *ep, |
4843 | const struct sctp_association *asoc, | 4923 | const struct sctp_association *asoc, |
4844 | const sctp_subtype_t type, | 4924 | const sctp_subtype_t type, |
@@ -4847,7 +4927,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_prm_shutdown( | |||
4847 | /* There is a single T1 timer, so we should be able to use | 4927 | /* There is a single T1 timer, so we should be able to use |
4848 | * common function with the COOKIE-WAIT state. | 4928 | * common function with the COOKIE-WAIT state. |
4849 | */ | 4929 | */ |
4850 | return sctp_sf_cookie_wait_prm_shutdown(ep, asoc, type, arg, commands); | 4930 | return sctp_sf_cookie_wait_prm_shutdown(net, ep, asoc, type, arg, commands); |
4851 | } | 4931 | } |
4852 | 4932 | ||
4853 | /* | 4933 | /* |
@@ -4865,6 +4945,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_prm_shutdown( | |||
4865 | * (timers) | 4945 | * (timers) |
4866 | */ | 4946 | */ |
4867 | sctp_disposition_t sctp_sf_cookie_wait_prm_abort( | 4947 | sctp_disposition_t sctp_sf_cookie_wait_prm_abort( |
4948 | struct net *net, | ||
4868 | const struct sctp_endpoint *ep, | 4949 | const struct sctp_endpoint *ep, |
4869 | const struct sctp_association *asoc, | 4950 | const struct sctp_association *asoc, |
4870 | const sctp_subtype_t type, | 4951 | const sctp_subtype_t type, |
@@ -4884,7 +4965,7 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_abort( | |||
4884 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, | 4965 | sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, |
4885 | SCTP_STATE(SCTP_STATE_CLOSED)); | 4966 | SCTP_STATE(SCTP_STATE_CLOSED)); |
4886 | 4967 | ||
4887 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 4968 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
4888 | 4969 | ||
4889 | /* Even if we can't send the ABORT due to low memory delete the | 4970 | /* Even if we can't send the ABORT due to low memory delete the |
4890 | * TCB. This is a departure from our typical NOMEM handling. | 4971 | * TCB. This is a departure from our typical NOMEM handling. |
@@ -4914,6 +4995,7 @@ sctp_disposition_t sctp_sf_cookie_wait_prm_abort( | |||
4914 | * (timers) | 4995 | * (timers) |
4915 | */ | 4996 | */ |
4916 | sctp_disposition_t sctp_sf_cookie_echoed_prm_abort( | 4997 | sctp_disposition_t sctp_sf_cookie_echoed_prm_abort( |
4998 | struct net *net, | ||
4917 | const struct sctp_endpoint *ep, | 4999 | const struct sctp_endpoint *ep, |
4918 | const struct sctp_association *asoc, | 5000 | const struct sctp_association *asoc, |
4919 | const sctp_subtype_t type, | 5001 | const sctp_subtype_t type, |
@@ -4923,7 +5005,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_prm_abort( | |||
4923 | /* There is a single T1 timer, so we should be able to use | 5005 | /* There is a single T1 timer, so we should be able to use |
4924 | * common function with the COOKIE-WAIT state. | 5006 | * common function with the COOKIE-WAIT state. |
4925 | */ | 5007 | */ |
4926 | return sctp_sf_cookie_wait_prm_abort(ep, asoc, type, arg, commands); | 5008 | return sctp_sf_cookie_wait_prm_abort(net, ep, asoc, type, arg, commands); |
4927 | } | 5009 | } |
4928 | 5010 | ||
4929 | /* | 5011 | /* |
@@ -4939,6 +5021,7 @@ sctp_disposition_t sctp_sf_cookie_echoed_prm_abort( | |||
4939 | * (timers) | 5021 | * (timers) |
4940 | */ | 5022 | */ |
4941 | sctp_disposition_t sctp_sf_shutdown_pending_prm_abort( | 5023 | sctp_disposition_t sctp_sf_shutdown_pending_prm_abort( |
5024 | struct net *net, | ||
4942 | const struct sctp_endpoint *ep, | 5025 | const struct sctp_endpoint *ep, |
4943 | const struct sctp_association *asoc, | 5026 | const struct sctp_association *asoc, |
4944 | const sctp_subtype_t type, | 5027 | const sctp_subtype_t type, |
@@ -4949,7 +5032,7 @@ sctp_disposition_t sctp_sf_shutdown_pending_prm_abort( | |||
4949 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 5032 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
4950 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); | 5033 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); |
4951 | 5034 | ||
4952 | return sctp_sf_do_9_1_prm_abort(ep, asoc, type, arg, commands); | 5035 | return sctp_sf_do_9_1_prm_abort(net, ep, asoc, type, arg, commands); |
4953 | } | 5036 | } |
4954 | 5037 | ||
4955 | /* | 5038 | /* |
@@ -4965,6 +5048,7 @@ sctp_disposition_t sctp_sf_shutdown_pending_prm_abort( | |||
4965 | * (timers) | 5048 | * (timers) |
4966 | */ | 5049 | */ |
4967 | sctp_disposition_t sctp_sf_shutdown_sent_prm_abort( | 5050 | sctp_disposition_t sctp_sf_shutdown_sent_prm_abort( |
5051 | struct net *net, | ||
4968 | const struct sctp_endpoint *ep, | 5052 | const struct sctp_endpoint *ep, |
4969 | const struct sctp_association *asoc, | 5053 | const struct sctp_association *asoc, |
4970 | const sctp_subtype_t type, | 5054 | const sctp_subtype_t type, |
@@ -4979,7 +5063,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_prm_abort( | |||
4979 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, | 5063 | sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, |
4980 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); | 5064 | SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); |
4981 | 5065 | ||
4982 | return sctp_sf_do_9_1_prm_abort(ep, asoc, type, arg, commands); | 5066 | return sctp_sf_do_9_1_prm_abort(net, ep, asoc, type, arg, commands); |
4983 | } | 5067 | } |
4984 | 5068 | ||
4985 | /* | 5069 | /* |
@@ -4995,6 +5079,7 @@ sctp_disposition_t sctp_sf_shutdown_sent_prm_abort( | |||
4995 | * (timers) | 5079 | * (timers) |
4996 | */ | 5080 | */ |
4997 | sctp_disposition_t sctp_sf_shutdown_ack_sent_prm_abort( | 5081 | sctp_disposition_t sctp_sf_shutdown_ack_sent_prm_abort( |
5082 | struct net *net, | ||
4998 | const struct sctp_endpoint *ep, | 5083 | const struct sctp_endpoint *ep, |
4999 | const struct sctp_association *asoc, | 5084 | const struct sctp_association *asoc, |
5000 | const sctp_subtype_t type, | 5085 | const sctp_subtype_t type, |
@@ -5004,7 +5089,7 @@ sctp_disposition_t sctp_sf_shutdown_ack_sent_prm_abort( | |||
5004 | /* The same T2 timer, so we should be able to use | 5089 | /* The same T2 timer, so we should be able to use |
5005 | * common function with the SHUTDOWN-SENT state. | 5090 | * common function with the SHUTDOWN-SENT state. |
5006 | */ | 5091 | */ |
5007 | return sctp_sf_shutdown_sent_prm_abort(ep, asoc, type, arg, commands); | 5092 | return sctp_sf_shutdown_sent_prm_abort(net, ep, asoc, type, arg, commands); |
5008 | } | 5093 | } |
5009 | 5094 | ||
5010 | /* | 5095 | /* |
@@ -5030,6 +5115,7 @@ sctp_disposition_t sctp_sf_shutdown_ack_sent_prm_abort( | |||
5030 | * association on which a heartbeat should be issued. | 5115 | * association on which a heartbeat should be issued. |
5031 | */ | 5116 | */ |
5032 | sctp_disposition_t sctp_sf_do_prm_requestheartbeat( | 5117 | sctp_disposition_t sctp_sf_do_prm_requestheartbeat( |
5118 | struct net *net, | ||
5033 | const struct sctp_endpoint *ep, | 5119 | const struct sctp_endpoint *ep, |
5034 | const struct sctp_association *asoc, | 5120 | const struct sctp_association *asoc, |
5035 | const sctp_subtype_t type, | 5121 | const sctp_subtype_t type, |
@@ -5061,7 +5147,8 @@ sctp_disposition_t sctp_sf_do_prm_requestheartbeat( | |||
5061 | * When an endpoint has an ASCONF signaled change to be sent to the | 5147 | * When an endpoint has an ASCONF signaled change to be sent to the |
5062 | * remote endpoint it should do A1 to A9 | 5148 | * remote endpoint it should do A1 to A9 |
5063 | */ | 5149 | */ |
5064 | sctp_disposition_t sctp_sf_do_prm_asconf(const struct sctp_endpoint *ep, | 5150 | sctp_disposition_t sctp_sf_do_prm_asconf(struct net *net, |
5151 | const struct sctp_endpoint *ep, | ||
5065 | const struct sctp_association *asoc, | 5152 | const struct sctp_association *asoc, |
5066 | const sctp_subtype_t type, | 5153 | const sctp_subtype_t type, |
5067 | void *arg, | 5154 | void *arg, |
@@ -5082,6 +5169,7 @@ sctp_disposition_t sctp_sf_do_prm_asconf(const struct sctp_endpoint *ep, | |||
5082 | * The return value is the disposition of the primitive. | 5169 | * The return value is the disposition of the primitive. |
5083 | */ | 5170 | */ |
5084 | sctp_disposition_t sctp_sf_ignore_primitive( | 5171 | sctp_disposition_t sctp_sf_ignore_primitive( |
5172 | struct net *net, | ||
5085 | const struct sctp_endpoint *ep, | 5173 | const struct sctp_endpoint *ep, |
5086 | const struct sctp_association *asoc, | 5174 | const struct sctp_association *asoc, |
5087 | const sctp_subtype_t type, | 5175 | const sctp_subtype_t type, |
@@ -5103,6 +5191,7 @@ sctp_disposition_t sctp_sf_ignore_primitive( | |||
5103 | * retransmit, the stack will immediately send up this notification. | 5191 | * retransmit, the stack will immediately send up this notification. |
5104 | */ | 5192 | */ |
5105 | sctp_disposition_t sctp_sf_do_no_pending_tsn( | 5193 | sctp_disposition_t sctp_sf_do_no_pending_tsn( |
5194 | struct net *net, | ||
5106 | const struct sctp_endpoint *ep, | 5195 | const struct sctp_endpoint *ep, |
5107 | const struct sctp_association *asoc, | 5196 | const struct sctp_association *asoc, |
5108 | const sctp_subtype_t type, | 5197 | const sctp_subtype_t type, |
@@ -5134,6 +5223,7 @@ sctp_disposition_t sctp_sf_do_no_pending_tsn( | |||
5134 | * The return value is the disposition. | 5223 | * The return value is the disposition. |
5135 | */ | 5224 | */ |
5136 | sctp_disposition_t sctp_sf_do_9_2_start_shutdown( | 5225 | sctp_disposition_t sctp_sf_do_9_2_start_shutdown( |
5226 | struct net *net, | ||
5137 | const struct sctp_endpoint *ep, | 5227 | const struct sctp_endpoint *ep, |
5138 | const struct sctp_association *asoc, | 5228 | const struct sctp_association *asoc, |
5139 | const sctp_subtype_t type, | 5229 | const sctp_subtype_t type, |
@@ -5203,6 +5293,7 @@ nomem: | |||
5203 | * The return value is the disposition. | 5293 | * The return value is the disposition. |
5204 | */ | 5294 | */ |
5205 | sctp_disposition_t sctp_sf_do_9_2_shutdown_ack( | 5295 | sctp_disposition_t sctp_sf_do_9_2_shutdown_ack( |
5296 | struct net *net, | ||
5206 | const struct sctp_endpoint *ep, | 5297 | const struct sctp_endpoint *ep, |
5207 | const struct sctp_association *asoc, | 5298 | const struct sctp_association *asoc, |
5208 | const sctp_subtype_t type, | 5299 | const sctp_subtype_t type, |
@@ -5221,11 +5312,11 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown_ack( | |||
5221 | */ | 5312 | */ |
5222 | if (chunk) { | 5313 | if (chunk) { |
5223 | if (!sctp_vtag_verify(chunk, asoc)) | 5314 | if (!sctp_vtag_verify(chunk, asoc)) |
5224 | return sctp_sf_pdiscard(ep, asoc, type, arg, commands); | 5315 | return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); |
5225 | 5316 | ||
5226 | /* Make sure that the SHUTDOWN chunk has a valid length. */ | 5317 | /* Make sure that the SHUTDOWN chunk has a valid length. */ |
5227 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk_t))) | 5318 | if (!sctp_chunk_length_valid(chunk, sizeof(struct sctp_shutdown_chunk_t))) |
5228 | return sctp_sf_violation_chunklen(ep, asoc, type, arg, | 5319 | return sctp_sf_violation_chunklen(net, ep, asoc, type, arg, |
5229 | commands); | 5320 | commands); |
5230 | } | 5321 | } |
5231 | 5322 | ||
@@ -5273,7 +5364,8 @@ nomem: | |||
5273 | * | 5364 | * |
5274 | * The return value is the disposition of the event. | 5365 | * The return value is the disposition of the event. |
5275 | */ | 5366 | */ |
5276 | sctp_disposition_t sctp_sf_ignore_other(const struct sctp_endpoint *ep, | 5367 | sctp_disposition_t sctp_sf_ignore_other(struct net *net, |
5368 | const struct sctp_endpoint *ep, | ||
5277 | const struct sctp_association *asoc, | 5369 | const struct sctp_association *asoc, |
5278 | const sctp_subtype_t type, | 5370 | const sctp_subtype_t type, |
5279 | void *arg, | 5371 | void *arg, |
@@ -5298,7 +5390,8 @@ sctp_disposition_t sctp_sf_ignore_other(const struct sctp_endpoint *ep, | |||
5298 | * | 5390 | * |
5299 | * The return value is the disposition of the chunk. | 5391 | * The return value is the disposition of the chunk. |
5300 | */ | 5392 | */ |
5301 | sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep, | 5393 | sctp_disposition_t sctp_sf_do_6_3_3_rtx(struct net *net, |
5394 | const struct sctp_endpoint *ep, | ||
5302 | const struct sctp_association *asoc, | 5395 | const struct sctp_association *asoc, |
5303 | const sctp_subtype_t type, | 5396 | const sctp_subtype_t type, |
5304 | void *arg, | 5397 | void *arg, |
@@ -5306,7 +5399,7 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep, | |||
5306 | { | 5399 | { |
5307 | struct sctp_transport *transport = arg; | 5400 | struct sctp_transport *transport = arg; |
5308 | 5401 | ||
5309 | SCTP_INC_STATS(SCTP_MIB_T3_RTX_EXPIREDS); | 5402 | SCTP_INC_STATS(net, SCTP_MIB_T3_RTX_EXPIREDS); |
5310 | 5403 | ||
5311 | if (asoc->overall_error_count >= asoc->max_retrans) { | 5404 | if (asoc->overall_error_count >= asoc->max_retrans) { |
5312 | if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { | 5405 | if (asoc->state == SCTP_STATE_SHUTDOWN_PENDING) { |
@@ -5327,8 +5420,8 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep, | |||
5327 | /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ | 5420 | /* CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ |
5328 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 5421 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
5329 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); | 5422 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); |
5330 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 5423 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
5331 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 5424 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
5332 | return SCTP_DISPOSITION_DELETE_TCB; | 5425 | return SCTP_DISPOSITION_DELETE_TCB; |
5333 | } | 5426 | } |
5334 | } | 5427 | } |
@@ -5384,13 +5477,14 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep, | |||
5384 | * allow. However, an SCTP transmitter MUST NOT be more aggressive than | 5477 | * allow. However, an SCTP transmitter MUST NOT be more aggressive than |
5385 | * the following algorithms allow. | 5478 | * the following algorithms allow. |
5386 | */ | 5479 | */ |
5387 | sctp_disposition_t sctp_sf_do_6_2_sack(const struct sctp_endpoint *ep, | 5480 | sctp_disposition_t sctp_sf_do_6_2_sack(struct net *net, |
5481 | const struct sctp_endpoint *ep, | ||
5388 | const struct sctp_association *asoc, | 5482 | const struct sctp_association *asoc, |
5389 | const sctp_subtype_t type, | 5483 | const sctp_subtype_t type, |
5390 | void *arg, | 5484 | void *arg, |
5391 | sctp_cmd_seq_t *commands) | 5485 | sctp_cmd_seq_t *commands) |
5392 | { | 5486 | { |
5393 | SCTP_INC_STATS(SCTP_MIB_DELAY_SACK_EXPIREDS); | 5487 | SCTP_INC_STATS(net, SCTP_MIB_DELAY_SACK_EXPIREDS); |
5394 | sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_FORCE()); | 5488 | sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_FORCE()); |
5395 | return SCTP_DISPOSITION_CONSUME; | 5489 | return SCTP_DISPOSITION_CONSUME; |
5396 | } | 5490 | } |
@@ -5414,7 +5508,8 @@ sctp_disposition_t sctp_sf_do_6_2_sack(const struct sctp_endpoint *ep, | |||
5414 | * (timers, events) | 5508 | * (timers, events) |
5415 | * | 5509 | * |
5416 | */ | 5510 | */ |
5417 | sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep, | 5511 | sctp_disposition_t sctp_sf_t1_init_timer_expire(struct net *net, |
5512 | const struct sctp_endpoint *ep, | ||
5418 | const struct sctp_association *asoc, | 5513 | const struct sctp_association *asoc, |
5419 | const sctp_subtype_t type, | 5514 | const sctp_subtype_t type, |
5420 | void *arg, | 5515 | void *arg, |
@@ -5425,7 +5520,7 @@ sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep, | |||
5425 | int attempts = asoc->init_err_counter + 1; | 5520 | int attempts = asoc->init_err_counter + 1; |
5426 | 5521 | ||
5427 | SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n"); | 5522 | SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n"); |
5428 | SCTP_INC_STATS(SCTP_MIB_T1_INIT_EXPIREDS); | 5523 | SCTP_INC_STATS(net, SCTP_MIB_T1_INIT_EXPIREDS); |
5429 | 5524 | ||
5430 | if (attempts <= asoc->max_init_attempts) { | 5525 | if (attempts <= asoc->max_init_attempts) { |
5431 | bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; | 5526 | bp = (struct sctp_bind_addr *) &asoc->base.bind_addr; |
@@ -5475,7 +5570,8 @@ sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep, | |||
5475 | * (timers, events) | 5570 | * (timers, events) |
5476 | * | 5571 | * |
5477 | */ | 5572 | */ |
5478 | sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep, | 5573 | sctp_disposition_t sctp_sf_t1_cookie_timer_expire(struct net *net, |
5574 | const struct sctp_endpoint *ep, | ||
5479 | const struct sctp_association *asoc, | 5575 | const struct sctp_association *asoc, |
5480 | const sctp_subtype_t type, | 5576 | const sctp_subtype_t type, |
5481 | void *arg, | 5577 | void *arg, |
@@ -5485,7 +5581,7 @@ sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep | |||
5485 | int attempts = asoc->init_err_counter + 1; | 5581 | int attempts = asoc->init_err_counter + 1; |
5486 | 5582 | ||
5487 | SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n"); | 5583 | SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n"); |
5488 | SCTP_INC_STATS(SCTP_MIB_T1_COOKIE_EXPIREDS); | 5584 | SCTP_INC_STATS(net, SCTP_MIB_T1_COOKIE_EXPIREDS); |
5489 | 5585 | ||
5490 | if (attempts <= asoc->max_init_attempts) { | 5586 | if (attempts <= asoc->max_init_attempts) { |
5491 | repl = sctp_make_cookie_echo(asoc, NULL); | 5587 | repl = sctp_make_cookie_echo(asoc, NULL); |
@@ -5523,7 +5619,8 @@ sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep | |||
5523 | * the T2-Shutdown timer, giving its peer ample opportunity to transmit | 5619 | * the T2-Shutdown timer, giving its peer ample opportunity to transmit |
5524 | * all of its queued DATA chunks that have not yet been sent. | 5620 | * all of its queued DATA chunks that have not yet been sent. |
5525 | */ | 5621 | */ |
5526 | sctp_disposition_t sctp_sf_t2_timer_expire(const struct sctp_endpoint *ep, | 5622 | sctp_disposition_t sctp_sf_t2_timer_expire(struct net *net, |
5623 | const struct sctp_endpoint *ep, | ||
5527 | const struct sctp_association *asoc, | 5624 | const struct sctp_association *asoc, |
5528 | const sctp_subtype_t type, | 5625 | const sctp_subtype_t type, |
5529 | void *arg, | 5626 | void *arg, |
@@ -5532,7 +5629,7 @@ sctp_disposition_t sctp_sf_t2_timer_expire(const struct sctp_endpoint *ep, | |||
5532 | struct sctp_chunk *reply = NULL; | 5629 | struct sctp_chunk *reply = NULL; |
5533 | 5630 | ||
5534 | SCTP_DEBUG_PRINTK("Timer T2 expired.\n"); | 5631 | SCTP_DEBUG_PRINTK("Timer T2 expired.\n"); |
5535 | SCTP_INC_STATS(SCTP_MIB_T2_SHUTDOWN_EXPIREDS); | 5632 | SCTP_INC_STATS(net, SCTP_MIB_T2_SHUTDOWN_EXPIREDS); |
5536 | 5633 | ||
5537 | ((struct sctp_association *)asoc)->shutdown_retries++; | 5634 | ((struct sctp_association *)asoc)->shutdown_retries++; |
5538 | 5635 | ||
@@ -5542,8 +5639,8 @@ sctp_disposition_t sctp_sf_t2_timer_expire(const struct sctp_endpoint *ep, | |||
5542 | /* Note: CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ | 5639 | /* Note: CMD_ASSOC_FAILED calls CMD_DELETE_TCB. */ |
5543 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 5640 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
5544 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); | 5641 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); |
5545 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 5642 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
5546 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 5643 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
5547 | return SCTP_DISPOSITION_DELETE_TCB; | 5644 | return SCTP_DISPOSITION_DELETE_TCB; |
5548 | } | 5645 | } |
5549 | 5646 | ||
@@ -5592,6 +5689,7 @@ nomem: | |||
5592 | * If the T4 RTO timer expires the endpoint should do B1 to B5 | 5689 | * If the T4 RTO timer expires the endpoint should do B1 to B5 |
5593 | */ | 5690 | */ |
5594 | sctp_disposition_t sctp_sf_t4_timer_expire( | 5691 | sctp_disposition_t sctp_sf_t4_timer_expire( |
5692 | struct net *net, | ||
5595 | const struct sctp_endpoint *ep, | 5693 | const struct sctp_endpoint *ep, |
5596 | const struct sctp_association *asoc, | 5694 | const struct sctp_association *asoc, |
5597 | const sctp_subtype_t type, | 5695 | const sctp_subtype_t type, |
@@ -5601,7 +5699,7 @@ sctp_disposition_t sctp_sf_t4_timer_expire( | |||
5601 | struct sctp_chunk *chunk = asoc->addip_last_asconf; | 5699 | struct sctp_chunk *chunk = asoc->addip_last_asconf; |
5602 | struct sctp_transport *transport = chunk->transport; | 5700 | struct sctp_transport *transport = chunk->transport; |
5603 | 5701 | ||
5604 | SCTP_INC_STATS(SCTP_MIB_T4_RTO_EXPIREDS); | 5702 | SCTP_INC_STATS(net, SCTP_MIB_T4_RTO_EXPIREDS); |
5605 | 5703 | ||
5606 | /* ADDIP 4.1 B1) Increment the error counters and perform path failure | 5704 | /* ADDIP 4.1 B1) Increment the error counters and perform path failure |
5607 | * detection on the appropriate destination address as defined in | 5705 | * detection on the appropriate destination address as defined in |
@@ -5626,8 +5724,8 @@ sctp_disposition_t sctp_sf_t4_timer_expire( | |||
5626 | SCTP_ERROR(ETIMEDOUT)); | 5724 | SCTP_ERROR(ETIMEDOUT)); |
5627 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 5725 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
5628 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); | 5726 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); |
5629 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 5727 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
5630 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 5728 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
5631 | return SCTP_DISPOSITION_ABORT; | 5729 | return SCTP_DISPOSITION_ABORT; |
5632 | } | 5730 | } |
5633 | 5731 | ||
@@ -5662,7 +5760,8 @@ sctp_disposition_t sctp_sf_t4_timer_expire( | |||
5662 | * At the expiration of this timer the sender SHOULD abort the association | 5760 | * At the expiration of this timer the sender SHOULD abort the association |
5663 | * by sending an ABORT chunk. | 5761 | * by sending an ABORT chunk. |
5664 | */ | 5762 | */ |
5665 | sctp_disposition_t sctp_sf_t5_timer_expire(const struct sctp_endpoint *ep, | 5763 | sctp_disposition_t sctp_sf_t5_timer_expire(struct net *net, |
5764 | const struct sctp_endpoint *ep, | ||
5666 | const struct sctp_association *asoc, | 5765 | const struct sctp_association *asoc, |
5667 | const sctp_subtype_t type, | 5766 | const sctp_subtype_t type, |
5668 | void *arg, | 5767 | void *arg, |
@@ -5671,7 +5770,7 @@ sctp_disposition_t sctp_sf_t5_timer_expire(const struct sctp_endpoint *ep, | |||
5671 | struct sctp_chunk *reply = NULL; | 5770 | struct sctp_chunk *reply = NULL; |
5672 | 5771 | ||
5673 | SCTP_DEBUG_PRINTK("Timer T5 expired.\n"); | 5772 | SCTP_DEBUG_PRINTK("Timer T5 expired.\n"); |
5674 | SCTP_INC_STATS(SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS); | 5773 | SCTP_INC_STATS(net, SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS); |
5675 | 5774 | ||
5676 | reply = sctp_make_abort(asoc, NULL, 0); | 5775 | reply = sctp_make_abort(asoc, NULL, 0); |
5677 | if (!reply) | 5776 | if (!reply) |
@@ -5683,8 +5782,8 @@ sctp_disposition_t sctp_sf_t5_timer_expire(const struct sctp_endpoint *ep, | |||
5683 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 5782 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
5684 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); | 5783 | SCTP_PERR(SCTP_ERROR_NO_ERROR)); |
5685 | 5784 | ||
5686 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 5785 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
5687 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 5786 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
5688 | 5787 | ||
5689 | return SCTP_DISPOSITION_DELETE_TCB; | 5788 | return SCTP_DISPOSITION_DELETE_TCB; |
5690 | nomem: | 5789 | nomem: |
@@ -5697,6 +5796,7 @@ nomem: | |||
5697 | * the user. So this routine looks same as sctp_sf_do_9_2_prm_shutdown(). | 5796 | * the user. So this routine looks same as sctp_sf_do_9_2_prm_shutdown(). |
5698 | */ | 5797 | */ |
5699 | sctp_disposition_t sctp_sf_autoclose_timer_expire( | 5798 | sctp_disposition_t sctp_sf_autoclose_timer_expire( |
5799 | struct net *net, | ||
5700 | const struct sctp_endpoint *ep, | 5800 | const struct sctp_endpoint *ep, |
5701 | const struct sctp_association *asoc, | 5801 | const struct sctp_association *asoc, |
5702 | const sctp_subtype_t type, | 5802 | const sctp_subtype_t type, |
@@ -5705,7 +5805,7 @@ sctp_disposition_t sctp_sf_autoclose_timer_expire( | |||
5705 | { | 5805 | { |
5706 | int disposition; | 5806 | int disposition; |
5707 | 5807 | ||
5708 | SCTP_INC_STATS(SCTP_MIB_AUTOCLOSE_EXPIREDS); | 5808 | SCTP_INC_STATS(net, SCTP_MIB_AUTOCLOSE_EXPIREDS); |
5709 | 5809 | ||
5710 | /* From 9.2 Shutdown of an Association | 5810 | /* From 9.2 Shutdown of an Association |
5711 | * Upon receipt of the SHUTDOWN primitive from its upper | 5811 | * Upon receipt of the SHUTDOWN primitive from its upper |
@@ -5720,7 +5820,7 @@ sctp_disposition_t sctp_sf_autoclose_timer_expire( | |||
5720 | 5820 | ||
5721 | disposition = SCTP_DISPOSITION_CONSUME; | 5821 | disposition = SCTP_DISPOSITION_CONSUME; |
5722 | if (sctp_outq_is_empty(&asoc->outqueue)) { | 5822 | if (sctp_outq_is_empty(&asoc->outqueue)) { |
5723 | disposition = sctp_sf_do_9_2_start_shutdown(ep, asoc, type, | 5823 | disposition = sctp_sf_do_9_2_start_shutdown(net, ep, asoc, type, |
5724 | arg, commands); | 5824 | arg, commands); |
5725 | } | 5825 | } |
5726 | return disposition; | 5826 | return disposition; |
@@ -5738,7 +5838,8 @@ sctp_disposition_t sctp_sf_autoclose_timer_expire( | |||
5738 | * | 5838 | * |
5739 | * The return value is the disposition of the chunk. | 5839 | * The return value is the disposition of the chunk. |
5740 | */ | 5840 | */ |
5741 | sctp_disposition_t sctp_sf_not_impl(const struct sctp_endpoint *ep, | 5841 | sctp_disposition_t sctp_sf_not_impl(struct net *net, |
5842 | const struct sctp_endpoint *ep, | ||
5742 | const struct sctp_association *asoc, | 5843 | const struct sctp_association *asoc, |
5743 | const sctp_subtype_t type, | 5844 | const sctp_subtype_t type, |
5744 | void *arg, | 5845 | void *arg, |
@@ -5755,7 +5856,8 @@ sctp_disposition_t sctp_sf_not_impl(const struct sctp_endpoint *ep, | |||
5755 | * | 5856 | * |
5756 | * The return value is the disposition of the chunk. | 5857 | * The return value is the disposition of the chunk. |
5757 | */ | 5858 | */ |
5758 | sctp_disposition_t sctp_sf_bug(const struct sctp_endpoint *ep, | 5859 | sctp_disposition_t sctp_sf_bug(struct net *net, |
5860 | const struct sctp_endpoint *ep, | ||
5759 | const struct sctp_association *asoc, | 5861 | const struct sctp_association *asoc, |
5760 | const sctp_subtype_t type, | 5862 | const sctp_subtype_t type, |
5761 | void *arg, | 5863 | void *arg, |
@@ -5775,7 +5877,8 @@ sctp_disposition_t sctp_sf_bug(const struct sctp_endpoint *ep, | |||
5775 | * | 5877 | * |
5776 | * The return value is the disposition of the chunk. | 5878 | * The return value is the disposition of the chunk. |
5777 | */ | 5879 | */ |
5778 | sctp_disposition_t sctp_sf_timer_ignore(const struct sctp_endpoint *ep, | 5880 | sctp_disposition_t sctp_sf_timer_ignore(struct net *net, |
5881 | const struct sctp_endpoint *ep, | ||
5779 | const struct sctp_association *asoc, | 5882 | const struct sctp_association *asoc, |
5780 | const sctp_subtype_t type, | 5883 | const sctp_subtype_t type, |
5781 | void *arg, | 5884 | void *arg, |
@@ -5817,7 +5920,8 @@ static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk) | |||
5817 | /* Create an ABORT packet to be sent as a response, with the specified | 5920 | /* Create an ABORT packet to be sent as a response, with the specified |
5818 | * error causes. | 5921 | * error causes. |
5819 | */ | 5922 | */ |
5820 | static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | 5923 | static struct sctp_packet *sctp_abort_pkt_new(struct net *net, |
5924 | const struct sctp_endpoint *ep, | ||
5821 | const struct sctp_association *asoc, | 5925 | const struct sctp_association *asoc, |
5822 | struct sctp_chunk *chunk, | 5926 | struct sctp_chunk *chunk, |
5823 | const void *payload, | 5927 | const void *payload, |
@@ -5826,7 +5930,7 @@ static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | |||
5826 | struct sctp_packet *packet; | 5930 | struct sctp_packet *packet; |
5827 | struct sctp_chunk *abort; | 5931 | struct sctp_chunk *abort; |
5828 | 5932 | ||
5829 | packet = sctp_ootb_pkt_new(asoc, chunk); | 5933 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
5830 | 5934 | ||
5831 | if (packet) { | 5935 | if (packet) { |
5832 | /* Make an ABORT. | 5936 | /* Make an ABORT. |
@@ -5858,7 +5962,8 @@ static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | |||
5858 | } | 5962 | } |
5859 | 5963 | ||
5860 | /* Allocate a packet for responding in the OOTB conditions. */ | 5964 | /* Allocate a packet for responding in the OOTB conditions. */ |
5861 | static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc, | 5965 | static struct sctp_packet *sctp_ootb_pkt_new(struct net *net, |
5966 | const struct sctp_association *asoc, | ||
5862 | const struct sctp_chunk *chunk) | 5967 | const struct sctp_chunk *chunk) |
5863 | { | 5968 | { |
5864 | struct sctp_packet *packet; | 5969 | struct sctp_packet *packet; |
@@ -5911,7 +6016,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc | |||
5911 | } | 6016 | } |
5912 | 6017 | ||
5913 | /* Make a transport for the bucket, Eliza... */ | 6018 | /* Make a transport for the bucket, Eliza... */ |
5914 | transport = sctp_transport_new(sctp_source(chunk), GFP_ATOMIC); | 6019 | transport = sctp_transport_new(net, sctp_source(chunk), GFP_ATOMIC); |
5915 | if (!transport) | 6020 | if (!transport) |
5916 | goto nomem; | 6021 | goto nomem; |
5917 | 6022 | ||
@@ -5919,7 +6024,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc | |||
5919 | * the source address. | 6024 | * the source address. |
5920 | */ | 6025 | */ |
5921 | sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, | 6026 | sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, |
5922 | sctp_sk(sctp_get_ctl_sock())); | 6027 | sctp_sk(net->sctp.ctl_sock)); |
5923 | 6028 | ||
5924 | packet = sctp_packet_init(&transport->packet, transport, sport, dport); | 6029 | packet = sctp_packet_init(&transport->packet, transport, sport, dport); |
5925 | packet = sctp_packet_config(packet, vtag, 0); | 6030 | packet = sctp_packet_config(packet, vtag, 0); |
@@ -5937,7 +6042,8 @@ void sctp_ootb_pkt_free(struct sctp_packet *packet) | |||
5937 | } | 6042 | } |
5938 | 6043 | ||
5939 | /* Send a stale cookie error when a invalid COOKIE ECHO chunk is found */ | 6044 | /* Send a stale cookie error when a invalid COOKIE ECHO chunk is found */ |
5940 | static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, | 6045 | static void sctp_send_stale_cookie_err(struct net *net, |
6046 | const struct sctp_endpoint *ep, | ||
5941 | const struct sctp_association *asoc, | 6047 | const struct sctp_association *asoc, |
5942 | const struct sctp_chunk *chunk, | 6048 | const struct sctp_chunk *chunk, |
5943 | sctp_cmd_seq_t *commands, | 6049 | sctp_cmd_seq_t *commands, |
@@ -5946,7 +6052,7 @@ static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, | |||
5946 | struct sctp_packet *packet; | 6052 | struct sctp_packet *packet; |
5947 | 6053 | ||
5948 | if (err_chunk) { | 6054 | if (err_chunk) { |
5949 | packet = sctp_ootb_pkt_new(asoc, chunk); | 6055 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
5950 | if (packet) { | 6056 | if (packet) { |
5951 | struct sctp_signed_cookie *cookie; | 6057 | struct sctp_signed_cookie *cookie; |
5952 | 6058 | ||
@@ -5959,7 +6065,7 @@ static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, | |||
5959 | sctp_packet_append_chunk(packet, err_chunk); | 6065 | sctp_packet_append_chunk(packet, err_chunk); |
5960 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, | 6066 | sctp_add_cmd_sf(commands, SCTP_CMD_SEND_PKT, |
5961 | SCTP_PACKET(packet)); | 6067 | SCTP_PACKET(packet)); |
5962 | SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS); | 6068 | SCTP_INC_STATS(net, SCTP_MIB_OUTCTRLCHUNKS); |
5963 | } else | 6069 | } else |
5964 | sctp_chunk_free (err_chunk); | 6070 | sctp_chunk_free (err_chunk); |
5965 | } | 6071 | } |
@@ -5979,6 +6085,7 @@ static int sctp_eat_data(const struct sctp_association *asoc, | |||
5979 | __u32 tsn; | 6085 | __u32 tsn; |
5980 | struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; | 6086 | struct sctp_tsnmap *map = (struct sctp_tsnmap *)&asoc->peer.tsn_map; |
5981 | struct sock *sk = asoc->base.sk; | 6087 | struct sock *sk = asoc->base.sk; |
6088 | struct net *net = sock_net(sk); | ||
5982 | u16 ssn; | 6089 | u16 ssn; |
5983 | u16 sid; | 6090 | u16 sid; |
5984 | u8 ordered = 0; | 6091 | u8 ordered = 0; |
@@ -6109,8 +6216,8 @@ static int sctp_eat_data(const struct sctp_association *asoc, | |||
6109 | SCTP_ERROR(ECONNABORTED)); | 6216 | SCTP_ERROR(ECONNABORTED)); |
6110 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, | 6217 | sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_FAILED, |
6111 | SCTP_PERR(SCTP_ERROR_NO_DATA)); | 6218 | SCTP_PERR(SCTP_ERROR_NO_DATA)); |
6112 | SCTP_INC_STATS(SCTP_MIB_ABORTEDS); | 6219 | SCTP_INC_STATS(net, SCTP_MIB_ABORTEDS); |
6113 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 6220 | SCTP_DEC_STATS(net, SCTP_MIB_CURRESTAB); |
6114 | return SCTP_IERROR_NO_DATA; | 6221 | return SCTP_IERROR_NO_DATA; |
6115 | } | 6222 | } |
6116 | 6223 | ||
@@ -6120,9 +6227,9 @@ static int sctp_eat_data(const struct sctp_association *asoc, | |||
6120 | * if we renege and the chunk arrives again. | 6227 | * if we renege and the chunk arrives again. |
6121 | */ | 6228 | */ |
6122 | if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) | 6229 | if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) |
6123 | SCTP_INC_STATS(SCTP_MIB_INUNORDERCHUNKS); | 6230 | SCTP_INC_STATS(net, SCTP_MIB_INUNORDERCHUNKS); |
6124 | else { | 6231 | else { |
6125 | SCTP_INC_STATS(SCTP_MIB_INORDERCHUNKS); | 6232 | SCTP_INC_STATS(net, SCTP_MIB_INORDERCHUNKS); |
6126 | ordered = 1; | 6233 | ordered = 1; |
6127 | } | 6234 | } |
6128 | 6235 | ||
diff --git a/net/sctp/sm_statetable.c b/net/sctp/sm_statetable.c index 7c211a7f90f4..84d98d8a5a74 100644 --- a/net/sctp/sm_statetable.c +++ b/net/sctp/sm_statetable.c | |||
@@ -59,7 +59,8 @@ other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES]; | |||
59 | static const sctp_sm_table_entry_t | 59 | static const sctp_sm_table_entry_t |
60 | timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES]; | 60 | timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES]; |
61 | 61 | ||
62 | static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid, | 62 | static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net, |
63 | sctp_cid_t cid, | ||
63 | sctp_state_t state); | 64 | sctp_state_t state); |
64 | 65 | ||
65 | 66 | ||
@@ -82,13 +83,14 @@ static const sctp_sm_table_entry_t bug = { | |||
82 | rtn; \ | 83 | rtn; \ |
83 | }) | 84 | }) |
84 | 85 | ||
85 | const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type, | 86 | const sctp_sm_table_entry_t *sctp_sm_lookup_event(struct net *net, |
87 | sctp_event_t event_type, | ||
86 | sctp_state_t state, | 88 | sctp_state_t state, |
87 | sctp_subtype_t event_subtype) | 89 | sctp_subtype_t event_subtype) |
88 | { | 90 | { |
89 | switch (event_type) { | 91 | switch (event_type) { |
90 | case SCTP_EVENT_T_CHUNK: | 92 | case SCTP_EVENT_T_CHUNK: |
91 | return sctp_chunk_event_lookup(event_subtype.chunk, state); | 93 | return sctp_chunk_event_lookup(net, event_subtype.chunk, state); |
92 | case SCTP_EVENT_T_TIMEOUT: | 94 | case SCTP_EVENT_T_TIMEOUT: |
93 | return DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout, | 95 | return DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout, |
94 | timeout_event_table); | 96 | timeout_event_table); |
@@ -906,7 +908,8 @@ static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][S | |||
906 | TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE, | 908 | TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE, |
907 | }; | 909 | }; |
908 | 910 | ||
909 | static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid, | 911 | static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net, |
912 | sctp_cid_t cid, | ||
910 | sctp_state_t state) | 913 | sctp_state_t state) |
911 | { | 914 | { |
912 | if (state > SCTP_STATE_MAX) | 915 | if (state > SCTP_STATE_MAX) |
@@ -915,12 +918,12 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid, | |||
915 | if (cid <= SCTP_CID_BASE_MAX) | 918 | if (cid <= SCTP_CID_BASE_MAX) |
916 | return &chunk_event_table[cid][state]; | 919 | return &chunk_event_table[cid][state]; |
917 | 920 | ||
918 | if (sctp_prsctp_enable) { | 921 | if (net->sctp.prsctp_enable) { |
919 | if (cid == SCTP_CID_FWD_TSN) | 922 | if (cid == SCTP_CID_FWD_TSN) |
920 | return &prsctp_chunk_event_table[0][state]; | 923 | return &prsctp_chunk_event_table[0][state]; |
921 | } | 924 | } |
922 | 925 | ||
923 | if (sctp_addip_enable) { | 926 | if (net->sctp.addip_enable) { |
924 | if (cid == SCTP_CID_ASCONF) | 927 | if (cid == SCTP_CID_ASCONF) |
925 | return &addip_chunk_event_table[0][state]; | 928 | return &addip_chunk_event_table[0][state]; |
926 | 929 | ||
@@ -928,7 +931,7 @@ static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t cid, | |||
928 | return &addip_chunk_event_table[1][state]; | 931 | return &addip_chunk_event_table[1][state]; |
929 | } | 932 | } |
930 | 933 | ||
931 | if (sctp_auth_enable) { | 934 | if (net->sctp.auth_enable) { |
932 | if (cid == SCTP_CID_AUTH) | 935 | if (cid == SCTP_CID_AUTH) |
933 | return &auth_chunk_event_table[0][state]; | 936 | return &auth_chunk_event_table[0][state]; |
934 | } | 937 | } |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 5e259817a7f3..d37d24ff197f 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -427,6 +427,7 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len) | |||
427 | static int sctp_send_asconf(struct sctp_association *asoc, | 427 | static int sctp_send_asconf(struct sctp_association *asoc, |
428 | struct sctp_chunk *chunk) | 428 | struct sctp_chunk *chunk) |
429 | { | 429 | { |
430 | struct net *net = sock_net(asoc->base.sk); | ||
430 | int retval = 0; | 431 | int retval = 0; |
431 | 432 | ||
432 | /* If there is an outstanding ASCONF chunk, queue it for later | 433 | /* If there is an outstanding ASCONF chunk, queue it for later |
@@ -439,7 +440,7 @@ static int sctp_send_asconf(struct sctp_association *asoc, | |||
439 | 440 | ||
440 | /* Hold the chunk until an ASCONF_ACK is received. */ | 441 | /* Hold the chunk until an ASCONF_ACK is received. */ |
441 | sctp_chunk_hold(chunk); | 442 | sctp_chunk_hold(chunk); |
442 | retval = sctp_primitive_ASCONF(asoc, chunk); | 443 | retval = sctp_primitive_ASCONF(net, asoc, chunk); |
443 | if (retval) | 444 | if (retval) |
444 | sctp_chunk_free(chunk); | 445 | sctp_chunk_free(chunk); |
445 | else | 446 | else |
@@ -515,6 +516,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk, | |||
515 | struct sockaddr *addrs, | 516 | struct sockaddr *addrs, |
516 | int addrcnt) | 517 | int addrcnt) |
517 | { | 518 | { |
519 | struct net *net = sock_net(sk); | ||
518 | struct sctp_sock *sp; | 520 | struct sctp_sock *sp; |
519 | struct sctp_endpoint *ep; | 521 | struct sctp_endpoint *ep; |
520 | struct sctp_association *asoc; | 522 | struct sctp_association *asoc; |
@@ -529,7 +531,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk, | |||
529 | int i; | 531 | int i; |
530 | int retval = 0; | 532 | int retval = 0; |
531 | 533 | ||
532 | if (!sctp_addip_enable) | 534 | if (!net->sctp.addip_enable) |
533 | return retval; | 535 | return retval; |
534 | 536 | ||
535 | sp = sctp_sk(sk); | 537 | sp = sctp_sk(sk); |
@@ -717,6 +719,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk, | |||
717 | struct sockaddr *addrs, | 719 | struct sockaddr *addrs, |
718 | int addrcnt) | 720 | int addrcnt) |
719 | { | 721 | { |
722 | struct net *net = sock_net(sk); | ||
720 | struct sctp_sock *sp; | 723 | struct sctp_sock *sp; |
721 | struct sctp_endpoint *ep; | 724 | struct sctp_endpoint *ep; |
722 | struct sctp_association *asoc; | 725 | struct sctp_association *asoc; |
@@ -732,7 +735,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk, | |||
732 | int stored = 0; | 735 | int stored = 0; |
733 | 736 | ||
734 | chunk = NULL; | 737 | chunk = NULL; |
735 | if (!sctp_addip_enable) | 738 | if (!net->sctp.addip_enable) |
736 | return retval; | 739 | return retval; |
737 | 740 | ||
738 | sp = sctp_sk(sk); | 741 | sp = sctp_sk(sk); |
@@ -1050,6 +1053,7 @@ static int __sctp_connect(struct sock* sk, | |||
1050 | int addrs_size, | 1053 | int addrs_size, |
1051 | sctp_assoc_t *assoc_id) | 1054 | sctp_assoc_t *assoc_id) |
1052 | { | 1055 | { |
1056 | struct net *net = sock_net(sk); | ||
1053 | struct sctp_sock *sp; | 1057 | struct sctp_sock *sp; |
1054 | struct sctp_endpoint *ep; | 1058 | struct sctp_endpoint *ep; |
1055 | struct sctp_association *asoc = NULL; | 1059 | struct sctp_association *asoc = NULL; |
@@ -1200,7 +1204,7 @@ static int __sctp_connect(struct sock* sk, | |||
1200 | goto out_free; | 1204 | goto out_free; |
1201 | } | 1205 | } |
1202 | 1206 | ||
1203 | err = sctp_primitive_ASSOCIATE(asoc, NULL); | 1207 | err = sctp_primitive_ASSOCIATE(net, asoc, NULL); |
1204 | if (err < 0) { | 1208 | if (err < 0) { |
1205 | goto out_free; | 1209 | goto out_free; |
1206 | } | 1210 | } |
@@ -1458,6 +1462,7 @@ SCTP_STATIC int sctp_getsockopt_connectx3(struct sock* sk, int len, | |||
1458 | */ | 1462 | */ |
1459 | SCTP_STATIC void sctp_close(struct sock *sk, long timeout) | 1463 | SCTP_STATIC void sctp_close(struct sock *sk, long timeout) |
1460 | { | 1464 | { |
1465 | struct net *net = sock_net(sk); | ||
1461 | struct sctp_endpoint *ep; | 1466 | struct sctp_endpoint *ep; |
1462 | struct sctp_association *asoc; | 1467 | struct sctp_association *asoc; |
1463 | struct list_head *pos, *temp; | 1468 | struct list_head *pos, *temp; |
@@ -1499,9 +1504,9 @@ SCTP_STATIC void sctp_close(struct sock *sk, long timeout) | |||
1499 | 1504 | ||
1500 | chunk = sctp_make_abort_user(asoc, NULL, 0); | 1505 | chunk = sctp_make_abort_user(asoc, NULL, 0); |
1501 | if (chunk) | 1506 | if (chunk) |
1502 | sctp_primitive_ABORT(asoc, chunk); | 1507 | sctp_primitive_ABORT(net, asoc, chunk); |
1503 | } else | 1508 | } else |
1504 | sctp_primitive_SHUTDOWN(asoc, NULL); | 1509 | sctp_primitive_SHUTDOWN(net, asoc, NULL); |
1505 | } | 1510 | } |
1506 | 1511 | ||
1507 | /* On a TCP-style socket, block for at most linger_time if set. */ | 1512 | /* On a TCP-style socket, block for at most linger_time if set. */ |
@@ -1569,6 +1574,7 @@ SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *, sctp_cmsgs_t *); | |||
1569 | SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, | 1574 | SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, |
1570 | struct msghdr *msg, size_t msg_len) | 1575 | struct msghdr *msg, size_t msg_len) |
1571 | { | 1576 | { |
1577 | struct net *net = sock_net(sk); | ||
1572 | struct sctp_sock *sp; | 1578 | struct sctp_sock *sp; |
1573 | struct sctp_endpoint *ep; | 1579 | struct sctp_endpoint *ep; |
1574 | struct sctp_association *new_asoc=NULL, *asoc=NULL; | 1580 | struct sctp_association *new_asoc=NULL, *asoc=NULL; |
@@ -1714,7 +1720,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
1714 | if (sinfo_flags & SCTP_EOF) { | 1720 | if (sinfo_flags & SCTP_EOF) { |
1715 | SCTP_DEBUG_PRINTK("Shutting down association: %p\n", | 1721 | SCTP_DEBUG_PRINTK("Shutting down association: %p\n", |
1716 | asoc); | 1722 | asoc); |
1717 | sctp_primitive_SHUTDOWN(asoc, NULL); | 1723 | sctp_primitive_SHUTDOWN(net, asoc, NULL); |
1718 | err = 0; | 1724 | err = 0; |
1719 | goto out_unlock; | 1725 | goto out_unlock; |
1720 | } | 1726 | } |
@@ -1727,7 +1733,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
1727 | } | 1733 | } |
1728 | 1734 | ||
1729 | SCTP_DEBUG_PRINTK("Aborting association: %p\n", asoc); | 1735 | SCTP_DEBUG_PRINTK("Aborting association: %p\n", asoc); |
1730 | sctp_primitive_ABORT(asoc, chunk); | 1736 | sctp_primitive_ABORT(net, asoc, chunk); |
1731 | err = 0; | 1737 | err = 0; |
1732 | goto out_unlock; | 1738 | goto out_unlock; |
1733 | } | 1739 | } |
@@ -1900,7 +1906,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
1900 | 1906 | ||
1901 | /* Auto-connect, if we aren't connected already. */ | 1907 | /* Auto-connect, if we aren't connected already. */ |
1902 | if (sctp_state(asoc, CLOSED)) { | 1908 | if (sctp_state(asoc, CLOSED)) { |
1903 | err = sctp_primitive_ASSOCIATE(asoc, NULL); | 1909 | err = sctp_primitive_ASSOCIATE(net, asoc, NULL); |
1904 | if (err < 0) | 1910 | if (err < 0) |
1905 | goto out_free; | 1911 | goto out_free; |
1906 | SCTP_DEBUG_PRINTK("We associated primitively.\n"); | 1912 | SCTP_DEBUG_PRINTK("We associated primitively.\n"); |
@@ -1928,7 +1934,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
1928 | * works that way today. Keep it that way or this | 1934 | * works that way today. Keep it that way or this |
1929 | * breaks. | 1935 | * breaks. |
1930 | */ | 1936 | */ |
1931 | err = sctp_primitive_SEND(asoc, datamsg); | 1937 | err = sctp_primitive_SEND(net, asoc, datamsg); |
1932 | /* Did the lower layer accept the chunk? */ | 1938 | /* Did the lower layer accept the chunk? */ |
1933 | if (err) | 1939 | if (err) |
1934 | sctp_datamsg_free(datamsg); | 1940 | sctp_datamsg_free(datamsg); |
@@ -2320,7 +2326,9 @@ static int sctp_apply_peer_addr_params(struct sctp_paddrparams *params, | |||
2320 | int error; | 2326 | int error; |
2321 | 2327 | ||
2322 | if (params->spp_flags & SPP_HB_DEMAND && trans) { | 2328 | if (params->spp_flags & SPP_HB_DEMAND && trans) { |
2323 | error = sctp_primitive_REQUESTHEARTBEAT (trans->asoc, trans); | 2329 | struct net *net = sock_net(trans->asoc->base.sk); |
2330 | |||
2331 | error = sctp_primitive_REQUESTHEARTBEAT(net, trans->asoc, trans); | ||
2324 | if (error) | 2332 | if (error) |
2325 | return error; | 2333 | return error; |
2326 | } | 2334 | } |
@@ -3033,6 +3041,7 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned | |||
3033 | static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optval, | 3041 | static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optval, |
3034 | unsigned int optlen) | 3042 | unsigned int optlen) |
3035 | { | 3043 | { |
3044 | struct net *net = sock_net(sk); | ||
3036 | struct sctp_sock *sp; | 3045 | struct sctp_sock *sp; |
3037 | struct sctp_association *asoc = NULL; | 3046 | struct sctp_association *asoc = NULL; |
3038 | struct sctp_setpeerprim prim; | 3047 | struct sctp_setpeerprim prim; |
@@ -3042,7 +3051,7 @@ static int sctp_setsockopt_peer_primary_addr(struct sock *sk, char __user *optva | |||
3042 | 3051 | ||
3043 | sp = sctp_sk(sk); | 3052 | sp = sctp_sk(sk); |
3044 | 3053 | ||
3045 | if (!sctp_addip_enable) | 3054 | if (!net->sctp.addip_enable) |
3046 | return -EPERM; | 3055 | return -EPERM; |
3047 | 3056 | ||
3048 | if (optlen != sizeof(struct sctp_setpeerprim)) | 3057 | if (optlen != sizeof(struct sctp_setpeerprim)) |
@@ -3279,9 +3288,10 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk, | |||
3279 | char __user *optval, | 3288 | char __user *optval, |
3280 | unsigned int optlen) | 3289 | unsigned int optlen) |
3281 | { | 3290 | { |
3291 | struct net *net = sock_net(sk); | ||
3282 | struct sctp_authchunk val; | 3292 | struct sctp_authchunk val; |
3283 | 3293 | ||
3284 | if (!sctp_auth_enable) | 3294 | if (!net->sctp.auth_enable) |
3285 | return -EACCES; | 3295 | return -EACCES; |
3286 | 3296 | ||
3287 | if (optlen != sizeof(struct sctp_authchunk)) | 3297 | if (optlen != sizeof(struct sctp_authchunk)) |
@@ -3311,11 +3321,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, | |||
3311 | char __user *optval, | 3321 | char __user *optval, |
3312 | unsigned int optlen) | 3322 | unsigned int optlen) |
3313 | { | 3323 | { |
3324 | struct net *net = sock_net(sk); | ||
3314 | struct sctp_hmacalgo *hmacs; | 3325 | struct sctp_hmacalgo *hmacs; |
3315 | u32 idents; | 3326 | u32 idents; |
3316 | int err; | 3327 | int err; |
3317 | 3328 | ||
3318 | if (!sctp_auth_enable) | 3329 | if (!net->sctp.auth_enable) |
3319 | return -EACCES; | 3330 | return -EACCES; |
3320 | 3331 | ||
3321 | if (optlen < sizeof(struct sctp_hmacalgo)) | 3332 | if (optlen < sizeof(struct sctp_hmacalgo)) |
@@ -3348,11 +3359,12 @@ static int sctp_setsockopt_auth_key(struct sock *sk, | |||
3348 | char __user *optval, | 3359 | char __user *optval, |
3349 | unsigned int optlen) | 3360 | unsigned int optlen) |
3350 | { | 3361 | { |
3362 | struct net *net = sock_net(sk); | ||
3351 | struct sctp_authkey *authkey; | 3363 | struct sctp_authkey *authkey; |
3352 | struct sctp_association *asoc; | 3364 | struct sctp_association *asoc; |
3353 | int ret; | 3365 | int ret; |
3354 | 3366 | ||
3355 | if (!sctp_auth_enable) | 3367 | if (!net->sctp.auth_enable) |
3356 | return -EACCES; | 3368 | return -EACCES; |
3357 | 3369 | ||
3358 | if (optlen <= sizeof(struct sctp_authkey)) | 3370 | if (optlen <= sizeof(struct sctp_authkey)) |
@@ -3389,10 +3401,11 @@ static int sctp_setsockopt_active_key(struct sock *sk, | |||
3389 | char __user *optval, | 3401 | char __user *optval, |
3390 | unsigned int optlen) | 3402 | unsigned int optlen) |
3391 | { | 3403 | { |
3404 | struct net *net = sock_net(sk); | ||
3392 | struct sctp_authkeyid val; | 3405 | struct sctp_authkeyid val; |
3393 | struct sctp_association *asoc; | 3406 | struct sctp_association *asoc; |
3394 | 3407 | ||
3395 | if (!sctp_auth_enable) | 3408 | if (!net->sctp.auth_enable) |
3396 | return -EACCES; | 3409 | return -EACCES; |
3397 | 3410 | ||
3398 | if (optlen != sizeof(struct sctp_authkeyid)) | 3411 | if (optlen != sizeof(struct sctp_authkeyid)) |
@@ -3417,10 +3430,11 @@ static int sctp_setsockopt_del_key(struct sock *sk, | |||
3417 | char __user *optval, | 3430 | char __user *optval, |
3418 | unsigned int optlen) | 3431 | unsigned int optlen) |
3419 | { | 3432 | { |
3433 | struct net *net = sock_net(sk); | ||
3420 | struct sctp_authkeyid val; | 3434 | struct sctp_authkeyid val; |
3421 | struct sctp_association *asoc; | 3435 | struct sctp_association *asoc; |
3422 | 3436 | ||
3423 | if (!sctp_auth_enable) | 3437 | if (!net->sctp.auth_enable) |
3424 | return -EACCES; | 3438 | return -EACCES; |
3425 | 3439 | ||
3426 | if (optlen != sizeof(struct sctp_authkeyid)) | 3440 | if (optlen != sizeof(struct sctp_authkeyid)) |
@@ -3471,7 +3485,7 @@ static int sctp_setsockopt_auto_asconf(struct sock *sk, char __user *optval, | |||
3471 | sp->do_auto_asconf = 0; | 3485 | sp->do_auto_asconf = 0; |
3472 | } else if (val && !sp->do_auto_asconf) { | 3486 | } else if (val && !sp->do_auto_asconf) { |
3473 | list_add_tail(&sp->auto_asconf_list, | 3487 | list_add_tail(&sp->auto_asconf_list, |
3474 | &sctp_auto_asconf_splist); | 3488 | &sock_net(sk)->sctp.auto_asconf_splist); |
3475 | sp->do_auto_asconf = 1; | 3489 | sp->do_auto_asconf = 1; |
3476 | } | 3490 | } |
3477 | return 0; | 3491 | return 0; |
@@ -3843,6 +3857,7 @@ out: | |||
3843 | */ | 3857 | */ |
3844 | SCTP_STATIC int sctp_init_sock(struct sock *sk) | 3858 | SCTP_STATIC int sctp_init_sock(struct sock *sk) |
3845 | { | 3859 | { |
3860 | struct net *net = sock_net(sk); | ||
3846 | struct sctp_endpoint *ep; | 3861 | struct sctp_endpoint *ep; |
3847 | struct sctp_sock *sp; | 3862 | struct sctp_sock *sp; |
3848 | 3863 | ||
@@ -3872,7 +3887,7 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3872 | sp->default_timetolive = 0; | 3887 | sp->default_timetolive = 0; |
3873 | 3888 | ||
3874 | sp->default_rcv_context = 0; | 3889 | sp->default_rcv_context = 0; |
3875 | sp->max_burst = sctp_max_burst; | 3890 | sp->max_burst = net->sctp.max_burst; |
3876 | 3891 | ||
3877 | /* Initialize default setup parameters. These parameters | 3892 | /* Initialize default setup parameters. These parameters |
3878 | * can be modified with the SCTP_INITMSG socket option or | 3893 | * can be modified with the SCTP_INITMSG socket option or |
@@ -3880,24 +3895,24 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3880 | */ | 3895 | */ |
3881 | sp->initmsg.sinit_num_ostreams = sctp_max_outstreams; | 3896 | sp->initmsg.sinit_num_ostreams = sctp_max_outstreams; |
3882 | sp->initmsg.sinit_max_instreams = sctp_max_instreams; | 3897 | sp->initmsg.sinit_max_instreams = sctp_max_instreams; |
3883 | sp->initmsg.sinit_max_attempts = sctp_max_retrans_init; | 3898 | sp->initmsg.sinit_max_attempts = net->sctp.max_retrans_init; |
3884 | sp->initmsg.sinit_max_init_timeo = sctp_rto_max; | 3899 | sp->initmsg.sinit_max_init_timeo = net->sctp.rto_max; |
3885 | 3900 | ||
3886 | /* Initialize default RTO related parameters. These parameters can | 3901 | /* Initialize default RTO related parameters. These parameters can |
3887 | * be modified for with the SCTP_RTOINFO socket option. | 3902 | * be modified for with the SCTP_RTOINFO socket option. |
3888 | */ | 3903 | */ |
3889 | sp->rtoinfo.srto_initial = sctp_rto_initial; | 3904 | sp->rtoinfo.srto_initial = net->sctp.rto_initial; |
3890 | sp->rtoinfo.srto_max = sctp_rto_max; | 3905 | sp->rtoinfo.srto_max = net->sctp.rto_max; |
3891 | sp->rtoinfo.srto_min = sctp_rto_min; | 3906 | sp->rtoinfo.srto_min = net->sctp.rto_min; |
3892 | 3907 | ||
3893 | /* Initialize default association related parameters. These parameters | 3908 | /* Initialize default association related parameters. These parameters |
3894 | * can be modified with the SCTP_ASSOCINFO socket option. | 3909 | * can be modified with the SCTP_ASSOCINFO socket option. |
3895 | */ | 3910 | */ |
3896 | sp->assocparams.sasoc_asocmaxrxt = sctp_max_retrans_association; | 3911 | sp->assocparams.sasoc_asocmaxrxt = net->sctp.max_retrans_association; |
3897 | sp->assocparams.sasoc_number_peer_destinations = 0; | 3912 | sp->assocparams.sasoc_number_peer_destinations = 0; |
3898 | sp->assocparams.sasoc_peer_rwnd = 0; | 3913 | sp->assocparams.sasoc_peer_rwnd = 0; |
3899 | sp->assocparams.sasoc_local_rwnd = 0; | 3914 | sp->assocparams.sasoc_local_rwnd = 0; |
3900 | sp->assocparams.sasoc_cookie_life = sctp_valid_cookie_life; | 3915 | sp->assocparams.sasoc_cookie_life = net->sctp.valid_cookie_life; |
3901 | 3916 | ||
3902 | /* Initialize default event subscriptions. By default, all the | 3917 | /* Initialize default event subscriptions. By default, all the |
3903 | * options are off. | 3918 | * options are off. |
@@ -3907,10 +3922,10 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3907 | /* Default Peer Address Parameters. These defaults can | 3922 | /* Default Peer Address Parameters. These defaults can |
3908 | * be modified via SCTP_PEER_ADDR_PARAMS | 3923 | * be modified via SCTP_PEER_ADDR_PARAMS |
3909 | */ | 3924 | */ |
3910 | sp->hbinterval = sctp_hb_interval; | 3925 | sp->hbinterval = net->sctp.hb_interval; |
3911 | sp->pathmaxrxt = sctp_max_retrans_path; | 3926 | sp->pathmaxrxt = net->sctp.max_retrans_path; |
3912 | sp->pathmtu = 0; // allow default discovery | 3927 | sp->pathmtu = 0; // allow default discovery |
3913 | sp->sackdelay = sctp_sack_timeout; | 3928 | sp->sackdelay = net->sctp.sack_timeout; |
3914 | sp->sackfreq = 2; | 3929 | sp->sackfreq = 2; |
3915 | sp->param_flags = SPP_HB_ENABLE | | 3930 | sp->param_flags = SPP_HB_ENABLE | |
3916 | SPP_PMTUD_ENABLE | | 3931 | SPP_PMTUD_ENABLE | |
@@ -3961,10 +3976,10 @@ SCTP_STATIC int sctp_init_sock(struct sock *sk) | |||
3961 | 3976 | ||
3962 | local_bh_disable(); | 3977 | local_bh_disable(); |
3963 | percpu_counter_inc(&sctp_sockets_allocated); | 3978 | percpu_counter_inc(&sctp_sockets_allocated); |
3964 | sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); | 3979 | sock_prot_inuse_add(net, sk->sk_prot, 1); |
3965 | if (sctp_default_auto_asconf) { | 3980 | if (net->sctp.default_auto_asconf) { |
3966 | list_add_tail(&sp->auto_asconf_list, | 3981 | list_add_tail(&sp->auto_asconf_list, |
3967 | &sctp_auto_asconf_splist); | 3982 | &net->sctp.auto_asconf_splist); |
3968 | sp->do_auto_asconf = 1; | 3983 | sp->do_auto_asconf = 1; |
3969 | } else | 3984 | } else |
3970 | sp->do_auto_asconf = 0; | 3985 | sp->do_auto_asconf = 0; |
@@ -4011,6 +4026,7 @@ SCTP_STATIC void sctp_destroy_sock(struct sock *sk) | |||
4011 | */ | 4026 | */ |
4012 | SCTP_STATIC void sctp_shutdown(struct sock *sk, int how) | 4027 | SCTP_STATIC void sctp_shutdown(struct sock *sk, int how) |
4013 | { | 4028 | { |
4029 | struct net *net = sock_net(sk); | ||
4014 | struct sctp_endpoint *ep; | 4030 | struct sctp_endpoint *ep; |
4015 | struct sctp_association *asoc; | 4031 | struct sctp_association *asoc; |
4016 | 4032 | ||
@@ -4022,7 +4038,7 @@ SCTP_STATIC void sctp_shutdown(struct sock *sk, int how) | |||
4022 | if (!list_empty(&ep->asocs)) { | 4038 | if (!list_empty(&ep->asocs)) { |
4023 | asoc = list_entry(ep->asocs.next, | 4039 | asoc = list_entry(ep->asocs.next, |
4024 | struct sctp_association, asocs); | 4040 | struct sctp_association, asocs); |
4025 | sctp_primitive_SHUTDOWN(asoc, NULL); | 4041 | sctp_primitive_SHUTDOWN(net, asoc, NULL); |
4026 | } | 4042 | } |
4027 | } | 4043 | } |
4028 | } | 4044 | } |
@@ -4653,9 +4669,10 @@ static int sctp_copy_laddrs(struct sock *sk, __u16 port, void *to, | |||
4653 | union sctp_addr temp; | 4669 | union sctp_addr temp; |
4654 | int cnt = 0; | 4670 | int cnt = 0; |
4655 | int addrlen; | 4671 | int addrlen; |
4672 | struct net *net = sock_net(sk); | ||
4656 | 4673 | ||
4657 | rcu_read_lock(); | 4674 | rcu_read_lock(); |
4658 | list_for_each_entry_rcu(addr, &sctp_local_addr_list, list) { | 4675 | list_for_each_entry_rcu(addr, &net->sctp.local_addr_list, list) { |
4659 | if (!addr->valid) | 4676 | if (!addr->valid) |
4660 | continue; | 4677 | continue; |
4661 | 4678 | ||
@@ -5299,12 +5316,13 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len, | |||
5299 | static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, | 5316 | static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, |
5300 | char __user *optval, int __user *optlen) | 5317 | char __user *optval, int __user *optlen) |
5301 | { | 5318 | { |
5319 | struct net *net = sock_net(sk); | ||
5302 | struct sctp_hmacalgo __user *p = (void __user *)optval; | 5320 | struct sctp_hmacalgo __user *p = (void __user *)optval; |
5303 | struct sctp_hmac_algo_param *hmacs; | 5321 | struct sctp_hmac_algo_param *hmacs; |
5304 | __u16 data_len = 0; | 5322 | __u16 data_len = 0; |
5305 | u32 num_idents; | 5323 | u32 num_idents; |
5306 | 5324 | ||
5307 | if (!sctp_auth_enable) | 5325 | if (!net->sctp.auth_enable) |
5308 | return -EACCES; | 5326 | return -EACCES; |
5309 | 5327 | ||
5310 | hmacs = sctp_sk(sk)->ep->auth_hmacs_list; | 5328 | hmacs = sctp_sk(sk)->ep->auth_hmacs_list; |
@@ -5328,10 +5346,11 @@ static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, | |||
5328 | static int sctp_getsockopt_active_key(struct sock *sk, int len, | 5346 | static int sctp_getsockopt_active_key(struct sock *sk, int len, |
5329 | char __user *optval, int __user *optlen) | 5347 | char __user *optval, int __user *optlen) |
5330 | { | 5348 | { |
5349 | struct net *net = sock_net(sk); | ||
5331 | struct sctp_authkeyid val; | 5350 | struct sctp_authkeyid val; |
5332 | struct sctp_association *asoc; | 5351 | struct sctp_association *asoc; |
5333 | 5352 | ||
5334 | if (!sctp_auth_enable) | 5353 | if (!net->sctp.auth_enable) |
5335 | return -EACCES; | 5354 | return -EACCES; |
5336 | 5355 | ||
5337 | if (len < sizeof(struct sctp_authkeyid)) | 5356 | if (len < sizeof(struct sctp_authkeyid)) |
@@ -5360,6 +5379,7 @@ static int sctp_getsockopt_active_key(struct sock *sk, int len, | |||
5360 | static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, | 5379 | static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, |
5361 | char __user *optval, int __user *optlen) | 5380 | char __user *optval, int __user *optlen) |
5362 | { | 5381 | { |
5382 | struct net *net = sock_net(sk); | ||
5363 | struct sctp_authchunks __user *p = (void __user *)optval; | 5383 | struct sctp_authchunks __user *p = (void __user *)optval; |
5364 | struct sctp_authchunks val; | 5384 | struct sctp_authchunks val; |
5365 | struct sctp_association *asoc; | 5385 | struct sctp_association *asoc; |
@@ -5367,7 +5387,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, | |||
5367 | u32 num_chunks = 0; | 5387 | u32 num_chunks = 0; |
5368 | char __user *to; | 5388 | char __user *to; |
5369 | 5389 | ||
5370 | if (!sctp_auth_enable) | 5390 | if (!net->sctp.auth_enable) |
5371 | return -EACCES; | 5391 | return -EACCES; |
5372 | 5392 | ||
5373 | if (len < sizeof(struct sctp_authchunks)) | 5393 | if (len < sizeof(struct sctp_authchunks)) |
@@ -5403,6 +5423,7 @@ num: | |||
5403 | static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, | 5423 | static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, |
5404 | char __user *optval, int __user *optlen) | 5424 | char __user *optval, int __user *optlen) |
5405 | { | 5425 | { |
5426 | struct net *net = sock_net(sk); | ||
5406 | struct sctp_authchunks __user *p = (void __user *)optval; | 5427 | struct sctp_authchunks __user *p = (void __user *)optval; |
5407 | struct sctp_authchunks val; | 5428 | struct sctp_authchunks val; |
5408 | struct sctp_association *asoc; | 5429 | struct sctp_association *asoc; |
@@ -5410,7 +5431,7 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, | |||
5410 | u32 num_chunks = 0; | 5431 | u32 num_chunks = 0; |
5411 | char __user *to; | 5432 | char __user *to; |
5412 | 5433 | ||
5413 | if (!sctp_auth_enable) | 5434 | if (!net->sctp.auth_enable) |
5414 | return -EACCES; | 5435 | return -EACCES; |
5415 | 5436 | ||
5416 | if (len < sizeof(struct sctp_authchunks)) | 5437 | if (len < sizeof(struct sctp_authchunks)) |
@@ -5769,7 +5790,7 @@ static void sctp_unhash(struct sock *sk) | |||
5769 | * a fastreuse flag (FIXME: NPI ipg). | 5790 | * a fastreuse flag (FIXME: NPI ipg). |
5770 | */ | 5791 | */ |
5771 | static struct sctp_bind_bucket *sctp_bucket_create( | 5792 | static struct sctp_bind_bucket *sctp_bucket_create( |
5772 | struct sctp_bind_hashbucket *head, unsigned short snum); | 5793 | struct sctp_bind_hashbucket *head, struct net *, unsigned short snum); |
5773 | 5794 | ||
5774 | static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) | 5795 | static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) |
5775 | { | 5796 | { |
@@ -5799,11 +5820,12 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) | |||
5799 | rover = low; | 5820 | rover = low; |
5800 | if (inet_is_reserved_local_port(rover)) | 5821 | if (inet_is_reserved_local_port(rover)) |
5801 | continue; | 5822 | continue; |
5802 | index = sctp_phashfn(rover); | 5823 | index = sctp_phashfn(sock_net(sk), rover); |
5803 | head = &sctp_port_hashtable[index]; | 5824 | head = &sctp_port_hashtable[index]; |
5804 | sctp_spin_lock(&head->lock); | 5825 | sctp_spin_lock(&head->lock); |
5805 | sctp_for_each_hentry(pp, node, &head->chain) | 5826 | sctp_for_each_hentry(pp, node, &head->chain) |
5806 | if (pp->port == rover) | 5827 | if ((pp->port == rover) && |
5828 | net_eq(sock_net(sk), pp->net)) | ||
5807 | goto next; | 5829 | goto next; |
5808 | break; | 5830 | break; |
5809 | next: | 5831 | next: |
@@ -5827,10 +5849,10 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) | |||
5827 | * to the port number (snum) - we detect that with the | 5849 | * to the port number (snum) - we detect that with the |
5828 | * port iterator, pp being NULL. | 5850 | * port iterator, pp being NULL. |
5829 | */ | 5851 | */ |
5830 | head = &sctp_port_hashtable[sctp_phashfn(snum)]; | 5852 | head = &sctp_port_hashtable[sctp_phashfn(sock_net(sk), snum)]; |
5831 | sctp_spin_lock(&head->lock); | 5853 | sctp_spin_lock(&head->lock); |
5832 | sctp_for_each_hentry(pp, node, &head->chain) { | 5854 | sctp_for_each_hentry(pp, node, &head->chain) { |
5833 | if (pp->port == snum) | 5855 | if ((pp->port == snum) && net_eq(pp->net, sock_net(sk))) |
5834 | goto pp_found; | 5856 | goto pp_found; |
5835 | } | 5857 | } |
5836 | } | 5858 | } |
@@ -5881,7 +5903,7 @@ pp_found: | |||
5881 | pp_not_found: | 5903 | pp_not_found: |
5882 | /* If there was a hash table miss, create a new port. */ | 5904 | /* If there was a hash table miss, create a new port. */ |
5883 | ret = 1; | 5905 | ret = 1; |
5884 | if (!pp && !(pp = sctp_bucket_create(head, snum))) | 5906 | if (!pp && !(pp = sctp_bucket_create(head, sock_net(sk), snum))) |
5885 | goto fail_unlock; | 5907 | goto fail_unlock; |
5886 | 5908 | ||
5887 | /* In either case (hit or miss), make sure fastreuse is 1 only | 5909 | /* In either case (hit or miss), make sure fastreuse is 1 only |
@@ -6113,7 +6135,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
6113 | ********************************************************************/ | 6135 | ********************************************************************/ |
6114 | 6136 | ||
6115 | static struct sctp_bind_bucket *sctp_bucket_create( | 6137 | static struct sctp_bind_bucket *sctp_bucket_create( |
6116 | struct sctp_bind_hashbucket *head, unsigned short snum) | 6138 | struct sctp_bind_hashbucket *head, struct net *net, unsigned short snum) |
6117 | { | 6139 | { |
6118 | struct sctp_bind_bucket *pp; | 6140 | struct sctp_bind_bucket *pp; |
6119 | 6141 | ||
@@ -6123,6 +6145,7 @@ static struct sctp_bind_bucket *sctp_bucket_create( | |||
6123 | pp->port = snum; | 6145 | pp->port = snum; |
6124 | pp->fastreuse = 0; | 6146 | pp->fastreuse = 0; |
6125 | INIT_HLIST_HEAD(&pp->owner); | 6147 | INIT_HLIST_HEAD(&pp->owner); |
6148 | pp->net = net; | ||
6126 | hlist_add_head(&pp->node, &head->chain); | 6149 | hlist_add_head(&pp->node, &head->chain); |
6127 | } | 6150 | } |
6128 | return pp; | 6151 | return pp; |
@@ -6142,7 +6165,8 @@ static void sctp_bucket_destroy(struct sctp_bind_bucket *pp) | |||
6142 | static inline void __sctp_put_port(struct sock *sk) | 6165 | static inline void __sctp_put_port(struct sock *sk) |
6143 | { | 6166 | { |
6144 | struct sctp_bind_hashbucket *head = | 6167 | struct sctp_bind_hashbucket *head = |
6145 | &sctp_port_hashtable[sctp_phashfn(inet_sk(sk)->inet_num)]; | 6168 | &sctp_port_hashtable[sctp_phashfn(sock_net(sk), |
6169 | inet_sk(sk)->inet_num)]; | ||
6146 | struct sctp_bind_bucket *pp; | 6170 | struct sctp_bind_bucket *pp; |
6147 | 6171 | ||
6148 | sctp_spin_lock(&head->lock); | 6172 | sctp_spin_lock(&head->lock); |
@@ -6809,7 +6833,8 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk, | |||
6809 | newsp->hmac = NULL; | 6833 | newsp->hmac = NULL; |
6810 | 6834 | ||
6811 | /* Hook this new socket in to the bind_hash list. */ | 6835 | /* Hook this new socket in to the bind_hash list. */ |
6812 | head = &sctp_port_hashtable[sctp_phashfn(inet_sk(oldsk)->inet_num)]; | 6836 | head = &sctp_port_hashtable[sctp_phashfn(sock_net(oldsk), |
6837 | inet_sk(oldsk)->inet_num)]; | ||
6813 | sctp_local_bh_disable(); | 6838 | sctp_local_bh_disable(); |
6814 | sctp_spin_lock(&head->lock); | 6839 | sctp_spin_lock(&head->lock); |
6815 | pp = sctp_sk(oldsk)->bind_hash; | 6840 | pp = sctp_sk(oldsk)->bind_hash; |
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index 2b2bfe933ff1..70e3ba5cb50b 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c | |||
@@ -64,8 +64,34 @@ extern int sysctl_sctp_wmem[3]; | |||
64 | 64 | ||
65 | static ctl_table sctp_table[] = { | 65 | static ctl_table sctp_table[] = { |
66 | { | 66 | { |
67 | .procname = "sctp_mem", | ||
68 | .data = &sysctl_sctp_mem, | ||
69 | .maxlen = sizeof(sysctl_sctp_mem), | ||
70 | .mode = 0644, | ||
71 | .proc_handler = proc_doulongvec_minmax | ||
72 | }, | ||
73 | { | ||
74 | .procname = "sctp_rmem", | ||
75 | .data = &sysctl_sctp_rmem, | ||
76 | .maxlen = sizeof(sysctl_sctp_rmem), | ||
77 | .mode = 0644, | ||
78 | .proc_handler = proc_dointvec, | ||
79 | }, | ||
80 | { | ||
81 | .procname = "sctp_wmem", | ||
82 | .data = &sysctl_sctp_wmem, | ||
83 | .maxlen = sizeof(sysctl_sctp_wmem), | ||
84 | .mode = 0644, | ||
85 | .proc_handler = proc_dointvec, | ||
86 | }, | ||
87 | |||
88 | { /* sentinel */ } | ||
89 | }; | ||
90 | |||
91 | static ctl_table sctp_net_table[] = { | ||
92 | { | ||
67 | .procname = "rto_initial", | 93 | .procname = "rto_initial", |
68 | .data = &sctp_rto_initial, | 94 | .data = &init_net.sctp.rto_initial, |
69 | .maxlen = sizeof(unsigned int), | 95 | .maxlen = sizeof(unsigned int), |
70 | .mode = 0644, | 96 | .mode = 0644, |
71 | .proc_handler = proc_dointvec_minmax, | 97 | .proc_handler = proc_dointvec_minmax, |
@@ -74,7 +100,7 @@ static ctl_table sctp_table[] = { | |||
74 | }, | 100 | }, |
75 | { | 101 | { |
76 | .procname = "rto_min", | 102 | .procname = "rto_min", |
77 | .data = &sctp_rto_min, | 103 | .data = &init_net.sctp.rto_min, |
78 | .maxlen = sizeof(unsigned int), | 104 | .maxlen = sizeof(unsigned int), |
79 | .mode = 0644, | 105 | .mode = 0644, |
80 | .proc_handler = proc_dointvec_minmax, | 106 | .proc_handler = proc_dointvec_minmax, |
@@ -83,7 +109,7 @@ static ctl_table sctp_table[] = { | |||
83 | }, | 109 | }, |
84 | { | 110 | { |
85 | .procname = "rto_max", | 111 | .procname = "rto_max", |
86 | .data = &sctp_rto_max, | 112 | .data = &init_net.sctp.rto_max, |
87 | .maxlen = sizeof(unsigned int), | 113 | .maxlen = sizeof(unsigned int), |
88 | .mode = 0644, | 114 | .mode = 0644, |
89 | .proc_handler = proc_dointvec_minmax, | 115 | .proc_handler = proc_dointvec_minmax, |
@@ -91,17 +117,22 @@ static ctl_table sctp_table[] = { | |||
91 | .extra2 = &timer_max | 117 | .extra2 = &timer_max |
92 | }, | 118 | }, |
93 | { | 119 | { |
94 | .procname = "valid_cookie_life", | 120 | .procname = "rto_alpha_exp_divisor", |
95 | .data = &sctp_valid_cookie_life, | 121 | .data = &init_net.sctp.rto_alpha, |
96 | .maxlen = sizeof(unsigned int), | 122 | .maxlen = sizeof(int), |
97 | .mode = 0644, | 123 | .mode = 0444, |
98 | .proc_handler = proc_dointvec_minmax, | 124 | .proc_handler = proc_dointvec, |
99 | .extra1 = &one, | 125 | }, |
100 | .extra2 = &timer_max | 126 | { |
127 | .procname = "rto_beta_exp_divisor", | ||
128 | .data = &init_net.sctp.rto_beta, | ||
129 | .maxlen = sizeof(int), | ||
130 | .mode = 0444, | ||
131 | .proc_handler = proc_dointvec, | ||
101 | }, | 132 | }, |
102 | { | 133 | { |
103 | .procname = "max_burst", | 134 | .procname = "max_burst", |
104 | .data = &sctp_max_burst, | 135 | .data = &init_net.sctp.max_burst, |
105 | .maxlen = sizeof(int), | 136 | .maxlen = sizeof(int), |
106 | .mode = 0644, | 137 | .mode = 0644, |
107 | .proc_handler = proc_dointvec_minmax, | 138 | .proc_handler = proc_dointvec_minmax, |
@@ -109,31 +140,42 @@ static ctl_table sctp_table[] = { | |||
109 | .extra2 = &int_max | 140 | .extra2 = &int_max |
110 | }, | 141 | }, |
111 | { | 142 | { |
112 | .procname = "association_max_retrans", | 143 | .procname = "cookie_preserve_enable", |
113 | .data = &sctp_max_retrans_association, | 144 | .data = &init_net.sctp.cookie_preserve_enable, |
114 | .maxlen = sizeof(int), | 145 | .maxlen = sizeof(int), |
115 | .mode = 0644, | 146 | .mode = 0644, |
147 | .proc_handler = proc_dointvec, | ||
148 | }, | ||
149 | { | ||
150 | .procname = "valid_cookie_life", | ||
151 | .data = &init_net.sctp.valid_cookie_life, | ||
152 | .maxlen = sizeof(unsigned int), | ||
153 | .mode = 0644, | ||
116 | .proc_handler = proc_dointvec_minmax, | 154 | .proc_handler = proc_dointvec_minmax, |
117 | .extra1 = &one, | 155 | .extra1 = &one, |
118 | .extra2 = &int_max | 156 | .extra2 = &timer_max |
119 | }, | 157 | }, |
120 | { | 158 | { |
121 | .procname = "sndbuf_policy", | 159 | .procname = "sack_timeout", |
122 | .data = &sctp_sndbuf_policy, | 160 | .data = &init_net.sctp.sack_timeout, |
123 | .maxlen = sizeof(int), | 161 | .maxlen = sizeof(int), |
124 | .mode = 0644, | 162 | .mode = 0644, |
125 | .proc_handler = proc_dointvec, | 163 | .proc_handler = proc_dointvec_minmax, |
164 | .extra1 = &sack_timer_min, | ||
165 | .extra2 = &sack_timer_max, | ||
126 | }, | 166 | }, |
127 | { | 167 | { |
128 | .procname = "rcvbuf_policy", | 168 | .procname = "hb_interval", |
129 | .data = &sctp_rcvbuf_policy, | 169 | .data = &init_net.sctp.hb_interval, |
130 | .maxlen = sizeof(int), | 170 | .maxlen = sizeof(unsigned int), |
131 | .mode = 0644, | 171 | .mode = 0644, |
132 | .proc_handler = proc_dointvec, | 172 | .proc_handler = proc_dointvec_minmax, |
173 | .extra1 = &one, | ||
174 | .extra2 = &timer_max | ||
133 | }, | 175 | }, |
134 | { | 176 | { |
135 | .procname = "path_max_retrans", | 177 | .procname = "association_max_retrans", |
136 | .data = &sctp_max_retrans_path, | 178 | .data = &init_net.sctp.max_retrans_association, |
137 | .maxlen = sizeof(int), | 179 | .maxlen = sizeof(int), |
138 | .mode = 0644, | 180 | .mode = 0644, |
139 | .proc_handler = proc_dointvec_minmax, | 181 | .proc_handler = proc_dointvec_minmax, |
@@ -141,17 +183,17 @@ static ctl_table sctp_table[] = { | |||
141 | .extra2 = &int_max | 183 | .extra2 = &int_max |
142 | }, | 184 | }, |
143 | { | 185 | { |
144 | .procname = "pf_retrans", | 186 | .procname = "path_max_retrans", |
145 | .data = &sctp_pf_retrans, | 187 | .data = &init_net.sctp.max_retrans_path, |
146 | .maxlen = sizeof(int), | 188 | .maxlen = sizeof(int), |
147 | .mode = 0644, | 189 | .mode = 0644, |
148 | .proc_handler = proc_dointvec_minmax, | 190 | .proc_handler = proc_dointvec_minmax, |
149 | .extra1 = &zero, | 191 | .extra1 = &one, |
150 | .extra2 = &int_max | 192 | .extra2 = &int_max |
151 | }, | 193 | }, |
152 | { | 194 | { |
153 | .procname = "max_init_retransmits", | 195 | .procname = "max_init_retransmits", |
154 | .data = &sctp_max_retrans_init, | 196 | .data = &init_net.sctp.max_retrans_init, |
155 | .maxlen = sizeof(int), | 197 | .maxlen = sizeof(int), |
156 | .mode = 0644, | 198 | .mode = 0644, |
157 | .proc_handler = proc_dointvec_minmax, | 199 | .proc_handler = proc_dointvec_minmax, |
@@ -159,103 +201,66 @@ static ctl_table sctp_table[] = { | |||
159 | .extra2 = &int_max | 201 | .extra2 = &int_max |
160 | }, | 202 | }, |
161 | { | 203 | { |
162 | .procname = "hb_interval", | 204 | .procname = "pf_retrans", |
163 | .data = &sctp_hb_interval, | 205 | .data = &init_net.sctp.pf_retrans, |
164 | .maxlen = sizeof(unsigned int), | 206 | .maxlen = sizeof(int), |
165 | .mode = 0644, | 207 | .mode = 0644, |
166 | .proc_handler = proc_dointvec_minmax, | 208 | .proc_handler = proc_dointvec_minmax, |
167 | .extra1 = &one, | 209 | .extra1 = &zero, |
168 | .extra2 = &timer_max | 210 | .extra2 = &int_max |
169 | }, | 211 | }, |
170 | { | 212 | { |
171 | .procname = "cookie_preserve_enable", | 213 | .procname = "sndbuf_policy", |
172 | .data = &sctp_cookie_preserve_enable, | 214 | .data = &init_net.sctp.sndbuf_policy, |
173 | .maxlen = sizeof(int), | 215 | .maxlen = sizeof(int), |
174 | .mode = 0644, | 216 | .mode = 0644, |
175 | .proc_handler = proc_dointvec, | 217 | .proc_handler = proc_dointvec, |
176 | }, | 218 | }, |
177 | { | 219 | { |
178 | .procname = "rto_alpha_exp_divisor", | 220 | .procname = "rcvbuf_policy", |
179 | .data = &sctp_rto_alpha, | 221 | .data = &init_net.sctp.rcvbuf_policy, |
180 | .maxlen = sizeof(int), | ||
181 | .mode = 0444, | ||
182 | .proc_handler = proc_dointvec, | ||
183 | }, | ||
184 | { | ||
185 | .procname = "rto_beta_exp_divisor", | ||
186 | .data = &sctp_rto_beta, | ||
187 | .maxlen = sizeof(int), | ||
188 | .mode = 0444, | ||
189 | .proc_handler = proc_dointvec, | ||
190 | }, | ||
191 | { | ||
192 | .procname = "addip_enable", | ||
193 | .data = &sctp_addip_enable, | ||
194 | .maxlen = sizeof(int), | 222 | .maxlen = sizeof(int), |
195 | .mode = 0644, | 223 | .mode = 0644, |
196 | .proc_handler = proc_dointvec, | 224 | .proc_handler = proc_dointvec, |
197 | }, | 225 | }, |
198 | { | 226 | { |
199 | .procname = "default_auto_asconf", | 227 | .procname = "default_auto_asconf", |
200 | .data = &sctp_default_auto_asconf, | 228 | .data = &init_net.sctp.default_auto_asconf, |
201 | .maxlen = sizeof(int), | 229 | .maxlen = sizeof(int), |
202 | .mode = 0644, | 230 | .mode = 0644, |
203 | .proc_handler = proc_dointvec, | 231 | .proc_handler = proc_dointvec, |
204 | }, | 232 | }, |
205 | { | 233 | { |
206 | .procname = "prsctp_enable", | 234 | .procname = "addip_enable", |
207 | .data = &sctp_prsctp_enable, | 235 | .data = &init_net.sctp.addip_enable, |
208 | .maxlen = sizeof(int), | 236 | .maxlen = sizeof(int), |
209 | .mode = 0644, | 237 | .mode = 0644, |
210 | .proc_handler = proc_dointvec, | 238 | .proc_handler = proc_dointvec, |
211 | }, | 239 | }, |
212 | { | 240 | { |
213 | .procname = "sack_timeout", | 241 | .procname = "addip_noauth_enable", |
214 | .data = &sctp_sack_timeout, | 242 | .data = &init_net.sctp.addip_noauth, |
215 | .maxlen = sizeof(int), | 243 | .maxlen = sizeof(int), |
216 | .mode = 0644, | 244 | .mode = 0644, |
217 | .proc_handler = proc_dointvec_minmax, | ||
218 | .extra1 = &sack_timer_min, | ||
219 | .extra2 = &sack_timer_max, | ||
220 | }, | ||
221 | { | ||
222 | .procname = "sctp_mem", | ||
223 | .data = &sysctl_sctp_mem, | ||
224 | .maxlen = sizeof(sysctl_sctp_mem), | ||
225 | .mode = 0644, | ||
226 | .proc_handler = proc_doulongvec_minmax | ||
227 | }, | ||
228 | { | ||
229 | .procname = "sctp_rmem", | ||
230 | .data = &sysctl_sctp_rmem, | ||
231 | .maxlen = sizeof(sysctl_sctp_rmem), | ||
232 | .mode = 0644, | ||
233 | .proc_handler = proc_dointvec, | ||
234 | }, | ||
235 | { | ||
236 | .procname = "sctp_wmem", | ||
237 | .data = &sysctl_sctp_wmem, | ||
238 | .maxlen = sizeof(sysctl_sctp_wmem), | ||
239 | .mode = 0644, | ||
240 | .proc_handler = proc_dointvec, | 245 | .proc_handler = proc_dointvec, |
241 | }, | 246 | }, |
242 | { | 247 | { |
243 | .procname = "auth_enable", | 248 | .procname = "prsctp_enable", |
244 | .data = &sctp_auth_enable, | 249 | .data = &init_net.sctp.prsctp_enable, |
245 | .maxlen = sizeof(int), | 250 | .maxlen = sizeof(int), |
246 | .mode = 0644, | 251 | .mode = 0644, |
247 | .proc_handler = proc_dointvec, | 252 | .proc_handler = proc_dointvec, |
248 | }, | 253 | }, |
249 | { | 254 | { |
250 | .procname = "addip_noauth_enable", | 255 | .procname = "auth_enable", |
251 | .data = &sctp_addip_noauth, | 256 | .data = &init_net.sctp.auth_enable, |
252 | .maxlen = sizeof(int), | 257 | .maxlen = sizeof(int), |
253 | .mode = 0644, | 258 | .mode = 0644, |
254 | .proc_handler = proc_dointvec, | 259 | .proc_handler = proc_dointvec, |
255 | }, | 260 | }, |
256 | { | 261 | { |
257 | .procname = "addr_scope_policy", | 262 | .procname = "addr_scope_policy", |
258 | .data = &sctp_scope_policy, | 263 | .data = &init_net.sctp.scope_policy, |
259 | .maxlen = sizeof(int), | 264 | .maxlen = sizeof(int), |
260 | .mode = 0644, | 265 | .mode = 0644, |
261 | .proc_handler = proc_dointvec_minmax, | 266 | .proc_handler = proc_dointvec_minmax, |
@@ -264,7 +269,7 @@ static ctl_table sctp_table[] = { | |||
264 | }, | 269 | }, |
265 | { | 270 | { |
266 | .procname = "rwnd_update_shift", | 271 | .procname = "rwnd_update_shift", |
267 | .data = &sctp_rwnd_upd_shift, | 272 | .data = &init_net.sctp.rwnd_upd_shift, |
268 | .maxlen = sizeof(int), | 273 | .maxlen = sizeof(int), |
269 | .mode = 0644, | 274 | .mode = 0644, |
270 | .proc_handler = &proc_dointvec_minmax, | 275 | .proc_handler = &proc_dointvec_minmax, |
@@ -273,7 +278,7 @@ static ctl_table sctp_table[] = { | |||
273 | }, | 278 | }, |
274 | { | 279 | { |
275 | .procname = "max_autoclose", | 280 | .procname = "max_autoclose", |
276 | .data = &sctp_max_autoclose, | 281 | .data = &init_net.sctp.max_autoclose, |
277 | .maxlen = sizeof(unsigned long), | 282 | .maxlen = sizeof(unsigned long), |
278 | .mode = 0644, | 283 | .mode = 0644, |
279 | .proc_handler = &proc_doulongvec_minmax, | 284 | .proc_handler = &proc_doulongvec_minmax, |
@@ -284,6 +289,27 @@ static ctl_table sctp_table[] = { | |||
284 | { /* sentinel */ } | 289 | { /* sentinel */ } |
285 | }; | 290 | }; |
286 | 291 | ||
292 | int sctp_sysctl_net_register(struct net *net) | ||
293 | { | ||
294 | struct ctl_table *table; | ||
295 | int i; | ||
296 | |||
297 | table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); | ||
298 | if (!table) | ||
299 | return -ENOMEM; | ||
300 | |||
301 | for (i = 0; table[i].data; i++) | ||
302 | table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; | ||
303 | |||
304 | net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table); | ||
305 | return 0; | ||
306 | } | ||
307 | |||
308 | void sctp_sysctl_net_unregister(struct net *net) | ||
309 | { | ||
310 | unregister_net_sysctl_table(net->sctp.sysctl_header); | ||
311 | } | ||
312 | |||
287 | static struct ctl_table_header * sctp_sysctl_header; | 313 | static struct ctl_table_header * sctp_sysctl_header; |
288 | 314 | ||
289 | /* Sysctl registration. */ | 315 | /* Sysctl registration. */ |
diff --git a/net/sctp/transport.c b/net/sctp/transport.c index c97472b248a2..953c21e4af97 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c | |||
@@ -59,7 +59,8 @@ | |||
59 | /* 1st Level Abstractions. */ | 59 | /* 1st Level Abstractions. */ |
60 | 60 | ||
61 | /* Initialize a new transport from provided memory. */ | 61 | /* Initialize a new transport from provided memory. */ |
62 | static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | 62 | static struct sctp_transport *sctp_transport_init(struct net *net, |
63 | struct sctp_transport *peer, | ||
63 | const union sctp_addr *addr, | 64 | const union sctp_addr *addr, |
64 | gfp_t gfp) | 65 | gfp_t gfp) |
65 | { | 66 | { |
@@ -76,7 +77,7 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | |||
76 | * given destination transport address, set RTO to the protocol | 77 | * given destination transport address, set RTO to the protocol |
77 | * parameter 'RTO.Initial'. | 78 | * parameter 'RTO.Initial'. |
78 | */ | 79 | */ |
79 | peer->rto = msecs_to_jiffies(sctp_rto_initial); | 80 | peer->rto = msecs_to_jiffies(net->sctp.rto_initial); |
80 | 81 | ||
81 | peer->last_time_heard = jiffies; | 82 | peer->last_time_heard = jiffies; |
82 | peer->last_time_ecne_reduced = jiffies; | 83 | peer->last_time_ecne_reduced = jiffies; |
@@ -86,8 +87,8 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | |||
86 | SPP_SACKDELAY_ENABLE; | 87 | SPP_SACKDELAY_ENABLE; |
87 | 88 | ||
88 | /* Initialize the default path max_retrans. */ | 89 | /* Initialize the default path max_retrans. */ |
89 | peer->pathmaxrxt = sctp_max_retrans_path; | 90 | peer->pathmaxrxt = net->sctp.max_retrans_path; |
90 | peer->pf_retrans = sctp_pf_retrans; | 91 | peer->pf_retrans = net->sctp.pf_retrans; |
91 | 92 | ||
92 | INIT_LIST_HEAD(&peer->transmitted); | 93 | INIT_LIST_HEAD(&peer->transmitted); |
93 | INIT_LIST_HEAD(&peer->send_ready); | 94 | INIT_LIST_HEAD(&peer->send_ready); |
@@ -109,7 +110,8 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | |||
109 | } | 110 | } |
110 | 111 | ||
111 | /* Allocate and initialize a new transport. */ | 112 | /* Allocate and initialize a new transport. */ |
112 | struct sctp_transport *sctp_transport_new(const union sctp_addr *addr, | 113 | struct sctp_transport *sctp_transport_new(struct net *net, |
114 | const union sctp_addr *addr, | ||
113 | gfp_t gfp) | 115 | gfp_t gfp) |
114 | { | 116 | { |
115 | struct sctp_transport *transport; | 117 | struct sctp_transport *transport; |
@@ -118,7 +120,7 @@ struct sctp_transport *sctp_transport_new(const union sctp_addr *addr, | |||
118 | if (!transport) | 120 | if (!transport) |
119 | goto fail; | 121 | goto fail; |
120 | 122 | ||
121 | if (!sctp_transport_init(transport, addr, gfp)) | 123 | if (!sctp_transport_init(net, transport, addr, gfp)) |
122 | goto fail_init; | 124 | goto fail_init; |
123 | 125 | ||
124 | transport->malloced = 1; | 126 | transport->malloced = 1; |
@@ -316,6 +318,7 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt) | |||
316 | SCTP_ASSERT(tp->rto_pending, "rto_pending not set", return); | 318 | SCTP_ASSERT(tp->rto_pending, "rto_pending not set", return); |
317 | 319 | ||
318 | if (tp->rttvar || tp->srtt) { | 320 | if (tp->rttvar || tp->srtt) { |
321 | struct net *net = sock_net(tp->asoc->base.sk); | ||
319 | /* 6.3.1 C3) When a new RTT measurement R' is made, set | 322 | /* 6.3.1 C3) When a new RTT measurement R' is made, set |
320 | * RTTVAR <- (1 - RTO.Beta) * RTTVAR + RTO.Beta * |SRTT - R'| | 323 | * RTTVAR <- (1 - RTO.Beta) * RTTVAR + RTO.Beta * |SRTT - R'| |
321 | * SRTT <- (1 - RTO.Alpha) * SRTT + RTO.Alpha * R' | 324 | * SRTT <- (1 - RTO.Alpha) * SRTT + RTO.Alpha * R' |
@@ -327,10 +330,10 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt) | |||
327 | * For example, assuming the default value of RTO.Alpha of | 330 | * For example, assuming the default value of RTO.Alpha of |
328 | * 1/8, rto_alpha would be expressed as 3. | 331 | * 1/8, rto_alpha would be expressed as 3. |
329 | */ | 332 | */ |
330 | tp->rttvar = tp->rttvar - (tp->rttvar >> sctp_rto_beta) | 333 | tp->rttvar = tp->rttvar - (tp->rttvar >> net->sctp.rto_beta) |
331 | + ((abs(tp->srtt - rtt)) >> sctp_rto_beta); | 334 | + ((abs(tp->srtt - rtt)) >> net->sctp.rto_beta); |
332 | tp->srtt = tp->srtt - (tp->srtt >> sctp_rto_alpha) | 335 | tp->srtt = tp->srtt - (tp->srtt >> net->sctp.rto_alpha) |
333 | + (rtt >> sctp_rto_alpha); | 336 | + (rtt >> net->sctp.rto_alpha); |
334 | } else { | 337 | } else { |
335 | /* 6.3.1 C2) When the first RTT measurement R is made, set | 338 | /* 6.3.1 C2) When the first RTT measurement R is made, set |
336 | * SRTT <- R, RTTVAR <- R/2. | 339 | * SRTT <- R, RTTVAR <- R/2. |
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 | */ |
329 | static struct sctp_ulpevent *sctp_make_reassembled_event(struct sk_buff_head *queue, struct sk_buff *f_frag, struct sk_buff *l_frag) | 329 | static 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 | |||
503 | done: | 506 | done: |
504 | return retval; | 507 | return retval; |
505 | found: | 508 | found: |
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 | */ |
565 | done: | 569 | done: |
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 | */ |
657 | done: | 662 | done: |
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 | ||