Commit 0ad060ee authored by Roi Dayan's avatar Roi Dayan Committed by Saeed Mahameed

net/mlx5e: Don't make internal use of errno to denote missing neigh

EAGAIN is treated as a specific case when we consider the attachment
successful but wait for neigh event before offloading the flow.
This can result in unwanted behavior when sub calls on the offloading
path will return EAGAIN and we pass this error up.

Instead of attaching to a specific error code return a  boolean value
from the attach encap operation saying if the encap is valid or not.
Signed-off-by: default avatarRoi Dayan <roid@mellanox.com>
Reviewed-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 733d4f36
...@@ -295,7 +295,9 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, ...@@ -295,7 +295,9 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv,
if (!(nud_state & NUD_VALID)) { if (!(nud_state & NUD_VALID)) {
neigh_event_send(n, NULL); neigh_event_send(n, NULL);
err = -EAGAIN; /* the encap entry will be made valid on neigh update event
* and not used before that.
*/
goto out; goto out;
} }
...@@ -408,7 +410,9 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, ...@@ -408,7 +410,9 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv,
if (!(nud_state & NUD_VALID)) { if (!(nud_state & NUD_VALID)) {
neigh_event_send(n, NULL); neigh_event_send(n, NULL);
err = -EAGAIN; /* the encap entry will be made valid on neigh update event
* and not used before that.
*/
goto out; goto out;
} }
......
...@@ -854,7 +854,8 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, ...@@ -854,7 +854,8 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
struct net_device *mirred_dev, struct net_device *mirred_dev,
int out_index, int out_index,
struct netlink_ext_ack *extack, struct netlink_ext_ack *extack,
struct net_device **encap_dev); struct net_device **encap_dev,
bool *encap_valid);
static struct mlx5_flow_handle * static struct mlx5_flow_handle *
mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw, mlx5e_tc_offload_fdb_rules(struct mlx5_eswitch *esw,
...@@ -940,7 +941,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, ...@@ -940,7 +941,8 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
struct mlx5_fc *counter = NULL; struct mlx5_fc *counter = NULL;
struct mlx5e_rep_priv *rpriv; struct mlx5e_rep_priv *rpriv;
struct mlx5e_priv *out_priv; struct mlx5e_priv *out_priv;
int err = 0, encap_err = 0; bool encap_valid = true;
int err = 0;
int out_index; int out_index;
if (!mlx5_eswitch_prios_supported(esw) && attr->prio != 1) { if (!mlx5_eswitch_prios_supported(esw) && attr->prio != 1) {
...@@ -970,11 +972,10 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, ...@@ -970,11 +972,10 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
out_dev = __dev_get_by_index(dev_net(priv->netdev), out_dev = __dev_get_by_index(dev_net(priv->netdev),
mirred_ifindex); mirred_ifindex);
err = mlx5e_attach_encap(priv, flow, out_dev, out_index, err = mlx5e_attach_encap(priv, flow, out_dev, out_index,
extack, &encap_dev); extack, &encap_dev, &encap_valid);
if (err && err != -EAGAIN) if (err)
goto err_attach_encap; goto err_attach_encap;
if (err == -EAGAIN)
encap_err = err;
out_priv = netdev_priv(encap_dev); out_priv = netdev_priv(encap_dev);
rpriv = out_priv->ppriv; rpriv = out_priv->ppriv;
attr->dests[out_index].rep = rpriv->rep; attr->dests[out_index].rep = rpriv->rep;
...@@ -1002,10 +1003,11 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv, ...@@ -1002,10 +1003,11 @@ mlx5e_tc_add_fdb_flow(struct mlx5e_priv *priv,
attr->counter = counter; attr->counter = counter;
} }
/* we get here if (1) there's no error or when /* we get here if one of the following takes place:
* (2) there's an encap action and we're on -EAGAIN (no valid neigh) * (1) there's no error
* (2) there's an encap action and we don't have valid neigh
*/ */
if (encap_err == -EAGAIN) { if (!encap_valid) {
/* continue with goto slow path rule instead */ /* continue with goto slow path rule instead */
struct mlx5_esw_flow_attr slow_attr; struct mlx5_esw_flow_attr slow_attr;
...@@ -2343,7 +2345,8 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, ...@@ -2343,7 +2345,8 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
struct net_device *mirred_dev, struct net_device *mirred_dev,
int out_index, int out_index,
struct netlink_ext_ack *extack, struct netlink_ext_ack *extack,
struct net_device **encap_dev) struct net_device **encap_dev,
bool *encap_valid)
{ {
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch; struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
struct mlx5_esw_flow_attr *attr = flow->esw_attr; struct mlx5_esw_flow_attr *attr = flow->esw_attr;
...@@ -2391,7 +2394,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, ...@@ -2391,7 +2394,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
else if (family == AF_INET6) else if (family == AF_INET6)
err = mlx5e_tc_tun_create_header_ipv6(priv, mirred_dev, e); err = mlx5e_tc_tun_create_header_ipv6(priv, mirred_dev, e);
if (err && err != -EAGAIN) if (err)
goto out_err; goto out_err;
hash_add_rcu(esw->offloads.encap_tbl, &e->encap_hlist, hash_key); hash_add_rcu(esw->offloads.encap_tbl, &e->encap_hlist, hash_key);
...@@ -2403,8 +2406,9 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv, ...@@ -2403,8 +2406,9 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
if (e->flags & MLX5_ENCAP_ENTRY_VALID) { if (e->flags & MLX5_ENCAP_ENTRY_VALID) {
attr->dests[out_index].encap_id = e->encap_id; attr->dests[out_index].encap_id = e->encap_id;
attr->dests[out_index].flags |= MLX5_ESW_DEST_ENCAP_VALID; attr->dests[out_index].flags |= MLX5_ESW_DEST_ENCAP_VALID;
*encap_valid = true;
} else { } else {
err = -EAGAIN; *encap_valid = false;
} }
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment