Skip to contentSkip to conversation

display permanent hardware address

PATCH Applied Michal Kubecek 2 participants 4 messages Dec 15, 2019 – Dec 17, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover display permanent hardware address

Since kernel commit f74877a5457d ("rtnetlink: provide permanent hardware address in RTM_NEWLINK"), in net-next tree at the moment, kernel provides the permanent hardware address of a network device (if set). Patch 2 adds this information to the output of "ip link show" and "ip address show", patch 1 updates UAPI header copies to get IFLA_PERM_ADDRESS constant.

Michal Kubecek (2):
Update kernel headers
ip link: show permanent hardware address

 include/uapi/linux/if_bonding.h | 10 ++++++++++
 include/uapi/linux/if_bridge.h  | 10 ++++++++++
 include/uapi/linux/if_link.h    |  1 +
 ip/ipaddress.c                  | 18 ++++++++++++++++++
 4 files changed, 39 insertions(+)
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/2 Update kernel headers

Update kernel headers to commit:
f5058a27dac7 ("net: phylink: propagate phy_attach_direct() return code")

---
 include/uapi/linux/if_bonding.h | 10 ++++++++++
 include/uapi/linux/if_bridge.h  | 10 ++++++++++
 include/uapi/linux/if_link.h    |  1 +
 3 files changed, 21 insertions(+)
include/uapi/linux/if_bonding.h +10 -0
index 790585f0e61b..6829213a54c5 100644
@@ -95,6 +95,16 @@
 #define BOND_XMIT_POLICY_ENCAP23	3 /* encapsulated layer 2+3 */
 #define BOND_XMIT_POLICY_ENCAP34	4 /* encapsulated layer 3+4 */
 
+/* 802.3ad port state definitions (43.4.2.2 in the 802.3ad standard) */
+#define AD_STATE_LACP_ACTIVITY   0x1
+#define AD_STATE_LACP_TIMEOUT    0x2
+#define AD_STATE_AGGREGATION     0x4
+#define AD_STATE_SYNCHRONIZATION 0x8
+#define AD_STATE_COLLECTING      0x10
+#define AD_STATE_DISTRIBUTING    0x20
+#define AD_STATE_DEFAULTED       0x40
+#define AD_STATE_EXPIRED         0x80
+
 typedef struct ifbond {
 	__s32 bond_mode;
 	__s32 num_slaves;
include/uapi/linux/if_bridge.h +10 -0
index 31fc51bdedb3..9fefc7f30d7b 100644
@@ -156,6 +156,15 @@ struct bridge_vlan_xstats {
 	__u32 pad2;
 };
 
+struct bridge_stp_xstats {
+	__u64 transition_blk;
+	__u64 transition_fwd;
+	__u64 rx_bpdu;
+	__u64 tx_bpdu;
+	__u64 rx_tcn;
+	__u64 tx_tcn;
+};
+
 /* Bridge multicast database attributes
  * [MDBA_MDB] = {
  *     [MDBA_MDB_ENTRY] = {
@@ -262,6 +271,7 @@ enum {
 	BRIDGE_XSTATS_VLAN,
 	BRIDGE_XSTATS_MCAST,
 	BRIDGE_XSTATS_PAD,
+	BRIDGE_XSTATS_STP,
 	__BRIDGE_XSTATS_MAX
 };
 #define BRIDGE_XSTATS_MAX (__BRIDGE_XSTATS_MAX - 1)
include/uapi/linux/if_link.h +1 -0
index 1c49f436424d..29eac87e0e0f 100644
@@ -169,6 +169,7 @@ enum {
 	IFLA_MAX_MTU,
 	IFLA_PROP_LIST,
 	IFLA_ALT_IFNAME, /* Alternative ifname */
+	IFLA_PERM_ADDRESS,
 	__IFLA_MAX
 };
 
Signature · 1 line
2.24.1
#2 lore raw

PATCH 2/2 ip link: show permanent hardware address

In reply to Michal Kubecek

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.

---
 ip/ipaddress.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
ip/ipaddress.c +18 -0
index 964f14df93f0..9415d7682c12 100644
@@ -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]) {
Signature · 1 line
2.24.1
Applied
#3 lore raw

Re: [PATCH iproute2-next 2/2] ip link: show permanent hardware address

Quoted 9 lines · Michal Kubecek

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.

---
 ip/ipaddress.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

applied to iproute2-next. Thanks