diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2006-11-20 20:10:20 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:26:46 -0500 |
commit | 4bdf4b5fe22c26750c39fdd2939a5f33df0cc341 (patch) | |
tree | 36daeb8ec4543df2e02e51a11d13852d4eb1fc3c /net/sctp | |
parent | b488c7dd58f61e07b54e5d286c7b45c43dd52f1a (diff) |
[SCTP]: Switch sctp_assoc_add_peer() to net-endian.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/associola.c | 12 | ||||
-rw-r--r-- | net/sctp/sm_make_chunk.c | 15 | ||||
-rw-r--r-- | net/sctp/socket.c | 13 |
3 files changed, 21 insertions, 19 deletions
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 7824aeaa3d60..5b8971be9775 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -533,19 +533,17 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, | |||
533 | struct sctp_transport *peer; | 533 | struct sctp_transport *peer; |
534 | struct sctp_sock *sp; | 534 | struct sctp_sock *sp; |
535 | unsigned short port; | 535 | unsigned short port; |
536 | union sctp_addr tmp; | ||
537 | flip_to_n(&tmp, addr); | ||
538 | 536 | ||
539 | sp = sctp_sk(asoc->base.sk); | 537 | sp = sctp_sk(asoc->base.sk); |
540 | 538 | ||
541 | /* AF_INET and AF_INET6 share common port field. */ | 539 | /* AF_INET and AF_INET6 share common port field. */ |
542 | port = addr->v4.sin_port; | 540 | port = ntohs(addr->v4.sin_port); |
543 | 541 | ||
544 | SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ", | 542 | SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ", |
545 | " port: %d state:%d\n", | 543 | " port: %d state:%d\n", |
546 | asoc, | 544 | asoc, |
547 | addr, | 545 | addr, |
548 | addr->v4.sin_port, | 546 | port, |
549 | peer_state); | 547 | peer_state); |
550 | 548 | ||
551 | /* Set the port if it has not been set yet. */ | 549 | /* Set the port if it has not been set yet. */ |
@@ -553,7 +551,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, | |||
553 | asoc->peer.port = port; | 551 | asoc->peer.port = port; |
554 | 552 | ||
555 | /* Check to see if this is a duplicate. */ | 553 | /* Check to see if this is a duplicate. */ |
556 | peer = sctp_assoc_lookup_paddr(asoc, &tmp); | 554 | peer = sctp_assoc_lookup_paddr(asoc, addr); |
557 | if (peer) { | 555 | if (peer) { |
558 | if (peer->state == SCTP_UNKNOWN) { | 556 | if (peer->state == SCTP_UNKNOWN) { |
559 | if (peer_state == SCTP_ACTIVE) | 557 | if (peer_state == SCTP_ACTIVE) |
@@ -564,7 +562,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, | |||
564 | return peer; | 562 | return peer; |
565 | } | 563 | } |
566 | 564 | ||
567 | peer = sctp_transport_new(&tmp, gfp); | 565 | peer = sctp_transport_new(addr, gfp); |
568 | if (!peer) | 566 | if (!peer) |
569 | return NULL; | 567 | return NULL; |
570 | 568 | ||
@@ -1070,7 +1068,7 @@ void sctp_assoc_update(struct sctp_association *asoc, | |||
1070 | trans = list_entry(pos, struct sctp_transport, | 1068 | trans = list_entry(pos, struct sctp_transport, |
1071 | transports); | 1069 | transports); |
1072 | if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr)) | 1070 | if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr)) |
1073 | sctp_assoc_add_peer(asoc, &trans->ipaddr_h, | 1071 | sctp_assoc_add_peer(asoc, &trans->ipaddr, |
1074 | GFP_ATOMIC, trans->state); | 1072 | GFP_ATOMIC, trans->state); |
1075 | } | 1073 | } |
1076 | 1074 | ||
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 632a1159610e..2c887d3f3911 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -1842,6 +1842,7 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, | |||
1842 | struct sctp_transport *transport; | 1842 | struct sctp_transport *transport; |
1843 | struct list_head *pos, *temp; | 1843 | struct list_head *pos, *temp; |
1844 | char *cookie; | 1844 | char *cookie; |
1845 | union sctp_addr tmp; | ||
1845 | 1846 | ||
1846 | /* We must include the address that the INIT packet came from. | 1847 | /* We must include the address that the INIT packet came from. |
1847 | * This is the only address that matters for an INIT packet. | 1848 | * This is the only address that matters for an INIT packet. |
@@ -1853,9 +1854,11 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, | |||
1853 | * added as the primary transport. The source address seems to | 1854 | * added as the primary transport. The source address seems to |
1854 | * be a a better choice than any of the embedded addresses. | 1855 | * be a a better choice than any of the embedded addresses. |
1855 | */ | 1856 | */ |
1856 | if (peer_addr) | 1857 | if (peer_addr) { |
1857 | if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE)) | 1858 | flip_to_n(&tmp, peer_addr); |
1859 | if(!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_ACTIVE)) | ||
1858 | goto nomem; | 1860 | goto nomem; |
1861 | } | ||
1859 | 1862 | ||
1860 | /* Process the initialization parameters. */ | 1863 | /* Process the initialization parameters. */ |
1861 | 1864 | ||
@@ -2016,6 +2019,7 @@ static int sctp_process_param(struct sctp_association *asoc, | |||
2016 | sctp_scope_t scope; | 2019 | sctp_scope_t scope; |
2017 | time_t stale; | 2020 | time_t stale; |
2018 | struct sctp_af *af; | 2021 | struct sctp_af *af; |
2022 | union sctp_addr tmp; | ||
2019 | 2023 | ||
2020 | /* We maintain all INIT parameters in network byte order all the | 2024 | /* We maintain all INIT parameters in network byte order all the |
2021 | * time. This allows us to not worry about whether the parameters | 2025 | * time. This allows us to not worry about whether the parameters |
@@ -2029,9 +2033,10 @@ static int sctp_process_param(struct sctp_association *asoc, | |||
2029 | case SCTP_PARAM_IPV4_ADDRESS: | 2033 | case SCTP_PARAM_IPV4_ADDRESS: |
2030 | af = sctp_get_af_specific(param_type2af(param.p->type)); | 2034 | af = sctp_get_af_specific(param_type2af(param.p->type)); |
2031 | af->from_addr_param(&addr, param.addr, asoc->peer.port, 0); | 2035 | af->from_addr_param(&addr, param.addr, asoc->peer.port, 0); |
2036 | flip_to_n(&tmp, &addr); | ||
2032 | scope = sctp_scope(peer_addr); | 2037 | scope = sctp_scope(peer_addr); |
2033 | if (sctp_in_scope(&addr, scope)) | 2038 | if (sctp_in_scope(&tmp, scope)) |
2034 | if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED)) | 2039 | if (!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_UNCONFIRMED)) |
2035 | return 0; | 2040 | return 0; |
2036 | break; | 2041 | break; |
2037 | 2042 | ||
@@ -2434,7 +2439,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc, | |||
2434 | * Due to Resource Shortage'. | 2439 | * Due to Resource Shortage'. |
2435 | */ | 2440 | */ |
2436 | 2441 | ||
2437 | peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC, SCTP_UNCONFIRMED); | 2442 | peer = sctp_assoc_add_peer(asoc, &tmp_addr, GFP_ATOMIC, SCTP_UNCONFIRMED); |
2438 | if (!peer) | 2443 | if (!peer) |
2439 | return SCTP_ERROR_RSRC_LOW; | 2444 | return SCTP_ERROR_RSRC_LOW; |
2440 | 2445 | ||
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index f00b03845247..3dd7ada8026c 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -969,7 +969,7 @@ static int __sctp_connect(struct sock* sk, | |||
969 | int err = 0; | 969 | int err = 0; |
970 | int addrcnt = 0; | 970 | int addrcnt = 0; |
971 | int walk_size = 0; | 971 | int walk_size = 0; |
972 | struct sockaddr *sa_addr; | 972 | union sctp_addr *sa_addr; |
973 | void *addr_buf; | 973 | void *addr_buf; |
974 | 974 | ||
975 | sp = sctp_sk(sk); | 975 | sp = sctp_sk(sk); |
@@ -989,8 +989,8 @@ static int __sctp_connect(struct sock* sk, | |||
989 | /* Walk through the addrs buffer and count the number of addresses. */ | 989 | /* Walk through the addrs buffer and count the number of addresses. */ |
990 | addr_buf = kaddrs; | 990 | addr_buf = kaddrs; |
991 | while (walk_size < addrs_size) { | 991 | while (walk_size < addrs_size) { |
992 | sa_addr = (struct sockaddr *)addr_buf; | 992 | sa_addr = (union sctp_addr *)addr_buf; |
993 | af = sctp_get_af_specific(sa_addr->sa_family); | 993 | af = sctp_get_af_specific(sa_addr->sa.sa_family); |
994 | 994 | ||
995 | /* If the address family is not supported or if this address | 995 | /* If the address family is not supported or if this address |
996 | * causes the address buffer to overflow return EINVAL. | 996 | * causes the address buffer to overflow return EINVAL. |
@@ -1000,8 +1000,7 @@ static int __sctp_connect(struct sock* sk, | |||
1000 | goto out_free; | 1000 | goto out_free; |
1001 | } | 1001 | } |
1002 | 1002 | ||
1003 | err = sctp_verify_addr(sk, (union sctp_addr *)sa_addr, | 1003 | err = sctp_verify_addr(sk, sa_addr, af->sockaddr_len); |
1004 | af->sockaddr_len); | ||
1005 | if (err) | 1004 | if (err) |
1006 | goto out_free; | 1005 | goto out_free; |
1007 | 1006 | ||
@@ -1064,7 +1063,7 @@ static int __sctp_connect(struct sock* sk, | |||
1064 | } | 1063 | } |
1065 | 1064 | ||
1066 | /* Prime the peer's transport structures. */ | 1065 | /* Prime the peer's transport structures. */ |
1067 | transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, | 1066 | transport = sctp_assoc_add_peer(asoc, sa_addr, GFP_KERNEL, |
1068 | SCTP_UNKNOWN); | 1067 | SCTP_UNKNOWN); |
1069 | if (!transport) { | 1068 | if (!transport) { |
1070 | err = -ENOMEM; | 1069 | err = -ENOMEM; |
@@ -1618,7 +1617,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
1618 | } | 1617 | } |
1619 | 1618 | ||
1620 | /* Prime the peer's transport structures. */ | 1619 | /* Prime the peer's transport structures. */ |
1621 | transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, SCTP_UNKNOWN); | 1620 | transport = sctp_assoc_add_peer(asoc, &tmp, GFP_KERNEL, SCTP_UNKNOWN); |
1622 | if (!transport) { | 1621 | if (!transport) { |
1623 | err = -ENOMEM; | 1622 | err = -ENOMEM; |
1624 | goto out_free; | 1623 | goto out_free; |