netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davide Caratti <dcaratti@redhat.com>
To: Boris Sukholitko <boris.sukholitko@broadcom.com>
Cc: netdev@vger.kernel.org, Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Ilya Lifshits <ilya.lifshits@broadcom.com>,
	Shmulik Ladkani <shmulik.ladkani@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH net-next v2 1/3] net/sched: act_vlan: Fix modify to allow 0
Date: Tue, 25 May 2021 22:35:50 +0200	[thread overview]
Message-ID: <YK1fpkmyiITfaVpr@dcaratti.users.ipa.redhat.com> (raw)
In-Reply-To: <20210525153601.6705-2-boris.sukholitko@broadcom.com>

On Tue, May 25, 2021 at 06:35:59PM +0300, Boris Sukholitko wrote:
> Currently vlan modification action checks existence of vlan priority by
> comparing it to 0. Therefore it is impossible to modify existing vlan
> tag to have priority 0.
> 
> For example, the following tc command will change the vlan id but will
> not affect vlan priority:
> 
> tc filter add dev eth1 ingress matchall action vlan modify id 300 \
>         priority 0 pipe mirred egress redirect dev eth2

hello Boris, thanks a lot for following up! A small nit below:
 
> diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c
> index 1cac3c6fbb49..cca10b5e99c9 100644
> --- a/net/sched/act_vlan.c
> +++ b/net/sched/act_vlan.c

[...]

> @@ -121,6 +121,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
>  	struct tc_action_net *tn = net_generic(net, vlan_net_id);
>  	struct nlattr *tb[TCA_VLAN_MAX + 1];
>  	struct tcf_chain *goto_ch = NULL;
> +	bool push_prio_exists = false;
>  	struct tcf_vlan_params *p;
>  	struct tc_vlan *parm;
>  	struct tcf_vlan *v;
> @@ -189,7 +190,8 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
>  			push_proto = htons(ETH_P_8021Q);
>  		}
>  
> -		if (tb[TCA_VLAN_PUSH_VLAN_PRIORITY])
> +		push_prio_exists = !!tb[TCA_VLAN_PUSH_VLAN_PRIORITY];

when the VLAN tag is pushed, not modified, the value of 'push_prio' is
used in the traffic path regardless of the true/false value of
'push_prio_exists'. See below:

 50         case TCA_VLAN_ACT_PUSH:
 51                 err = skb_vlan_push(skb, p->tcfv_push_proto, p->tcfv_push_vid |
 52                                     (p->tcfv_push_prio << VLAN_PRIO_SHIFT));

So, I think that 'p->push_prio_exists' should be identically set to
true when 'v_action' is TCA_VLAN_ACT_PUSH. That would allow a better
display of rules once patch 2 of your series is applied: otherwise,
2 rules configuring the same TCA_VLAN_ACT_PUSH rule would be displayed
differently, depending on whether userspace provided or not the
TCA_VLAN_PUSH_VLAN_PRIORITY attribute set to 0. In other words, the
last hunk should be something like:

@@ -241,6 +243,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
 	p->tcfv_action = action;
 	p->tcfv_push_vid = push_vid;
 	p->tcfv_push_prio = push_prio;
+	p->tcfv_push_prio_exists = push_prio_exists || action == TCA_VLAN_ACT_PUSH;


WDYT?

thanks!
-- 
davide


  reply	other threads:[~2021-05-25 20:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25 15:35 [PATCH net-next v2 0/3] net/sched: act_vlan: Fix modify to allow 0 Boris Sukholitko
2021-05-25 15:35 ` [PATCH net-next v2 1/3] " Boris Sukholitko
2021-05-25 20:35   ` Davide Caratti [this message]
2021-05-26 11:45     ` Boris Sukholitko
2021-05-27 17:00       ` Davide Caratti
2021-05-30 11:47         ` Boris Sukholitko
2021-05-25 15:36 ` [PATCH net-next v2 2/3] net/sched: act_vlan: No dump for unset priority Boris Sukholitko
2021-05-25 15:36 ` [PATCH net-next v2 3/3] net/sched: act_vlan: Test priority 0 modification Boris Sukholitko

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=YK1fpkmyiITfaVpr@dcaratti.users.ipa.redhat.com \
    --to=dcaratti@redhat.com \
    --cc=boris.sukholitko@broadcom.com \
    --cc=ilya.lifshits@broadcom.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shmulik.ladkani@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).