diff options
-rw-r--r-- | include/net/sctp/structs.h | 2 | ||||
-rw-r--r-- | net/sctp/associola.c | 4 | ||||
-rw-r--r-- | net/sctp/sm_statefuns.c | 15 | ||||
-rw-r--r-- | net/sctp/socket.c | 22 |
4 files changed, 23 insertions, 20 deletions
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 6e5f0e0c7967..cd2e18778f81 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -1980,7 +1980,7 @@ void sctp_assoc_set_primary(struct sctp_association *, | |||
1980 | void sctp_assoc_del_nonprimary_peers(struct sctp_association *, | 1980 | void sctp_assoc_del_nonprimary_peers(struct sctp_association *, |
1981 | struct sctp_transport *); | 1981 | struct sctp_transport *); |
1982 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, | 1982 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, |
1983 | gfp_t); | 1983 | sctp_scope_t, gfp_t); |
1984 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, | 1984 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, |
1985 | struct sctp_cookie*, | 1985 | struct sctp_cookie*, |
1986 | gfp_t gfp); | 1986 | gfp_t gfp); |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 8450960df24f..7eed77a39d0d 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -1485,15 +1485,13 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned len) | |||
1485 | * local endpoint and the remote peer. | 1485 | * local endpoint and the remote peer. |
1486 | */ | 1486 | */ |
1487 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, | 1487 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, |
1488 | gfp_t gfp) | 1488 | sctp_scope_t scope, gfp_t gfp) |
1489 | { | 1489 | { |
1490 | sctp_scope_t scope; | ||
1491 | int flags; | 1490 | int flags; |
1492 | 1491 | ||
1493 | /* Use scoping rules to determine the subset of addresses from | 1492 | /* Use scoping rules to determine the subset of addresses from |
1494 | * the endpoint. | 1493 | * the endpoint. |
1495 | */ | 1494 | */ |
1496 | scope = sctp_scope(&asoc->peer.active_path->ipaddr); | ||
1497 | flags = (PF_INET6 == asoc->base.sk->sk_family) ? SCTP_ADDR6_ALLOWED : 0; | 1495 | flags = (PF_INET6 == asoc->base.sk->sk_family) ? SCTP_ADDR6_ALLOWED : 0; |
1498 | if (asoc->peer.ipv4_address) | 1496 | if (asoc->peer.ipv4_address) |
1499 | flags |= SCTP_ADDR4_PEERSUPP; | 1497 | flags |= SCTP_ADDR4_PEERSUPP; |
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index c8fae1983dd1..d4df45022ffa 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
@@ -384,6 +384,11 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
384 | if (!new_asoc) | 384 | if (!new_asoc) |
385 | goto nomem; | 385 | goto nomem; |
386 | 386 | ||
387 | if (sctp_assoc_set_bind_addr_from_ep(new_asoc, | ||
388 | sctp_scope(sctp_source(chunk)), | ||
389 | GFP_ATOMIC) < 0) | ||
390 | goto nomem_init; | ||
391 | |||
387 | /* The call, sctp_process_init(), can fail on memory allocation. */ | 392 | /* The call, sctp_process_init(), can fail on memory allocation. */ |
388 | if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type, | 393 | if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type, |
389 | sctp_source(chunk), | 394 | sctp_source(chunk), |
@@ -401,9 +406,6 @@ sctp_disposition_t sctp_sf_do_5_1B_init(const struct sctp_endpoint *ep, | |||
401 | len = ntohs(err_chunk->chunk_hdr->length) - | 406 | len = ntohs(err_chunk->chunk_hdr->length) - |
402 | sizeof(sctp_chunkhdr_t); | 407 | sizeof(sctp_chunkhdr_t); |
403 | 408 | ||
404 | if (sctp_assoc_set_bind_addr_from_ep(new_asoc, GFP_ATOMIC) < 0) | ||
405 | goto nomem_init; | ||
406 | |||
407 | repl = sctp_make_init_ack(new_asoc, chunk, GFP_ATOMIC, len); | 409 | repl = sctp_make_init_ack(new_asoc, chunk, GFP_ATOMIC, len); |
408 | if (!repl) | 410 | if (!repl) |
409 | goto nomem_init; | 411 | goto nomem_init; |
@@ -1452,6 +1454,10 @@ static sctp_disposition_t sctp_sf_do_unexpected_init( | |||
1452 | if (!new_asoc) | 1454 | if (!new_asoc) |
1453 | goto nomem; | 1455 | goto nomem; |
1454 | 1456 | ||
1457 | if (sctp_assoc_set_bind_addr_from_ep(new_asoc, | ||
1458 | sctp_scope(sctp_source(chunk)), GFP_ATOMIC) < 0) | ||
1459 | goto nomem; | ||
1460 | |||
1455 | /* In the outbound INIT ACK the endpoint MUST copy its current | 1461 | /* In the outbound INIT ACK the endpoint MUST copy its current |
1456 | * Verification Tag and Peers Verification tag into a reserved | 1462 | * Verification Tag and Peers Verification tag into a reserved |
1457 | * place (local tie-tag and per tie-tag) within the state cookie. | 1463 | * place (local tie-tag and per tie-tag) within the state cookie. |
@@ -1488,9 +1494,6 @@ static sctp_disposition_t sctp_sf_do_unexpected_init( | |||
1488 | sizeof(sctp_chunkhdr_t); | 1494 | sizeof(sctp_chunkhdr_t); |
1489 | } | 1495 | } |
1490 | 1496 | ||
1491 | if (sctp_assoc_set_bind_addr_from_ep(new_asoc, GFP_ATOMIC) < 0) | ||
1492 | goto nomem; | ||
1493 | |||
1494 | repl = sctp_make_init_ack(new_asoc, chunk, GFP_ATOMIC, len); | 1497 | repl = sctp_make_init_ack(new_asoc, chunk, GFP_ATOMIC, len); |
1495 | if (!repl) | 1498 | if (!repl) |
1496 | goto nomem; | 1499 | goto nomem; |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index c8d05758661d..bf705ba97231 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -1080,6 +1080,13 @@ static int __sctp_connect(struct sock* sk, | |||
1080 | err = -ENOMEM; | 1080 | err = -ENOMEM; |
1081 | goto out_free; | 1081 | goto out_free; |
1082 | } | 1082 | } |
1083 | |||
1084 | err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, | ||
1085 | GFP_KERNEL); | ||
1086 | if (err < 0) { | ||
1087 | goto out_free; | ||
1088 | } | ||
1089 | |||
1083 | } | 1090 | } |
1084 | 1091 | ||
1085 | /* Prime the peer's transport structures. */ | 1092 | /* Prime the peer's transport structures. */ |
@@ -1095,11 +1102,6 @@ static int __sctp_connect(struct sock* sk, | |||
1095 | walk_size += af->sockaddr_len; | 1102 | walk_size += af->sockaddr_len; |
1096 | } | 1103 | } |
1097 | 1104 | ||
1098 | err = sctp_assoc_set_bind_addr_from_ep(asoc, GFP_KERNEL); | ||
1099 | if (err < 0) { | ||
1100 | goto out_free; | ||
1101 | } | ||
1102 | |||
1103 | /* In case the user of sctp_connectx() wants an association | 1105 | /* In case the user of sctp_connectx() wants an association |
1104 | * id back, assign one now. | 1106 | * id back, assign one now. |
1105 | */ | 1107 | */ |
@@ -1689,6 +1691,11 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
1689 | goto out_unlock; | 1691 | goto out_unlock; |
1690 | } | 1692 | } |
1691 | asoc = new_asoc; | 1693 | asoc = new_asoc; |
1694 | err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, GFP_KERNEL); | ||
1695 | if (err < 0) { | ||
1696 | err = -ENOMEM; | ||
1697 | goto out_free; | ||
1698 | } | ||
1692 | 1699 | ||
1693 | /* If the SCTP_INIT ancillary data is specified, set all | 1700 | /* If the SCTP_INIT ancillary data is specified, set all |
1694 | * the association init values accordingly. | 1701 | * the association init values accordingly. |
@@ -1718,11 +1725,6 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
1718 | err = -ENOMEM; | 1725 | err = -ENOMEM; |
1719 | goto out_free; | 1726 | goto out_free; |
1720 | } | 1727 | } |
1721 | err = sctp_assoc_set_bind_addr_from_ep(asoc, GFP_KERNEL); | ||
1722 | if (err < 0) { | ||
1723 | err = -ENOMEM; | ||
1724 | goto out_free; | ||
1725 | } | ||
1726 | } | 1728 | } |
1727 | 1729 | ||
1728 | /* ASSERT: we have a valid association at this point. */ | 1730 | /* ASSERT: we have a valid association at this point. */ |