[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>
This commit is contained in:
@@ -533,19 +533,17 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
|
|||||||
struct sctp_transport *peer;
|
struct sctp_transport *peer;
|
||||||
struct sctp_sock *sp;
|
struct sctp_sock *sp;
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
union sctp_addr tmp;
|
|
||||||
flip_to_n(&tmp, addr);
|
|
||||||
|
|
||||||
sp = sctp_sk(asoc->base.sk);
|
sp = sctp_sk(asoc->base.sk);
|
||||||
|
|
||||||
/* AF_INET and AF_INET6 share common port field. */
|
/* 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: ",
|
SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ",
|
||||||
" port: %d state:%d\n",
|
" port: %d state:%d\n",
|
||||||
asoc,
|
asoc,
|
||||||
addr,
|
addr,
|
||||||
addr->v4.sin_port,
|
port,
|
||||||
peer_state);
|
peer_state);
|
||||||
|
|
||||||
/* Set the port if it has not been set yet. */
|
/* 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;
|
asoc->peer.port = port;
|
||||||
|
|
||||||
/* Check to see if this is a duplicate. */
|
/* 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) {
|
||||||
if (peer->state == SCTP_UNKNOWN) {
|
if (peer->state == SCTP_UNKNOWN) {
|
||||||
if (peer_state == SCTP_ACTIVE)
|
if (peer_state == SCTP_ACTIVE)
|
||||||
@@ -564,7 +562,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
|
|||||||
return peer;
|
return peer;
|
||||||
}
|
}
|
||||||
|
|
||||||
peer = sctp_transport_new(&tmp, gfp);
|
peer = sctp_transport_new(addr, gfp);
|
||||||
if (!peer)
|
if (!peer)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1070,7 +1068,7 @@ void sctp_assoc_update(struct sctp_association *asoc,
|
|||||||
trans = list_entry(pos, struct sctp_transport,
|
trans = list_entry(pos, struct sctp_transport,
|
||||||
transports);
|
transports);
|
||||||
if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr))
|
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);
|
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 sctp_transport *transport;
|
||||||
struct list_head *pos, *temp;
|
struct list_head *pos, *temp;
|
||||||
char *cookie;
|
char *cookie;
|
||||||
|
union sctp_addr tmp;
|
||||||
|
|
||||||
/* We must include the address that the INIT packet came from.
|
/* We must include the address that the INIT packet came from.
|
||||||
* This is the only address that matters for an INIT packet.
|
* 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
|
* added as the primary transport. The source address seems to
|
||||||
* be a a better choice than any of the embedded addresses.
|
* be a a better choice than any of the embedded addresses.
|
||||||
*/
|
*/
|
||||||
if (peer_addr)
|
if (peer_addr) {
|
||||||
if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
|
flip_to_n(&tmp, peer_addr);
|
||||||
|
if(!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_ACTIVE))
|
||||||
goto nomem;
|
goto nomem;
|
||||||
|
}
|
||||||
|
|
||||||
/* Process the initialization parameters. */
|
/* Process the initialization parameters. */
|
||||||
|
|
||||||
@@ -2016,6 +2019,7 @@ static int sctp_process_param(struct sctp_association *asoc,
|
|||||||
sctp_scope_t scope;
|
sctp_scope_t scope;
|
||||||
time_t stale;
|
time_t stale;
|
||||||
struct sctp_af *af;
|
struct sctp_af *af;
|
||||||
|
union sctp_addr tmp;
|
||||||
|
|
||||||
/* We maintain all INIT parameters in network byte order all the
|
/* We maintain all INIT parameters in network byte order all the
|
||||||
* time. This allows us to not worry about whether the parameters
|
* 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:
|
case SCTP_PARAM_IPV4_ADDRESS:
|
||||||
af = sctp_get_af_specific(param_type2af(param.p->type));
|
af = sctp_get_af_specific(param_type2af(param.p->type));
|
||||||
af->from_addr_param(&addr, param.addr, asoc->peer.port, 0);
|
af->from_addr_param(&addr, param.addr, asoc->peer.port, 0);
|
||||||
|
flip_to_n(&tmp, &addr);
|
||||||
scope = sctp_scope(peer_addr);
|
scope = sctp_scope(peer_addr);
|
||||||
if (sctp_in_scope(&addr, scope))
|
if (sctp_in_scope(&tmp, scope))
|
||||||
if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED))
|
if (!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_UNCONFIRMED))
|
||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2434,7 +2439,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
|
|||||||
* Due to Resource Shortage'.
|
* 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)
|
if (!peer)
|
||||||
return SCTP_ERROR_RSRC_LOW;
|
return SCTP_ERROR_RSRC_LOW;
|
||||||
|
|
||||||
|
@@ -969,7 +969,7 @@ static int __sctp_connect(struct sock* sk,
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
int addrcnt = 0;
|
int addrcnt = 0;
|
||||||
int walk_size = 0;
|
int walk_size = 0;
|
||||||
struct sockaddr *sa_addr;
|
union sctp_addr *sa_addr;
|
||||||
void *addr_buf;
|
void *addr_buf;
|
||||||
|
|
||||||
sp = sctp_sk(sk);
|
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. */
|
/* Walk through the addrs buffer and count the number of addresses. */
|
||||||
addr_buf = kaddrs;
|
addr_buf = kaddrs;
|
||||||
while (walk_size < addrs_size) {
|
while (walk_size < addrs_size) {
|
||||||
sa_addr = (struct sockaddr *)addr_buf;
|
sa_addr = (union sctp_addr *)addr_buf;
|
||||||
af = sctp_get_af_specific(sa_addr->sa_family);
|
af = sctp_get_af_specific(sa_addr->sa.sa_family);
|
||||||
|
|
||||||
/* If the address family is not supported or if this address
|
/* If the address family is not supported or if this address
|
||||||
* causes the address buffer to overflow return EINVAL.
|
* causes the address buffer to overflow return EINVAL.
|
||||||
@@ -1000,8 +1000,7 @@ static int __sctp_connect(struct sock* sk,
|
|||||||
goto out_free;
|
goto out_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = sctp_verify_addr(sk, (union sctp_addr *)sa_addr,
|
err = sctp_verify_addr(sk, sa_addr, af->sockaddr_len);
|
||||||
af->sockaddr_len);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
@@ -1064,7 +1063,7 @@ static int __sctp_connect(struct sock* sk,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Prime the peer's transport structures. */
|
/* 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);
|
SCTP_UNKNOWN);
|
||||||
if (!transport) {
|
if (!transport) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
@@ -1618,7 +1617,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Prime the peer's transport structures. */
|
/* 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) {
|
if (!transport) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
Reference in New Issue
Block a user