Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f8a739e authored by Cong Wang's avatar Cong Wang Committed by David S. Miller
Browse files

act_mirred: get rid of tcfm_ifindex from struct tcf_mirred



tcfm_dev always points to the correct netdev and we already
hold a refcnt, so no need to use tcfm_ifindex to lookup again.

If we would support moving target netdev across netns, using
pointer would be better than ifindex.

This also fixes dumping obsolete ifindex, now after the
target device is gone we just dump 0 as ifindex.

Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3a9ab393
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -54,12 +54,10 @@ static int bnxt_tc_parse_redir(struct bnxt *bp,
			       struct bnxt_tc_actions *actions,
			       const struct tc_action *tc_act)
{
	int ifindex = tcf_mirred_ifindex(tc_act);
	struct net_device *dev;
	struct net_device *dev = tcf_mirred_dev(tc_act);

	dev = __dev_get_by_index(dev_net(bp->dev), ifindex);
	if (!dev) {
		netdev_info(bp->dev, "no dev for ifindex=%d", ifindex);
		netdev_info(bp->dev, "no dev in mirred action");
		return -EINVAL;
	}

+5 −7
Original line number Diff line number Diff line
@@ -405,9 +405,7 @@ static void cxgb4_process_flow_actions(struct net_device *in,
		} else if (is_tcf_gact_shot(a)) {
			fs->action = FILTER_DROP;
		} else if (is_tcf_mirred_egress_redirect(a)) {
			int ifindex = tcf_mirred_ifindex(a);
			struct net_device *out = __dev_get_by_index(dev_net(in),
								    ifindex);
			struct net_device *out = tcf_mirred_dev(a);
			struct port_info *pi = netdev_priv(out);

			fs->action = FILTER_SWITCH;
@@ -582,14 +580,14 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,
			/* Do nothing */
		} else if (is_tcf_mirred_egress_redirect(a)) {
			struct adapter *adap = netdev2adap(dev);
			struct net_device *n_dev;
			unsigned int i, ifindex;
			struct net_device *n_dev, *target_dev;
			unsigned int i;
			bool found = false;

			ifindex = tcf_mirred_ifindex(a);
			target_dev = tcf_mirred_dev(a);
			for_each_port(adap, i) {
				n_dev = adap->port[i];
				if (ifindex == n_dev->ifindex) {
				if (target_dev == n_dev) {
					found = true;
					break;
				}
+4 −4
Original line number Diff line number Diff line
@@ -114,14 +114,14 @@ static int fill_action_fields(struct adapter *adap,

		/* Re-direct to specified port in hardware. */
		if (is_tcf_mirred_egress_redirect(a)) {
			struct net_device *n_dev;
			unsigned int i, index;
			struct net_device *n_dev, *target_dev;
			bool found = false;
			unsigned int i;

			index = tcf_mirred_ifindex(a);
			target_dev = tcf_mirred_dev(a);
			for_each_port(adap, i) {
				n_dev = adap->port[i];
				if (index == n_dev->ifindex) {
				if (target_dev == n_dev) {
					fs->action = FILTER_SWITCH;
					fs->eport = i;
					found = true;
+4 −2
Original line number Diff line number Diff line
@@ -9101,9 +9101,11 @@ static int parse_tc_actions(struct ixgbe_adapter *adapter,

		/* Redirect to a VF or a offloaded macvlan */
		if (is_tcf_mirred_egress_redirect(a)) {
			int ifindex = tcf_mirred_ifindex(a);
			struct net_device *dev = tcf_mirred_dev(a);

			err = handle_redirect_action(adapter, ifindex, queue,
			if (!dev)
				return -EINVAL;
			err = handle_redirect_action(adapter, dev->ifindex, queue,
						     action);
			if (err == 0)
				return err;
+2 −3
Original line number Diff line number Diff line
@@ -1982,11 +1982,10 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
		}

		if (is_tcf_mirred_egress_redirect(a)) {
			int ifindex = tcf_mirred_ifindex(a);
			struct net_device *out_dev;
			struct mlx5e_priv *out_priv;

			out_dev = __dev_get_by_index(dev_net(priv->netdev), ifindex);
			out_dev = tcf_mirred_dev(a);

			if (switchdev_port_same_parent_id(priv->netdev,
							  out_dev)) {
@@ -1996,7 +1995,7 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
				rpriv = out_priv->ppriv;
				attr->out_rep = rpriv->rep;
			} else if (encap) {
				parse_attr->mirred_ifindex = ifindex;
				parse_attr->mirred_ifindex = out_dev->ifindex;
				parse_attr->tun_info = *info;
				attr->parse_attr = parse_attr;
				attr->action |= MLX5_FLOW_CONTEXT_ACTION_ENCAP |
Loading