datapath: Correct byte order annotations.
authorJesse Gross <jesse@nicira.com>
Sat, 4 Dec 2010 20:04:39 +0000 (12:04 -0800)
committerJesse Gross <jesse@nicira.com>
Mon, 13 Dec 2010 21:40:20 +0000 (13:40 -0800)
We have generally been using the byte order specific data types
(i.e. __be32 instead of u32) in most places.  This corrects a
declaration and adds a few needed casts.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
datapath/datapath.c
datapath/flow.c
datapath/tunnel.c
datapath/vport-gre.c

index 5e2821a543496a1ac42195be01f3a1c1452cf01c..c633e8463315285a36adddfacde66d5a90879ac3 100644 (file)
@@ -493,7 +493,8 @@ void dp_process_received_packet(struct vport *p, struct sk_buff *skb)
                flow_node = tbl_lookup(rcu_dereference(dp->table), &key,
                                        flow_hash(&key), flow_cmp);
                if (unlikely(!flow_node)) {
-                       dp_output_control(dp, skb, _ODPL_MISS_NR, OVS_CB(skb)->tun_id);
+                       dp_output_control(dp, skb, _ODPL_MISS_NR,
+                                        (__force u64)OVS_CB(skb)->tun_id);
                        stats_counter_off = offsetof(struct dp_stats_percpu, n_missed);
                        goto out;
                }
index 8a6ee23d3e833ce0a5761a321f291c670df116be..5cf0d54a7839860519c9f7337e1890f220c8db95 100644 (file)
@@ -218,7 +218,7 @@ static __be16 parse_ethertype(struct sk_buff *skb)
                u8  ssap;  /* Always 0xAA */
                u8  ctrl;
                u8  oui[3];
-               u16 ethertype;
+               __be16 ethertype;
        };
        struct llc_snap_hdr *llc;
        __be16 proto;
index d2ede147ea4b7e0d80f9bbd757d2dbd36854454b..9824129145b874d56019145698dc833b41190a41 100644 (file)
@@ -191,8 +191,9 @@ static int port_cmp(const struct tbl_node *node, void *target)
 
 static u32 port_hash(struct port_lookup_key *k)
 {
-       u32 x = jhash_3words(k->saddr, k->daddr, k->tunnel_type, 0);
-       return jhash_2words(k->key >> 32, k->key, x);
+       u32 x = jhash_3words((__force u32)k->saddr, (__force u32)k->daddr,
+                            k->tunnel_type, 0);
+       return jhash_2words((__force u64)k->key >> 32, (__force u32)k->key, x);
 }
 
 static u32 mutable_hash(const struct tnl_mutable_config *mutable)
index eb109035a3bfb55db1ab5535f4f6512e43a86358..191fd06342cceabdec876a85af9850492ee85faa 100644 (file)
@@ -54,9 +54,9 @@ static int gre_hdr_len(const struct tnl_port_config *port_config)
 static __be32 be64_get_low32(__be64 x)
 {
 #ifdef __BIG_ENDIAN
-       return x;
+       return (__force __be32)x;
 #else
-       return x >> 32;
+       return (__force __be32)((__force u64)x >> 32);
 #endif
 }
 
@@ -116,9 +116,9 @@ static struct sk_buff *gre_update_header(const struct vport *vport,
 static __be64 be32_extend_to_be64(__be32 x)
 {
 #ifdef __BIG_ENDIAN
-       return x;
+       return (__force __be64)x;
 #else
-       return (__be64) x << 32;
+       return (__force __be64)((__force u64)x << 32);
 #endif
 }