]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[SCTP]: Switch ->cmp_addr() and sctp_cmp_addr_exact() to net-endian.
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 21 Nov 2006 01:05:23 +0000 (17:05 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sun, 3 Dec 2006 05:26:32 +0000 (21:26 -0800)
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 <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/associola.c
net/sctp/bind_addr.c
net/sctp/proc.c
net/sctp/protocol.c
net/sctp/sm_make_chunk.c
net/sctp/sm_sideeffect.c
net/sctp/sm_statefuns.c
net/sctp/socket.c

index 83318e727905acede05efd06921505bd97d893ad..72199d149573cd6570181d74c869d652b207f416 100644 (file)
@@ -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;
        }
 
index 2b36e4238170a51678ac34c0c889266b153b8e96..9085e531d575c275b0a63a8b5554bad4e36a3b2a 100644 (file)
@@ -181,10 +181,13 @@ int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr)
 {
        struct list_head *pos, *temp;
        struct sctp_sockaddr_entry *addr;
+       union sctp_addr tmp;
+
+       flip_to_n(&tmp, del_addr);
 
        list_for_each_safe(pos, temp, &bp->address_list) {
                addr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               if (sctp_cmp_addr_exact(&addr->a_h, del_addr)) {
+               if (sctp_cmp_addr_exact(&addr->a, &tmp)) {
                        /* Found the exact match. */
                        list_del(pos);
                        kfree(addr);
@@ -304,10 +307,12 @@ int sctp_bind_addr_match(struct sctp_bind_addr *bp,
 {
        struct sctp_sockaddr_entry *laddr;
        struct list_head *pos;
+       union sctp_addr tmp;
 
+       flip_to_n(&tmp, addr);
        list_for_each(pos, &bp->address_list) {
                laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               if (opt->pf->cmp_addr(&laddr->a_h, addr, opt))
+               if (opt->pf->cmp_addr(&laddr->a, &tmp, opt))
                        return 1;
        }
 
@@ -334,14 +339,12 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr     *bp,
                
                addr_buf = (union sctp_addr *)addrs;
                for (i = 0; i < addrcnt; i++) {
-                       union sctp_addr tmp;
                        addr = (union sctp_addr *)addr_buf;
                        af = sctp_get_af_specific(addr->v4.sin_family);
                        if (!af) 
                                return NULL;
-                       flip_to_h(&tmp, addr);
 
-                       if (opt->pf->cmp_addr(&laddr->a_h, &tmp, opt))
+                       if (opt->pf->cmp_addr(&laddr->a, addr, opt))
                                break;
 
                        addr_buf += af->sockaddr_len;
index bf0144ed3e3ad7fc64a0da6f7c6304002d77faa0..04faa4a706d42de62cc5605840ad7fee78c79101 100644 (file)
@@ -155,17 +155,17 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo
        if (epb->type == SCTP_EP_TYPE_ASSOCIATION) {
            asoc = sctp_assoc(epb);
            peer = asoc->peer.primary_path;
-           primary = &peer->saddr_h;
+           primary = &peer->saddr;
        }
 
        list_for_each(pos, &epb->bind_addr.address_list) {
                laddr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               addr = (union sctp_addr *)&laddr->a_h;
+               addr = &laddr->a;
                af = sctp_get_af_specific(addr->sa.sa_family);
                if (primary && af->cmp_addr(addr, primary)) {
                        seq_printf(seq, "*");
                }
-               af->seq_dump_addr(seq, &laddr->a);
+               af->seq_dump_addr(seq, addr);
        }
 }
 
@@ -175,17 +175,19 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa
        struct list_head *pos;
        struct sctp_transport *transport;
        union sctp_addr *addr, *primary;
+       union sctp_addr tmp;
        struct sctp_af *af;
 
        primary = &(assoc->peer.primary_addr);
+       flip_to_n(&tmp, primary);
        list_for_each(pos, &assoc->peer.transport_addr_list) {
                transport = list_entry(pos, struct sctp_transport, transports);
-               addr = (union sctp_addr *)&transport->ipaddr_h;
+               addr = &transport->ipaddr;
                af = sctp_get_af_specific(addr->sa.sa_family);
-               if (af->cmp_addr(addr, primary)) {
+               if (af->cmp_addr(addr, &tmp)) {
                        seq_printf(seq, "*");
                }
-               af->seq_dump_addr(seq, &transport->ipaddr);
+               af->seq_dump_addr(seq, addr);
        }
 }
 
index 3632740450324065768f53182fff174b420dd77b..2db140e901d0cf9a0ae181bbc22f8ed8e7c40e86 100644 (file)
@@ -478,12 +478,14 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
                 */
                sctp_read_lock(addr_lock);
                list_for_each(pos, &bp->address_list) {
+                       union sctp_addr tmp;
                        laddr = list_entry(pos, struct sctp_sockaddr_entry,
                                           list);
                        if (!laddr->use_as_src)
                                continue;
                        sctp_v4_dst_saddr(&dst_saddr, dst, bp->port);
-                       if (sctp_v4_cmp_addr(&dst_saddr, &laddr->a_h))
+                       flip_to_n(&tmp, &dst_saddr);
+                       if (sctp_v4_cmp_addr(&tmp, &laddr->a))
                                goto out_unlock;
                }
                sctp_read_unlock(addr_lock);
index b8e0f72b319fb28c9966a94946645b0b00915f4a..ee907ea7eed109ded5fbc00292f3cdd936cca781 100644 (file)
@@ -2414,7 +2414,8 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
        union sctp_addr addr;
        struct list_head *pos;
        union sctp_addr_param *addr_param;
-                                
+       union sctp_addr tmp, tmp_addr;
+
        addr_param = (union sctp_addr_param *)
                        ((void *)asconf_param + sizeof(sctp_addip_param_t));
 
@@ -2423,6 +2424,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
                return SCTP_ERROR_INV_PARAM;
 
        af->from_addr_param(&addr, addr_param, asoc->peer.port, 0);
+       flip_to_n(&tmp_addr, &addr);
        switch (asconf_param->param_hdr.type) {
        case SCTP_PARAM_ADD_IP:
                /* ADDIP 4.3 D9) If an endpoint receives an ADD IP address
@@ -2457,7 +2459,8 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
                 * an Error Cause TLV set to the new error code 'Request to
                 * Delete Source IP Address'
                 */
-               if (sctp_cmp_addr_exact(sctp_source(asconf), &addr))
+               flip_to_n(&tmp, sctp_source(asconf));
+               if (sctp_cmp_addr_exact(&tmp, &tmp_addr))
                        return SCTP_ERROR_DEL_SRC_IP;
 
                sctp_assoc_del_peer(asoc, &addr);
@@ -2581,6 +2584,7 @@ static int sctp_asconf_param_success(struct sctp_association *asoc,
        struct sctp_transport *transport;
        struct sctp_sockaddr_entry *saddr;
        int retval = 0;
+       union sctp_addr tmp;
 
        addr_param = (union sctp_addr_param *)
                        ((void *)asconf_param + sizeof(sctp_addip_param_t));
@@ -2588,6 +2592,7 @@ static int sctp_asconf_param_success(struct sctp_association *asoc,
        /* We have checked the packet before, so we do not check again. */
        af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type));
        af->from_addr_param(&addr, addr_param, bp->port, 0);
+       flip_to_n(&tmp, &addr);
 
        switch (asconf_param->param_hdr.type) {
        case SCTP_PARAM_ADD_IP:
@@ -2595,7 +2600,7 @@ static int sctp_asconf_param_success(struct sctp_association *asoc,
                sctp_write_lock(&asoc->base.addr_lock);
                list_for_each(pos, &bp->address_list) {
                        saddr = list_entry(pos, struct sctp_sockaddr_entry, list);
-                       if (sctp_cmp_addr_exact(&saddr->a_h, &addr))
+                       if (sctp_cmp_addr_exact(&saddr->a, &tmp))
                                saddr->use_as_src = 1;
                }
                sctp_write_unlock(&asoc->base.addr_lock);
index e1c5cddf32da58fb890c350b8c21d10b6dfcb18e..3d9213dfaa10f7a052c47d75aa2250961c95eaa6 100644 (file)
@@ -830,11 +830,13 @@ static void sctp_cmd_del_non_primary(struct sctp_association *asoc)
        struct sctp_transport *t;
        struct list_head *pos;
        struct list_head *temp;
+       union sctp_addr tmp;
+       flip_to_n(&tmp, &asoc->peer.primary_addr);
 
        list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {
                t = list_entry(pos, struct sctp_transport, transports);
-               if (!sctp_cmp_addr_exact(&t->ipaddr_h,
-                                        &asoc->peer.primary_addr)) {
+               if (!sctp_cmp_addr_exact(&t->ipaddr,
+                                        &tmp)) {
                        sctp_assoc_del_peer(asoc, &t->ipaddr_h);
                }
        }
index f460727675492646a7766be612ef1b2390b05f52..ac776fd206673fda28cf16bd9df834ee691666c5 100644 (file)
@@ -1167,8 +1167,8 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc,
                list_for_each(pos2, &asoc->peer.transport_addr_list) {
                        addr = list_entry(pos2, struct sctp_transport,
                                          transports);
-                       if (sctp_cmp_addr_exact(&new_addr->ipaddr_h,
-                                               &addr->ipaddr_h)) {
+                       if (sctp_cmp_addr_exact(&new_addr->ipaddr,
+                                               &addr->ipaddr)) {
                                found = 1;
                                break;
                        }
index 459f32c5c3ae7f4b17f88e85de172d4fde282f3f..e03ba9055eb1986ddb813cd9ceb20d08d24e1f80 100644 (file)
@@ -693,7 +693,6 @@ static int sctp_send_asconf_del_ip(struct sock              *sk,
        struct sctp_bind_addr   *bp;
        struct sctp_chunk       *chunk;
        union sctp_addr         *laddr;
-       union sctp_addr         saveaddr;
        void                    *addr_buf;
        struct sctp_af          *af;
        struct list_head        *pos, *pos1;
@@ -773,13 +772,11 @@ static int sctp_send_asconf_del_ip(struct sock            *sk,
                for (i = 0; i < addrcnt; i++) {
                        laddr = (union sctp_addr *)addr_buf;
                        af = sctp_get_af_specific(laddr->v4.sin_family);
-                       memcpy(&saveaddr, laddr, af->sockaddr_len);
-                       saveaddr.v4.sin_port = ntohs(saveaddr.v4.sin_port);
                        list_for_each(pos1, &bp->address_list) {
                                saddr = list_entry(pos1,
                                                   struct sctp_sockaddr_entry,
                                                   list);
-                               if (sctp_cmp_addr_exact(&saddr->a_h, &saveaddr))
+                               if (sctp_cmp_addr_exact(&saddr->a, laddr))
                                        saddr->use_as_src = 0;
                        }
                        addr_buf += af->sockaddr_len;