Commit 4bdf4b5f authored by Al Viro's avatar Al Viro Committed by David S. Miller

[SCTP]: Switch sctp_assoc_add_peer() to net-endian.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b488c7dd
......@@ -533,19 +533,17 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
struct sctp_transport *peer;
struct sctp_sock *sp;
unsigned short port;
union sctp_addr tmp;
flip_to_n(&tmp, addr);
sp = sctp_sk(asoc->base.sk);
/* AF_INET and AF_INET6 share common port field. */
port = addr->v4.sin_port;
port = ntohs(addr->v4.sin_port);
SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ",
" port: %d state:%d\n",
asoc,
addr,
addr->v4.sin_port,
port,
peer_state);
/* 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,
asoc->peer.port = port;
/* Check to see if this is a duplicate. */
peer = sctp_assoc_lookup_paddr(asoc, &tmp);
peer = sctp_assoc_lookup_paddr(asoc, addr);
if (peer) {
if (peer->state == SCTP_UNKNOWN) {
if (peer_state == SCTP_ACTIVE)
......@@ -564,7 +562,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
return peer;
}
peer = sctp_transport_new(&tmp, gfp);
peer = sctp_transport_new(addr, gfp);
if (!peer)
return NULL;
......@@ -1070,7 +1068,7 @@ void sctp_assoc_update(struct sctp_association *asoc,
trans = list_entry(pos, struct sctp_transport,
transports);
if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr))
sctp_assoc_add_peer(asoc, &trans->ipaddr_h,
sctp_assoc_add_peer(asoc, &trans->ipaddr,
GFP_ATOMIC, trans->state);
}
......
......@@ -1842,6 +1842,7 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid,
struct sctp_transport *transport;
struct list_head *pos, *temp;
char *cookie;
union sctp_addr tmp;
/* We must include the address that the INIT packet came from.
* 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,
* added as the primary transport. The source address seems to
* be a a better choice than any of the embedded addresses.
*/
if (peer_addr)
if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
if (peer_addr) {
flip_to_n(&tmp, peer_addr);
if(!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_ACTIVE))
goto nomem;
}
/* Process the initialization parameters. */
......@@ -2016,6 +2019,7 @@ static int sctp_process_param(struct sctp_association *asoc,
sctp_scope_t scope;
time_t stale;
struct sctp_af *af;
union sctp_addr tmp;
/* We maintain all INIT parameters in network byte order all the
* time. This allows us to not worry about whether the parameters
......@@ -2029,9 +2033,10 @@ static int sctp_process_param(struct sctp_association *asoc,
case SCTP_PARAM_IPV4_ADDRESS:
af = sctp_get_af_specific(param_type2af(param.p->type));
af->from_addr_param(&addr, param.addr, asoc->peer.port, 0);
flip_to_n(&tmp, &addr);
scope = sctp_scope(peer_addr);
if (sctp_in_scope(&addr, scope))
if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED))
if (sctp_in_scope(&tmp, scope))
if (!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_UNCONFIRMED))
return 0;
break;
......@@ -2434,7 +2439,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
* Due to Resource Shortage'.
*/
peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC, SCTP_UNCONFIRMED);
peer = sctp_assoc_add_peer(asoc, &tmp_addr, GFP_ATOMIC, SCTP_UNCONFIRMED);
if (!peer)
return SCTP_ERROR_RSRC_LOW;
......
......@@ -969,7 +969,7 @@ static int __sctp_connect(struct sock* sk,
int err = 0;
int addrcnt = 0;
int walk_size = 0;
struct sockaddr *sa_addr;
union sctp_addr *sa_addr;
void *addr_buf;
sp = sctp_sk(sk);
......@@ -989,8 +989,8 @@ static int __sctp_connect(struct sock* sk,
/* Walk through the addrs buffer and count the number of addresses. */
addr_buf = kaddrs;
while (walk_size < addrs_size) {
sa_addr = (struct sockaddr *)addr_buf;
af = sctp_get_af_specific(sa_addr->sa_family);
sa_addr = (union sctp_addr *)addr_buf;
af = sctp_get_af_specific(sa_addr->sa.sa_family);
/* If the address family is not supported or if this address
* causes the address buffer to overflow return EINVAL.
......@@ -1000,8 +1000,7 @@ static int __sctp_connect(struct sock* sk,
goto out_free;
}
err = sctp_verify_addr(sk, (union sctp_addr *)sa_addr,
af->sockaddr_len);
err = sctp_verify_addr(sk, sa_addr, af->sockaddr_len);
if (err)
goto out_free;
......@@ -1064,7 +1063,7 @@ static int __sctp_connect(struct sock* sk,
}
/* Prime the peer's transport structures. */
transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL,
transport = sctp_assoc_add_peer(asoc, sa_addr, GFP_KERNEL,
SCTP_UNKNOWN);
if (!transport) {
err = -ENOMEM;
......@@ -1618,7 +1617,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
}
/* Prime the peer's transport structures. */
transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, SCTP_UNKNOWN);
transport = sctp_assoc_add_peer(asoc, &tmp, GFP_KERNEL, SCTP_UNKNOWN);
if (!transport) {
err = -ENOMEM;
goto out_free;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment