public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH ifupdown2 5/5] d/patches: read ipv6 devconf `disable_ipv6` attribute through netlink
Date: Fri, 22 Aug 2025 14:27:52 +0200	[thread overview]
Message-ID: <20250822122754.842281-6-c.heiss@proxmox.com> (raw)
In-Reply-To: <20250822122754.842281-1-c.heiss@proxmox.com>

Instead of using sysfs, read it directly from netlink, making it more
robust and enabling caching of the value.

As this patch relies on changes from
  upstream/0001-add-ipv6-slaac-support-inet6-auto-and-accept_ra.patch
it needs to be applied after that.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 ...pv6-devconf-disable_ipv6-attribute-t.patch | 102 ++++++++++++++++++
 debian/patches/series                         |   1 +
 2 files changed, 103 insertions(+)
 create mode 100644 debian/patches/pve/0014-nlmanager-read-ipv6-devconf-disable_ipv6-attribute-t.patch

diff --git a/debian/patches/pve/0014-nlmanager-read-ipv6-devconf-disable_ipv6-attribute-t.patch b/debian/patches/pve/0014-nlmanager-read-ipv6-devconf-disable_ipv6-attribute-t.patch
new file mode 100644
index 0000000..08ad68d
--- /dev/null
+++ b/debian/patches/pve/0014-nlmanager-read-ipv6-devconf-disable_ipv6-attribute-t.patch
@@ -0,0 +1,102 @@
+From 04874163c94a638361dd811e5c5a3f4060b45e21 Mon Sep 17 00:00:00 2001
+From: Christoph Heiss <c.heiss@proxmox.com>
+Date: Fri, 22 Aug 2025 11:59:21 +0200
+Subject: [PATCH] nlmanager: read ipv6 devconf `disable_ipv6` attribute through
+ netlink
+
+Instead of using sysfs, read it directly from netlink, making it more
+robust and enabling caching of the value.
+
+Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
+---
+ ifupdown2/addons/address.py     |  3 +--
+ ifupdown2/lib/iproute2.py       |  2 +-
+ ifupdown2/lib/nlcache.py        | 10 ++++++++++
+ ifupdown2/lib/sysfs.py          |  8 --------
+ ifupdown2/nlmanager/nlpacket.py |  1 +
+ 5 files changed, 13 insertions(+), 11 deletions(-)
+
+diff --git a/ifupdown2/addons/address.py b/ifupdown2/addons/address.py
+index 377b419..46226a9 100644
+--- a/ifupdown2/addons/address.py
++++ b/ifupdown2/addons/address.py
+@@ -1517,12 +1517,11 @@ class address(AddonWithIpBlackList, moduleBase):
+             return
+ 
+         user_config_bool = utils.get_boolean_from_string(user_config)
+-        sysfs_path = f"/proc/sys/net/ipv6/conf/{ifaceobj.name}/disable_ipv6"
+ 
+         ifaceobjcurr.update_config_with_status(
+             "disable-ipv6",
+             user_config,
+-            user_config_bool != utils.get_boolean_from_string(self.sysfs.read_file_oneline(sysfs_path))
++            user_config_bool != self.cache.get_link_inet6_disable(ifaceobj.name),
+         )
+ 
+     def _query_check(self, ifaceobj, ifaceobjcurr, ifaceobj_getfunc=None):
+diff --git a/ifupdown2/lib/iproute2.py b/ifupdown2/lib/iproute2.py
+index 3760963..8192d93 100644
+--- a/ifupdown2/lib/iproute2.py
++++ b/ifupdown2/lib/iproute2.py
+@@ -512,7 +512,7 @@ class IPRoute2(Cache, Requirements):
+         if cached_ipv6_addr_gen_mode == addrgen:
+             return True
+ 
+-        disabled_ipv6 = self.sysfs.get_ipv6_conf_disable_ipv6(ifname)
++        disabled_ipv6 = self.cache.get_link_inet6_disable(ifname)
+ 
+         if disabled_ipv6:
+             self.logger.info("%s: cannot set addrgen: ipv6 is disabled on this device" % ifname)
+diff --git a/ifupdown2/lib/nlcache.py b/ifupdown2/lib/nlcache.py
+index 9c15b6b..855ec43 100644
+--- a/ifupdown2/lib/nlcache.py
++++ b/ifupdown2/lib/nlcache.py
+@@ -1275,6 +1275,16 @@ class _NetlinkCache:
+         except Exception:
+             pass
+ 
++    def get_link_inet6_disable(self, ifname):
++        """
++        Whether IPv6 is disabled on this link or not.
++        :param ifname: str - Interface name
++        :return: boolean
++        """
++        inet6conf = self.get_link_inet6_conf(ifname)
++        if inet6conf and 'disable_ipv6' in inet6conf:
++            return bool(inet6conf['disable_ipv6'])
++        return False
+ 
+     #####################################################
+     #####################################################
+diff --git a/ifupdown2/lib/sysfs.py b/ifupdown2/lib/sysfs.py
+index fb1e405..6aa4284 100644
+--- a/ifupdown2/lib/sysfs.py
++++ b/ifupdown2/lib/sysfs.py
+@@ -201,12 +201,4 @@ class __Sysfs(IO, Requirements):
+             except Exception as e:
+                 self.logger.warning("%s: %s %s: %s" % (bond_name, bond_attr_name, value, str(e)))
+ 
+-    ############################################################################
+-    # /proc/sys/ipv6/conf
+-    ############################################################################
+-
+-    def get_ipv6_conf_disable_ipv6(self, ifname):
+-        return int(self.read_file_oneline("/proc/sys/net/ipv6/conf/%s/disable_ipv6" % ifname) or 0)
+-
+-
+ Sysfs = __Sysfs()
+diff --git a/ifupdown2/nlmanager/nlpacket.py b/ifupdown2/nlmanager/nlpacket.py
+index 6a0fef2..c3b0b67 100644
+--- a/ifupdown2/nlmanager/nlpacket.py
++++ b/ifupdown2/nlmanager/nlpacket.py
+@@ -1892,6 +1892,7 @@ class AttributeIFLA_AF_SPEC(Attribute):
+             self.IPV6_DEVCONF_ACCEPT_RA: 'accept_ra',
+             self.IPV6_DEVCONF_ACCEPT_REDIRECTS: 'accept_redirects',
+             self.IPV6_DEVCONF_AUTOCONF: 'autoconf',
++            self.IPV6_DEVCONF_DISABLE_IPV6: 'disable_ipv6',
+         }
+ 
+         self.decode_length_type(data)
+-- 
+2.50.1
+
diff --git a/debian/patches/series b/debian/patches/series
index 743e05e..266f57d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -13,3 +13,4 @@ pve/0012-addons-nlcache-set-interface-mtu-through-netlink-ins.patch
 pve/0013-addons-nlcache-set-interface-alias-through-netlink-i.patch
 upstream/0001-add-ipv6-slaac-support-inet6-auto-and-accept_ra.patch
 upstream/0001-use-raw-strings-for-regex-to-fix-backslash-interpret.patch
+pve/0014-nlmanager-read-ipv6-devconf-disable_ipv6-attribute-t.patch
-- 
2.50.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-08-22 12:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22 12:27 [pve-devel] [PATCH ifupdown2 0/5] d/patches: improve altname support Christoph Heiss
2025-08-22 12:27 ` [pve-devel] [PATCH ifupdown2 1/5] d/patches: altname support: add translation in some more places Christoph Heiss
2025-08-22 12:27 ` [pve-devel] [PATCH ifupdown2 2/5] d/patches: set interface mtu through netlink instead of sysfs Christoph Heiss
2025-08-22 12:27 ` [pve-devel] [PATCH ifupdown2 3/5] d/patches: set interface alias " Christoph Heiss
2025-08-22 12:27 ` [pve-devel] [PATCH ifupdown2 4/5] d/patches: ipv6 slaac: properly decode IPv6 devconf attributes Christoph Heiss
2025-08-22 12:27 ` Christoph Heiss [this message]
2025-08-26 22:33 ` [pve-devel] applied-series: [PATCH ifupdown2 0/5] d/patches: improve altname support Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250822122754.842281-6-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal