[ovs-dev] [PATCH] [rfc v2] datapath: Clear rxhash when using an action that may affect it

Simon Horman horms at verge.net.au
Mon Feb 7 02:07:14 UTC 2011


Signed-off-by: Simon Horman <horms at verge.net.au>

---

Several moons ago Jesse Gross mentioned that the rxhash ought
to be cleared when the datapath makes a modification that could
affect it. This patch is a first pass at making that change.

Compile tested only.

v2: As suggested by Jesse Gross
* Use kernel version rather than a feature check for #ifdef
  - I am not aware of a backport that would warrant a feature check
  - Call skb_clear_rxhash on tunnel encapsulation and decapsulation
---
 datapath/actions.c |    3 +++
 datapath/actions.h |    7 +++++++
 datapath/tunnel.c  |    2 ++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/datapath/actions.c b/datapath/actions.c
index 3223c65..16faaf0 100644
--- a/datapath/actions.c
+++ b/datapath/actions.c
@@ -250,6 +250,8 @@ static struct sk_buff *set_nw_addr(struct sk_buff *skb,
 		inet_proto_csum_replace4(check, skb, *nwaddr, new_nwaddr, 1);
 	csum_replace4(&nh->check, *nwaddr, new_nwaddr);
 
+	skb_clear_rxhash(skb);
+
 	*nwaddr = new_nwaddr;
 
 	return skb;
@@ -309,6 +311,7 @@ static struct sk_buff *set_tp_port(struct sk_buff *skb,
 	port = nla_type(a) == ODP_ACTION_ATTR_SET_TP_SRC ? &th->source : &th->dest;
 	inet_proto_csum_replace2(check, skb, *port, nla_get_be16(a), 0);
 	*port = nla_get_be16(a);
+	skb_clear_rxhash(skb);
 
 	return skb;
 }
diff --git a/datapath/actions.h b/datapath/actions.h
index 5ad322f..9b7b088 100644
--- a/datapath/actions.h
+++ b/datapath/actions.h
@@ -20,4 +20,11 @@ int execute_actions(struct datapath *dp, struct sk_buff *skb,
 		    const struct sw_flow_key *,
 		    const struct nlattr *, u32 actions_len);
 
+static inline void skb_clear_rxhash(struct sk_buff *skb)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)
+	skb->rxhash = 0;
+#endif
+}
+
 #endif /* actions.h */
diff --git a/datapath/tunnel.c b/datapath/tunnel.c
index 40577fb..22b6834 100644
--- a/datapath/tunnel.c
+++ b/datapath/tunnel.c
@@ -435,6 +435,7 @@ void tnl_rcv(struct vport *vport, struct sk_buff *skb)
 
 	skb_dst_drop(skb);
 	nf_reset(skb);
+	skb_clear_rxhash(skb);
 	secpath_reset(skb);
 
 	ecn_decapsulate(skb);
@@ -1208,6 +1209,7 @@ int tnl_send(struct vport *vport, struct sk_buff *skb)
 	nf_reset(skb);
 	secpath_reset(skb);
 	skb_dst_drop(skb);
+	skb_clear_rxhash(skb);
 
 	/* Offloading */
 	skb = handle_offloads(skb, mutable, rt);
-- 
1.7.2.3





More information about the dev mailing list