diff mbox

[iproute2] ip: mroute: Add table output to show command

Message ID 1497442092-14252-1-git-send-email-sharpd@cumulusnetworks.com
State Accepted, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Donald Sharp June 14, 2017, 12:08 p.m. UTC
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

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
---
 ip/ipmroute.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Nikolay Aleksandrov June 14, 2017, 12:53 p.m. UTC | #1
On 14/06/17 15:08, Donald Sharp wrote:
> 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
> 
> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
> ---
>  ip/ipmroute.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/ip/ipmroute.c b/ip/ipmroute.c
> index 4d2d758..70f4c4f 100644
> --- a/ip/ipmroute.c
> +++ b/ip/ipmroute.c
> @@ -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;
> 

LGTM, thanks!

Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
David Ahern June 14, 2017, 3:42 p.m. UTC | #2
On 6/14/17 6:08 AM, Donald Sharp wrote:
> diff --git a/ip/ipmroute.c b/ip/ipmroute.c
> index 4d2d758..70f4c4f 100644
> --- a/ip/ipmroute.c
> +++ b/ip/ipmroute.c
> @@ -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.

> +			rtnl_rttable_n2a(table, b1, sizeof(b1)));
> +
>  	fprintf(fp, "\n");
>  	fflush(fp);
>  	return 0;
> --
Nikolay Aleksandrov June 14, 2017, 3:44 p.m. UTC | #3
On 14/06/17 18:42, David Ahern wrote:
> On 6/14/17 6:08 AM, Donald Sharp wrote:
>> diff --git a/ip/ipmroute.c b/ip/ipmroute.c
>> index 4d2d758..70f4c4f 100644
>> --- a/ip/ipmroute.c
>> +++ b/ip/ipmroute.c
>> @@ -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.

> 
>> +			rtnl_rttable_n2a(table, b1, sizeof(b1)));
>> +
>>  	fprintf(fp, "\n");
>>  	fflush(fp);
>>  	return 0;
>> --
David Ahern June 14, 2017, 3:47 p.m. UTC | #4
On 6/14/17 9:44 AM, Nikolay Aleksandrov wrote:
> On 14/06/17 18:42, David Ahern wrote:
>> On 6/14/17 6:08 AM, Donald Sharp wrote:
>>> diff --git a/ip/ipmroute.c b/ip/ipmroute.c
>>> index 4d2d758..70f4c4f 100644
>>> --- a/ip/ipmroute.c
>>> +++ b/ip/ipmroute.c
>>> @@ -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.
> 

ok.
Stephen Hemminger June 14, 2017, 8:32 p.m. UTC | #5
On Wed, 14 Jun 2017 08:08:12 -0400
Donald Sharp <sharpd@cumulusnetworks.com> wrote:

> 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
> 
> Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>

Applied, thanks.
diff mbox

Patch

diff --git a/ip/ipmroute.c b/ip/ipmroute.c
index 4d2d758..70f4c4f 100644
--- a/ip/ipmroute.c
+++ b/ip/ipmroute.c
@@ -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;