aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-11-20 20:10:38 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-03 00:26:47 -0500
commit5ab7b859ab58e3479a5a66e383ecd6bc447f6c1d (patch)
treef876ff7c51eb7d5a2d3fdb8dcb97b6b19d79dde7 /net
parent4bdf4b5fe22c26750c39fdd2939a5f33df0cc341 (diff)
[SCTP]: Switch sctp_add_bind_addr() 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')
-rw-r--r--net/sctp/bind_addr.c16
-rw-r--r--net/sctp/protocol.c2
-rw-r--r--net/sctp/sm_make_chunk.c4
-rw-r--r--net/sctp/socket.c5
4 files changed, 15 insertions, 12 deletions
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index eafdd11152d0..eb3a5e25777d 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -155,15 +155,15 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
155 if (!addr) 155 if (!addr)
156 return -ENOMEM; 156 return -ENOMEM;
157 157
158 memcpy(&addr->a_h, new, sizeof(*new)); 158 memcpy(&addr->a, new, sizeof(*new));
159 159
160 /* Fix up the port if it has not yet been set. 160 /* Fix up the port if it has not yet been set.
161 * Both v4 and v6 have the port at the same offset. 161 * Both v4 and v6 have the port at the same offset.
162 */ 162 */
163 if (!addr->a_h.v4.sin_port) 163 if (!addr->a.v4.sin_port)
164 addr->a_h.v4.sin_port = bp->port; 164 addr->a.v4.sin_port = htons(bp->port);
165 165
166 flip_to_n(&addr->a, &addr->a_h); 166 flip_to_h(&addr->a_h, &addr->a);
167 167
168 addr->use_as_src = use_as_src; 168 addr->use_as_src = use_as_src;
169 169
@@ -264,6 +264,7 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list,
264 int retval = 0; 264 int retval = 0;
265 int len; 265 int len;
266 struct sctp_af *af; 266 struct sctp_af *af;
267 union sctp_addr tmp;
267 268
268 /* Convert the raw address to standard address format */ 269 /* Convert the raw address to standard address format */
269 while (addrs_len) { 270 while (addrs_len) {
@@ -278,7 +279,8 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list,
278 } 279 }
279 280
280 af->from_addr_param(&addr, rawaddr, port, 0); 281 af->from_addr_param(&addr, rawaddr, port, 0);
281 retval = sctp_add_bind_addr(bp, &addr, 1, gfp); 282 flip_to_n(&tmp, &addr);
283 retval = sctp_add_bind_addr(bp, &tmp, 1, gfp);
282 if (retval) { 284 if (retval) {
283 /* Can't finish building the list, clean up. */ 285 /* Can't finish building the list, clean up. */
284 sctp_bind_addr_clean(bp); 286 sctp_bind_addr_clean(bp);
@@ -358,6 +360,8 @@ static int sctp_copy_one_addr(struct sctp_bind_addr *dest,
358 int flags) 360 int flags)
359{ 361{
360 int error = 0; 362 int error = 0;
363 union sctp_addr tmp;
364 flip_to_n(&tmp, addr);
361 365
362 if (sctp_is_any(addr)) { 366 if (sctp_is_any(addr)) {
363 error = sctp_copy_local_addr_list(dest, scope, gfp, flags); 367 error = sctp_copy_local_addr_list(dest, scope, gfp, flags);
@@ -371,7 +375,7 @@ static int sctp_copy_one_addr(struct sctp_bind_addr *dest,
371 (((AF_INET6 == addr->sa.sa_family) && 375 (((AF_INET6 == addr->sa.sa_family) &&
372 (flags & SCTP_ADDR6_ALLOWED) && 376 (flags & SCTP_ADDR6_ALLOWED) &&
373 (flags & SCTP_ADDR6_PEERSUPP)))) 377 (flags & SCTP_ADDR6_PEERSUPP))))
374 error = sctp_add_bind_addr(dest, addr, 1, gfp); 378 error = sctp_add_bind_addr(dest, &tmp, 1, gfp);
375 } 379 }
376 380
377 return error; 381 return error;
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index d08bafd4439e..a6bcbf560e36 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -234,7 +234,7 @@ int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope,
234 (((AF_INET6 == addr->a_h.sa.sa_family) && 234 (((AF_INET6 == addr->a_h.sa.sa_family) &&
235 (copy_flags & SCTP_ADDR6_ALLOWED) && 235 (copy_flags & SCTP_ADDR6_ALLOWED) &&
236 (copy_flags & SCTP_ADDR6_PEERSUPP)))) { 236 (copy_flags & SCTP_ADDR6_PEERSUPP)))) {
237 error = sctp_add_bind_addr(bp, &addr->a_h, 1, 237 error = sctp_add_bind_addr(bp, &addr->a, 1,
238 GFP_ATOMIC); 238 GFP_ATOMIC);
239 if (error) 239 if (error)
240 goto end_copy; 240 goto end_copy;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 2c887d3f3911..46cfcca5e41b 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1507,7 +1507,9 @@ no_hmac:
1507 1507
1508 /* Also, add the destination address. */ 1508 /* Also, add the destination address. */
1509 if (list_empty(&retval->base.bind_addr.address_list)) { 1509 if (list_empty(&retval->base.bind_addr.address_list)) {
1510 sctp_add_bind_addr(&retval->base.bind_addr, &chunk->dest, 1, 1510 union sctp_addr tmp;
1511 flip_to_n(&tmp, &chunk->dest);
1512 sctp_add_bind_addr(&retval->base.bind_addr, &tmp, 1,
1511 GFP_ATOMIC); 1513 GFP_ATOMIC);
1512 } 1514 }
1513 1515
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 3dd7ada8026c..d09589a51c44 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -313,7 +313,6 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
313 struct sctp_af *af; 313 struct sctp_af *af;
314 unsigned short snum; 314 unsigned short snum;
315 int ret = 0; 315 int ret = 0;
316 union sctp_addr tmp;
317 316
318 /* Common sockaddr verification. */ 317 /* Common sockaddr verification. */
319 af = sctp_sockaddr_af(sp, addr, len); 318 af = sctp_sockaddr_af(sp, addr, len);
@@ -369,8 +368,7 @@ SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
369 sctp_write_lock(&ep->base.addr_lock); 368 sctp_write_lock(&ep->base.addr_lock);
370 369
371 /* Use GFP_ATOMIC since BHs are disabled. */ 370 /* Use GFP_ATOMIC since BHs are disabled. */
372 flip_to_h(&tmp, addr); 371 ret = sctp_add_bind_addr(bp, addr, 1, GFP_ATOMIC);
373 ret = sctp_add_bind_addr(bp, &tmp, 1, GFP_ATOMIC);
374 sctp_write_unlock(&ep->base.addr_lock); 372 sctp_write_unlock(&ep->base.addr_lock);
375 sctp_local_bh_enable(); 373 sctp_local_bh_enable();
376 374
@@ -572,7 +570,6 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
572 addr = (union sctp_addr *)addr_buf; 570 addr = (union sctp_addr *)addr_buf;
573 af = sctp_get_af_specific(addr->v4.sin_family); 571 af = sctp_get_af_specific(addr->v4.sin_family);
574 memcpy(&saveaddr, addr, af->sockaddr_len); 572 memcpy(&saveaddr, addr, af->sockaddr_len);
575 saveaddr.v4.sin_port = ntohs(saveaddr.v4.sin_port);
576 retval = sctp_add_bind_addr(bp, &saveaddr, 0, 573 retval = sctp_add_bind_addr(bp, &saveaddr, 0,
577 GFP_ATOMIC); 574 GFP_ATOMIC);
578 addr_buf += af->sockaddr_len; 575 addr_buf += af->sockaddr_len;