Skip to contentSkip to conversation

ip: mroute: Add table output to show command

PATCH Applied Donald Sharp 4 participants 6 messages Jun 14, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip: mroute: Add table output to show command

When the user specifies table all or table 0 to the ip mroute show command we dump the entirety of the known mroute tables. Without some sort of divisor to tell us what table we are looking at the command is useless.

Add Table: <vrf name> to the output of 'ip mroute show table 0'

Follow the convention established by 'ip route show table 0' for when to display

---
 ip/ipmroute.c | 5 +++++
 1 file changed, 5 insertions(+)
ip/ipmroute.c +5 -0
index 4d2d758..70f4c4f 100644
@@ -189,6 +189,11 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 		fprintf(fp, ", Age %4i.%.2i", (int)tv.tv_sec,
 			(int)tv.tv_usec/10000);
 	}
+
+	if (table && (table != RT_TABLE_MAIN || show_details > 0) && !filter.tb)
+		fprintf(fp, " Table: %s",
+			rtnl_rttable_n2a(table, b1, sizeof(b1)));
+
 	fprintf(fp, "\n");
 	fflush(fp);
 	return 0;
Signature · 1 line
2.1.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Donald Sharp

When the user specifies table all or table 0 to the ip mroute show command we dump the entirety of the known mroute tables. Without some sort of divisor to tell us what table we are looking at the command is useless.

Add Table: <vrf name> to the output of 'ip mroute show table 0'

Follow the convention established by 'ip route show table 0' for when to display

---
 ip/ipmroute.c | 5 +++++
 1 file changed, 5 insertions(+)
ip/ipmroute.c +0 -0
index 4d2d758..70f4c4f 100644
@@ -189,6 +189,11 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 		fprintf(fp, ", Age %4i.%.2i", (int)tv.tv_sec,

ip/ipmroute.c int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) · line 199

Quoted 10 lines
ip/ipmroute.c +5 -0
 			(int)tv.tv_usec/10000);
 	}
+
+	if (table && (table != RT_TABLE_MAIN || show_details > 0) && !filter.tb)
+		fprintf(fp, " Table: %s",
+			rtnl_rttable_n2a(table, b1, sizeof(b1)));
+
 	fprintf(fp, "\n");
 	fflush(fp);
 	return 0;

LGTM, thanks!

#2 lore raw
In reply to Donald Sharp

ip/ipmroute.c int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) · line 194

Quoted 11 lines · Donald Sharp
ip/ipmroute.c +3 -0
index 4d2d758..70f4c4f 100644
@@ -189,6 +189,11 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 		fprintf(fp, ", Age %4i.%.2i", (int)tv.tv_sec,
 			(int)tv.tv_usec/10000);
 	}
+
+	if (table && (table != RT_TABLE_MAIN || show_details > 0) && !filter.tb)
+		fprintf(fp, " Table: %s",

I suggest lowercase 'table' to be consistent with ip route output.

Quoted 6 lines
ip/ipmroute.c +2 -0
+			rtnl_rttable_n2a(table, b1, sizeof(b1)));
+
 	fprintf(fp, "\n");
 	fflush(fp);
 	return 0;
#3 lore raw
Quoted 14 lines · David Ahern

ip/ipmroute.c int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) · line 194

Quoted 11 lines · Donald Sharp
ip/ipmroute.c +3 -0
index 4d2d758..70f4c4f 100644
@@ -189,6 +189,11 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 		fprintf(fp, ", Age %4i.%.2i", (int)tv.tv_sec,
 			(int)tv.tv_usec/10000);
 	}
+
+	if (table && (table != RT_TABLE_MAIN || show_details > 0) && !filter.tb)
+		fprintf(fp, " Table: %s",

I suggest lowercase 'table' to be consistent with ip route output.

This is consistent with the mroute show command, all of its fields start with upper case.

Quoted 7 lines
Quoted 7 lines
ip/ipmroute.c +2 -0
+			rtnl_rttable_n2a(table, b1, sizeof(b1)));
+
 	fprintf(fp, "\n");
 	fflush(fp);
 	return 0;
#4 lore raw
Quoted 14 lines · Nikolay Aleksandrov
Quoted 13 lines · David Ahern

ip/ipmroute.c int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) · line 194

Quoted 11 lines · Donald Sharp
ip/ipmroute.c +3 -0
index 4d2d758..70f4c4f 100644
@@ -189,6 +189,11 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 		fprintf(fp, ", Age %4i.%.2i", (int)tv.tv_sec,
 			(int)tv.tv_usec/10000);
 	}
+
+	if (table && (table != RT_TABLE_MAIN || show_details > 0) && !filter.tb)
+		fprintf(fp, " Table: %s",

I suggest lowercase 'table' to be consistent with ip route output.

Quoted 3 lines

This is consistent with the mroute show command, all of its fields start with upper case.

ok.

#5 lore raw
In reply to Donald Sharp
Quoted 6 lines · On Wed, 14 Jun 2017 08:08:12 -0400 Donald Sharp <[email protected]>…

When the user specifies table all or table 0 to the ip mroute show command we dump the entirety of the known mroute tables. Without some sort of divisor to tell us what table we are looking at the command is useless.

Quoted 6 lines

Add Table: <vrf name> to the output of 'ip mroute show table 0'

Follow the convention established by 'ip route show table 0' for when to display

Applied, thanks.