public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: Jesse Gross <jesse@nicira.com>,
	davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [RFC] vxlan: use ether header as fallback hash
Date: Thu, 04 Oct 2012 06:57:53 +0200	[thread overview]
Message-ID: <1349326673.16011.5.camel@edumazet-glaptop> (raw)
In-Reply-To: <20121003213906.09b57539@nehalam.linuxnetplumber.net>

On Wed, 2012-10-03 at 21:39 -0700, Stephen Hemminger wrote:
> 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 <shemminger@vyatta.com>
> 
> ---
> 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>

> +/* 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);



> +
> +	if (!hash)
> +		hash = jhash(skb->data, 3, skb->protocol);
> +

then here, do :

	hash ^= hash >> 16;
	hash &= 0xffff;


> +	if (!hash)
> +		hash = 1;
> +
> +	return hash;
> +}
> +

  reply	other threads:[~2012-10-04  4:57 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20121001223232.566037595@vyatta.com>
2012-10-01 22:32 ` [PATCH 1/3] netlink: add attributes to fdb interface Stephen Hemminger
2012-10-01 22:40   ` David Miller
2012-10-01 22:32 ` [PATCH 2/3] igmp: export symbol ip_mc_leave_group Stephen Hemminger
2012-10-01 22:40   ` David Miller
2012-10-01 22:32 ` [PATCH 3/3] vxlan: virtual extensible lan Stephen Hemminger
2012-10-01 22:40   ` David Miller
2012-10-04  1:54   ` Jesse Gross
2012-10-04  4:02     ` Stephen Hemminger
2012-10-04  6:34       ` Eric Dumazet
2012-10-04 15:12         ` Stephen Hemminger
2012-10-04 16:25           ` Jesse Gross
2012-10-04  4:39     ` [RFC] vxlan: use ether header as fallback hash Stephen Hemminger
2012-10-04  4:57       ` Eric Dumazet [this message]
2012-10-04  5:06         ` Stephen Hemminger
2012-10-04 16:27       ` Jesse Gross
2012-10-04 16:43         ` Stephen Hemminger
2012-10-04 17:06           ` Jesse Gross
2012-10-04 17:07           ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1349326673.16011.5.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=jesse@nicira.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox