diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-08-06 04:43:06 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-15 02:17:26 -0400 |
commit | 2ce955035081112cf1590c961da8d94324142b5e (patch) | |
tree | 1c9c9afdcac42e283a7383fa67842470753a0bb4 /net/sctp/sm_statefuns.c | |
parent | 4db67e808640e3934d82ce61ee8e2e89fd877ba8 (diff) |
sctp: Make the ctl_sock per network namespace
- Kill sctp_get_ctl_sock, it is useless now.
- Pass struct net where needed so net->sctp.ctl_sock is accessible.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/sm_statefuns.c')
-rw-r--r-- | net/sctp/sm_statefuns.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 9fca10357350..f2daf615e8fe 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
@@ -74,7 +74,8 @@ static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | |||
74 | static int sctp_eat_data(const struct sctp_association *asoc, | 74 | static int sctp_eat_data(const struct sctp_association *asoc, |
75 | struct sctp_chunk *chunk, | 75 | struct sctp_chunk *chunk, |
76 | sctp_cmd_seq_t *commands); | 76 | sctp_cmd_seq_t *commands); |
77 | static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc, | 77 | static struct sctp_packet *sctp_ootb_pkt_new(struct net *net, |
78 | const struct sctp_association *asoc, | ||
78 | const struct sctp_chunk *chunk); | 79 | const struct sctp_chunk *chunk); |
79 | static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, | 80 | static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, |
80 | const struct sctp_association *asoc, | 81 | const struct sctp_association *asoc, |
@@ -301,6 +302,7 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
301 | struct sctp_chunk *err_chunk; | 302 | struct sctp_chunk *err_chunk; |
302 | struct sctp_packet *packet; | 303 | struct sctp_packet *packet; |
303 | sctp_unrecognized_param_t *unk_param; | 304 | sctp_unrecognized_param_t *unk_param; |
305 | struct net *net; | ||
304 | int len; | 306 | int len; |
305 | 307 | ||
306 | /* 6.10 Bundling | 308 | /* 6.10 Bundling |
@@ -318,7 +320,8 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
318 | /* If the packet is an OOTB packet which is temporarily on the | 320 | /* If the packet is an OOTB packet which is temporarily on the |
319 | * control endpoint, respond with an ABORT. | 321 | * control endpoint, respond with an ABORT. |
320 | */ | 322 | */ |
321 | if (ep == sctp_sk((sctp_get_ctl_sock()))->ep) { | 323 | net = sock_net(ep->base.sk); |
324 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { | ||
322 | SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); | 325 | SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); |
323 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 326 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); |
324 | } | 327 | } |
@@ -646,11 +649,13 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, | |||
646 | int error = 0; | 649 | int error = 0; |
647 | struct sctp_chunk *err_chk_p; | 650 | struct sctp_chunk *err_chk_p; |
648 | struct sock *sk; | 651 | struct sock *sk; |
652 | struct net *net; | ||
649 | 653 | ||
650 | /* If the packet is an OOTB packet which is temporarily on the | 654 | /* If the packet is an OOTB packet which is temporarily on the |
651 | * control endpoint, respond with an ABORT. | 655 | * control endpoint, respond with an ABORT. |
652 | */ | 656 | */ |
653 | if (ep == sctp_sk((sctp_get_ctl_sock()))->ep) { | 657 | net = sock_net(ep->base.sk); |
658 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) { | ||
654 | SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); | 659 | SCTP_INC_STATS(SCTP_MIB_OUTOFBLUES); |
655 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); | 660 | return sctp_sf_tabort_8_4_8(ep, asoc, type, arg, commands); |
656 | } | 661 | } |
@@ -1171,7 +1176,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 | 1176 | /* Helper function to send out an abort for the restart |
1172 | * condition. | 1177 | * condition. |
1173 | */ | 1178 | */ |
1174 | static int sctp_sf_send_restart_abort(union sctp_addr *ssa, | 1179 | static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa, |
1175 | struct sctp_chunk *init, | 1180 | struct sctp_chunk *init, |
1176 | sctp_cmd_seq_t *commands) | 1181 | sctp_cmd_seq_t *commands) |
1177 | { | 1182 | { |
@@ -1197,7 +1202,7 @@ static int sctp_sf_send_restart_abort(union sctp_addr *ssa, | |||
1197 | errhdr->length = htons(len); | 1202 | errhdr->length = htons(len); |
1198 | 1203 | ||
1199 | /* Assign to the control socket. */ | 1204 | /* Assign to the control socket. */ |
1200 | ep = sctp_sk((sctp_get_ctl_sock()))->ep; | 1205 | ep = sctp_sk(net->sctp.ctl_sock)->ep; |
1201 | 1206 | ||
1202 | /* Association is NULL since this may be a restart attack and we | 1207 | /* Association is NULL since this may be a restart attack and we |
1203 | * want to send back the attacker's vtag. | 1208 | * want to send back the attacker's vtag. |
@@ -1240,6 +1245,7 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc, | |||
1240 | struct sctp_chunk *init, | 1245 | struct sctp_chunk *init, |
1241 | sctp_cmd_seq_t *commands) | 1246 | sctp_cmd_seq_t *commands) |
1242 | { | 1247 | { |
1248 | struct net *net = sock_net(new_asoc->base.sk); | ||
1243 | struct sctp_transport *new_addr; | 1249 | struct sctp_transport *new_addr; |
1244 | int ret = 1; | 1250 | int ret = 1; |
1245 | 1251 | ||
@@ -1258,7 +1264,7 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc, | |||
1258 | transports) { | 1264 | transports) { |
1259 | if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, | 1265 | if (!list_has_sctp_addr(&asoc->peer.transport_addr_list, |
1260 | &new_addr->ipaddr)) { | 1266 | &new_addr->ipaddr)) { |
1261 | sctp_sf_send_restart_abort(&new_addr->ipaddr, init, | 1267 | sctp_sf_send_restart_abort(net, &new_addr->ipaddr, init, |
1262 | commands); | 1268 | commands); |
1263 | ret = 0; | 1269 | ret = 0; |
1264 | break; | 1270 | break; |
@@ -1650,10 +1656,11 @@ sctp_disposition_t sctp_sf_do_5_2_3_initack(const struct sctp_endpoint *ep, | |||
1650 | const sctp_subtype_t type, | 1656 | const sctp_subtype_t type, |
1651 | void *arg, sctp_cmd_seq_t *commands) | 1657 | void *arg, sctp_cmd_seq_t *commands) |
1652 | { | 1658 | { |
1659 | struct net *net = sock_net(ep->base.sk); | ||
1653 | /* Per the above section, we'll discard the chunk if we have an | 1660 | /* 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. | 1661 | * endpoint. If this is an OOTB INIT-ACK, treat it as such. |
1655 | */ | 1662 | */ |
1656 | if (ep == sctp_sk((sctp_get_ctl_sock()))->ep) | 1663 | if (ep == sctp_sk(net->sctp.ctl_sock)->ep) |
1657 | return sctp_sf_ootb(ep, asoc, type, arg, commands); | 1664 | return sctp_sf_ootb(ep, asoc, type, arg, commands); |
1658 | else | 1665 | else |
1659 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); | 1666 | return sctp_sf_discard_chunk(ep, asoc, type, arg, commands); |
@@ -3163,8 +3170,10 @@ static sctp_disposition_t sctp_sf_tabort_8_4_8(const struct sctp_endpoint *ep, | |||
3163 | struct sctp_packet *packet = NULL; | 3170 | struct sctp_packet *packet = NULL; |
3164 | struct sctp_chunk *chunk = arg; | 3171 | struct sctp_chunk *chunk = arg; |
3165 | struct sctp_chunk *abort; | 3172 | struct sctp_chunk *abort; |
3173 | struct net *net; | ||
3166 | 3174 | ||
3167 | packet = sctp_ootb_pkt_new(asoc, chunk); | 3175 | net = sock_net(ep->base.sk); |
3176 | packet = sctp_ootb_pkt_new(net, asoc, chunk); | ||
3168 | 3177 | ||
3169 | if (packet) { | 3178 | if (packet) { |
3170 | /* Make an ABORT. The T bit will be set if the asoc | 3179 | /* Make an ABORT. The T bit will be set if the asoc |
@@ -3425,8 +3434,10 @@ static sctp_disposition_t sctp_sf_shut_8_4_5(const struct sctp_endpoint *ep, | |||
3425 | struct sctp_packet *packet = NULL; | 3434 | struct sctp_packet *packet = NULL; |
3426 | struct sctp_chunk *chunk = arg; | 3435 | struct sctp_chunk *chunk = arg; |
3427 | struct sctp_chunk *shut; | 3436 | struct sctp_chunk *shut; |
3437 | struct net *net; | ||
3428 | 3438 | ||
3429 | packet = sctp_ootb_pkt_new(asoc, chunk); | 3439 | net = sock_net(ep->base.sk); |
3440 | packet = sctp_ootb_pkt_new(net, asoc, chunk); | ||
3430 | 3441 | ||
3431 | if (packet) { | 3442 | if (packet) { |
3432 | /* Make an SHUTDOWN_COMPLETE. | 3443 | /* Make an SHUTDOWN_COMPLETE. |
@@ -4262,6 +4273,7 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
4262 | struct sctp_packet *packet = NULL; | 4273 | struct sctp_packet *packet = NULL; |
4263 | struct sctp_chunk *chunk = arg; | 4274 | struct sctp_chunk *chunk = arg; |
4264 | struct sctp_chunk *abort = NULL; | 4275 | struct sctp_chunk *abort = NULL; |
4276 | struct net *net; | ||
4265 | 4277 | ||
4266 | /* SCTP-AUTH, Section 6.3: | 4278 | /* SCTP-AUTH, Section 6.3: |
4267 | * It should be noted that if the receiver wants to tear | 4279 | * It should be noted that if the receiver wants to tear |
@@ -4282,6 +4294,7 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
4282 | if (!abort) | 4294 | if (!abort) |
4283 | goto nomem; | 4295 | goto nomem; |
4284 | 4296 | ||
4297 | net = sock_net(ep->base.sk); | ||
4285 | if (asoc) { | 4298 | if (asoc) { |
4286 | /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ | 4299 | /* Treat INIT-ACK as a special case during COOKIE-WAIT. */ |
4287 | if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && | 4300 | if (chunk->chunk_hdr->type == SCTP_CID_INIT_ACK && |
@@ -4319,7 +4332,7 @@ static sctp_disposition_t sctp_sf_abort_violation( | |||
4319 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); | 4332 | SCTP_DEC_STATS(SCTP_MIB_CURRESTAB); |
4320 | } | 4333 | } |
4321 | } else { | 4334 | } else { |
4322 | packet = sctp_ootb_pkt_new(asoc, chunk); | 4335 | packet = sctp_ootb_pkt_new(net, asoc, chunk); |
4323 | 4336 | ||
4324 | if (!packet) | 4337 | if (!packet) |
4325 | goto nomem_pkt; | 4338 | goto nomem_pkt; |
@@ -5825,8 +5838,10 @@ static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | |||
5825 | { | 5838 | { |
5826 | struct sctp_packet *packet; | 5839 | struct sctp_packet *packet; |
5827 | struct sctp_chunk *abort; | 5840 | struct sctp_chunk *abort; |
5841 | struct net *net; | ||
5828 | 5842 | ||
5829 | packet = sctp_ootb_pkt_new(asoc, chunk); | 5843 | net = sock_net(ep->base.sk); |
5844 | packet = sctp_ootb_pkt_new(net, asoc, chunk); | ||
5830 | 5845 | ||
5831 | if (packet) { | 5846 | if (packet) { |
5832 | /* Make an ABORT. | 5847 | /* Make an ABORT. |
@@ -5858,7 +5873,8 @@ static struct sctp_packet *sctp_abort_pkt_new(const struct sctp_endpoint *ep, | |||
5858 | } | 5873 | } |
5859 | 5874 | ||
5860 | /* Allocate a packet for responding in the OOTB conditions. */ | 5875 | /* Allocate a packet for responding in the OOTB conditions. */ |
5861 | static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc, | 5876 | static struct sctp_packet *sctp_ootb_pkt_new(struct net *net, |
5877 | const struct sctp_association *asoc, | ||
5862 | const struct sctp_chunk *chunk) | 5878 | const struct sctp_chunk *chunk) |
5863 | { | 5879 | { |
5864 | struct sctp_packet *packet; | 5880 | struct sctp_packet *packet; |
@@ -5919,7 +5935,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc | |||
5919 | * the source address. | 5935 | * the source address. |
5920 | */ | 5936 | */ |
5921 | sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, | 5937 | sctp_transport_route(transport, (union sctp_addr *)&chunk->dest, |
5922 | sctp_sk(sctp_get_ctl_sock())); | 5938 | sctp_sk(net->sctp.ctl_sock)); |
5923 | 5939 | ||
5924 | packet = sctp_packet_init(&transport->packet, transport, sport, dport); | 5940 | packet = sctp_packet_init(&transport->packet, transport, sport, dport); |
5925 | packet = sctp_packet_config(packet, vtag, 0); | 5941 | packet = sctp_packet_config(packet, vtag, 0); |
@@ -5946,7 +5962,8 @@ static void sctp_send_stale_cookie_err(const struct sctp_endpoint *ep, | |||
5946 | struct sctp_packet *packet; | 5962 | struct sctp_packet *packet; |
5947 | 5963 | ||
5948 | if (err_chunk) { | 5964 | if (err_chunk) { |
5949 | packet = sctp_ootb_pkt_new(asoc, chunk); | 5965 | struct net *net = sock_net(ep->base.sk); |
5966 | packet = sctp_ootb_pkt_new(net, asoc, chunk); | ||
5950 | if (packet) { | 5967 | if (packet) { |
5951 | struct sctp_signed_cookie *cookie; | 5968 | struct sctp_signed_cookie *cookie; |
5952 | 5969 | ||