]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ip link: show permanent hardware address
authorMichal Kubecek <mkubecek@suse.cz>
Sun, 15 Dec 2019 21:06:10 +0000 (22:06 +0100)
committerDavid Ahern <dsahern@gmail.com>
Tue, 17 Dec 2019 16:28:02 +0000 (16:28 +0000)
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 <mkubecek@suse.cz>
Signed-off-by: David Ahern <dsahern@gmail.com>
ip/ipaddress.c

index 964f14df93f04a3be4fdfd1bb483d9d93622740a..9415d7682c1247481fff337af45fa6f3ec9f4842 100644 (file)
@@ -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]) {