]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
tc: ematch: Ignore all-zero mask value when printing filters
authorPhil Sutter <phil@nwl.cc>
Thu, 14 Jul 2016 21:10:53 +0000 (23:10 +0200)
committerStephen Hemminger <shemming@brocade.com>
Wed, 20 Jul 2016 19:20:13 +0000 (12:20 -0700)
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 <tgraf@suug.ch>
Signed-off-by: Phil Sutter <phil@nwl.cc>
tc/em_meta.c

index b00dd35886e97f0552e632c0c8205be2fe741b72..bf47093799f4d0d58ca9660f3eabbe1a3921af64 100644 (file)
@@ -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;
        }