netlink: add attributes to fdb interface
Subsystems (6)
PATCH 1/3 netlink: add attributes to fdb interface
In reply to a message not in the archiveLater changes need to be able to refer to neighbour attributes when doing fdb_add.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- drivers/net/macvlan.c | 2 +- include/linux/netdevice.h | 4 +++- net/bridge/br_fdb.c | 3 ++- net/bridge/br_private.h | 2 +- net/core/rtnetlink.c | 6 ++++-- 6 files changed, 12 insertions(+), 7 deletions(-)
drivers/net/macvlan.c +1 -1
@@ -546,7 +546,7 @@ static int macvlan_vlan_rx_kill_vid(strureturn 0 ; } -static int macvlan_fdb_add (struct ndmsg *ndm, +static int macvlan_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 flags)
include/linux/netdevice.h +3 -1
@@ -904,7 +904,8 @@ struct netdev_fcoe_hbainfo {* feature set might be less than what was returned by ndo_fix_features()). * Must return >0 or -errno if it changed dev->features itself. * -* int (*ndo_fdb_add)(struct ndmsg *ndm, struct net_device *dev, +* int (*ndo_fdb_add)(struct ndmsg *ndm, struct nlattr *tb[], +* struct net_device *dev, * const unsigned char *addr, u16 flags) * Adds an FDB entry to dev for addr. * int (*ndo_fdb_del)(struct ndmsg *ndm, struct net_device *dev,
@@ -1014,6 +1015,7 @@ struct net_device_ops {void (*ndo_neigh_destroy)(struct neighbour *n);int (*ndo_fdb_add)(struct ndmsg *ndm, +struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 flags);
net/bridge/br_fdb.c +2 -1
@@ -608,7 +608,8 @@ static int fdb_add_entry(struct net_brid }/* Add new permanent fdb entry with RTM_NEWNEIGH */ -int br_fdb_add (struct ndmsg *ndm,struct net_device *dev, +int br_fdb_add (struct ndmsg *ndm,struct nlattr *tb[], +struct net_device *dev,const unsigned char *addr,u16 nlh_flags) {struct net_bridge_port *p;
net/bridge/br_private.h +1 -1
@@ -364,7 +364,7 @@ extern void br_fdb_update(struct net_briextern int br_fdb_delete (struct ndmsg *ndm,struct net_device *dev,const unsigned char *addr); -extern int br_fdb_add (struct ndmsg *nlh, +extern int br_fdb_add (struct ndmsg *nlh,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 nlh_flags);
net/core/rtnetlink.c +4 -2
@@ -2090,7 +2090,8 @@ static int rtnl_fdb_add(struct sk_buff *if ((!ndm->ndm_flags || ndm->ndm_flags &NTF_MASTER ) && (dev->priv_flags &IFF_BRIDGE_PORT )) { master = dev->master; - err = master->netdev_ops->ndo_fdb_add (ndm, dev, addr, + err = master->netdev_ops->ndo_fdb_add (ndm, tb, + dev, addr, nlh->nlmsg_flags);if (err) goto out;
@@ -2100,7 +2101,8 @@ static int rtnl_fdb_add(struct sk_buff */* Embedded bridge, macvlan, and any other device support */ if ((ndm->ndm_flags &NTF_SELF ) && dev->netdev_ops->ndo_fdb_add) { - err = dev->netdev_ops->ndo_fdb_add (ndm, dev, addr, + err = dev->netdev_ops->ndo_fdb_add (ndm, tb, + dev, addr, nlh->nlmsg_flags);if (!err) {
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +1 -1
@@ -6889,7 +6889,7 @@ static int ixgbe_set_features(struct netreturn 0 ; } -static int ixgbe_ndo_fdb_add (struct ndmsg *ndm, +static int ixgbe_ndo_fdb_add (struct ndmsg *ndm,struct nlattr *tb[],struct net_device *dev,const unsigned char *addr,u16 flags)
PATCH 2/3 igmp: export symbol ip_mc_leave_group
In reply to a message not in the archiveNeeded for VXLAN.
net/ipv4/igmp.c +1 -0
@@ -1904,6 +1904,7 @@ int ip_mc_leave_group(struct sock *sk, srtnl_unlock ();return ret; } +EXPORT_SYMBOL (ip_mc_leave_group);int ip_mc_source (int add,int omode,struct sock *sk,struct ip_mreq_source *mreqs,int ifindex)
PATCH 3/3 vxlan: virtual extensible lan
In reply to a message not in the archiveThis is an implementation of Virtual eXtensible Local Area Network as described in draft RFC:
http://tools.ietf.org/html/draft-mahalingam-dutt-dcops-vxlan-02
The driver integrates a Virtual Tunnel Endpoint (VTEP) functionality that learns MAC to IP address mapping.
This implementation has not been tested only against the Linux userspace implementation using TAP, not against other vendor's equipment.
---
v6 - simplify hash function
allow configuring forwarding table limit and ageing timer account for VLAN in header
adjust mtu based on lower device (if any)
fix fields in fdb_show
v5 - drop MTU discovery since network is overlaid
use common code to do ECN decapsulation
v4 - fix ecn and set state of fdb entries
v3 - fix ordering of change versus migration message v2 - fix use of ip header after pskb_may_pull
Documentation/networking/vxlan.txt | 47 + drivers/net/Kconfig | 13 drivers/net/Makefile | 1 drivers/net/vxlan.c | 1217 +++++++++++++++++++++++++++++++++++++ include/linux/if_link.h | 16 5 files changed, 1294 insertions(+)
drivers/net/Kconfig +13 -0
@@ -149,6 +149,19 @@ config MACVTAP To compile this driver as a module, choose M here: the module will be called macvtap. +config VXLAN + tristate "Virtual eXtensible Local Area Network (VXLAN)" + depends on EXPERIMENTAL + ---help--- + This allows one to create vxlan virtual interfaces that provide + Layer 2 Networks over Layer 3 Networks. VXLAN is often used + to tunnel virtual network infrastructure in virtualized environments. + For more information see: + http://tools.ietf.org/html/draft-mahalingam-dutt-dcops-vxlan-02 + + To compile this driver as a module, choose M here: the module + will be called vxlan. + config NETCONSOLE tristate "Network console logging support" ---help---
drivers/net/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_NET_TEAM) += team/ obj-$(CONFIG_TUN) += tun.o obj-$(CONFIG_VETH) += veth.o obj-$(CONFIG_VIRTIO_NET) += virtio_net.o +obj-$(CONFIG_VXLAN) += vxlan.o # # Networking Drivers
drivers/net/vxlan.c new file +1217 -0
1,217 lines not on this page · raw message
include/linux/if_link.h +16 -0
@@ -272,6 +272,22 @@ enum macvlan_mode {#define MACVLAN_FLAG_NOPROMISC 1 +/* VXLAN section */ +enum { +IFLA_VXLAN_UNSPEC , +IFLA_VXLAN_ID , +IFLA_VXLAN_GROUP , +IFLA_VXLAN_LINK , +IFLA_VXLAN_LOCAL , +IFLA_VXLAN_TTL , +IFLA_VXLAN_TOS , +IFLA_VXLAN_LEARNING , +IFLA_VXLAN_AGEING , +IFLA_VXLAN_LIMIT , + __IFLA_VXLAN_MAX +}; +#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1) +/* SR-IOV virtual function management section */ enum {
Documentation/networking/vxlan.txt new file +47 -0
47 lines not on this page · raw message
From: Stephen Hemminger <[email protected]>
Date: Mon, 01 Oct 2012 15:32:33 -0700
Quoted 4 lines
Later changes need to be able to refer to neighbour attributes when doing
fdb_add.Signed-off-by Stephen Hemminger <[email protected]>
Applied.
Re: [PATCH 2/3] igmp: export symbol ip_mc_leave_group
In reply to Stephen HemmingerFrom: Stephen Hemminger <[email protected]>
Date: Mon, 01 Oct 2012 15:32:34 -0700
Quoted 3 lines
Needed for VXLAN.
Signed-off-by Stephen Hemminger <[email protected]>
Applied.
Re: [PATCH 3/3] vxlan: virtual extensible lan
In reply to Stephen HemmingerFrom: Stephen Hemminger <[email protected]>
Date: Mon, 01 Oct 2012 15:32:35 -0700
Quoted 4 lines
This is an implementation of Virtual eXtensible Local Area Network as described in draft RFC:
http://tools.ietf.org/html/draft-mahalingam-dutt-dcops-vxlan-02
Quoted 8 lines
The driver integrates a Virtual Tunnel Endpoint (VTEP) functionality that learns MAC to IP address mapping.
This implementation has not been tested only against the Linux userspace implementation using TAP, not against other vendor's equipment.
Signed-off-by Stephen Hemminger <[email protected]>
Applied.
Re: [PATCH 3/3] vxlan: virtual extensible lan
In reply to Stephen HemmingerQuoted 10 lines · Stephen Hemminger
drivers/net/vxlan.c 2012-10-01 15:08:38.024499080 -0700 renamed from dev/null 1970-01-01 00:00:00.000000000 +0000 +8
-0+/* Transmit local packets over Vxlan + * + * Outer IP header inherits ECN and DF from inner header. + * Outer UDP destination is the VXLAN assigned port. + * source port is based on hash of flow if available + * otherwise use a random value + */ +static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
[...]
Quoted 1 line
+ hash =
skb_get_rxhash(skb);
[...]
drivers/net/vxlan.c 2012-10-01 15:08:38.024499080 -0700
Quoted 2 lines
drivers/net/vxlan.c 2012-10-01 15:08:38.024499080 -0700 renamed from dev/null 1970-01-01 00:00:00.000000000 +0000 +2
-0+ uh->dest = htons(vxlan_port); + uh->source = hash ? :random32();
I think this may lead to packet reordering in some cases. If the protocol is unknown then it may still represent part of a flow and random source ports could lead to taking different paths.
Also, does it make sense to restrict the range of ports to, say, the upper half of the range?
Re: [PATCH 3/3] vxlan: virtual extensible lan
Quoted 17 lines · On Wed, 3 Oct 2012 18:54:46 -0700 Jesse Gross <[email protected]> wrote:
Quoted 10 lines · Stephen Hemminger
drivers/net/vxlan.c 2012-10-01 15:08:38.024499080 -0700 renamed from dev/null 1970-01-01 00:00:00.000000000 +0000 +8
-0+/* Transmit local packets over Vxlan + * + * Outer IP header inherits ECN and DF from inner header. + * Outer UDP destination is the VXLAN assigned port. + * source port is based on hash of flow if available + * otherwise use a random value + */ +static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)[...]
Quoted 1 line
+ hash =
skb_get_rxhash(skb);[...]
drivers/net/vxlan.c 2012-10-01 15:08:38.024499080 -0700
Quoted 2 lines
drivers/net/vxlan.c 2012-10-01 15:08:38.024499080 -0700 renamed from dev/null 1970-01-01 00:00:00.000000000 +0000 +2
-0+ uh->dest = htons(vxlan_port); + uh->source = hash ? :random32();
Quoted 6 lines
I think this may lead to packet reordering in some cases. If the protocol is unknown then it may still represent part of a flow and random source ports could lead to taking different paths.
Also, does it make sense to restrict the range of ports to, say, the upper half of the range?
Since port is always a pair, there is no need to restrict range, unless there was a broken firewall in the way. One bug there is that random32() can return 0 which is not a valid port number. A better fallback would be a hash of the MAC header.
RFC 1/1 vxlan: use ether header as fallback hash
In reply to Jesse GrossVXLAN 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.
---
RFC for now, compile tested only
drivers/net/vxlan.c +23 -5
@@ -622,12 +622,30 @@ static inline u8 vxlan_ecn_encap(u8 tos,return INET_ECN_encapsulate (tos, inner); } +/* 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); + +if (!hash) + hash =jhash (skb->data,3 , skb->protocol); + +if (!hash) + hash =1 ; + +return hash; +} +/* Transmit local packets over Vxlan * * Outer IP header inherits ECN and DF from inner header. * Outer UDP destination is the VXLAN assigned port. -* source port is based on hash of flow if available -* otherwise use a random value +* source port is based on hash of flow */ static netdev_tx_t vxlan_xmit (struct sk_buff *skb,struct net_device *dev) {
@@ -641,8 +659,8 @@ static netdev_tx_t vxlan_xmit(struct sk_struct flowi4 fl4;struct vxlan_fdb *f;unsigned int pkt_len = skb->len; -u32 hash;__be32 dst; +__be16 src_port;__be16 df =0 ;__u8 tos, ttl;int err;
@@ -670,7 +688,7 @@ static netdev_tx_t vxlan_xmit(struct sk_if (tos ==1 ) tos =vxlan_get_dsfield (old_iph, skb); - hash =skb_get_rxhash (skb); + src_port = (__force __be16 )vxlan_flow_hash (skb); rt = ip_route_output_gre(dev_net(dev), &fl4, dst, vxlan->saddr, vxlan->vni,
@@ -703,7 +721,7 @@ static netdev_tx_t vxlan_xmit(struct sk_ uh =udp_hdr (skb); uh->dest =htons (vxlan_port); - uh->source = hash ? :random32 (); + uh->source = src_port; uh->len =htons (skb->len); uh->check =0 ;
Re: [RFC] vxlan: use ether header as fallback hash
Quoted 20 lines · Stephen Hemminger
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 <[email protected]>---
RFC for now, compile tested only
drivers/net/vxlan.c static inline u8 vxlan_ecn_encap(u8 tos, · line 624
Quoted 3 lines
drivers/net/vxlan.c +0
-0@@ -622,12 +622,30 @@ static inline u8 vxlan_ecn_encap(u8 tos,return INET_ECN_encapsulate (tos, inner); }
#include <linux/jhash.h>
drivers/net/vxlan.c static inline u8 vxlan_ecn_encap(u8 tos, · line 633
Quoted 9 lines
drivers/net/vxlan.c +9
-0+/* 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);
drivers/net/vxlan.c static inline u8 vxlan_ecn_encap(u8 tos, · line 637
Quoted 4 lines
drivers/net/vxlan.c +4
-0+ +if (!hash) + hash =jhash (skb->data,3 , skb->protocol); +
then here, do :
hash ^= hash >> 16; hash &= 0xffff;
Quoted 6 lines
drivers/net/vxlan.c +6
-0+if (!hash) + hash =1 ; + +return hash; +} +
Re: [RFC] vxlan: use ether header as fallback hash
Quoted 42 lines · Stephen Hemminger
Quoted 20 lines
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 <[email protected]>---
RFC for now, compile tested onlydrivers/net/vxlan.c static inline u8 vxlan_ecn_encap(u8 tos, · line 624
Quoted 3 lines
drivers/net/vxlan.c +0
-0@@ -622,12 +622,30 @@ static inline u8 vxlan_ecn_encap(u8 tos,return INET_ECN_encapsulate (tos, inner); }#include <
linux/jhash.h>drivers/net/vxlan.c static inline u8 vxlan_ecn_encap(u8 tos, · line 633
Quoted 9 lines
drivers/net/vxlan.c +9
-0+/* 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.
Quoted 1 line
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)
Re: [PATCH 3/3] vxlan: virtual extensible lan
In reply to Stephen HemmingerQuoted 5 lines · Stephen Hemminger
Since port is always a pair, there is no need to restrict range, unless there was a broken firewall in the way. One bug there is that
random32()can return 0 which is not a valid port number. A better fallback would be a hash of the MAC header.
But using up to 65536 values for the port means that if vxlan traffic crosses a statefull firewall (eg netfilter with conntrack), this might need 65536 contexts/sessions.
So random32() is not needed.
What might be needed is additional parameters for a vxlan tunnel, to give an optional range for the source port.
Re: [PATCH 3/3] vxlan: virtual extensible lan
Quoted 11 lines · On Thu, 04 Oct 2012 08:34:50 +0200 Eric Dumazet <[email protected]> wrote:
Quoted 5 lines · Stephen Hemminger
Since port is always a pair, there is no need to restrict range, unless there was a broken firewall in the way. One bug there is that
random32()can return 0 which is not a valid port number. A better fallback would be a hash of the MAC header.But using up to 65536 values for the port means that if vxlan traffic crosses a statefull firewall (eg netfilter with conntrack), this might need 65536 contexts/sessions.
This is UDP, there is no usable state to be found.
But as a practical matter it only needs to be wide enough to hit the number of receive channels. Therefore even 64 is probably enough for most people.
Quoted 4 lines
So
random32()is not needed.What might be needed is additional parameters for a vxlan tunnel, to give an optional range for the source port.
It could be per vxlan without a lot of pain. or just derive it value from existing ephermeral port range.
Re: [PATCH 3/3] vxlan: virtual extensible lan
Quoted 11 lines · Stephen Hemminger
Quoted 8 lines · On Thu, 04 Oct 2012 08:34:50 +0200 Eric Dumazet <[email protected]> wrote:
Quoted 5 lines · Stephen Hemminger
Since port is always a pair, there is no need to restrict range, unless there was a broken firewall in the way. One bug there is that
random32()can return 0 which is not a valid port number. A better fallback would be a hash of the MAC header.
Quoted 8 lines
Quoted 3 lines
But using up to 65536 values for the port means that if vxlan traffic crosses a statefull firewall (eg netfilter with conntrack), this might need 65536 contexts/sessions.
This is UDP, there is no usable state to be found.
But as a practical matter it only needs to be wide enough to hit the number of receive channels. Therefore even 64 is probably enough for most people.
I don't think it actually matters all that much either way because there will be one vxlan flow for each encapsulated flow. If you're running iptables on a hypervisor, for example, you probably end up seeing the same number of flows as you do today.
There is some benefit to using a slightly wider range than the number of paths you can take because devices in the path will do their own hash. Having a larger range on the vxlan side will reduce the impact of collisions in the second hash.
Quoted 7 lines
Quoted 4 lines
So
random32()is not needed.What might be needed is additional parameters for a vxlan tunnel, to give an optional range for the source port.
It could be per vxlan without a lot of pain. or just derive it value from existing ephermeral port range.
In the STT draft we recommended using the ephemeral range. It seemed like a good balance.
Re: [RFC] vxlan: use ether header as fallback hash
In reply to Stephen HemmingerQuoted 25 lines · Stephen Hemminger
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 <[email protected]>---
RFC for now, compile tested onlydrivers/net/vxlan.c 2012-10-03 21:36:10.213805422 -0700 renamed from drivers/net/vxlan.c 2012-10-03 21:25:43.747968165 -0700 +2
-0@@ -622,12 +622,30 @@ static inline u8 vxlan_ecn_encap(u8 tos, return INET_ECN_encapsulate(tos, inner); } +/* Compute hash to use for source port + * first choice to use L4 flow hash since it will spread
drivers/net/vxlan.c 2012-10-03 21:36:10.213805422 -0700 static inline u8 vxlan_ecn_encap(u8 tos, · line 636
Quoted 10 lines
drivers/net/vxlan.c 2012-10-03 21:36:10.213805422 -0700 renamed from drivers/net/vxlan.c 2012-10-03 21:25:43.747968165 -0700 +10
-0+ * 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); + + if (!hash) + hash = jhash(skb->data, 3, skb->protocol);
Shouldn't this be jhash2 for words?
Re: [RFC] vxlan: use ether header as fallback hash
Quoted 24 lines · On Thu, 4 Oct 2012 09:27:14 -0700 Jesse Gross <[email protected]> wrote:
Quoted 23 lines · Stephen Hemminger
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 <[email protected]>---
RFC for now, compile tested onlydrivers/net/vxlan.c 2012-10-03 21:36:10.213805422 -0700 renamed from drivers/net/vxlan.c 2012-10-03 21:25:43.747968165 -0700 +0
-0@@ -622,12 +622,30 @@ static inline u8 vxlan_ecn_encap(u8 tos, return INET_ECN_encapsulate(tos, inner); }
Quoted 14 lines
drivers/net/vxlan.c 2012-10-03 21:36:10.213805422 -0700 static inline u8 vxlan_ecn_encap(u8 tos, · line 636
Quoted 12 lines
drivers/net/vxlan.c 2012-10-03 21:36:10.213805422 -0700 renamed from drivers/net/vxlan.c 2012-10-03 21:25:43.747968165 -0700 +12
-0+/* 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); + + if (!hash) + hash = jhash(skb->data, 3, skb->protocol);Shouldn't this be jhash2 for words?
No. for a couple of reasons. First, the ethernet header may not be aligned. Second we want to get source/destination and type. The source/destination is 12 bytes (3 words) and the ether type is already in skb->protocol.
Re: [RFC] vxlan: use ether header as fallback hash
Quoted 42 lines · Stephen Hemminger
Quoted 24 lines · On Thu, 4 Oct 2012 09:27:14 -0700 Jesse Gross <[email protected]> wrote:
Quoted 23 lines · Stephen Hemminger
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 <[email protected]>---
RFC for now, compile tested onlydrivers/net/vxlan.c 2012-10-03 21:36:10.213805422 -0700 renamed from drivers/net/vxlan.c 2012-10-03 21:25:43.747968165 -0700 +0
-0@@ -622,12 +622,30 @@ static inline u8 vxlan_ecn_encap(u8 tos, return INET_ECN_encapsulate(tos, inner); }Quoted 14 lines
drivers/net/vxlan.c 2012-10-03 21:36:10.213805422 -0700 static inline u8 vxlan_ecn_encap(u8 tos, · line 636
Quoted 12 lines
drivers/net/vxlan.c 2012-10-03 21:36:10.213805422 -0700 renamed from drivers/net/vxlan.c 2012-10-03 21:25:43.747968165 -0700 +12
-0+/* 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); + + if (!hash) + hash = jhash(skb->data, 3, skb->protocol);Shouldn't this be jhash2 for words?
Quoted 3 lines
No. for a couple of reasons. First, the ethernet header may not be aligned. Second we want to get source/destination and type. The source/destination is 12 bytes (3 words) and the ether type is already in
skb->protocol.
OK, it might not be aligned but jhash takes it's length as the number of bytes, not words.
Re: [RFC] vxlan: use ether header as fallback hash
In reply to Stephen HemmingerQuoted 12 lines · Stephen Hemminger
Quoted 8 lines · On Thu, 4 Oct 2012 09:27:14 -0700 Jesse Gross <[email protected]> wrote:
drivers/net/vxlan.c static inline u8 vxlan_ecn_encap(u8 tos, · line 636
Quoted 6 lines
drivers/net/vxlan.c +6
-0+static u16 vxlan_flow_hash (struct sk_buff *skb) +{ +u16 hash =skb_get_rxhash (skb); + +if (!hash) + hash =jhash (skb->data,3 , skb->protocol);Shouldn't this be jhash2 for words?
Quoted 3 lines
No. for a couple of reasons. First, the ethernet header may not be aligned. Second we want to get source/destination and type. The source/destination is 12 bytes (3 words) and the ether type is already in
skb->protocol.
jhash(skb->data, 12, initval)