From 247ace611526e51d9f5a2f4b6e965c59b0f8b739 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 14 Jul 2016 23:10:53 +0200 Subject: [PATCH] tc: ematch: Ignore all-zero mask value when printing filters The optional mask which may be added to int values is considered by the kernel only if it is non-zero, therefore tc should only then also print it. Without this, not passing a mask value like so: | # tc filter add dev d0 parent 8001: \ | basic match meta\(vlan eq 1\) \ | classid 8001:1 Would lead to tc printing an all-zero mask later: | # tc filter show dev d0 | filter parent 8001: protocol all pref 49151 basic | filter parent 8001: protocol all pref 49151 basic handle 0x1 flowid 8001:1 | meta(vlan mask 0x00000000 eq 1) This is obviously confusing as an all-zero mask strictly means to eliminate all bits from the value, but the opposite is the case. Cc: Thomas Graf Signed-off-by: Phil Sutter --- tc/em_meta.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tc/em_meta.c b/tc/em_meta.c index b00dd358..bf470937 100644 --- a/tc/em_meta.c +++ b/tc/em_meta.c @@ -483,8 +483,9 @@ static int print_object(FILE *fd, struct tcf_meta_val *obj, struct rtattr *rta) if (RTA_PAYLOAD(rta) < sizeof(__u32)) goto size_mismatch; - fprintf(fd, " mask 0x%08x", - rta_getattr_u32(rta)); + if (rta_getattr_u32(rta)) + fprintf(fd, " mask 0x%08x", + rta_getattr_u32(rta)); } break; }