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: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
3a9ab39328
commit
9f8a739e72
@@ -139,8 +139,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
|
||||
m->tcf_action = parm->action;
|
||||
m->tcfm_eaction = parm->eaction;
|
||||
if (dev != NULL) {
|
||||
m->tcfm_ifindex = parm->ifindex;
|
||||
m->net = net;
|
||||
if (ret != ACT_P_CREATED)
|
||||
dev_put(rcu_dereference_protected(m->tcfm_dev, 1));
|
||||
dev_hold(dev);
|
||||
@@ -247,13 +245,14 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind,
|
||||
{
|
||||
unsigned char *b = skb_tail_pointer(skb);
|
||||
struct tcf_mirred *m = to_mirred(a);
|
||||
struct net_device *dev = rtnl_dereference(m->tcfm_dev);
|
||||
struct tc_mirred opt = {
|
||||
.index = m->tcf_index,
|
||||
.action = m->tcf_action,
|
||||
.refcnt = m->tcf_refcnt - ref,
|
||||
.bindcnt = m->tcf_bindcnt - bind,
|
||||
.eaction = m->tcfm_eaction,
|
||||
.ifindex = m->tcfm_ifindex,
|
||||
.ifindex = dev ? dev->ifindex : 0,
|
||||
};
|
||||
struct tcf_t t;
|
||||
|
||||
@@ -318,7 +317,7 @@ static struct net_device *tcf_mirred_get_dev(const struct tc_action *a)
|
||||
{
|
||||
struct tcf_mirred *m = to_mirred(a);
|
||||
|
||||
return __dev_get_by_index(m->net, m->tcfm_ifindex);
|
||||
return rtnl_dereference(m->tcfm_dev);
|
||||
}
|
||||
|
||||
static struct tc_action_ops act_mirred_ops = {
|
||||
|
Reference in New Issue
Block a user