From: Michal Kubecek Date: Sun, 15 Dec 2019 21:06:10 +0000 (+0100) Subject: ip link: show permanent hardware address X-Git-Tag: v5.6.0~22^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b8e6995fe36b5863c394ddf6444eb4163c8c83c;p=thirdparty%2Fiproute2.git ip link: show permanent hardware address Display permanent hardware address of an interface in output of "ip link show" and "ip addr show". To reduce noise, permanent address is only shown if it is different from current one. Signed-off-by: Michal Kubecek Signed-off-by: David Ahern --- diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 964f14df9..9415d7682 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -1011,6 +1011,24 @@ int print_linkinfo(struct nlmsghdr *n, void *arg) ifi->ifi_type, b1, sizeof(b1))); } + if (tb[IFLA_PERM_ADDRESS]) { + unsigned int len = RTA_PAYLOAD(tb[IFLA_PERM_ADDRESS]); + + if (!tb[IFLA_ADDRESS] || + RTA_PAYLOAD(tb[IFLA_ADDRESS]) != len || + memcmp(RTA_DATA(tb[IFLA_PERM_ADDRESS]), + RTA_DATA(tb[IFLA_ADDRESS]), len)) { + print_string(PRINT_FP, NULL, " permaddr ", NULL); + print_color_string(PRINT_ANY, + COLOR_MAC, + "permaddr", + "%s", + ll_addr_n2a(RTA_DATA(tb[IFLA_PERM_ADDRESS]), + RTA_PAYLOAD(tb[IFLA_PERM_ADDRESS]), + ifi->ifi_type, + b1, sizeof(b1))); + } + } } if (tb[IFLA_LINK_NETNSID]) {