From b68dbcab1dc70938fa5516d0ee82c0bf94e9a768 Mon Sep 17 00:00:00 2001 From: Vlad Yasevich Date: Thu, 9 Nov 2006 16:29:57 -0800 Subject: [SCTP]: Fix warning An alternate solution would be to make the digest a pointer, allocate it in sctp_endpoint_init() and free it in sctp_endpoint_destroy(). I guess I should have originally done it this way... CC [M] net/sctp/sm_make_chunk.o net/sctp/sm_make_chunk.c: In function 'sctp_unpack_cookie': net/sctp/sm_make_chunk.c:1358: warning: initialization discards qualifiers from pointer target type The reason is that sctp_unpack_cookie() takes a const struct sctp_endpoint and modifies the digest in it (digest being embedded in the struct, not a pointer). Make digest a pointer to fix this warning. Signed-off-by: Vlad Yasevich Acked-by: Sridhar Samudrala Signed-off-by: David S. Miller --- net/sctp/endpointola.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'net/sctp/endpointola.c') diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 9b6b394b66f6..090f2b2a0cab 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -72,6 +72,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, { memset(ep, 0, sizeof(struct sctp_endpoint)); + ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp); + if (!ep->digest) + return NULL; + /* Initialize the base structure. */ /* What type of endpoint are we? */ ep->base.type = SCTP_EP_TYPE_SOCKET; @@ -182,6 +186,9 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep) /* Free up the HMAC transform. */ crypto_free_hash(sctp_sk(ep->base.sk)->hmac); + /* Free the digest buffer */ + kfree(ep->digest); + /* Cleanup. */ sctp_inq_free(&ep->base.inqueue); sctp_bind_addr_free(&ep->base.bind_addr); -- cgit v1.2.3 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 --- include/net/sctp/structs.h | 8 ++++---- net/sctp/associola.c | 30 +++++++++++++++--------------- net/sctp/bind_addr.c | 22 +++++++++++----------- net/sctp/endpointola.c | 2 +- net/sctp/ipv6.c | 24 ++++++++++++------------ net/sctp/proc.c | 6 +++--- net/sctp/protocol.c | 20 ++++++++++---------- net/sctp/sm_make_chunk.c | 8 ++++---- net/sctp/sm_sideeffect.c | 8 ++++---- net/sctp/sm_statefuns.c | 8 ++++---- net/sctp/socket.c | 32 ++++++++++++++++---------------- net/sctp/transport.c | 14 +++++++------- 12 files changed, 91 insertions(+), 91 deletions(-) (limited to 'net/sctp/endpointola.c') diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 2aa61ac9a9f3..953a73f9689c 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -713,7 +713,7 @@ struct sctp_chunk { unsigned long sent_at; /* What is the origin IP address for this chunk? */ - union sctp_addr source; + union sctp_addr source_h; /* Destination address for this chunk. */ union sctp_addr dest; @@ -756,7 +756,7 @@ const union sctp_addr *sctp_source(const struct sctp_chunk *chunk); /* This is a structure for holding either an IPv6 or an IPv4 address. */ struct sctp_sockaddr_entry { struct list_head list; - union sctp_addr a; + union sctp_addr a_h; __u8 use_as_src; }; @@ -842,7 +842,7 @@ struct sctp_transport { int dead; /* This is the peer's IP address and port. */ - union sctp_addr ipaddr; + union sctp_addr ipaddr_h; /* These are the functions we call to handle LLP stuff. */ struct sctp_af *af_specific; @@ -900,7 +900,7 @@ struct sctp_transport { /* Destination */ struct dst_entry *dst; /* Source address. */ - union sctp_addr saddr; + union sctp_addr saddr_h; /* When was the last time(in jiffies) that a data packet was sent on * this transport? This is used to adjust the cwnd when the transport 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; diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c index 23b5b664a8a0..b8115cb31ae3 100644 --- a/net/sctp/bind_addr.c +++ b/net/sctp/bind_addr.c @@ -77,7 +77,7 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest, /* Extract the addresses which are relevant for this scope. */ list_for_each(pos, &src->address_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); - error = sctp_copy_one_addr(dest, &addr->a, scope, + error = sctp_copy_one_addr(dest, &addr->a_h, scope, gfp, flags); if (error < 0) goto out; @@ -91,7 +91,7 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest, list_for_each(pos, &src->address_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); - error = sctp_copy_one_addr(dest, &addr->a, + error = sctp_copy_one_addr(dest, &addr->a_h, SCTP_SCOPE_LINK, gfp, flags); if (error < 0) @@ -155,13 +155,13 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new, if (!addr) return -ENOMEM; - memcpy(&addr->a, new, sizeof(*new)); + memcpy(&addr->a_h, new, sizeof(*new)); /* Fix up the port if it has not yet been set. * Both v4 and v6 have the port at the same offset. */ - if (!addr->a.v4.sin_port) - addr->a.v4.sin_port = bp->port; + if (!addr->a_h.v4.sin_port) + addr->a_h.v4.sin_port = bp->port; addr->use_as_src = use_as_src; @@ -182,7 +182,7 @@ int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *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, del_addr)) { + if (sctp_cmp_addr_exact(&addr->a_h, del_addr)) { /* Found the exact match. */ list_del(pos); kfree(addr); @@ -237,8 +237,8 @@ union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp, list_for_each(pos, &bp->address_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); - af = sctp_get_af_specific(addr->a.v4.sin_family); - len = af->to_addr_param(&addr->a, &rawaddr); + af = sctp_get_af_specific(addr->a_h.v4.sin_family); + len = af->to_addr_param(&addr->a_h, &rawaddr); memcpy(addrparms.v, &rawaddr, len); addrparms.v += len; addrparms_len += len; @@ -305,7 +305,7 @@ int sctp_bind_addr_match(struct sctp_bind_addr *bp, list_for_each(pos, &bp->address_list) { laddr = list_entry(pos, struct sctp_sockaddr_entry, list); - if (opt->pf->cmp_addr(&laddr->a, addr, opt)) + if (opt->pf->cmp_addr(&laddr->a_h, addr, opt)) return 1; } @@ -339,13 +339,13 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, return NULL; flip_to_h(&tmp, addr); - if (opt->pf->cmp_addr(&laddr->a, &tmp, opt)) + if (opt->pf->cmp_addr(&laddr->a_h, &tmp, opt)) break; addr_buf += af->sockaddr_len; } if (i == addrcnt) - return &laddr->a; + return &laddr->a_h; } return NULL; diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 090f2b2a0cab..75904b037ec6 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -305,7 +305,7 @@ int sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep, bp = &ep->base.bind_addr; list_for_each(pos, &bp->address_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); - if (sctp_has_association(&addr->a, paddr)) { + if (sctp_has_association(&addr->a_h, paddr)) { sctp_read_unlock(&ep->base.addr_lock); return 1; } diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 1f9f5ec07595..e533970fa335 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -161,17 +161,17 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport, /* Fill in the dest address from the route entry passed with the skb * and the source address from the transport. */ - ipv6_addr_copy(&fl.fl6_dst, &transport->ipaddr.v6.sin6_addr); - ipv6_addr_copy(&fl.fl6_src, &transport->saddr.v6.sin6_addr); + ipv6_addr_copy(&fl.fl6_dst, &transport->ipaddr_h.v6.sin6_addr); + ipv6_addr_copy(&fl.fl6_src, &transport->saddr_h.v6.sin6_addr); fl.fl6_flowlabel = np->flow_label; IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel); if (ipv6_addr_type(&fl.fl6_src) & IPV6_ADDR_LINKLOCAL) - fl.oif = transport->saddr.v6.sin6_scope_id; + fl.oif = transport->saddr_h.v6.sin6_scope_id; else fl.oif = sk->sk_bound_dev_if; fl.fl_ip_sport = inet_sk(sk)->sport; - fl.fl_ip_dport = transport->ipaddr.v6.sin6_port; + fl.fl_ip_dport = transport->ipaddr_h.v6.sin6_port; if (np->opt && np->opt->srcrt) { struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt; @@ -290,11 +290,11 @@ static void sctp_v6_get_saddr(struct sctp_association *asoc, list_for_each(pos, &bp->address_list) { laddr = list_entry(pos, struct sctp_sockaddr_entry, list); if ((laddr->use_as_src) && - (laddr->a.sa.sa_family == AF_INET6) && - (scope <= sctp_scope(&laddr->a))) { - bmatchlen = sctp_v6_addr_match_len(daddr, &laddr->a); + (laddr->a_h.sa.sa_family == AF_INET6) && + (scope <= sctp_scope(&laddr->a_h))) { + bmatchlen = sctp_v6_addr_match_len(daddr, &laddr->a_h); if (!baddr || (matchlen < bmatchlen)) { - baddr = &laddr->a; + baddr = &laddr->a_h; matchlen = bmatchlen; } } @@ -332,10 +332,10 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist, /* Add the address to the local list. */ addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC); if (addr) { - addr->a.v6.sin6_family = AF_INET6; - addr->a.v6.sin6_port = 0; - addr->a.v6.sin6_addr = ifp->addr; - addr->a.v6.sin6_scope_id = dev->ifindex; + addr->a_h.v6.sin6_family = AF_INET6; + addr->a_h.v6.sin6_port = 0; + addr->a_h.v6.sin6_addr = ifp->addr; + addr->a_h.v6.sin6_scope_id = dev->ifindex; INIT_LIST_HEAD(&addr->list); list_add_tail(&addr->list, addrlist); } diff --git a/net/sctp/proc.c b/net/sctp/proc.c index 7f49e769080e..47ccec565a24 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c @@ -155,12 +155,12 @@ 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; + primary = &peer->saddr_h; } list_for_each(pos, &epb->bind_addr.address_list) { laddr = list_entry(pos, struct sctp_sockaddr_entry, list); - addr = (union sctp_addr *)&laddr->a; + addr = (union sctp_addr *)&laddr->a_h; af = sctp_get_af_specific(addr->sa.sa_family); if (primary && af->cmp_addr(addr, primary)) { seq_printf(seq, "*"); @@ -180,7 +180,7 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa primary = &(assoc->peer.primary_addr); list_for_each(pos, &assoc->peer.transport_addr_list) { transport = list_entry(pos, struct sctp_transport, transports); - addr = (union sctp_addr *)&transport->ipaddr; + addr = (union sctp_addr *)&transport->ipaddr_h; af = sctp_get_af_specific(addr->sa.sa_family); if (af->cmp_addr(addr, primary)) { seq_printf(seq, "*"); diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 4310e7fac443..20883ffd51d9 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c @@ -150,9 +150,9 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist, /* Add the address to the local list. */ addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC); if (addr) { - addr->a.v4.sin_family = AF_INET; - addr->a.v4.sin_port = 0; - addr->a.v4.sin_addr.s_addr = ifa->ifa_local; + addr->a_h.v4.sin_family = AF_INET; + addr->a_h.v4.sin_port = 0; + addr->a_h.v4.sin_addr.s_addr = ifa->ifa_local; list_add_tail(&addr->list, addrlist); } } @@ -223,17 +223,17 @@ int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope, sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); list_for_each(pos, &sctp_local_addr_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); - if (sctp_in_scope(&addr->a, scope)) { + if (sctp_in_scope(&addr->a_h, scope)) { /* Now that the address is in scope, check to see if * the address type is really supported by the local * sock as well as the remote peer. */ - if ((((AF_INET == addr->a.sa.sa_family) && + if ((((AF_INET == addr->a_h.sa.sa_family) && (copy_flags & SCTP_ADDR4_PEERSUPP))) || - (((AF_INET6 == addr->a.sa.sa_family) && + (((AF_INET6 == addr->a_h.sa.sa_family) && (copy_flags & SCTP_ADDR6_ALLOWED) && (copy_flags & SCTP_ADDR6_PEERSUPP)))) { - error = sctp_add_bind_addr(bp, &addr->a, 1, + error = sctp_add_bind_addr(bp, &addr->a_h, 1, GFP_ATOMIC); if (error) goto end_copy; @@ -482,7 +482,7 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc, if (!laddr->use_as_src) continue; sctp_v4_dst_saddr(&dst_saddr, dst, bp->port); - if (sctp_v4_cmp_addr(&dst_saddr, &laddr->a)) + if (sctp_v4_cmp_addr(&dst_saddr, &laddr->a_h)) goto out_unlock; } sctp_read_unlock(addr_lock); @@ -502,8 +502,8 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc, laddr = list_entry(pos, struct sctp_sockaddr_entry, list); if ((laddr->use_as_src) && - (AF_INET == laddr->a.sa.sa_family)) { - fl.fl4_src = laddr->a.v4.sin_addr.s_addr; + (AF_INET == laddr->a_h.sa.sa_family)) { + fl.fl4_src = laddr->a_h.v4.sin_addr.s_addr; if (!ip_route_output_key(&rt, &fl)) { dst = &rt->u.dst; goto out_unlock; diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index ccbba6b24d1d..13109cfc3ae5 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -1031,7 +1031,7 @@ nodata: void sctp_init_addrs(struct sctp_chunk *chunk, union sctp_addr *src, union sctp_addr *dest) { - memcpy(&chunk->source, src, sizeof(union sctp_addr)); + memcpy(&chunk->source_h, src, sizeof(union sctp_addr)); memcpy(&chunk->dest, dest, sizeof(union sctp_addr)); } @@ -1040,10 +1040,10 @@ const union sctp_addr *sctp_source(const struct sctp_chunk *chunk) { /* If we have a known transport, use that. */ if (chunk->transport) { - return &chunk->transport->ipaddr; + return &chunk->transport->ipaddr_h; } else { /* Otherwise, extract it from the IP header. */ - return &chunk->source; + return &chunk->source_h; } } @@ -2594,7 +2594,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, &addr)) + if (sctp_cmp_addr_exact(&saddr->a_h, &addr)) saddr->use_as_src = 1; } sctp_write_unlock(&asoc->base.addr_lock); diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 2423b8ef9ce0..e1c5cddf32da 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c @@ -441,8 +441,8 @@ static void sctp_do_8_2_transport_strike(struct sctp_association *asoc, SCTP_DEBUG_PRINTK_IPADDR("transport_strike:association %p", " transport IP: port:%d failed.\n", asoc, - (&transport->ipaddr), - transport->ipaddr.v4.sin_port); + (&transport->ipaddr_h), + transport->ipaddr_h.v4.sin_port); sctp_assoc_control_transport(asoc, transport, SCTP_TRANSPORT_DOWN, SCTP_FAILED_THRESHOLD); @@ -833,9 +833,9 @@ static void sctp_cmd_del_non_primary(struct sctp_association *asoc) 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, + if (!sctp_cmp_addr_exact(&t->ipaddr_h, &asoc->peer.primary_addr)) { - sctp_assoc_del_peer(asoc, &t->ipaddr); + sctp_assoc_del_peer(asoc, &t->ipaddr_h); } } diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index b70e3258b6d3..f46072767549 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -852,7 +852,7 @@ static sctp_disposition_t sctp_sf_heartbeat(const struct sctp_endpoint *ep, hbinfo.param_hdr.type = SCTP_PARAM_HEARTBEAT_INFO; hbinfo.param_hdr.length = htons(sizeof(sctp_sender_hb_info_t)); - hbinfo.daddr = transport->ipaddr; + hbinfo.daddr = transport->ipaddr_h; hbinfo.sent_at = jiffies; hbinfo.hb_nonce = transport->hb_nonce; @@ -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, - &addr->ipaddr)) { + if (sctp_cmp_addr_exact(&new_addr->ipaddr_h, + &addr->ipaddr_h)) { found = 1; break; } @@ -1179,7 +1179,7 @@ static int sctp_sf_check_restart_addrs(const struct sctp_association *new_asoc, /* If a new address was added, ABORT the sender. */ if (!found && new_addr) { - sctp_sf_send_restart_abort(&new_addr->ipaddr, init, commands); + sctp_sf_send_restart_abort(&new_addr->ipaddr_h, init, commands); } /* Return success if all addresses were found. */ diff --git a/net/sctp/socket.c b/net/sctp/socket.c index b6e038a387c2..459f32c5c3ae 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -551,7 +551,7 @@ static int sctp_send_asconf_add_ip(struct sock *sk, laddr = list_entry(p, struct sctp_sockaddr_entry, list); sctp_read_unlock(&asoc->base.addr_lock); - chunk = sctp_make_asconf_update_ip(asoc, &laddr->a, addrs, + chunk = sctp_make_asconf_update_ip(asoc, &laddr->a_h, addrs, addrcnt, SCTP_PARAM_ADD_IP); if (!chunk) { retval = -ENOMEM; @@ -779,7 +779,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk, saddr = list_entry(pos1, struct sctp_sockaddr_entry, list); - if (sctp_cmp_addr_exact(&saddr->a, &saveaddr)) + if (sctp_cmp_addr_exact(&saddr->a_h, &saveaddr)) saddr->use_as_src = 0; } addr_buf += af->sockaddr_len; @@ -3218,7 +3218,7 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len, status.sstat_fragmentation_point = asoc->frag_point; status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc); flip_to_n((union sctp_addr *)&status.sstat_primary.spinfo_address, - &transport->ipaddr); + &transport->ipaddr_h); /* Map ipv4 address into v4-mapped-on-v6 address. */ sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), (union sctp_addr *)&status.sstat_primary.spinfo_address); @@ -3767,7 +3767,7 @@ static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len, to = (void __user *)getaddrs.addrs; list_for_each(pos, &asoc->peer.transport_addr_list) { from = list_entry(pos, struct sctp_transport, transports); - memcpy(&temp, &from->ipaddr, sizeof(temp)); + memcpy(&temp, &from->ipaddr_h, sizeof(temp)); sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; temp.v4.sin_port = htons(temp.v4.sin_port); @@ -3816,7 +3816,7 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len, list_for_each(pos, &asoc->peer.transport_addr_list) { from = list_entry(pos, struct sctp_transport, transports); - memcpy(&temp, &from->ipaddr, sizeof(temp)); + memcpy(&temp, &from->ipaddr_h, sizeof(temp)); sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; if(space_left < addrlen) @@ -3882,14 +3882,14 @@ static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len, if (sctp_list_single_entry(&bp->address_list)) { addr = list_entry(bp->address_list.next, struct sctp_sockaddr_entry, list); - if (sctp_is_any(&addr->a)) { + if (sctp_is_any(&addr->a_h)) { sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); list_for_each(pos, &sctp_local_addr_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); if ((PF_INET == sk->sk_family) && - (AF_INET6 == addr->a.sa.sa_family)) + (AF_INET6 == addr->a_h.sa.sa_family)) continue; cnt++; } @@ -3927,9 +3927,9 @@ static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_add list_for_each(pos, &sctp_local_addr_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); if ((PF_INET == sk->sk_family) && - (AF_INET6 == addr->a.sa.sa_family)) + (AF_INET6 == addr->a_h.sa.sa_family)) continue; - memcpy(&temp, &addr->a, sizeof(temp)); + memcpy(&temp, &addr->a_h, sizeof(temp)); sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), &temp); addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; @@ -3962,9 +3962,9 @@ static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, list_for_each(pos, &sctp_local_addr_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); if ((PF_INET == sk->sk_family) && - (AF_INET6 == addr->a.sa.sa_family)) + (AF_INET6 == addr->a_h.sa.sa_family)) continue; - memcpy(&temp, &addr->a, sizeof(temp)); + memcpy(&temp, &addr->a_h, sizeof(temp)); sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), &temp); addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; @@ -4038,7 +4038,7 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len, if (sctp_list_single_entry(&bp->address_list)) { addr = list_entry(bp->address_list.next, struct sctp_sockaddr_entry, list); - if (sctp_is_any(&addr->a)) { + if (sctp_is_any(&addr->a_h)) { cnt = sctp_copy_laddrs_to_user_old(sk, bp->port, getaddrs.addr_num, to); @@ -4052,7 +4052,7 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len, list_for_each(pos, &bp->address_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); - memcpy(&temp, &addr->a, sizeof(temp)); + memcpy(&temp, &addr->a_h, sizeof(temp)); sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; temp.v4.sin_port = htons(temp.v4.sin_port); @@ -4128,7 +4128,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len, if (sctp_list_single_entry(&bp->address_list)) { addr = list_entry(bp->address_list.next, struct sctp_sockaddr_entry, list); - if (sctp_is_any(&addr->a)) { + if (sctp_is_any(&addr->a_h)) { cnt = sctp_copy_laddrs_to_user(sk, bp->port, &to, space_left); if (cnt < 0) { @@ -4141,7 +4141,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len, list_for_each(pos, &bp->address_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); - memcpy(&temp, &addr->a, sizeof(temp)); + memcpy(&temp, &addr->a_h, sizeof(temp)); sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; if(space_left < addrlen) @@ -4195,7 +4195,7 @@ static int sctp_getsockopt_primary_addr(struct sock *sk, int len, return -ENOTCONN; flip_to_n((union sctp_addr *)&prim.ssp_addr, - &asoc->peer.primary_path->ipaddr); + &asoc->peer.primary_path->ipaddr_h); sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, (union sctp_addr *)&prim.ssp_addr); diff --git a/net/sctp/transport.c b/net/sctp/transport.c index 3e5936a5f671..1f56c9d95739 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c @@ -61,12 +61,12 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, gfp_t gfp) { /* Copy in the address. */ - peer->ipaddr = *addr; + peer->ipaddr_h = *addr; peer->af_specific = sctp_get_af_specific(addr->sa.sa_family); peer->asoc = NULL; peer->dst = NULL; - memset(&peer->saddr, 0, sizeof(union sctp_addr)); + memset(&peer->saddr_h, 0, sizeof(union sctp_addr)); /* From 6.3.1 RTO Calculation: * @@ -232,7 +232,7 @@ void sctp_transport_pmtu(struct sctp_transport *transport) { struct dst_entry *dst; - dst = transport->af_specific->get_dst(NULL, &transport->ipaddr, NULL); + dst = transport->af_specific->get_dst(NULL, &transport->ipaddr_h, NULL); if (dst) { transport->pathmtu = dst_mtu(dst); @@ -249,15 +249,15 @@ void sctp_transport_route(struct sctp_transport *transport, { struct sctp_association *asoc = transport->asoc; struct sctp_af *af = transport->af_specific; - union sctp_addr *daddr = &transport->ipaddr; + union sctp_addr *daddr = &transport->ipaddr_h; struct dst_entry *dst; dst = af->get_dst(asoc, daddr, saddr); if (saddr) - memcpy(&transport->saddr, saddr, sizeof(union sctp_addr)); + memcpy(&transport->saddr_h, saddr, sizeof(union sctp_addr)); else - af->get_saddr(asoc, dst, daddr, &transport->saddr); + af->get_saddr(asoc, dst, daddr, &transport->saddr_h); transport->dst = dst; if ((transport->param_flags & SPP_PMTUD_DISABLE) && transport->pathmtu) { @@ -270,7 +270,7 @@ void sctp_transport_route(struct sctp_transport *transport, * association's active path for getsockname(). */ if (asoc && (transport == asoc->peer.active_path)) - opt->pf->af->to_sk_saddr(&transport->saddr, + opt->pf->af->to_sk_saddr(&transport->saddr_h, asoc->base.sk); } else transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT; -- cgit v1.2.3 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 ++++---- net/sctp/bind_addr.c | 4 +--- net/sctp/endpointola.c | 4 +++- net/sctp/socket.c | 4 +--- 4 files changed, 9 insertions(+), 11 deletions(-) (limited to 'net/sctp/endpointola.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; diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c index 9085e531d575..442d891f68ea 100644 --- a/net/sctp/bind_addr.c +++ b/net/sctp/bind_addr.c @@ -307,12 +307,10 @@ 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, &tmp, opt)) + if (opt->pf->cmp_addr(&laddr->a, addr, opt)) return 1; } diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 75904b037ec6..d77fe9232dd1 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -228,10 +228,12 @@ struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep, const union sctp_addr *laddr) { struct sctp_endpoint *retval; + union sctp_addr tmp; + flip_to_n(&tmp, laddr); sctp_read_lock(&ep->base.addr_lock); if (ep->base.bind_addr.port == laddr->v4.sin_port) { - if (sctp_bind_addr_match(&ep->base.bind_addr, laddr, + if (sctp_bind_addr_match(&ep->base.bind_addr, &tmp, sctp_sk(ep->base.sk))) { retval = ep; goto out; diff --git a/net/sctp/socket.c b/net/sctp/socket.c index e03ba9055eb1..d42953efa355 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -4635,11 +4635,9 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) { struct sctp_bind_hashbucket *head; /* hash list */ struct sctp_bind_bucket *pp; /* hash list port iterator */ - union sctp_addr tmp; unsigned short snum; int ret; - flip_to_h(&tmp, addr); snum = ntohs(addr->v4.sin_port); SCTP_DEBUG_PRINTK("sctp_get_port() begins, snum=%d\n", snum); @@ -4737,7 +4735,7 @@ pp_found: if (reuse && sk2->sk_reuse) continue; - if (sctp_bind_addr_match(&ep2->base.bind_addr, &tmp, + if (sctp_bind_addr_match(&ep2->base.bind_addr, addr, sctp_sk(sk))) { ret = (long)sk2; goto fail_unlock; -- cgit v1.2.3 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 +++++++++-------- net/sctp/endpointola.c | 4 +++- net/sctp/sm_make_chunk.c | 2 +- net/sctp/sm_statefuns.c | 4 +++- net/sctp/socket.c | 5 +++-- 5 files changed, 19 insertions(+), 13 deletions(-) (limited to 'net/sctp/endpointola.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); } diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index d77fe9232dd1..7c781d663603 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -259,6 +259,8 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( int rport; struct sctp_association *asoc; struct list_head *pos; + union sctp_addr tmp; + flip_to_n(&tmp, paddr); rport = paddr->v4.sin_port; @@ -266,7 +268,7 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( asoc = list_entry(pos, struct sctp_association, asocs); if (rport == asoc->peer.port) { 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); if (*transport) diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 303830b40ab3..cc1b01152c34 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -2466,7 +2466,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc, sctp_assoc_del_peer(asoc, &tmp_addr); break; case SCTP_PARAM_SET_PRIMARY: - peer = sctp_assoc_lookup_paddr(asoc, &addr); + peer = sctp_assoc_lookup_paddr(asoc, &tmp_addr); if (!peer) return SCTP_ERROR_INV_PARAM; diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index ac776fd20667..7d722f5a31d7 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -1018,6 +1018,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const struct sctp_endpoint *ep, struct sctp_transport *link; sctp_sender_hb_info_t *hbinfo; unsigned long max_interval; + union sctp_addr tmp; if (!sctp_vtag_verify(chunk, asoc)) 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, } 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. */ if (unlikely(!link)) { diff --git a/net/sctp/socket.c b/net/sctp/socket.c index d42953efa355..ffdad8e842ac 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -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_transport *transport, *chunk_tp; struct sctp_chunk *chunk; - union sctp_addr to; + union sctp_addr to, tmp; struct sockaddr *msg_name = NULL; struct sctp_sndrcvinfo default_sinfo = { 0 }; struct sctp_sndrcvinfo *sinfo; @@ -1424,6 +1424,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, if (msg_namelen > sizeof(to)) msg_namelen = sizeof(to); memcpy(&to, msg->msg_name, msg_namelen); + memcpy(&tmp, msg->msg_name, msg_namelen); SCTP_DEBUG_PRINTK("Just memcpy'd. msg_name is " "0x%x:%u.\n", 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, */ if ((sctp_style(sk, TCP) && msg_name) || (sinfo_flags & SCTP_ADDR_OVER)) { - chunk_tp = sctp_assoc_lookup_paddr(asoc, &to); + chunk_tp = sctp_assoc_lookup_paddr(asoc, &tmp); if (!chunk_tp) { err = -EINVAL; goto out_free; -- cgit v1.2.3 From 1c7d1fc14974f44809b22521bd9796411d8ba440 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:08:09 -0800 Subject: [SCTP]: Switch sctp_endpoint_is_match() to net-endian. The only caller (__sctp_rcv_lookup_endpoint()) also switched, its caller adjusted Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/endpointola.c | 6 ++---- net/sctp/input.c | 7 +++++-- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'net/sctp/endpointola.c') diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 7c781d663603..c543f3250645 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -228,12 +228,10 @@ struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep, const union sctp_addr *laddr) { struct sctp_endpoint *retval; - union sctp_addr tmp; - flip_to_n(&tmp, laddr); sctp_read_lock(&ep->base.addr_lock); - if (ep->base.bind_addr.port == laddr->v4.sin_port) { - if (sctp_bind_addr_match(&ep->base.bind_addr, &tmp, + if (htons(ep->base.bind_addr.port) == laddr->v4.sin_port) { + if (sctp_bind_addr_match(&ep->base.bind_addr, laddr, sctp_sk(ep->base.sk))) { retval = ep; goto out; diff --git a/net/sctp/input.c b/net/sctp/input.c index 6d82f400d13c..1bb3f264da1f 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c @@ -127,6 +127,7 @@ int sctp_rcv(struct sk_buff *skb) struct sctphdr *sh; union sctp_addr src; union sctp_addr dest; + union sctp_addr tmp; int family; struct sctp_af *af; @@ -180,8 +181,10 @@ int sctp_rcv(struct sk_buff *skb) asoc = __sctp_rcv_lookup(skb, &src, &dest, &transport); + flip_to_n(&tmp, &dest); + if (!asoc) - ep = __sctp_rcv_lookup_endpoint(&dest); + ep = __sctp_rcv_lookup_endpoint(&tmp); /* Retrieve the common input handling substructure. */ rcvr = asoc ? &asoc->base : &ep->base; @@ -726,7 +729,7 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(const union sctp_addr *l struct sctp_endpoint *ep; int hash; - hash = sctp_ep_hashfn(laddr->v4.sin_port); + hash = sctp_ep_hashfn(ntohs(laddr->v4.sin_port)); head = &sctp_ep_hashtable[hash]; read_lock(&head->lock); for (epb = head->chain; epb; epb = epb->next) { -- cgit v1.2.3 From cd4ff034e3572679f7ff8f126469b3addd1a4fbc Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:11:33 -0800 Subject: [SCTP]: sctp_endpoint_lookup_assoc() switched to net-endian. Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/endpointola.c | 10 +++++----- net/sctp/socket.c | 8 +++----- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'net/sctp/endpointola.c') diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index c543f3250645..5ffb1af336c0 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -257,16 +257,14 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc( int rport; struct sctp_association *asoc; struct list_head *pos; - union sctp_addr tmp; - flip_to_n(&tmp, paddr); - rport = paddr->v4.sin_port; + rport = ntohs(paddr->v4.sin_port); list_for_each(pos, &ep->asocs) { asoc = list_entry(pos, struct sctp_association, asocs); if (rport == asoc->peer.port) { sctp_read_lock(&asoc->base.addr_lock); - *transport = sctp_assoc_lookup_paddr(asoc, &tmp); + *transport = sctp_assoc_lookup_paddr(asoc, paddr); sctp_read_unlock(&asoc->base.addr_lock); if (*transport) @@ -348,8 +346,10 @@ static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep) * COOKIE-ECHO chunk. */ if (NULL == chunk->asoc) { + union sctp_addr tmp; + flip_to_n(&tmp, sctp_source(chunk)); asoc = sctp_endpoint_lookup_assoc(ep, - sctp_source(chunk), + &tmp, &transport); chunk->asoc = asoc; chunk->transport = transport; diff --git a/net/sctp/socket.c b/net/sctp/socket.c index d09589a51c44..6beaa7821ca6 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -228,11 +228,9 @@ static struct sctp_transport *sctp_addr_id2transport(struct sock *sk, struct sctp_association *addr_asoc = NULL, *id_asoc = NULL; struct sctp_transport *transport; union sctp_addr *laddr = (union sctp_addr *)addr; - union sctp_addr tmp; - flip_to_h(&tmp, laddr); addr_asoc = sctp_endpoint_lookup_assoc(sctp_sk(sk)->ep, - &tmp, + laddr, &transport); if (!addr_asoc) @@ -1007,7 +1005,7 @@ static int __sctp_connect(struct sock* sk, /* Check if there already is a matching association on the * endpoint (other than the one created here). */ - asoc2 = sctp_endpoint_lookup_assoc(ep, &to, &transport); + asoc2 = sctp_endpoint_lookup_assoc(ep, sa_addr, &transport); if (asoc2 && asoc2 != asoc) { if (asoc2->state >= SCTP_STATE_ESTABLISHED) err = -EISCONN; @@ -1468,7 +1466,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, /* If a msg_name has been specified, assume this is to be used. */ if (msg_name) { /* Look for a matching association on the endpoint. */ - asoc = sctp_endpoint_lookup_assoc(ep, &to, &transport); + asoc = sctp_endpoint_lookup_assoc(ep, &tmp, &transport); if (!asoc) { /* If we could not find a matching association on the * endpoint, make sure that it is not a TCP-style -- cgit v1.2.3 From 6c7be55ca0c204473d07a030a03c49a7471b4508 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:11:50 -0800 Subject: [SCTP]: sctp_has_association() switched to net-endian. Ditto for its only caller (sctp_endpoint_is_peeled_off) Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/endpointola.c | 2 +- net/sctp/input.c | 5 +---- net/sctp/socket.c | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'net/sctp/endpointola.c') diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 5ffb1af336c0..4cca7792c961 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -305,7 +305,7 @@ int sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep, bp = &ep->base.bind_addr; list_for_each(pos, &bp->address_list) { addr = list_entry(pos, struct sctp_sockaddr_entry, list); - if (sctp_has_association(&addr->a_h, paddr)) { + if (sctp_has_association(&addr->a, paddr)) { sctp_read_unlock(&ep->base.addr_lock); return 1; } diff --git a/net/sctp/input.c b/net/sctp/input.c index 2d660f8d94fd..33111873a488 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c @@ -872,11 +872,8 @@ int sctp_has_association(const union sctp_addr *laddr, { struct sctp_association *asoc; struct sctp_transport *transport; - union sctp_addr tmp, tmp2; - flip_to_n(&tmp, laddr); - flip_to_n(&tmp2, paddr); - if ((asoc = sctp_lookup_association(&tmp, &tmp2, &transport))) { + if ((asoc = sctp_lookup_association(laddr, paddr, &transport))) { sctp_association_put(asoc); return 1; } diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 6beaa7821ca6..e118e3c1285e 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -1018,7 +1018,7 @@ static int __sctp_connect(struct sock* sk, * make sure that there is no peeled-off association matching * the peer address even on another socket. */ - if (sctp_endpoint_is_peeled_off(ep, &to)) { + if (sctp_endpoint_is_peeled_off(ep, sa_addr)) { err = -EADDRNOTAVAIL; goto out_free; } @@ -1475,7 +1475,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, */ if ((sctp_style(sk, TCP) && sctp_sstate(sk, ESTABLISHED)) || - sctp_endpoint_is_peeled_off(ep, &to)) { + sctp_endpoint_is_peeled_off(ep, &tmp)) { err = -EADDRNOTAVAIL; goto out_unlock; } -- cgit v1.2.3 From 6a1e5f335461567f593e88b218f1c06817cbd323 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Mon, 20 Nov 2006 17:12:25 -0800 Subject: [SCTP]: sctp_process_init() and sctp_source() switched to net-endian. both are done in one go since almost always we have result of the latter immediately passed to the former. Possibly non-obvious note: sctp_process_param() is endian-agnostic Signed-off-by: Al Viro Signed-off-by: David S. Miller --- net/sctp/endpointola.c | 4 +--- net/sctp/sm_make_chunk.c | 12 ++++-------- net/sctp/sm_statefuns.c | 8 ++------ 3 files changed, 7 insertions(+), 17 deletions(-) (limited to 'net/sctp/endpointola.c') diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index 4cca7792c961..33a42e90c32f 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c @@ -346,10 +346,8 @@ static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep) * COOKIE-ECHO chunk. */ if (NULL == chunk->asoc) { - union sctp_addr tmp; - flip_to_n(&tmp, sctp_source(chunk)); asoc = sctp_endpoint_lookup_assoc(ep, - &tmp, + sctp_source(chunk), &transport); chunk->asoc = asoc; chunk->transport = transport; diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index b367ad59ed4a..44ddec90995e 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -1041,10 +1041,10 @@ const union sctp_addr *sctp_source(const struct sctp_chunk *chunk) { /* If we have a known transport, use that. */ if (chunk->transport) { - return &chunk->transport->ipaddr_h; + return &chunk->transport->ipaddr; } else { /* Otherwise, extract it from the IP header. */ - return &chunk->source_h; + return &chunk->source; } } @@ -1844,7 +1844,6 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, struct sctp_transport *transport; struct list_head *pos, *temp; char *cookie; - union sctp_addr tmp; /* We must include the address that the INIT packet came from. * This is the only address that matters for an INIT packet. @@ -1857,8 +1856,7 @@ int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, * be a a better choice than any of the embedded addresses. */ if (peer_addr) { - flip_to_n(&tmp, peer_addr); - if(!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_ACTIVE)) + if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE)) goto nomem; } @@ -2419,7 +2417,6 @@ 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; addr_param = (union sctp_addr_param *) ((void *)asconf_param + sizeof(sctp_addip_param_t)); @@ -2463,8 +2460,7 @@ 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' */ - flip_to_n(&tmp, sctp_source(asconf)); - if (sctp_cmp_addr_exact(&tmp, &addr)) + if (sctp_cmp_addr_exact(sctp_source(asconf), &addr)) return SCTP_ERROR_DEL_SRC_IP; sctp_assoc_del_peer(asoc, &addr); diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index c5362638d672..0848309773a5 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -598,7 +598,6 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, struct sctp_ulpevent *ev, *ai_ev = NULL; int error = 0; struct sctp_chunk *err_chk_p; - union sctp_addr tmp; /* If the packet is an OOTB packet which is temporarily on the * control endpoint, respond with an ABORT. @@ -666,9 +665,8 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(const struct sctp_endpoint *ep, */ peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; - flip_to_h(&tmp, &chunk->subh.cookie_hdr->c.peer_addr); if (!sctp_process_init(new_asoc, chunk->chunk_hdr->type, - &tmp, + &chunk->subh.cookie_hdr->c.peer_addr, peer_init, GFP_ATOMIC)) goto nomem_init; @@ -5105,7 +5103,6 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc __u16 sport; __u16 dport; __u32 vtag; - union sctp_addr tmp; /* Get the source and destination port from the inbound packet. */ sport = ntohs(chunk->sctp_hdr->dest); @@ -5136,8 +5133,7 @@ static struct sctp_packet *sctp_ootb_pkt_new(const struct sctp_association *asoc } /* Make a transport for the bucket, Eliza... */ - flip_to_n(&tmp, sctp_source(chunk)); - transport = sctp_transport_new(&tmp, GFP_ATOMIC); + transport = sctp_transport_new(sctp_source(chunk), GFP_ATOMIC); if (!transport) goto nomem; -- cgit v1.2.3