]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - net/sctp/ipv6.c
[SCTP]: Switch all remaining users of ->saddr_h to ->saddr.
[mirror_ubuntu-artful-kernel.git] / net / sctp / ipv6.c
index 99c0cefc04e072ff49b1b794777d7cb904a6cd95..3dc8ed14352123f0f627a58b90ad4641a5d11f23 100644 (file)
 
 #include <asm/uaccess.h>
 
-extern int sctp_inetaddr_event(struct notifier_block *, unsigned long, void *);
 static struct notifier_block sctp_inet6addr_notifier = {
        .notifier_call = sctp_inetaddr_event,
 };
 
 /* ICMP error handler. */
 SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
-                            int type, int code, int offset, __u32 info)
+                            int type, int code, int offset, __be32 info)
 {
        struct inet6_dev *idev;
        struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
@@ -162,7 +161,7 @@ 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_dst, &transport->ipaddr_h.v6.sin6_addr);
        ipv6_addr_copy(&fl.fl6_src, &transport->saddr.v6.sin6_addr);
 
        fl.fl6_flowlabel = np->flow_label;
@@ -172,7 +171,7 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport,
        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;
@@ -216,17 +215,17 @@ static struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc,
        }
 
        dst = ip6_route_output(NULL, &fl);
-       if (dst) {
+       if (!dst->error) {
                struct rt6_info *rt;
                rt = (struct rt6_info *)dst;
                SCTP_DEBUG_PRINTK(
                        "rt6_dst:" NIP6_FMT " rt6_src:" NIP6_FMT "\n",
                        NIP6(rt->rt6i_dst.addr), NIP6(rt->rt6i_src.addr));
-       } else {
-               SCTP_DEBUG_PRINTK("NO ROUTE\n");
+               return dst;
        }
-
-       return dst;
+       SCTP_DEBUG_PRINTK("NO ROUTE\n");
+       dst_release(dst);
+       return NULL;
 }
 
 /* Returns the number of consecutive initial bits that match in the 2 ipv6
@@ -240,7 +239,7 @@ static inline int sctp_v6_addr_match_len(union sctp_addr *s1,
        int i, j;
 
        for (i = 0; i < 4 ; i++) {
-               __u32 a1xora2;
+               __be32 a1xora2;
 
                a1xora2 = a1->s6_addr32[i] ^ a2->s6_addr32[i];
 
@@ -291,8 +290,8 @@ 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))) {
+                   (laddr->a_h.sa.sa_family == AF_INET6) &&
+                   (scope <= sctp_scope(&laddr->a_h))) {
                        bmatchlen = sctp_v6_addr_match_len(daddr, &laddr->a);
                        if (!baddr || (matchlen < bmatchlen)) {
                                baddr = &laddr->a;
@@ -322,9 +321,9 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist,
        struct inet6_ifaddr *ifp;
        struct sctp_sockaddr_entry *addr;
 
-       read_lock(&addrconf_lock);
+       rcu_read_lock();
        if ((in6_dev = __in6_dev_get(dev)) == NULL) {
-               read_unlock(&addrconf_lock);
+               rcu_read_unlock();
                return;
        }
 
@@ -337,13 +336,14 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist,
                        addr->a.v6.sin6_port = 0;
                        addr->a.v6.sin6_addr = ifp->addr;
                        addr->a.v6.sin6_scope_id = dev->ifindex;
+                       addr->a_h = addr->a;
                        INIT_LIST_HEAD(&addr->list);
                        list_add_tail(&addr->list, addrlist);
                }
        }
 
        read_unlock(&in6_dev->lock);
-       read_unlock(&addrconf_lock);
+       rcu_read_unlock();
 }
 
 /* Initialize a sockaddr_storage from in incoming skb. */
@@ -351,7 +351,7 @@ static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb,
                             int is_saddr)
 {
        void *from;
-       __u16 *port;
+       __be16 *port;
        struct sctphdr *sh;
 
        port = &addr->v6.sin6_port;
@@ -361,10 +361,10 @@ static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb,
 
        sh = (struct sctphdr *) skb->h.raw;
        if (is_saddr) {
-               *port  = ntohs(sh->source);
+               *port  = sh->source;
                from = &skb->nh.ipv6h->saddr;
        } else {
-               *port = ntohs(sh->dest);
+               *port = sh->dest;
                from = &skb->nh.ipv6h->daddr;
        }
        ipv6_addr_copy(&addr->v6.sin6_addr, from);
@@ -408,7 +408,7 @@ static void sctp_v6_to_sk_daddr(union sctp_addr *addr, struct sock *sk)
 /* Initialize a sctp_addr from an address parameter. */
 static void sctp_v6_from_addr_param(union sctp_addr *addr,
                                    union sctp_addr_param *param,
-                                   __u16 port, int iif)
+                                   __be16 port, int iif)
 {
        addr->v6.sin6_family = AF_INET6;
        addr->v6.sin6_port = port;
@@ -426,7 +426,7 @@ static int sctp_v6_to_addr_param(const union sctp_addr *addr,
        int length = sizeof(sctp_ipv6addr_param_t);
 
        param->v6.param_hdr.type = SCTP_PARAM_IPV6_ADDRESS;
-       param->v6.param_hdr.length = ntohs(length);
+       param->v6.param_hdr.length = htons(length);
        ipv6_addr_copy(&param->v6.addr, &addr->v6.sin6_addr);
 
        return length;
@@ -434,7 +434,7 @@ static int sctp_v6_to_addr_param(const union sctp_addr *addr,
 
 /* Initialize a sctp_addr from a dst_entry. */
 static void sctp_v6_dst_saddr(union sctp_addr *addr, struct dst_entry *dst,
-                             unsigned short port)
+                             __be16 port)
 {
        struct rt6_info *rt = (struct rt6_info *)dst;
        addr->sa.sa_family = AF_INET6;