[ovs-dev] [PATCH 06/12] datapath: Correct byte order annotations.
Jesse Gross
jesse at nicira.com
Sun Dec 12 20:53:01 UTC 2010
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 at nicira.com>
---
datapath/datapath.c | 3 ++-
datapath/flow.c | 2 +-
datapath/tunnel.c | 5 +++--
datapath/vport-gre.c | 8 ++++----
4 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/datapath/datapath.c b/datapath/datapath.c
index ef645f1..a6c5661 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -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;
}
diff --git a/datapath/flow.c b/datapath/flow.c
index 8a6ee23..5cf0d54 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -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;
diff --git a/datapath/tunnel.c b/datapath/tunnel.c
index 23a036f..3fe9dc4 100644
--- a/datapath/tunnel.c
+++ b/datapath/tunnel.c
@@ -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)
diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c
index eb10903..191fd06 100644
--- a/datapath/vport-gre.c
+++ b/datapath/vport-gre.c
@@ -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
}
--
1.7.1
More information about the dev
mailing list