diff mbox

[3/3] iproute2: Add support for phys_port_name

Message ID 1426520818-11198-3-git-send-email-dsahern@gmail.com
State Superseded, archived
Delegated to: stephen hemminger
Headers show

Commit Message

David Ahern March 16, 2015, 3:46 p.m. UTC
Display phys_port_name attribute if returned:

./ip link show sw1p1
4: sw1p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop port name sw1p1 state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:12:35:01 brd ff:ff:ff:ff:ff:ff

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 include/linux/if_link.h | 1 +
 ip/ipaddress.c          | 3 +++
 2 files changed, 4 insertions(+)

Comments

Stephen Hemminger March 24, 2015, 10:50 p.m. UTC | #1
On Mon, 16 Mar 2015 09:46:58 -0600
David Ahern <dsahern@gmail.com> wrote:

> Display phys_port_name attribute if returned:
> 
> ./ip link show sw1p1
> 4: sw1p1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop port name sw1p1 state DOWN mode DEFAULT group default qlen 1000
>     link/ether 52:54:00:12:35:01 brd ff:ff:ff:ff:ff:ff
> 
> Signed-off-by: David Ahern <dsahern@gmail.com>
> ---
>  include/linux/if_link.h | 1 +
>  ip/ipaddress.c          | 3 +++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/include/linux/if_link.h b/include/linux/if_link.h
> index 3450c3fbdc65..c5ee8c91b1c6 100644
> --- a/include/linux/if_link.h
> +++ b/include/linux/if_link.h
> @@ -147,6 +147,7 @@ enum {
>  	IFLA_CARRIER_CHANGES,
>  	IFLA_PHYS_SWITCH_ID,
>  	IFLA_LINK_NETNSID,
> +	IFLA_PHYS_PORT_NAME,
>  	__IFLA_MAX
>  };
>  
> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> index 99a6ab5977e3..9e65015b7a48 100644
> --- a/ip/ipaddress.c
> +++ b/ip/ipaddress.c
> @@ -645,6 +645,9 @@ int print_linkinfo(const struct sockaddr_nl *who,
>  				      b1, sizeof(b1)));
>  	}
>  
> +	if (tb[IFLA_PHYS_PORT_NAME])
> +		fprintf(fp, "port name %s ", rta_getattr_str(tb[IFLA_PHYS_PORT_NAME]));
> +
>  	if (tb[IFLA_OPERSTATE])
>  		print_operstate(fp, rta_getattr_u8(tb[IFLA_OPERSTATE]));
>  

In general, this is a good idea, but there are several of issues.
1. There are programs that parse ip route output, therefore all new
   fields need to go at the end.
2. The two word format 'port name' does not match other parts
3. Extra stuff usually goes int 'details' section
4. There are VPN scripts etc that expect all ip commands to
   be invertable. I.e the output of ip link should also be easily
   convertable to input.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Ahern March 27, 2015, 3:41 a.m. UTC | #2
On 3/24/15 4:50 PM, Stephen Hemminger wrote:
>> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
>> index 99a6ab5977e3..9e65015b7a48 100644
>> --- a/ip/ipaddress.c
>> +++ b/ip/ipaddress.c
>> @@ -645,6 +645,9 @@ int print_linkinfo(const struct sockaddr_nl *who,
>>   				      b1, sizeof(b1)));
>>   	}
>>
>> +	if (tb[IFLA_PHYS_PORT_NAME])
>> +		fprintf(fp, "port name %s ", rta_getattr_str(tb[IFLA_PHYS_PORT_NAME]));
>> +
>>   	if (tb[IFLA_OPERSTATE])
>>   		print_operstate(fp, rta_getattr_u8(tb[IFLA_OPERSTATE]));
>>
>
> In general, this is a good idea, but there are several of issues.
> 1. There are programs that parse ip route output, therefore all new
>     fields need to go at the end.
> 2. The two word format 'port name' does not match other parts
> 3. Extra stuff usually goes int 'details' section
> 4. There are VPN scripts etc that expect all ip commands to
>     be invertable. I.e the output of ip link should also be easily
>     convertable to input.

The location of PORT_NAME is right after PORT_ID. I take it from this 
list you want it elsewhere. At the end?

And rather than 'port name' how about 'port-name'? no precedence for 
CamelCase and both 'port' and 'name' are too generic. 'pname' is not 
intuitive. Suggestions?

David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 3450c3fbdc65..c5ee8c91b1c6 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -147,6 +147,7 @@  enum {
 	IFLA_CARRIER_CHANGES,
 	IFLA_PHYS_SWITCH_ID,
 	IFLA_LINK_NETNSID,
+	IFLA_PHYS_PORT_NAME,
 	__IFLA_MAX
 };
 
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 99a6ab5977e3..9e65015b7a48 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -645,6 +645,9 @@  int print_linkinfo(const struct sockaddr_nl *who,
 				      b1, sizeof(b1)));
 	}
 
+	if (tb[IFLA_PHYS_PORT_NAME])
+		fprintf(fp, "port name %s ", rta_getattr_str(tb[IFLA_PHYS_PORT_NAME]));
+
 	if (tb[IFLA_OPERSTATE])
 		print_operstate(fp, rta_getattr_u8(tb[IFLA_OPERSTATE]));