diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 31186d4a0e..c0c57618f9 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -3058,6 +3058,15 @@ _new_from_nl_link(NMPlatform * platform, } if (tb[IFLA_PERM_ADDRESS]) { + if (!_nm_platform_kernel_support_detected( + NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS)) { + /* support for IFLA_PERM_ADDRESS was added in f74877a5457d34d604dba6dbbb13c4c05bac8b93, + * kernel 5.6, 30 March 2020. + * + * We can only detect support if the attribute is present. A missing attribute + * is not conclusive. */ + _nm_platform_kernel_support_init(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS, 1); + } _nmp_link_address_set(&obj->link.l_perm_address, tb[IFLA_PERM_ADDRESS]); perm_address_complete_from_cache = FALSE; } diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index 0e0dc348b7..ae9ee04e97 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -349,6 +349,12 @@ static const struct { .name = "IFLA_BR_VLAN_STATS_ENABLE", .desc = "IFLA_BR_VLAN_STATS_ENABLE bridge link attribute", }, + [NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS] = + { + .compile_time_default = (IFLA_MAX >= 54 /* IFLA_PERM_ADDRESS */), + .name = "IFLA_PERM_ADDRESS", + .desc = "IFLA_PERM_ADDRESS netlink attribute", + }, }; int @@ -1779,6 +1785,13 @@ nm_platform_link_get_permanent_address(NMPlatform * self, *out_address = plink->l_perm_address; return TRUE; } + if (nm_platform_kernel_support_get_full(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS, + FALSE) + == NM_OPTION_BOOL_TRUE) { + /* kernel supports the netlink API IFLA_PERM_ADDRESS, but we don't have the + * address cached. There is no need to fallback to ethtool ioctl. */ + return FALSE; + } return nm_platform_link_get_permanent_address_ethtool(self, plink->ifindex, out_address); } diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 8965700082..b20b18c4dd 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -1018,6 +1018,7 @@ typedef enum { NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_UID_RANGE, NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_PROTOCOL, NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BR_VLAN_STATS_ENABLED, + NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_PERM_ADDRESS, /* this also includes FRA_SPORT_RANGE and FRA_DPORT_RANGE which * were added at the same time. */