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.
This commit is contained in:
Thomas Haller 2021-08-24 15:00:54 +02:00
parent 98ed0e9858
commit b2b50eba1b
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
5 changed files with 6 additions and 38 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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 */),

View file

@ -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);
}