Thread (14 messages) 14 messages, 5 authors, 2012-10-04

Re: [RFC] vxlan: use ether header as fallback hash

flat view

From: Stephen Hemminger <hidden>
Date: 2012-10-04 05:06:36

On Wed, 2012-10-03 at 21:39 -0700, Stephen Hemminger wrote:
quoted
VXLAN bases source UDP port based on flow to help the
receiver to be able to load balance based on outer header
contents.

This patches changes the algorithm to better handle packets
that can not be categorized by the rxhash() function.
It adds a fallback to use jhash on the Ether header.

It also fixes a bug where the old code could assign 0 as a port
value.


Signed-off-by: Stephen Hemminger <redacted>

---
RFC for now, compile tested only
--- a/drivers/net/vxlan.c	2012-10-03 21:25:43.747968165 -0700
+++ b/drivers/net/vxlan.c	2012-10-03 21:36:10.213805422 -0700
@@ -622,12 +622,30 @@ static inline u8 vxlan_ecn_encap(u8 tos,
 	return INET_ECN_encapsulate(tos, inner);
 }
 
#include <linux/jhash.h>
quoted
+/* Compute hash to use for source port
+ *   first choice to use L4 flow hash since it will spread
+ *     better and maybe available from hardware
+ *   secondary choice is to use jhash on the Ethernet header
+ * Always returns non-zero value
+ */
+static u16 vxlan_flow_hash(struct sk_buff *skb)
+{
+	u16 hash = skb_get_rxhash(skb);
skb_get_rxhash(skb) returns an u32, that could have low order 16bits
set
to 0.

So I would use u32 hash = skb_get_rxhash(skb);

Turns out that 0 is a valid source port if no reply is requested
(per RFC and wikipedia)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help