From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 8C1811FF15C for ; Fri, 22 Aug 2025 14:28:22 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CEACBF91D; Fri, 22 Aug 2025 14:28:03 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Fri, 22 Aug 2025 14:27:52 +0200 Message-ID: <20250822122754.842281-6-c.heiss@proxmox.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250822122754.842281-1-c.heiss@proxmox.com> References: <20250822122754.842281-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1755865676805 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.037 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH ifupdown2 5/5] d/patches: read ipv6 devconf `disable_ipv6` attribute through netlink X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" 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 --- ...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 +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 +--- + 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