Skip to content

Commit e069ba0

Browse files
apconoledavem330
authored andcommitted
net: openvswitch: add support for l4 symmetric hashing
Since its introduction, the ovs module execute_hash action allowed hash algorithms other than the skb->l4_hash to be used. However, additional hash algorithms were not implemented. This means flows requiring different hash distributions weren't able to use the kernel datapath. Now, introduce support for symmetric hashing algorithm as an alternative hash supported by the ovs module using the flow dissector. Output of flow using l4_sym hash: recirc_id(0),in_port(3),eth(),eth_type(0x0800), ipv4(dst=64.0.0.0/192.0.0.0,proto=6,frag=no), packets:30473425, bytes:45902883702, used:0.000s, flags:SP., actions:hash(sym_l4(0)),recirc(0xd) Some performance testing with no GRO/GSO, two veths, single flow: hash(l4(0)): 4.35 GBits/s hash(l4_sym(0)): 4.24 GBits/s Signed-off-by: Aaron Conole <aconole@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6513787 commit e069ba0

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

include/uapi/linux/openvswitch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,7 @@ struct ovs_action_push_vlan {
765765
*/
766766
enum ovs_hash_alg {
767767
OVS_HASH_ALG_L4,
768+
OVS_HASH_ALG_SYM_L4,
768769
};
769770

770771
/*

net/openvswitch/actions.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,8 +1073,16 @@ static void execute_hash(struct sk_buff *skb, struct sw_flow_key *key,
10731073
struct ovs_action_hash *hash_act = nla_data(attr);
10741074
u32 hash = 0;
10751075

1076-
/* OVS_HASH_ALG_L4 is the only possible hash algorithm. */
1077-
hash = skb_get_hash(skb);
1076+
if (hash_act->hash_alg == OVS_HASH_ALG_L4) {
1077+
/* OVS_HASH_ALG_L4 hasing type. */
1078+
hash = skb_get_hash(skb);
1079+
} else if (hash_act->hash_alg == OVS_HASH_ALG_SYM_L4) {
1080+
/* OVS_HASH_ALG_SYM_L4 hashing type. NOTE: this doesn't
1081+
* extend past an encapsulated header.
1082+
*/
1083+
hash = __skb_get_hash_symmetric(skb);
1084+
}
1085+
10781086
hash = jhash_1word(hash, hash_act->hash_basis);
10791087
if (!hash)
10801088
hash = 0x1;

net/openvswitch/flow_netlink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,6 +3221,8 @@ static int __ovs_nla_copy_actions(struct net *net, const struct nlattr *attr,
32213221

32223222
switch (act_hash->hash_alg) {
32233223
case OVS_HASH_ALG_L4:
3224+
fallthrough;
3225+
case OVS_HASH_ALG_SYM_L4:
32243226
break;
32253227
default:
32263228
return -EINVAL;

0 commit comments

Comments
 (0)