summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWen Liang <liangwen12year@gmail.com>2021-08-18 20:58:52 -0400
committerWen Liang <wenliang@redhat.com>2021-08-24 16:16:27 -0400
commit6da4464154dc7c2f3915c7216a8447e7145ea04c (patch)
treef456e8be23626b3bfa5a9832bab62930864c0441 /src
parent60bad3a41e9d66bb46f6cd76bff2e8e718519652 (diff)
downloadNetworkManager-6da4464154dc7c2f3915c7216a8447e7145ea04c.tar.gz
platform: track kernel support for IFLA_PERM_ADDRESS
Track whether kernel supports netlink API IFLA_PERM_ADDRESS. To use the platform cache preferably if kernel supports IFLA_PERM_ADDRESS. To fall back to the old ethtool call directly if kernel does not support IFLA_PERM_ADDRESS. https://bugzilla.redhat.com/show_bug.cgi?id=1987286 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/673 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/961 Signed-off-by: Wen Liang <liangwen12year@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/libnm-platform/nm-linux-platform.c9
-rw-r--r--src/libnm-platform/nm-platform.c13
-rw-r--r--src/libnm-platform/nm-platform.h1
3 files changed, 23 insertions, 0 deletions
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. */