netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roi Dayan <roid@mellanox.com>
To: netdev@vger.kernel.org
Cc: David Ahern <dsahern@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Jiri Pirko <jiri@mellanox.com>,
	Eli Britstein <elibr@mellanox.com>, Roi Dayan <roid@mellanox.com>
Subject: [PATCH iproute2 5/5] tc: flower: fix output for ip tos and ttl
Date: Wed, 13 Nov 2019 12:12:45 +0200	[thread overview]
Message-ID: <20191113101245.182025-6-roid@mellanox.com> (raw)
In-Reply-To: <20191113101245.182025-1-roid@mellanox.com>

From: Eli Britstein <elibr@mellanox.com>

Fix the output for ip tos and ttl to be numbers in JSON format.

Example:
$ tc qdisc add dev eth0 ingress
$ tc filter add dev eth0 protocol ip parent ffff: prio 1 flower skip_hw \
      ip_tos 5/0xf action drop

Non JSON format remains the same:
$ tc filter show dev eth0 parent ffff:
filter protocol ip pref 1 flower chain 0
filter protocol ip pref 1 flower chain 0 handle 0x1
  eth_type ipv4
  ip_tos 5/0xf
  skip_hw
  not_in_hw
        action order 1: gact action drop
         random type none pass val 0
         index 1 ref 1 bind 1

JSON format is changed (partial output):
$ tc -p -j filter show dev eth0 parent ffff:
Before:
        "options": {
            "keys": {
                "ip_tos": "0x5/f",
                ...
After:
        "options": {
            "keys": {
                "ip_tos": 5,
                "ip_tos_mask": 15,
                ...

Fixes: 6ea2c2b1cff6 ("tc: flower: add support for matching on ip tos and ttl")
Signed-off-by: Eli Britstein <elibr@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
---
 tc/f_flower.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/tc/f_flower.c b/tc/f_flower.c
index 724577563c27..1b518ef30583 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -1617,20 +1617,7 @@ static void flower_print_ip_proto(__u8 *p_ip_proto,
 static void flower_print_ip_attr(const char *name, struct rtattr *key_attr,
 				 struct rtattr *mask_attr)
 {
-	SPRINT_BUF(namefrm);
-	SPRINT_BUF(out);
-	size_t done;
-
-	if (!key_attr)
-		return;
-
-	done = sprintf(out, "0x%x", rta_getattr_u8(key_attr));
-	if (mask_attr)
-		sprintf(out + done, "/%x", rta_getattr_u8(mask_attr));
-
-	print_string(PRINT_FP, NULL, "%s  ", _SL_);
-	sprintf(namefrm, "%s %%s", name);
-	print_string(PRINT_ANY, name, namefrm, out);
+	print_masked_u8(name, key_attr, mask_attr, true);
 }
 
 static void flower_print_matching_flags(char *name,
-- 
2.8.4


  parent reply	other threads:[~2019-11-13 10:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13 10:12 [PATCH iproute2 0/5] fix json output for tos and ttl Roi Dayan
2019-11-13 10:12 ` [PATCH iproute2 1/5] tc_util: introduce a function to print JSON/non-JSON masked numbers Roi Dayan
2019-11-13 17:18   ` Stephen Hemminger
2019-11-14  8:24     ` Roi Dayan
2019-11-13 17:20   ` Stephen Hemminger
2019-11-14  9:38     ` Roi Dayan
2019-11-13 10:12 ` [PATCH iproute2 2/5] tc_util: add an option to print masked numbers with/without a newline Roi Dayan
2019-11-13 10:12 ` [PATCH iproute2 3/5] tc: flower: fix newline prints for ct-mark and ct-zone Roi Dayan
2019-11-13 10:12 ` [PATCH iproute2 4/5] tc_util: fix JSON " Roi Dayan
2019-11-13 10:12 ` Roi Dayan [this message]
2019-11-13 10:16 ` [PATCH iproute2 0/5] fix json output for tos and ttl Roi Dayan

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=20191113101245.182025-6-roid@mellanox.com \
    --to=roid@mellanox.com \
    --cc=dsahern@gmail.com \
    --cc=elibr@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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).