From b2b50eba1bd74b36ffe38cd3c8b29d41f3f58317 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 24 Aug 2021 15:00:54 +0200 Subject: [PATCH] platform: require IFLA_INET6_ADDR_GEN_MODE support in kernel This is supported since kernel 3.17, dated 5 October, 2014. Drop the backward compatibility for that. It's very hard to sensibly support a mode where we set the interface up, but prevent kernel from enabling IPv6. We would hack around that by disabling IPv6 altogether. But these code paths are not tested and likely make no sense. And it's hard to implement a sensible behavior in this case anyway. --- src/core/devices/nm-device.c | 18 +++++------------- src/core/platform/tests/test-link.c | 2 +- src/libnm-platform/nm-linux-platform.c | 15 --------------- src/libnm-platform/nm-platform.c | 6 ------ src/libnm-platform/nm-platform.h | 3 --- 5 files changed, 6 insertions(+), 38 deletions(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index e926885931..778b748df6 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -3145,12 +3145,9 @@ _set_ip_ifindex(NMDevice *self, int ifindex, const char *ifname) nm_platform_process_events_ensure_link(platform, priv->ip_ifindex, priv->ip_iface); - if (nm_platform_kernel_support_get( - NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE)) { - nm_platform_link_set_inet6_addr_gen_mode(platform, - priv->ip_ifindex, - NM_IN6_ADDR_GEN_MODE_NONE); - } + nm_platform_link_set_inet6_addr_gen_mode(platform, + priv->ip_ifindex, + NM_IN6_ADDR_GEN_MODE_NONE); if (!nm_platform_link_is_up(platform, priv->ip_ifindex)) nm_platform_link_change_flags(platform, priv->ip_ifindex, IFF_UP, TRUE); @@ -6095,10 +6092,8 @@ realize_start_setup(NMDevice * self, if (priv->firmware_version) _notify(self, PROP_FIRMWARE_VERSION); - if (nm_platform_kernel_support_get( - NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE)) - priv->ipv6ll_handle = (nm_platform_link_get_inet6_addr_gen_mode(platform, priv->ifindex) - == NM_IN6_ADDR_GEN_MODE_NONE); + priv->ipv6ll_handle = (nm_platform_link_get_inet6_addr_gen_mode(platform, priv->ifindex) + == NM_IN6_ADDR_GEN_MODE_NONE); if (nm_platform_link_supports_sriov(platform, priv->ifindex)) capabilities |= NM_DEVICE_CAP_SRIOV; @@ -11203,9 +11198,6 @@ set_nm_ipv6ll(NMDevice *self, gboolean enable) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); int ifindex = nm_device_get_ip_ifindex(self); - if (!nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE)) - return; - priv->ipv6ll_handle = enable; if (ifindex > 0) { int r; diff --git a/src/core/platform/tests/test-link.c b/src/core/platform/tests/test-link.c index 500a008751..394274daf3 100644 --- a/src/core/platform/tests/test-link.c +++ b/src/core/platform/tests/test-link.c @@ -602,7 +602,7 @@ test_bridge_addr(void) g_assert(plink); g_assert(!nm_platform_link_get_permanent_address(NM_PLATFORM_GET, plink, &hw_perm_addr)); - if (nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE)) { + if (nmtstp_is_root_test()) { g_assert_cmpint(nm_platform_link_get_inet6_addr_gen_mode(NM_PLATFORM_GET, link.ifindex), ==, NM_IN6_ADDR_GEN_MODE_EUI64); diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 30c0678c40..f22e2fdb5e 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -1279,16 +1279,6 @@ _parse_af_inet6(NMPlatform * platform, token_valid = TRUE; } - /* Hack to detect support addrgenmode of the kernel. We only parse - * netlink messages that we receive from kernel, hence this check - * is valid. */ - if (!_nm_platform_kernel_support_detected( - NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE)) { - /* IFLA_INET6_ADDR_GEN_MODE was added in kernel 3.17, dated 5 October, 2014. */ - _nm_platform_kernel_support_init(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE, - tb[IFLA_INET6_ADDR_GEN_MODE] ? 1 : -1); - } - if (tb[IFLA_INET6_ADDR_GEN_MODE]) { i6_addr_gen_mode_inv = _nm_platform_uint8_inv(nla_get_u8(tb[IFLA_INET6_ADDR_GEN_MODE])); if (i6_addr_gen_mode_inv == 0) { @@ -7517,11 +7507,6 @@ link_set_inet6_addr_gen_mode(NMPlatform *platform, int ifindex, guint8 mode) ifindex, nm_platform_link_inet6_addrgenmode2str(mode, sbuf, sizeof(sbuf))); - if (!nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE)) { - _LOGD("link: change %d: user-ipv6ll: not supported", ifindex); - return -NME_PL_OPNOTSUPP; - } - nlmsg = _nl_msg_new_link(RTM_NEWLINK, 0, ifindex, NULL); if (!nlmsg || !_nl_msg_new_link_set_afspec(nlmsg, mode, NULL)) g_return_val_if_reached(-NME_BUG); diff --git a/src/libnm-platform/nm-platform.c b/src/libnm-platform/nm-platform.c index 7c84c4dad5..531052bdb3 100644 --- a/src/libnm-platform/nm-platform.c +++ b/src/libnm-platform/nm-platform.c @@ -306,12 +306,6 @@ static const struct { .name = "EXTENDED_IFA_FLAGS", .desc = "IPv6 temporary addresses support", }, - [NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE] = - { - .compile_time_default = TRUE, - .name = "IFLA_INET6_ADDR_GEN_MODE", - .desc = "IFLA_INET6_ADDR_GEN_MODE support", - }, [NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF] = { .compile_time_default = (RTA_MAX >= 20 /* RTA_PREF */), diff --git a/src/libnm-platform/nm-platform.h b/src/libnm-platform/nm-platform.h index 8f50e4ef3e..ee914d00ce 100644 --- a/src/libnm-platform/nm-platform.h +++ b/src/libnm-platform/nm-platform.h @@ -1016,7 +1016,6 @@ typedef void (*NMPlatformAsyncCallback)(GError *error, gpointer user_data); typedef enum { NM_PLATFORM_KERNEL_SUPPORT_TYPE_EXTENDED_IFA_FLAGS, - NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE, NM_PLATFORM_KERNEL_SUPPORT_TYPE_RTA_PREF, NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_L3MDEV, NM_PLATFORM_KERNEL_SUPPORT_TYPE_FRA_UID_RANGE, @@ -1403,8 +1402,6 @@ _nm_platform_link_get_inet6_addr_gen_mode(const NMPlatformLink *pllink) { if (!pllink) return -ENODEV; - if (!nm_platform_kernel_support_get(NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_INET6_ADDR_GEN_MODE)) - return -EOPNOTSUPP; return _nm_platform_uint8_inv(pllink->inet6_addr_gen_mode_inv); }