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

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

Callers updated.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 38a03145
...@@ -533,6 +533,8 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, ...@@ -533,6 +533,8 @@ 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);
...@@ -551,7 +553,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, ...@@ -551,7 +553,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, addr); peer = sctp_assoc_lookup_paddr(asoc, &tmp);
if (peer) { if (peer) {
if (peer->state == SCTP_UNKNOWN) { if (peer->state == SCTP_UNKNOWN) {
if (peer_state == SCTP_ACTIVE) if (peer_state == SCTP_ACTIVE)
...@@ -684,14 +686,12 @@ struct sctp_transport *sctp_assoc_lookup_paddr( ...@@ -684,14 +686,12 @@ struct sctp_transport *sctp_assoc_lookup_paddr(
{ {
struct sctp_transport *t; struct sctp_transport *t;
struct list_head *pos; struct list_head *pos;
union sctp_addr tmp;
flip_to_n(&tmp, address);
/* Cycle through all transports searching for a peer address. */ /* Cycle through all transports searching for a peer address. */
list_for_each(pos, &asoc->peer.transport_addr_list) { list_for_each(pos, &asoc->peer.transport_addr_list) {
t = list_entry(pos, struct sctp_transport, transports); t = list_entry(pos, struct sctp_transport, transports);
if (sctp_cmp_addr_exact(&tmp, &t->ipaddr)) if (sctp_cmp_addr_exact(address, &t->ipaddr))
return t; return t;
} }
...@@ -927,14 +927,15 @@ struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc, ...@@ -927,14 +927,15 @@ struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc,
const union sctp_addr *paddr) const union sctp_addr *paddr)
{ {
struct sctp_transport *transport; struct sctp_transport *transport;
union sctp_addr tmp; union sctp_addr tmp, tmp2;
flip_to_n(&tmp, laddr); flip_to_n(&tmp, laddr);
flip_to_n(&tmp2, paddr);
sctp_read_lock(&asoc->base.addr_lock); sctp_read_lock(&asoc->base.addr_lock);
if ((asoc->base.bind_addr.port == laddr->v4.sin_port) && if ((asoc->base.bind_addr.port == laddr->v4.sin_port) &&
(asoc->peer.port == paddr->v4.sin_port)) { (asoc->peer.port == paddr->v4.sin_port)) {
transport = sctp_assoc_lookup_paddr(asoc, paddr); transport = sctp_assoc_lookup_paddr(asoc, &tmp2);
if (!transport) if (!transport)
goto out; goto out;
...@@ -1047,7 +1048,7 @@ void sctp_assoc_update(struct sctp_association *asoc, ...@@ -1047,7 +1048,7 @@ void sctp_assoc_update(struct sctp_association *asoc,
/* Remove any peer addresses not present in the new association. */ /* Remove any peer addresses not present in the new association. */
list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
trans = list_entry(pos, struct sctp_transport, transports); trans = list_entry(pos, struct sctp_transport, transports);
if (!sctp_assoc_lookup_paddr(new, &trans->ipaddr_h)) if (!sctp_assoc_lookup_paddr(new, &trans->ipaddr))
sctp_assoc_del_peer(asoc, &trans->ipaddr); sctp_assoc_del_peer(asoc, &trans->ipaddr);
} }
...@@ -1071,7 +1072,7 @@ void sctp_assoc_update(struct sctp_association *asoc, ...@@ -1071,7 +1072,7 @@ void sctp_assoc_update(struct sctp_association *asoc,
list_for_each(pos, &new->peer.transport_addr_list) { list_for_each(pos, &new->peer.transport_addr_list) {
trans = list_entry(pos, struct sctp_transport, trans = list_entry(pos, struct sctp_transport,
transports); transports);
if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr_h)) if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr))
sctp_assoc_add_peer(asoc, &trans->ipaddr_h, sctp_assoc_add_peer(asoc, &trans->ipaddr_h,
GFP_ATOMIC, trans->state); GFP_ATOMIC, trans->state);
} }
......
...@@ -259,6 +259,8 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( ...@@ -259,6 +259,8 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc(
int rport; int rport;
struct sctp_association *asoc; struct sctp_association *asoc;
struct list_head *pos; struct list_head *pos;
union sctp_addr tmp;
flip_to_n(&tmp, paddr);
rport = paddr->v4.sin_port; rport = paddr->v4.sin_port;
...@@ -266,7 +268,7 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( ...@@ -266,7 +268,7 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc(
asoc = list_entry(pos, struct sctp_association, asocs); asoc = list_entry(pos, struct sctp_association, asocs);
if (rport == asoc->peer.port) { if (rport == asoc->peer.port) {
sctp_read_lock(&asoc->base.addr_lock); sctp_read_lock(&asoc->base.addr_lock);
*transport = sctp_assoc_lookup_paddr(asoc, paddr); *transport = sctp_assoc_lookup_paddr(asoc, &tmp);
sctp_read_unlock(&asoc->base.addr_lock); sctp_read_unlock(&asoc->base.addr_lock);
if (*transport) if (*transport)
......
...@@ -2466,7 +2466,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc, ...@@ -2466,7 +2466,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
sctp_assoc_del_peer(asoc, &tmp_addr); sctp_assoc_del_peer(asoc, &tmp_addr);
break; break;
case SCTP_PARAM_SET_PRIMARY: case SCTP_PARAM_SET_PRIMARY:
peer = sctp_assoc_lookup_paddr(asoc, &addr); peer = sctp_assoc_lookup_paddr(asoc, &tmp_addr);
if (!peer) if (!peer)
return SCTP_ERROR_INV_PARAM; return SCTP_ERROR_INV_PARAM;
......
...@@ -1018,6 +1018,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep, ...@@ -1018,6 +1018,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep,
struct sctp_transport *link; struct sctp_transport *link;
sctp_sender_hb_info_t *hbinfo; sctp_sender_hb_info_t *hbinfo;
unsigned long max_interval; unsigned long max_interval;
union sctp_addr tmp;
if (!sctp_vtag_verify(chunk, asoc)) if (!sctp_vtag_verify(chunk, asoc))
return sctp_sf_pdiscard(ep, asoc, type, arg, commands); return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
...@@ -1035,7 +1036,8 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep, ...@@ -1035,7 +1036,8 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep,
} }
from_addr = hbinfo->daddr; from_addr = hbinfo->daddr;
link = sctp_assoc_lookup_paddr(asoc, &from_addr); flip_to_n(&tmp, &from_addr);
link = sctp_assoc_lookup_paddr(asoc, &tmp);
/* This should never happen, but lets log it if so. */ /* This should never happen, but lets log it if so. */
if (unlikely(!link)) { if (unlikely(!link)) {
......
...@@ -1370,7 +1370,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1370,7 +1370,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
struct sctp_association *new_asoc=NULL, *asoc=NULL; struct sctp_association *new_asoc=NULL, *asoc=NULL;
struct sctp_transport *transport, *chunk_tp; struct sctp_transport *transport, *chunk_tp;
struct sctp_chunk *chunk; struct sctp_chunk *chunk;
union sctp_addr to; union sctp_addr to, tmp;
struct sockaddr *msg_name = NULL; struct sockaddr *msg_name = NULL;
struct sctp_sndrcvinfo default_sinfo = { 0 }; struct sctp_sndrcvinfo default_sinfo = { 0 };
struct sctp_sndrcvinfo *sinfo; struct sctp_sndrcvinfo *sinfo;
...@@ -1424,6 +1424,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1424,6 +1424,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
if (msg_namelen > sizeof(to)) if (msg_namelen > sizeof(to))
msg_namelen = sizeof(to); msg_namelen = sizeof(to);
memcpy(&to, msg->msg_name, msg_namelen); memcpy(&to, msg->msg_name, msg_namelen);
memcpy(&tmp, msg->msg_name, msg_namelen);
SCTP_DEBUG_PRINTK("Just memcpy'd. msg_name is " SCTP_DEBUG_PRINTK("Just memcpy'd. msg_name is "
"0x%x:%u.\n", "0x%x:%u.\n",
to.v4.sin_addr.s_addr, to.v4.sin_port); to.v4.sin_addr.s_addr, to.v4.sin_port);
...@@ -1691,7 +1692,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1691,7 +1692,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
*/ */
if ((sctp_style(sk, TCP) && msg_name) || if ((sctp_style(sk, TCP) && msg_name) ||
(sinfo_flags & SCTP_ADDR_OVER)) { (sinfo_flags & SCTP_ADDR_OVER)) {
chunk_tp = sctp_assoc_lookup_paddr(asoc, &to); chunk_tp = sctp_assoc_lookup_paddr(asoc, &tmp);
if (!chunk_tp) { if (!chunk_tp) {
err = -EINVAL; err = -EINVAL;
goto out_free; 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