Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2 1/3] bridge: minor change to mdb print
@ 2018-09-06 15:30 Stephen Hemminger
  2018-09-06 15:30 ` [PATCH iproute2 2/3] bridge: use print_json for some outputs Stephen Hemminger
  2018-09-06 15:30 ` [PATCH iproute2 3/3] bridge: fix vlan show formatting Stephen Hemminger
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Hemminger @ 2018-09-06 15:30 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Get port ifname once rather than on both sides of if(is_json_context).

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 bridge/mdb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bridge/mdb.c b/bridge/mdb.c
index f38dc67c849a..9bdef0262c54 100644
--- a/bridge/mdb.c
+++ b/bridge/mdb.c
@@ -208,19 +208,19 @@ static void print_router_entries(FILE *fp, struct nlmsghdr *n,
 	} else {
 		struct rtattr *i = RTA_DATA(router);
 		uint32_t *port_ifindex = RTA_DATA(i);
+		const char *port_name = ll_index_to_name(*port_ifindex);
 
 		if (is_json_context()) {
 			open_json_array(PRINT_JSON, brifname);
 			open_json_object(NULL);
 
 			print_string(PRINT_JSON, "port", NULL,
-				     ll_index_to_name(*port_ifindex));
+				     port_name);
 			close_json_object();
 			close_json_array(PRINT_JSON, NULL);
 		} else {
 			fprintf(fp, "router port dev %s master %s\n",
-				ll_index_to_name(*port_ifindex),
-				brifname);
+				port_name, brifname);
 		}
 	}
 	close_json_array(PRINT_JSON, NULL);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-10 16:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-06 15:30 [PATCH iproute2 1/3] bridge: minor change to mdb print Stephen Hemminger
2018-09-06 15:30 ` [PATCH iproute2 2/3] bridge: use print_json for some outputs Stephen Hemminger
2018-09-06 15:30 ` [PATCH iproute2 3/3] bridge: fix vlan show formatting Stephen Hemminger
2018-09-10 11:52   ` Tobias Jungel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox