diff mbox series

[iproute2-next,v2,2/3] bridge: fdb: don't colorize the "dev" & "dst" keywords in "bridge -c fdb"

Message ID 20210814184727.2405108-3-gokulkumar792@gmail.com
State Superseded
Headers show
Series bridge: fixes regarding the colorized output | expand

Commit Message

Gokul Sivakumar Aug. 14, 2021, 6:47 p.m. UTC
To be consistent with the colorized output of "ip" command and to increase
readability, stop highlighting the "dev" & "dst" keywords in the colorized
output of "bridge -c fdb" cmd.

Example: in the following "bridge -c fdb" entry, only "00:00:00:00:00:00",
"vxlan100" and "2001:db8:2::1" fields should be highlighted in color.

00:00:00:00:00:00 dev vxlan100 dst 2001:db8:2::1 self permanent

Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
---
 bridge/fdb.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Stephen Hemminger Aug. 17, 2021, 3:27 p.m. UTC | #1
On Sun, 15 Aug 2021 00:17:26 +0530
Gokul Sivakumar <gokulkumar792@gmail.com> wrote:

> +		if (!is_json_context())

> +			print_string(PRINT_FP, NULL, "dev ", NULL);


Why not the check for is_json_context is unnecessary here.
That is what PRINT_FP does.
Gokul Sivakumar Aug. 17, 2021, 5:22 p.m. UTC | #2
On Tue, 2021-08-17 at 08:27 -0700, Stephen Hemminger wrote:
> On Sun, 15 Aug 2021 00:17:26 +0530

> Gokul Sivakumar <gokulkumar792@gmail.com> wrote:

> 

> > +		if (!is_json_context())

> > +			print_string(PRINT_FP, NULL, "dev ", NULL);

> 

> Why not the check for is_json_context is unnecessary here.

> That is what PRINT_FP does.


Thanks for pointing it out, will remove those two unnecessary
condition checks and send a v3 patchset now.

Gokul
diff mbox series

Patch

diff --git a/bridge/fdb.c b/bridge/fdb.c
index 37465e46..ea61f65a 100644
--- a/bridge/fdb.c
+++ b/bridge/fdb.c
@@ -192,10 +192,14 @@  int print_fdb(struct nlmsghdr *n, void *arg)
 				   "mac", "%s ", lladdr);
 	}
 
-	if (!filter_index && r->ndm_ifindex)
+	if (!filter_index && r->ndm_ifindex) {
+		if (!is_json_context())
+			print_string(PRINT_FP, NULL, "dev ", NULL);
+
 		print_color_string(PRINT_ANY, COLOR_IFNAME,
-				   "ifname", "dev %s ",
+				   "ifname", "%s ",
 				   ll_index_to_name(r->ndm_ifindex));
+	}
 
 	if (tb[NDA_DST]) {
 		int family = AF_INET;
@@ -208,9 +212,12 @@  int print_fdb(struct nlmsghdr *n, void *arg)
 				  RTA_PAYLOAD(tb[NDA_DST]),
 				  RTA_DATA(tb[NDA_DST]));
 
+		if (!is_json_context())
+			print_string(PRINT_FP, NULL, "dst ", NULL);
+
 		print_color_string(PRINT_ANY,
 				   ifa_family_color(family),
-				    "dst", "dst %s ", dst);
+				   "dst", "%s ", dst);
 	}
 
 	if (vid)