All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@mellanox.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>
Subject: Re: [Patch net-next] act_mirred: use tcfm_dev in tcf_mirred_get_dev()
Date: Fri, 1 Dec 2017 18:56:19 +0100	[thread overview]
Message-ID: <20171201175619.GC2396@nanopsycho> (raw)
In-Reply-To: <20171130225335.6957-1-xiyou.wangcong@gmail.com>

Thu, Nov 30, 2017 at 11:53:32PM CET, xiyou.wangcong@gmail.com wrote:
>tcfm_dev always points to the correct netdev and we already
>hold a refcnt, so no need to use ifindex to lookup again.
>
>If we would support moving target netdev across netns, using
>pointer would be better than ifindex.
>
>Cc: Jiri Pirko <jiri@mellanox.com>
>Cc: Jamal Hadi Salim <jhs@mojatatu.com>
>Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>---
> include/net/tc_act/tc_mirred.h | 1 -
> net/sched/act_mirred.c         | 3 +--
> 2 files changed, 1 insertion(+), 3 deletions(-)
>
>diff --git a/include/net/tc_act/tc_mirred.h b/include/net/tc_act/tc_mirred.h
>index 21d253c9a8c6..b2dbbfaefd22 100644
>--- a/include/net/tc_act/tc_mirred.h
>+++ b/include/net/tc_act/tc_mirred.h
>@@ -11,7 +11,6 @@ struct tcf_mirred {
> 	int			tcfm_ifindex;
> 	bool			tcfm_mac_header_xmit;
> 	struct net_device __rcu	*tcfm_dev;
>-	struct net		*net;
> 	struct list_head	tcfm_list;
> };
> #define to_mirred(a) ((struct tcf_mirred *)a)
>diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
>index 8b3e59388480..fe6489f9c3cf 100644
>--- a/net/sched/act_mirred.c
>+++ b/net/sched/act_mirred.c
>@@ -140,7 +140,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
> 	m->tcfm_eaction = parm->eaction;
> 	if (dev != NULL) {
> 		m->tcfm_ifindex = parm->ifindex;
>-		m->net = net;

Isn't this here so user may specify a ifindex of netdev which is not yet
present on the system (not sure how much sense that would make though...)



> 		if (ret != ACT_P_CREATED)
> 			dev_put(rcu_dereference_protected(m->tcfm_dev, 1));
> 		dev_hold(dev);
>@@ -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 = {
>-- 
>2.13.0
>

  parent reply	other threads:[~2017-12-01 17:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 22:53 [Patch net-next] act_mirred: use tcfm_dev in tcf_mirred_get_dev() Cong Wang
2017-11-30 22:53 ` [Patch net-next] act_mirred: get rid of mirred_list_lock spinlock Cong Wang
2017-11-30 23:12   ` Eric Dumazet
2017-12-01  1:02     ` Cong Wang
2017-12-01 17:56 ` Jiri Pirko [this message]
2017-12-01 21:46   ` [Patch net-next] act_mirred: use tcfm_dev in tcf_mirred_get_dev() Cong Wang
2017-12-02  6:56     ` Jiri Pirko
2017-12-02  8:57 ` Jiri Pirko
2017-12-02 19:47   ` Cong Wang
2017-12-02 19:53     ` Cong Wang
2017-12-03  6:39       ` Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171201175619.GC2396@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=jhs@mojatatu.com \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.