Skip to content

Commit ace7432

Browse files
Paul BlakeySaeed Mahameed
authored andcommitted
net/mlx5e: Fix erroneous freeing of encap header buffer
In case the neighbour for the tunnel destination isn't valid, we send a neighbour update request but we free the encap header buffer. This is wrong, because we still need it for allocating a HW encap entry once the neighbour is available. Fix that by skipping freeing it if we wait for neighbour. Fixes: 232c001 ('net/mlx5e: Add support to neighbour update flow') Signed-off-by: Paul Blakey <[email protected]> Reviewed-by: Or Gerlitz <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 16f1c5b commit ace7432

File tree

1 file changed

+10
-8
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
15641564
break;
15651565
default:
15661566
err = -EOPNOTSUPP;
1567-
goto out;
1567+
goto free_encap;
15681568
}
15691569
fl4.flowi4_tos = tun_key->tos;
15701570
fl4.daddr = tun_key->u.ipv4.dst;
@@ -1573,7 +1573,7 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
15731573
err = mlx5e_route_lookup_ipv4(priv, mirred_dev, &out_dev,
15741574
&fl4, &n, &ttl);
15751575
if (err)
1576-
goto out;
1576+
goto free_encap;
15771577

15781578
/* used by mlx5e_detach_encap to lookup a neigh hash table
15791579
* entry in the neigh hash table when a user deletes a rule
@@ -1590,7 +1590,7 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
15901590
*/
15911591
err = mlx5e_rep_encap_entry_attach(netdev_priv(out_dev), e);
15921592
if (err)
1593-
goto out;
1593+
goto free_encap;
15941594

15951595
read_lock_bh(&n->lock);
15961596
nud_state = n->nud_state;
@@ -1630,8 +1630,9 @@ static int mlx5e_create_encap_header_ipv4(struct mlx5e_priv *priv,
16301630

16311631
destroy_neigh_entry:
16321632
mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e);
1633-
out:
1633+
free_encap:
16341634
kfree(encap_header);
1635+
out:
16351636
if (n)
16361637
neigh_release(n);
16371638
return err;
@@ -1668,7 +1669,7 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
16681669
break;
16691670
default:
16701671
err = -EOPNOTSUPP;
1671-
goto out;
1672+
goto free_encap;
16721673
}
16731674

16741675
fl6.flowlabel = ip6_make_flowinfo(RT_TOS(tun_key->tos), tun_key->label);
@@ -1678,7 +1679,7 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
16781679
err = mlx5e_route_lookup_ipv6(priv, mirred_dev, &out_dev,
16791680
&fl6, &n, &ttl);
16801681
if (err)
1681-
goto out;
1682+
goto free_encap;
16821683

16831684
/* used by mlx5e_detach_encap to lookup a neigh hash table
16841685
* entry in the neigh hash table when a user deletes a rule
@@ -1695,7 +1696,7 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
16951696
*/
16961697
err = mlx5e_rep_encap_entry_attach(netdev_priv(out_dev), e);
16971698
if (err)
1698-
goto out;
1699+
goto free_encap;
16991700

17001701
read_lock_bh(&n->lock);
17011702
nud_state = n->nud_state;
@@ -1736,8 +1737,9 @@ static int mlx5e_create_encap_header_ipv6(struct mlx5e_priv *priv,
17361737

17371738
destroy_neigh_entry:
17381739
mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e);
1739-
out:
1740+
free_encap:
17401741
kfree(encap_header);
1742+
out:
17411743
if (n)
17421744
neigh_release(n);
17431745
return err;

0 commit comments

Comments
 (0)