From dbc16db1e58da6c346ca3e63870c17b93fbed0f0 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:01:42 -0800 Subject: [SCTP]: Trivial sctp endianness annotations. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index ed0445fe85e7..a5d7abba89e4 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -868,7 +868,7 @@ struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *asoc, struct list_head *entry, *pos; struct sctp_transport *transport; struct sctp_chunk *chunk; - __u32 key = htonl(tsn); + __be32 key = htonl(tsn); match = NULL; -- cgit v1.2.2 From 39940a48c42441da5e7428483ac515e822d52b1d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:02:22 -0800 Subject: [SCTP] bug: sctp_assoc_lookup_laddr() is broken with ipv6. It expects (and gets) laddr with net-endian sin_port. And then it calls sctp_bind_addr_match(), which *does* care about port numbers in case of ipv6 and expects them to be host-endian. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index a5d7abba89e4..7639044b0074 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -1335,10 +1335,12 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc, const union sctp_addr *laddr) { int found; + union sctp_addr tmp; + flip_to_h(&tmp, laddr); sctp_read_lock(&asoc->base.addr_lock); if ((asoc->base.bind_addr.port == ntohs(laddr->v4.sin_port)) && - sctp_bind_addr_match(&asoc->base.bind_addr, laddr, + sctp_bind_addr_match(&asoc->base.bind_addr, &tmp, sctp_sk(asoc->base.sk))) { found = 1; goto out; -- cgit v1.2.2 From 0906e20fa03afdb14faf7fd166bfe4ed67c8db55 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:03:01 -0800 Subject: [SCTP] bug: sctp_assoc_control_transport() breakage a) struct sockaddr_storage * passed to sctp_ulpevent_make_peer_addr_change() actually points at union sctp_addr field in a structure. Then that sucker gets copied to userland, with whatever junk we might have there. b) it's actually having host-endian sin_port. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 7639044b0074..746b0b0f5ace 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -709,6 +709,7 @@ void sctp_assoc_control_transport(struct sctp_association *asoc, struct sctp_transport *first; struct sctp_transport *second; struct sctp_ulpevent *event; + struct sockaddr_storage addr; struct list_head *pos; int spc_state = 0; @@ -731,8 +732,9 @@ void sctp_assoc_control_transport(struct sctp_association *asoc, /* Generate and send a SCTP_PEER_ADDR_CHANGE notification to the * user. */ - event = sctp_ulpevent_make_peer_addr_change(asoc, - (struct sockaddr_storage *) &transport->ipaddr, + memset(&addr, 0, sizeof(struct sockaddr_storage)); + flip_to_n((union sctp_addr *)&addr, &transport->ipaddr); + event = sctp_ulpevent_make_peer_addr_change(asoc, &addr, 0, spc_state, error, GFP_ATOMIC); if (event) sctp_ulpq_tail_event(&asoc->ulpq, event); -- cgit v1.2.2 From 09ef7fecea40c5e4c0dfe35bed3f0ed8da554cf5 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:04:10 -0800 Subject: [SCTP]: Beginning of conversion to net-endian for embedded sctp_addr. Part 1: rename sctp_chunk->source, sctp_sockaddr_entry->a, sctp_transport->ipaddr and sctp_transport->saddr (to ..._h) The next patch will reintroduce these fields and keep them as net-endian mirrors of the original (renamed) ones. Split in two patches to make sure that we hadn't forgotten any instanes. Later in the series we'll eliminate uses of host-endian variants (basically switching users to net-endian counterparts as we progress through that mess). Then host-endian ones will die. Other embedded host-endian sctp_addr will be easier to switch directly, so we leave them alone for now. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 746b0b0f5ace..83318e727905 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -442,7 +442,7 @@ void sctp_assoc_set_primary(struct sctp_association *asoc, asoc->peer.primary_path = transport; /* Set a default msg_name for events. */ - memcpy(&asoc->peer.primary_addr, &transport->ipaddr, + memcpy(&asoc->peer.primary_addr, &transport->ipaddr_h, sizeof(union sctp_addr)); /* If the primary path is changing, assume that the @@ -487,8 +487,8 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc, SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_rm_peer:association %p addr: ", " port: %d\n", asoc, - (&peer->ipaddr), - peer->ipaddr.v4.sin_port); + (&peer->ipaddr_h), + peer->ipaddr_h.v4.sin_port); /* If we are to remove the current retran_path, update it * to the next peer before removing this peer from the list. @@ -669,7 +669,7 @@ void sctp_assoc_del_peer(struct sctp_association *asoc, list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { transport = list_entry(pos, struct sctp_transport, transports); - if (sctp_cmp_addr_exact(addr, &transport->ipaddr)) { + if (sctp_cmp_addr_exact(addr, &transport->ipaddr_h)) { /* Do book keeping for removing the peer and free it. */ sctp_assoc_rm_peer(asoc, transport); break; @@ -689,7 +689,7 @@ struct sctp_transport *sctp_assoc_lookup_paddr( list_for_each(pos, &asoc->peer.transport_addr_list) { t = list_entry(pos, struct sctp_transport, transports); - if (sctp_cmp_addr_exact(address, &t->ipaddr)) + if (sctp_cmp_addr_exact(address, &t->ipaddr_h)) return t; } @@ -733,7 +733,7 @@ void sctp_assoc_control_transport(struct sctp_association *asoc, * user. */ memset(&addr, 0, sizeof(struct sockaddr_storage)); - flip_to_n((union sctp_addr *)&addr, &transport->ipaddr); + flip_to_n((union sctp_addr *)&addr, &transport->ipaddr_h); event = sctp_ulpevent_make_peer_addr_change(asoc, &addr, 0, spc_state, error, GFP_ATOMIC); if (event) @@ -1043,8 +1043,8 @@ void sctp_assoc_update(struct sctp_association *asoc, /* Remove any peer addresses not present in the new association. */ list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { trans = list_entry(pos, struct sctp_transport, transports); - if (!sctp_assoc_lookup_paddr(new, &trans->ipaddr)) - sctp_assoc_del_peer(asoc, &trans->ipaddr); + if (!sctp_assoc_lookup_paddr(new, &trans->ipaddr_h)) + sctp_assoc_del_peer(asoc, &trans->ipaddr_h); } /* If the case is A (association restart), use @@ -1067,8 +1067,8 @@ void sctp_assoc_update(struct sctp_association *asoc, list_for_each(pos, &new->peer.transport_addr_list) { trans = list_entry(pos, struct sctp_transport, transports); - if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr)) - sctp_assoc_add_peer(asoc, &trans->ipaddr, + if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr_h)) + sctp_assoc_add_peer(asoc, &trans->ipaddr_h, GFP_ATOMIC, trans->state); } @@ -1136,8 +1136,8 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc) " %p addr: ", " port: %d\n", asoc, - (&t->ipaddr), - t->ipaddr.v4.sin_port); + (&t->ipaddr_h), + t->ipaddr_h.v4.sin_port); } /* Choose the transport for sending a INIT packet. */ @@ -1161,8 +1161,8 @@ struct sctp_transport *sctp_assoc_choose_init_transport( " %p addr: ", " port: %d\n", asoc, - (&t->ipaddr), - t->ipaddr.v4.sin_port); + (&t->ipaddr_h), + t->ipaddr_h.v4.sin_port); return t; } @@ -1307,7 +1307,7 @@ int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, /* Use scoping rules to determine the subset of addresses from * the endpoint. */ - scope = sctp_scope(&asoc->peer.active_path->ipaddr); + scope = sctp_scope(&asoc->peer.active_path->ipaddr_h); flags = (PF_INET6 == asoc->base.sk->sk_family) ? SCTP_ADDR6_ALLOWED : 0; if (asoc->peer.ipv4_address) flags |= SCTP_ADDR4_PEERSUPP; -- cgit v1.2.2 From 5f242a13e8505e0f3efd3113da6e029f6e7dfa32 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:05:23 -0800 Subject: [SCTP]: Switch ->cmp_addr() and sctp_cmp_addr_exact() to net-endian. instances of ->cmp_addr() are fine with switching both arguments to net-endian; callers other than in sctp_cmp_addr_exact() (both as ->cmp_addr(...) and direct calls of instances) adjusted; sctp_cmp_addr_exact() switched to net-endian itself and adjustment is done in its callers Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 83318e727905..72199d149573 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -666,10 +666,13 @@ void sctp_assoc_del_peer(struct sctp_association *asoc, struct list_head *pos; struct list_head *temp; struct sctp_transport *transport; + union sctp_addr tmp; + + flip_to_n(&tmp, addr); list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { transport = list_entry(pos, struct sctp_transport, transports); - if (sctp_cmp_addr_exact(addr, &transport->ipaddr_h)) { + if (sctp_cmp_addr_exact(&tmp, &transport->ipaddr)) { /* Do book keeping for removing the peer and free it. */ sctp_assoc_rm_peer(asoc, transport); break; @@ -684,12 +687,14 @@ struct sctp_transport *sctp_assoc_lookup_paddr( { struct sctp_transport *t; struct list_head *pos; + union sctp_addr tmp; + flip_to_n(&tmp, address); /* Cycle through all transports searching for a peer address. */ list_for_each(pos, &asoc->peer.transport_addr_list) { t = list_entry(pos, struct sctp_transport, transports); - if (sctp_cmp_addr_exact(address, &t->ipaddr_h)) + if (sctp_cmp_addr_exact(&tmp, &t->ipaddr)) return t; } -- cgit v1.2.2 From 7e1e4a2b9dcc63ac3328f786f9d98bde90c8fc6c Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:05:43 -0800 Subject: [SCTP]: Switch sctp_bind_addr_match() to net-endian. Callers adjusted. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 72199d149573..8d841f16dcbd 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -930,6 +930,8 @@ struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc, const union sctp_addr *paddr) { struct sctp_transport *transport; + union sctp_addr tmp; + flip_to_n(&tmp, laddr); sctp_read_lock(&asoc->base.addr_lock); @@ -939,7 +941,7 @@ struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc, if (!transport) goto out; - if (sctp_bind_addr_match(&asoc->base.bind_addr, laddr, + if (sctp_bind_addr_match(&asoc->base.bind_addr, &tmp, sctp_sk(asoc->base.sk))) goto out; } @@ -1342,12 +1344,10 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc, const union sctp_addr *laddr) { int found; - union sctp_addr tmp; - flip_to_h(&tmp, laddr); sctp_read_lock(&asoc->base.addr_lock); if ((asoc->base.bind_addr.port == ntohs(laddr->v4.sin_port)) && - sctp_bind_addr_match(&asoc->base.bind_addr, &tmp, + sctp_bind_addr_match(&asoc->base.bind_addr, laddr, sctp_sk(asoc->base.sk))) { found = 1; goto out; -- cgit v1.2.2 From acd2bc96e19535fcd74c6eb94532c19c817857bd Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:06:04 -0800 Subject: [SCTP]: Switch ->primary_addr to net-endian. Users adjusted. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 8d841f16dcbd..22c2519d3fd8 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -442,7 +442,7 @@ void sctp_assoc_set_primary(struct sctp_association *asoc, asoc->peer.primary_path = transport; /* Set a default msg_name for events. */ - memcpy(&asoc->peer.primary_addr, &transport->ipaddr_h, + memcpy(&asoc->peer.primary_addr, &transport->ipaddr, sizeof(union sctp_addr)); /* If the primary path is changing, assume that the -- cgit v1.2.2 From 38a03145efcdbbcc60465fdffc0546208a52daf8 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:06:45 -0800 Subject: [SCTP]: sctp_assoc_del_peer() switched to net-endian. Callers adjusted. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 22c2519d3fd8..ab3141f05921 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -666,13 +666,10 @@ void sctp_assoc_del_peer(struct sctp_association *asoc, struct list_head *pos; struct list_head *temp; struct sctp_transport *transport; - union sctp_addr tmp; - - flip_to_n(&tmp, addr); list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { transport = list_entry(pos, struct sctp_transport, transports); - if (sctp_cmp_addr_exact(&tmp, &transport->ipaddr)) { + if (sctp_cmp_addr_exact(addr, &transport->ipaddr)) { /* Do book keeping for removing the peer and free it. */ sctp_assoc_rm_peer(asoc, transport); break; @@ -1051,7 +1048,7 @@ void sctp_assoc_update(struct sctp_association *asoc, list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { trans = list_entry(pos, struct sctp_transport, transports); if (!sctp_assoc_lookup_paddr(new, &trans->ipaddr_h)) - sctp_assoc_del_peer(asoc, &trans->ipaddr_h); + sctp_assoc_del_peer(asoc, &trans->ipaddr); } /* If the case is A (association restart), use -- cgit v1.2.2 From be29681edfbad72167df735e243e8621840dca4f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:07:06 -0800 Subject: [SCTP]: Switch sctp_assoc_lookup_paddr() to net-endian. Callers updated. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index ab3141f05921..3be8b6081a15 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -533,6 +533,8 @@ 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); @@ -551,7 +553,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, addr); + peer = sctp_assoc_lookup_paddr(asoc, &tmp); if (peer) { if (peer->state == SCTP_UNKNOWN) { if (peer_state == SCTP_ACTIVE) @@ -684,14 +686,12 @@ struct sctp_transport *sctp_assoc_lookup_paddr( { struct sctp_transport *t; struct list_head *pos; - union sctp_addr tmp; - flip_to_n(&tmp, address); /* Cycle through all transports searching for a peer address. */ list_for_each(pos, &asoc->peer.transport_addr_list) { 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; } @@ -927,14 +927,15 @@ struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc, const union sctp_addr *paddr) { struct sctp_transport *transport; - union sctp_addr tmp; + union sctp_addr tmp, tmp2; flip_to_n(&tmp, laddr); + flip_to_n(&tmp2, paddr); sctp_read_lock(&asoc->base.addr_lock); if ((asoc->base.bind_addr.port == laddr->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) goto out; @@ -1047,7 +1048,7 @@ void sctp_assoc_update(struct sctp_association *asoc, /* Remove any peer addresses not present in the new association. */ list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) { 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); } @@ -1071,7 +1072,7 @@ void sctp_assoc_update(struct sctp_association *asoc, list_for_each(pos, &new->peer.transport_addr_list) { trans = list_entry(pos, struct sctp_transport, 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, GFP_ATOMIC, trans->state); } -- cgit v1.2.2 From e2fccedb0136205d02e97a41851503e2b96d2a17 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:08:41 -0800 Subject: [SCTP]: Switch sctp_assoc_is_match to net-endian. Along with it, statics in input.c that end up calling it (__sctp_lookup_association, sctp_lookup_association, __sctp_rcv_init_lookup, __sctp_rcv_lookup). Callers are adjusted. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 3be8b6081a15..4bd916c808c1 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -927,19 +927,16 @@ struct sctp_transport *sctp_assoc_is_match(struct sctp_association *asoc, const union sctp_addr *paddr) { struct sctp_transport *transport; - union sctp_addr tmp, tmp2; - flip_to_n(&tmp, laddr); - flip_to_n(&tmp2, paddr); sctp_read_lock(&asoc->base.addr_lock); - if ((asoc->base.bind_addr.port == laddr->v4.sin_port) && - (asoc->peer.port == paddr->v4.sin_port)) { - transport = sctp_assoc_lookup_paddr(asoc, &tmp2); + if ((htons(asoc->base.bind_addr.port) == laddr->v4.sin_port) && + (htons(asoc->peer.port) == paddr->v4.sin_port)) { + transport = sctp_assoc_lookup_paddr(asoc, paddr); if (!transport) goto out; - if (sctp_bind_addr_match(&asoc->base.bind_addr, &tmp, + if (sctp_bind_addr_match(&asoc->base.bind_addr, laddr, sctp_sk(asoc->base.sk))) goto out; } -- cgit v1.2.2 From b488c7dd58f61e07b54e5d286c7b45c43dd52f1a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:10:03 -0800 Subject: [SCTP]: sctp_transport_{init,new}() switched to net-endian. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 4bd916c808c1..7824aeaa3d60 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -564,7 +564,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, return peer; } - peer = sctp_transport_new(addr, gfp); + peer = sctp_transport_new(&tmp, gfp); if (!peer) return NULL; -- cgit v1.2.2 From 4bdf4b5fe22c26750c39fdd2939a5f33df0cc341 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:10:20 -0800 Subject: [SCTP]: Switch sctp_assoc_add_peer() to net-endian. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'net/sctp/associola.c') 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, 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); } -- cgit v1.2.2 From b3f5b3b6654422bb0a6ef745fe4d11a4f01d006a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:22:43 -0800 Subject: [SCTP]: Trivial ->ipaddr_h -> ->ipaddr conversions. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 5b8971be9775..fa7cda4b1813 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -487,8 +487,8 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc, SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_rm_peer:association %p addr: ", " port: %d\n", asoc, - (&peer->ipaddr_h), - peer->ipaddr_h.v4.sin_port); + (&peer->ipaddr), + ntohs(peer->ipaddr.v4.sin_port)); /* If we are to remove the current retran_path, update it * to the next peer before removing this peer from the list. @@ -1136,8 +1136,8 @@ void sctp_assoc_update_retran_path(struct sctp_association *asoc) " %p addr: ", " port: %d\n", asoc, - (&t->ipaddr_h), - t->ipaddr_h.v4.sin_port); + (&t->ipaddr), + ntohs(t->ipaddr.v4.sin_port)); } /* Choose the transport for sending a INIT packet. */ @@ -1161,8 +1161,8 @@ struct sctp_transport *sctp_assoc_choose_init_transport( " %p addr: ", " port: %d\n", asoc, - (&t->ipaddr_h), - t->ipaddr_h.v4.sin_port); + (&t->ipaddr), + ntohs(t->ipaddr.v4.sin_port)); return t; } @@ -1307,7 +1307,7 @@ int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, /* Use scoping rules to determine the subset of addresses from * the endpoint. */ - scope = sctp_scope(&asoc->peer.active_path->ipaddr_h); + scope = sctp_scope(&asoc->peer.active_path->ipaddr); flags = (PF_INET6 == asoc->base.sk->sk_family) ? SCTP_ADDR6_ALLOWED : 0; if (asoc->peer.ipv4_address) flags |= SCTP_ADDR4_PEERSUPP; -- cgit v1.2.2 From 8cec6b80664eb20b0c033fd20d2c7ed15621437f Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:23:01 -0800 Subject: [SCTP]: We need to be careful when copying to sockaddr_storage. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/associola.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/sctp/associola.c') diff --git a/net/sctp/associola.c b/net/sctp/associola.c index fa7cda4b1813..39471d3b31b9 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -733,7 +733,7 @@ void sctp_assoc_control_transport(struct sctp_association *asoc, * user. */ memset(&addr, 0, sizeof(struct sockaddr_storage)); - flip_to_n((union sctp_addr *)&addr, &transport->ipaddr_h); + memcpy(&addr, &transport->ipaddr, transport->af_specific->sockaddr_len); event = sctp_ulpevent_make_peer_addr_change(asoc, &addr, 0, spc_state, error, GFP_ATOMIC); if (event) -- cgit v1.2.2