Skip to content

Commit 7f1a546

Browse files
Eli BritsteinSaeed Mahameed
authored andcommitted
net/mlx5e: Consider tunnel type for encap contexts
The driver allocates an encap context based on the tunnel properties, and reuse that context for all flows using the same tunnel properties. Commit df2ef3b ("net/mlx5e: Add GRE protocol offloading") introduced another tunnel protocol other than the single VXLAN previously supported. A flow that uses a tunnel with the same tunnel properties but with a different tunnel type (GRE vs VXLAN for example) would mistakenly reuse the previous alocated context, causing the traffic to be sent with the wrong encapsulation. Fix that by considering the tunnel type for encap contexts. Fixes: df2ef3b ("net/mlx5e: Add GRE protocol offloading") Signed-off-by: Eli Britstein <elibr@mellanox.com> Reviewed-by: Roi Dayan <roid@mellanox.com> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
1 parent e28408e commit 7f1a546

File tree

1 file changed

+19
-9
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+19
-9
lines changed

drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,15 +2384,22 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv,
23842384
return 0;
23852385
}
23862386

2387-
static inline int cmp_encap_info(struct ip_tunnel_key *a,
2388-
struct ip_tunnel_key *b)
2387+
struct encap_key {
2388+
struct ip_tunnel_key *ip_tun_key;
2389+
int tunnel_type;
2390+
};
2391+
2392+
static inline int cmp_encap_info(struct encap_key *a,
2393+
struct encap_key *b)
23892394
{
2390-
return memcmp(a, b, sizeof(*a));
2395+
return memcmp(a->ip_tun_key, b->ip_tun_key, sizeof(*a->ip_tun_key)) ||
2396+
a->tunnel_type != b->tunnel_type;
23912397
}
23922398

2393-
static inline int hash_encap_info(struct ip_tunnel_key *key)
2399+
static inline int hash_encap_info(struct encap_key *key)
23942400
{
2395-
return jhash(key, sizeof(*key), 0);
2401+
return jhash(key->ip_tun_key, sizeof(*key->ip_tun_key),
2402+
key->tunnel_type);
23962403
}
23972404

23982405

@@ -2423,7 +2430,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
24232430
struct mlx5_esw_flow_attr *attr = flow->esw_attr;
24242431
struct mlx5e_tc_flow_parse_attr *parse_attr;
24252432
struct ip_tunnel_info *tun_info;
2426-
struct ip_tunnel_key *key;
2433+
struct encap_key key, e_key;
24272434
struct mlx5e_encap_entry *e;
24282435
unsigned short family;
24292436
uintptr_t hash_key;
@@ -2433,13 +2440,16 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
24332440
parse_attr = attr->parse_attr;
24342441
tun_info = &parse_attr->tun_info[out_index];
24352442
family = ip_tunnel_info_af(tun_info);
2436-
key = &tun_info->key;
2443+
key.ip_tun_key = &tun_info->key;
2444+
key.tunnel_type = mlx5e_tc_tun_get_type(mirred_dev);
24372445

2438-
hash_key = hash_encap_info(key);
2446+
hash_key = hash_encap_info(&key);
24392447

24402448
hash_for_each_possible_rcu(esw->offloads.encap_tbl, e,
24412449
encap_hlist, hash_key) {
2442-
if (!cmp_encap_info(&e->tun_info.key, key)) {
2450+
e_key.ip_tun_key = &e->tun_info.key;
2451+
e_key.tunnel_type = e->tunnel_type;
2452+
if (!cmp_encap_info(&e_key, &key)) {
24432453
found = true;
24442454
break;
24452455
}

0 commit comments

Comments
 (0)