Patchwork [iproute2] ip: show physical port id

login
register
mail settings
Submitter Jiri Pirko
Date July 19, 2013, 1:55 p.m.
Message ID <1374242152-10325-5-git-send-email-jiri@resnulli.us>
Download mbox | patch
Permalink /patch/260269/
State Accepted
Delegated to: stephen hemminger
Headers show

Comments

Jiri Pirko - July 19, 2013, 1:55 p.m.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 include/linux/if_link.h |  1 +
 ip/ipaddress.c          | 10 ++++++++++
 2 files changed, 11 insertions(+)
stephen hemminger - Aug. 4, 2013, 6:48 p.m.
On Fri, 19 Jul 2013 15:55:52 +0200
Jiri Pirko <jiri@resnulli.us> wrote:

> Signed-off-by: Jiri Pirko <jiri@resnulli.us>

Applied to net-next-3.11 branch to go into the matching release
--
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

Patch

diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 965dc9f..ea0d5b7 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -143,6 +143,7 @@  enum {
 	IFLA_NUM_TX_QUEUES,
 	IFLA_NUM_RX_QUEUES,
 	IFLA_CARRIER,
+	IFLA_PHYS_PORT_ID,
 	__IFLA_MAX
 };
 
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 5b9a438..0c7c55b 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -429,6 +429,16 @@  int print_linkinfo(const struct sockaddr_nl *who,
 		fprintf(fp, "master %s ", ll_idx_n2a(*(int*)RTA_DATA(tb[IFLA_MASTER]), b1));
 	}
 
+	if (tb[IFLA_PHYS_PORT_ID]) {
+		int i;
+		unsigned char *buf = RTA_DATA(tb[IFLA_PHYS_PORT_ID]);
+		unsigned char len = RTA_PAYLOAD(tb[IFLA_PHYS_PORT_ID]);
+
+		fprintf(fp, "phys_port_id ");
+		for (i = 0; i < len; i++)
+			fprintf(fp, "%02x", buf[i]);
+		fprintf(fp, " ");
+	}
 	if (tb[IFLA_OPERSTATE])
 		print_operstate(fp, rta_getattr_u8(tb[IFLA_OPERSTATE]));