[IPV6]: flowlabels are net-endian
Al Viro [Wed, 8 Nov 2006 08:25:17 +0000 (00:25 -0800)]
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>

include/linux/in6.h
include/linux/ip6_tunnel.h
include/linux/ipv6.h
include/net/flow.h
include/net/ipv6.h
net/ipv6/af_inet6.c
net/ipv6/datagram.c
net/ipv6/ip6_flowlabel.c
net/ipv6/ip6_output.c
net/ipv6/ip6_tunnel.c
net/ipv6/route.c

index f28621f..4e8350a 100644 (file)
@@ -54,7 +54,7 @@ extern const struct in6_addr in6addr_loopback;
 struct sockaddr_in6 {
        unsigned short int      sin6_family;    /* AF_INET6 */
        __be16                  sin6_port;      /* Transport layer port # */
-       __u32                   sin6_flowinfo;  /* IPv6 flow information */
+       __be32                  sin6_flowinfo;  /* IPv6 flow information */
        struct in6_addr         sin6_addr;      /* IPv6 address */
        __u32                   sin6_scope_id;  /* scope id (new in RFC2553) */
 };
@@ -72,7 +72,7 @@ struct ipv6_mreq {
 struct in6_flowlabel_req
 {
        struct in6_addr flr_dst;
-       __u32   flr_label;
+       __be32  flr_label;
        __u8    flr_action;
        __u8    flr_share;
        __u16   flr_flags;
index 5c23aeb..af3f4a7 100644 (file)
@@ -25,7 +25,7 @@ struct ip6_tnl_parm {
        __u8 proto;             /* tunnel protocol */
        __u8 encap_limit;       /* encapsulation limit for tunnel */
        __u8 hop_limit;         /* hop limit for tunnel */
-       __u32 flowinfo;         /* traffic class and flowlabel for tunnel */
+       __be32 flowinfo;        /* traffic class and flowlabel for tunnel */
        __u32 flags;            /* tunnel flags */
        struct in6_addr laddr;  /* local tunnel end-point address */
        struct in6_addr raddr;  /* remote tunnel end-point address */
index 4f435c5..f824113 100644 (file)
@@ -274,7 +274,7 @@ struct ipv6_pinfo {
        struct in6_addr         *saddr_cache;
 #endif
 
-       __u32                   flow_label;
+       __be32                  flow_label;
        __u32                   frag_size;
        __s16                   hop_limit;
        __s16                   mcast_hops;
index 5cda27c..270d4c1 100644 (file)
@@ -27,7 +27,7 @@ struct flowi {
                        struct in6_addr         daddr;
                        struct in6_addr         saddr;
                        __u32                   fwmark;
-                       __u32                   flowlabel;
+                       __be32                  flowlabel;
                } ip6_u;
 
                struct {
index 4953fac..0b8c9b9 100644 (file)
@@ -191,7 +191,7 @@ struct ipv6_txoptions
 struct ip6_flowlabel
 {
        struct ip6_flowlabel    *next;
-       u32                     label;
+       __be32                  label;
        struct in6_addr         dst;
        struct ipv6_txoptions   *opt;
        atomic_t                users;
@@ -211,7 +211,7 @@ struct ipv6_fl_socklist
        struct ip6_flowlabel    *fl;
 };
 
-extern struct ip6_flowlabel    *fl6_sock_lookup(struct sock *sk, u32 label);
+extern struct ip6_flowlabel    *fl6_sock_lookup(struct sock *sk, __be32 label);
 extern struct ipv6_txoptions   *fl6_merge_options(struct ipv6_txoptions * opt_space,
                                                   struct ip6_flowlabel * fl,
                                                   struct ipv6_txoptions * fopt);
index 858cae2..92bfccf 100644 (file)
@@ -678,7 +678,7 @@ int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
        if (np->rxopt.all) {
                if ((opt->hop && (np->rxopt.bits.hopopts ||
                                  np->rxopt.bits.ohopopts)) ||
-                   ((IPV6_FLOWINFO_MASK & *(u32*)skb->nh.raw) &&
+                   ((IPV6_FLOWINFO_MASK & *(__be32*)skb->nh.raw) &&
                     np->rxopt.bits.rxflow) ||
                    (opt->srcrt && (np->rxopt.bits.srcrt ||
                     np->rxopt.bits.osrcrt)) ||
index 7206747..a67434a 100644 (file)
@@ -318,7 +318,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
                        ipv6_addr_copy(&sin->sin6_addr,
                          (struct in6_addr *)(skb->nh.raw + serr->addr_offset));
                        if (np->sndflow)
-                               sin->sin6_flowinfo = *(u32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK;
+                               sin->sin6_flowinfo = *(__be32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK;
                        if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
                                sin->sin6_scope_id = IP6CB(skb)->iif;
                } else {
@@ -401,8 +401,8 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
                put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
        }
 
-       if (np->rxopt.bits.rxflow && (*(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) {
-               u32 flowinfo = *(u32*)skb->nh.raw & IPV6_FLOWINFO_MASK;
+       if (np->rxopt.bits.rxflow && (*(__be32*)skb->nh.raw & IPV6_FLOWINFO_MASK)) {
+               __be32 flowinfo = *(__be32*)skb->nh.raw & IPV6_FLOWINFO_MASK;
                put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo);
        }
 
@@ -560,12 +560,12 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                        }
 
                        if (fl->fl6_flowlabel&IPV6_FLOWINFO_MASK) {
-                               if ((fl->fl6_flowlabel^*(u32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) {
+                               if ((fl->fl6_flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) {
                                        err = -EINVAL;
                                        goto exit_f;
                                }
                        }
-                       fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(u32 *)CMSG_DATA(cmsg);
+                       fl->fl6_flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg);
                        break;
 
                case IPV6_2292HOPOPTS:
index 6d4533b..624fae2 100644 (file)
@@ -61,7 +61,7 @@ static DEFINE_RWLOCK(ip6_fl_lock);
 static DEFINE_RWLOCK(ip6_sk_fl_lock);
 
 
-static __inline__ struct ip6_flowlabel * __fl_lookup(u32 label)
+static __inline__ struct ip6_flowlabel * __fl_lookup(__be32 label)
 {
        struct ip6_flowlabel *fl;
 
@@ -72,7 +72,7 @@ static __inline__ struct ip6_flowlabel * __fl_lookup(u32 label)
        return NULL;
 }
 
-static struct ip6_flowlabel * fl_lookup(u32 label)
+static struct ip6_flowlabel * fl_lookup(__be32 label)
 {
        struct ip6_flowlabel *fl;
 
@@ -153,7 +153,7 @@ static void ip6_fl_gc(unsigned long dummy)
        write_unlock(&ip6_fl_lock);
 }
 
-static int fl_intern(struct ip6_flowlabel *fl, __u32 label)
+static int fl_intern(struct ip6_flowlabel *fl, __be32 label)
 {
        fl->label = label & IPV6_FLOWLABEL_MASK;
 
@@ -182,7 +182,7 @@ static int fl_intern(struct ip6_flowlabel *fl, __u32 label)
 
 /* Socket flowlabel lists */
 
-struct ip6_flowlabel * fl6_sock_lookup(struct sock *sk, u32 label)
+struct ip6_flowlabel * fl6_sock_lookup(struct sock *sk, __be32 label)
 {
        struct ipv6_fl_socklist *sfl;
        struct ipv6_pinfo *np = inet6_sk(sk);
index 6671691..9ff1be1 100644 (file)
@@ -217,7 +217,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
        if (tclass < 0)
                tclass = 0;
 
-       *(u32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel;
+       *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl->fl6_flowlabel;
 
        hdr->payload_len = htons(seg_len);
        hdr->nexthdr = proto;
@@ -1311,7 +1311,7 @@ int ip6_push_pending_frames(struct sock *sk)
 
        skb->nh.ipv6h = hdr = (struct ipv6hdr*) skb_push(skb, sizeof(struct ipv6hdr));
        
-       *(u32*)hdr = fl->fl6_flowlabel |
+       *(__be32*)hdr = fl->fl6_flowlabel |
                     htonl(0x60000000 | ((int)np->cork.tclass << 20));
 
        if (skb->len <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN)
index 6a3026d..4919f92 100644 (file)
@@ -665,9 +665,9 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 
        dsfield = ipv6_get_dsfield(ipv6h);
        if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
-               fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_TCLASS_MASK);
+               fl.fl6_flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
        if ((t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL))
-               fl.fl6_flowlabel |= (*(__u32 *) ipv6h & IPV6_FLOWLABEL_MASK);
+               fl.fl6_flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK);
 
        if (encap_limit >= 0 && (opt = create_tel(encap_limit)) == NULL)
                goto tx_err;
@@ -735,7 +735,7 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
 
        skb->nh.raw = skb_push(skb, sizeof(struct ipv6hdr));
        ipv6h = skb->nh.ipv6h;
-       *(u32*)ipv6h = fl.fl6_flowlabel | htonl(0x60000000);
+       *(__be32*)ipv6h = fl.fl6_flowlabel | htonl(0x60000000);
        dsfield = INET_ECN_encapsulate(0, dsfield);
        ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield);
        ipv6h->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
index b39ae99..e9c1fc5 100644 (file)
@@ -714,7 +714,7 @@ void ip6_route_input(struct sk_buff *skb)
 #ifdef CONFIG_IPV6_ROUTE_FWMARK
                                .fwmark = skb->nfmark,
 #endif
-                               .flowlabel = (* (u32 *) iph)&IPV6_FLOWINFO_MASK,
+                               .flowlabel = (* (__be32 *) iph)&IPV6_FLOWINFO_MASK,
                        },
                },
                .proto = iph->nexthdr,