lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1532612730-1638-1-git-send-email-kleib@mojatatu.com>
Date:   Thu, 26 Jul 2018 09:45:30 -0400
From:   Keara Leibovitz <kleib@...atatu.com>
To:     dsahern@...il.com
Cc:     stephen@...workplumber.org, netdev@...r.kernel.org,
        kernel@...atatu.com, Keara Leibovitz <kleib@...atatu.com>
Subject: [PATCH iproute2-next 1/1] tc: fix bugs for tcp_flags and ip_attr hex output

Fix hex output for both the ip_attr and tcp_flags print functions.

Sample usage:

$ $TC qdisc add dev lo ingress
$ $TC filter add dev lo parent ffff: prio 3 proto ip flower ip_tos 0x8/32
$ $TC fitler add dev lo parent ffff: prio 5 proto ip flower ip_proto tcp \
	tcp_flags 0x909/f00

$ $TC filter show dev lo parent ffff:

filter protocol ip pref 3 flower chain 0 
filter protocol ip pref 3 flower chain 0 handle 0x1 
  eth_type ipv4
  ip_tos 0x8/32
  not_in_hw
filter protocol ip pref 5 flower chain 0 
filter protocol ip pref 5 flower chain 0 handle 0x1 
  eth_type ipv4
  ip_proto tcp
  tcp_flags 0x909/f00
  not_in_hw

$ $TC -j filter show dev lo parent ffff:

[{
    "protocol":"ip",
    "pref":3,
    "kind":"flower",
    "chain":0
},{
    "protocol":"ip", 
    "pref":3,
    "kind":"flower",
    "chain":0,
    "options": {
	"handle":1,
	"keys": {
	    "eth_type":"ipv4",
	    "ip_tos":"0x8/32"
    },
    "not_in_hw":true
    }
},{
    "protocol":"ip",
    "pref":5,
    "kind":"flower",
    "chain":0
},{
    "protocol":"ip",
    "pref":5,
    "kind":"flower",
    "chain":0,
    "options": {
	"handle":1,
	"keys": {
	    "eth_type":"ipv4",
	    "ip_proto":"tcp",
	    "tcp_flags":"0x909/f00"
	},
	"not_in_hw":true
    }
}]

Signed-off-by: Keara Leibovitz <kleib@...atatu.com>
---
 tc/f_flower.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/tc/f_flower.c b/tc/f_flower.c
index 9a3fd7751630..59e5f572c542 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -1189,7 +1189,7 @@ static void flower_print_ip_proto(__u8 *p_ip_proto,
 	*p_ip_proto = ip_proto;
 }
 
-static void flower_print_ip_attr(char *name, struct rtattr *key_attr,
+static void flower_print_ip_attr(const char *name, struct rtattr *key_attr,
 				 struct rtattr *mask_attr)
 {
 	SPRINT_BUF(namefrm);
@@ -1199,11 +1199,12 @@ static void flower_print_ip_attr(char *name, struct rtattr *key_attr,
 	if (!key_attr)
 		return;
 
-	done = sprintf(out, "%x", rta_getattr_u8(key_attr));
+	done = sprintf(out, "0x%x", rta_getattr_u8(key_attr));
 	if (mask_attr)
 		sprintf(out + done, "/%x", rta_getattr_u8(mask_attr));
 
-	sprintf(namefrm, "\n  %s %%s", name);
+	print_string(PRINT_FP, NULL, "%s  ", _SL_);
+	sprintf(namefrm, "%s %%s", name);
 	print_string(PRINT_ANY, name, namefrm, out);
 }
 
@@ -1308,7 +1309,7 @@ static void flower_print_port(char *name, struct rtattr *attr)
 	print_hu(PRINT_ANY, name, namefrm, rta_getattr_be16(attr));
 }
 
-static void flower_print_tcp_flags(char *name, struct rtattr *flags_attr,
+static void flower_print_tcp_flags(const char *name, struct rtattr *flags_attr,
 				   struct rtattr *mask_attr)
 {
 	SPRINT_BUF(namefrm);
@@ -1318,11 +1319,12 @@ static void flower_print_tcp_flags(char *name, struct rtattr *flags_attr,
 	if (!flags_attr)
 		return;
 
-	done = sprintf(out, "%x", rta_getattr_be16(flags_attr));
+	done = sprintf(out, "0x%x", rta_getattr_be16(flags_attr));
 	if (mask_attr)
-		sprintf(out + done, "%x", rta_getattr_be16(flags_attr));
+		sprintf(out + done, "/%x", rta_getattr_be16(mask_attr));
 
-	sprintf(namefrm, "\n  %s %%s", name);
+	print_string(PRINT_FP, NULL, "%s  ", _SL_);
+	sprintf(namefrm, "%s %%s", name);
 	print_string(PRINT_ANY, name, namefrm, out);
 }
 
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ