netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] iproute2: fix MPLS label parsing
@ 2020-03-11 15:16 Guillaume Nault
  2020-03-15 16:57 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Nault @ 2020-03-11 15:16 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev

The initial value of "label" in parse_mpls() is 0xffffffff. Therefore
we should test for this value, and not 0, to detect if a label has been
provided. The "!label" test not only fails to detect a missing label
parameter, it also prevents the use of the IPv4 explicit NULL label,
which actually equals 0.

Reproducer:
  $ ip link add name dm0 type dummy
  $ tc qdisc add dev dm0 ingress

  $ tc filter add dev dm0 parent ffff: matchall action mpls push
  Error: act_mpls: Label is required for MPLS push.
  We have an error talking to the kernel
  --> Filter was pushed to the kernel, where it got rejected.

  $ tc filter add dev dm0 parent ffff: matchall action mpls push label 0
  Error: argument "label" is required
  --> Label 0 was rejected by iproute2.

Expected result:
  $ tc filter add dev dm0 parent ffff: matchall action mpls push
  Error: argument "label" is required
  --> Filter was directly rejected by iproute2.

  $ tc filter add dev dm0 parent ffff: matchall action mpls push label 0
  --> Filter is accepted.

Signed-off-by: Guillaume Nault <gnault@redhat.com>
---
 tc/m_mpls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tc/m_mpls.c b/tc/m_mpls.c
index 6f3a39f4..50eba01c 100644
--- a/tc/m_mpls.c
+++ b/tc/m_mpls.c
@@ -156,7 +156,7 @@ static int parse_mpls(struct action_util *a, int *argc_p, char ***argv_p,
 		}
 	}
 
-	if (action == TCA_MPLS_ACT_PUSH && !label)
+	if (action == TCA_MPLS_ACT_PUSH && label == 0xffffffff)
 		missarg("label");
 
 	if (action == TCA_MPLS_ACT_PUSH && proto &&
-- 
2.21.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2] iproute2: fix MPLS label parsing
  2020-03-11 15:16 [PATCH iproute2] iproute2: fix MPLS label parsing Guillaume Nault
@ 2020-03-15 16:57 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2020-03-15 16:57 UTC (permalink / raw)
  To: Guillaume Nault; +Cc: netdev

On Wed, 11 Mar 2020 16:16:36 +0100
Guillaume Nault <gnault@redhat.com> wrote:

> The initial value of "label" in parse_mpls() is 0xffffffff. Therefore
> we should test for this value, and not 0, to detect if a label has been
> provided. The "!label" test not only fails to detect a missing label
> parameter, it also prevents the use of the IPv4 explicit NULL label,
> which actually equals 0.
> 
> Reproducer:
>   $ ip link add name dm0 type dummy
>   $ tc qdisc add dev dm0 ingress
> 
>   $ tc filter add dev dm0 parent ffff: matchall action mpls push
>   Error: act_mpls: Label is required for MPLS push.
>   We have an error talking to the kernel
>   --> Filter was pushed to the kernel, where it got rejected.  
> 
>   $ tc filter add dev dm0 parent ffff: matchall action mpls push label 0
>   Error: argument "label" is required
>   --> Label 0 was rejected by iproute2.  
> 
> Expected result:
>   $ tc filter add dev dm0 parent ffff: matchall action mpls push
>   Error: argument "label" is required
>   --> Filter was directly rejected by iproute2.  
> 
>   $ tc filter add dev dm0 parent ffff: matchall action mpls push label 0
>   --> Filter is accepted.  
> 
> Signed-off-by: Guillaume Nault <gnault@redhat.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-15 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-11 15:16 [PATCH iproute2] iproute2: fix MPLS label parsing Guillaume Nault
2020-03-15 16:57 ` Stephen Hemminger

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).