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 4/5] d/patches: ipv6 slaac: properly decode IPv6 devconf attributes
Date: Fri, 22 Aug 2025 14:27:51 +0200	[thread overview]
Message-ID: <20250822122754.842281-5-c.heiss@proxmox.com> (raw)
In-Reply-To: <20250822122754.842281-1-c.heiss@proxmox.com>

Properly decode the IFLA_INET6_CONF array in IFLA_AF_SPEC by matching up
the array indices as defined in the Linux UAPI. This makes decoding a
lot more robust by not silently relying on a "magic" sequence of
attributes.
Also enables easily decoding additional attributes in the future as
needed.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 debian/patches/series                         |   2 +-
 ...ac-support-inet6-auto-and-accept_ra.patch} | 140 +++++++++++++-----
 2 files changed, 107 insertions(+), 35 deletions(-)
 rename debian/patches/upstream/{0001-add-ipv6-slaac-support-inet6-auto-accept_ra.patch => 0001-add-ipv6-slaac-support-inet6-auto-and-accept_ra.patch} (82%)

diff --git a/debian/patches/series b/debian/patches/series
index 1945ba9..743e05e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -11,5 +11,5 @@ pve/0010-main-ignore-dpkg-files-when-running-hook-scripts.patch
 pve/0011-nlmanager-addons-add-transparent-support-interface-a.patch
 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-accept_ra.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
diff --git a/debian/patches/upstream/0001-add-ipv6-slaac-support-inet6-auto-accept_ra.patch b/debian/patches/upstream/0001-add-ipv6-slaac-support-inet6-auto-and-accept_ra.patch
similarity index 82%
rename from debian/patches/upstream/0001-add-ipv6-slaac-support-inet6-auto-accept_ra.patch
rename to debian/patches/upstream/0001-add-ipv6-slaac-support-inet6-auto-and-accept_ra.patch
index 4d5dbff..5a78d46 100644
--- a/debian/patches/upstream/0001-add-ipv6-slaac-support-inet6-auto-accept_ra.patch
+++ b/debian/patches/upstream/0001-add-ipv6-slaac-support-inet6-auto-and-accept_ra.patch
@@ -1,17 +1,17 @@
-From 38dadc7048726671b8e1bf6c63a3313720afeaf9 Mon Sep 17 00:00:00 2001
+From fbaf352df432f66429fd3d3144733b22e8317356 Mon Sep 17 00:00:00 2001
 From: Alexandre Derumier <aderumier@odiso.com>
 Date: Tue, 9 May 2023 17:48:14 +0200
-Subject: [PATCH] add ipv6 slaac support (inet6 auto && accept_ra)
+Subject: [PATCH] add ipv6 slaac support (inet6 auto and accept_ra)
+
+First, properly decode the IFLA_INET6_CONF array in IFLA_AF_SPEC by
+matching up the array indices as defined in the Linux UAPI.
 
 This should fix a lot of users request in the forum,
 and also fix upgrade from ifupdown1 to ifupdown2 if user have "inet6 auto" in configuration.
 (default on stock debian install, this break pbs install on top of stock debian)
 
-upstream pull request:
-
-https://github.com/CumulusNetworks/ifupdown2/pull/259
-Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
-Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+Upstream-PR: https://github.com/CumulusNetworks/ifupdown2/pull/325
+Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
 Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
 ---
  etc/network/ifupdown2/addons.conf       |   2 +
@@ -22,8 +22,8 @@ Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
  ifupdown2/ifupdown/networkinterfaces.py |   2 +-
  ifupdown2/lib/nlcache.py                |  63 ++++++++-
  ifupdown2/man/interfaces.5.rst          |   9 ++
- ifupdown2/nlmanager/nlpacket.py         |  24 +++-
- 9 files changed, 372 insertions(+), 26 deletions(-)
+ ifupdown2/nlmanager/nlpacket.py         |  89 ++++++++++++-
+ 9 files changed, 437 insertions(+), 26 deletions(-)
  create mode 100644 ifupdown2/addons/auto.py
 
 diff --git a/etc/network/ifupdown2/addons.conf b/etc/network/ifupdown2/addons.conf
@@ -47,7 +47,7 @@ index a8f2317..5a3964d 100644
  down,address
  down,usercmds
 diff --git a/ifupdown2/addons/address.py b/ifupdown2/addons/address.py
-index c19b138..3ab8309 100644
+index d158c44..3196a5e 100644
 --- a/ifupdown2/addons/address.py
 +++ b/ifupdown2/addons/address.py
 @@ -193,6 +193,18 @@ class address(AddonWithIpBlackList, moduleBase):
@@ -197,7 +197,7 @@ index c19b138..3ab8309 100644
              return
  
          if not user_configured_ipv6_addrgen:
-@@ -1269,7 +1343,7 @@ class address(AddonWithIpBlackList, moduleBase):
+@@ -1271,7 +1345,7 @@ class address(AddonWithIpBlackList, moduleBase):
              if not self.cache.link_exists(ifaceobj.name):
                  return
              addr_method = ifaceobj.addr_method
@@ -206,7 +206,7 @@ index c19b138..3ab8309 100644
                  if ifaceobj.get_attr_value_first('address-purge')=='no':
                      addrlist = ifaceobj.get_attr_value('address')
                      for addr in addrlist or []:
-@@ -1382,6 +1456,22 @@ class address(AddonWithIpBlackList, moduleBase):
+@@ -1384,6 +1458,22 @@ class address(AddonWithIpBlackList, moduleBase):
              ifaceobjcurr.update_config_with_status('mpls-enable',
                                                     running_mpls_enable,
                                              mpls_enable != running_mpls_enable)
@@ -229,7 +229,7 @@ index c19b138..3ab8309 100644
          return
  
      def query_check_ipv6_addrgen(self, ifaceobj, ifaceobjcurr):
-@@ -1452,7 +1542,7 @@ class address(AddonWithIpBlackList, moduleBase):
+@@ -1454,7 +1544,7 @@ class address(AddonWithIpBlackList, moduleBase):
  
      def _query_check_address(self, ifaceobj, ifaceobjcurr, ifaceobj_getfunc):
          """ ifquery-check: attribute: "address" """
@@ -592,41 +592,113 @@ index 262d726..ca461ea 100644
          source /etc/network/interfaces.d/*
  
 diff --git a/ifupdown2/nlmanager/nlpacket.py b/ifupdown2/nlmanager/nlpacket.py
-index efc4c4e..95d59dc 100644
+index efc4c4e..6a0fef2 100644
 --- a/ifupdown2/nlmanager/nlpacket.py
 +++ b/ifupdown2/nlmanager/nlpacket.py
-@@ -1818,6 +1818,15 @@ class AttributeIFLA_AF_SPEC(Attribute):
+@@ -1691,6 +1691,71 @@ class AttributeIFLA_AF_SPEC(Attribute):
+         Link.IFLA_BRIDGE_VLAN_INFO: (vflags, vlanid)
+     }
+     """
++
++    # from /usr/include/linux/ipv6.h
++    # index values for entries in Link.IFLA_INET6_CONF values
++    IPV6_DEVCONF_FORWARDING                        = 0
++    IPV6_DEVCONF_HOPLIMIT                          = 1
++    IPV6_DEVCONF_MTU6                              = 2
++    IPV6_DEVCONF_ACCEPT_RA                         = 3
++    IPV6_DEVCONF_ACCEPT_REDIRECTS                  = 4
++    IPV6_DEVCONF_AUTOCONF                          = 5
++    IPV6_DEVCONF_DAD_TRANSMITS                     = 6
++    IPV6_DEVCONF_RTR_SOLICITS                      = 7
++    IPV6_DEVCONF_RTR_SOLICIT_INTERVAL              = 8
++    IPV6_DEVCONF_RTR_SOLICIT_DELAY                 = 9
++    IPV6_DEVCONF_USE_TEMPADDR                      = 10
++    IPV6_DEVCONF_TEMP_VALID_LFT                    = 11
++    IPV6_DEVCONF_TEMP_PREFERED_LFT                 = 12
++    IPV6_DEVCONF_REGEN_MAX_RETRY                   = 13
++    IPV6_DEVCONF_MAX_DESYNC_FACTOR                 = 14
++    IPV6_DEVCONF_MAX_ADDRESSES                     = 15
++    IPV6_DEVCONF_FORCE_MLD_VERSION                 = 16
++    IPV6_DEVCONF_ACCEPT_RA_DEFRTR                  = 17
++    IPV6_DEVCONF_ACCEPT_RA_PINFO                   = 18
++    IPV6_DEVCONF_ACCEPT_RA_RTR_PREF                = 19
++    IPV6_DEVCONF_RTR_PROBE_INTERVAL                = 20
++    IPV6_DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN        = 21
++    IPV6_DEVCONF_PROXY_NDP                         = 22
++    IPV6_DEVCONF_OPTIMISTIC_DAD                    = 23
++    IPV6_DEVCONF_ACCEPT_SOURCE_ROUTE               = 24
++    IPV6_DEVCONF_MC_FORWARDING                     = 25
++    IPV6_DEVCONF_DISABLE_IPV6                      = 26
++    IPV6_DEVCONF_ACCEPT_DAD                        = 27
++    IPV6_DEVCONF_FORCE_TLLAO                       = 28
++    IPV6_DEVCONF_NDISC_NOTIFY                      = 29
++    IPV6_DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL = 30
++    IPV6_DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL = 31
++    IPV6_DEVCONF_SUPPRESS_FRAG_NDISC               = 32
++    IPV6_DEVCONF_ACCEPT_RA_FROM_LOCAL              = 33
++    IPV6_DEVCONF_USE_OPTIMISTIC                    = 34
++    IPV6_DEVCONF_ACCEPT_RA_MTU                     = 35
++    IPV6_DEVCONF_STABLE_SECRET                     = 36
++    IPV6_DEVCONF_USE_OIF_ADDRS_ONLY                = 37
++    IPV6_DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT           = 38
++    IPV6_DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN       = 39
++    IPV6_DEVCONF_DROP_UNICAST_IN_L2_MULTICAST      = 40
++    IPV6_DEVCONF_DROP_UNSOLICITED_NA               = 41
++    IPV6_DEVCONF_KEEP_ADDR_ON_DOWN                 = 42
++    IPV6_DEVCONF_RTR_SOLICIT_MAX_INTERVAL          = 43
++    IPV6_DEVCONF_SEG6_ENABLED                      = 44
++    IPV6_DEVCONF_SEG6_REQUIRE_HMAC                 = 45
++    IPV6_DEVCONF_ENHANCED_DAD                      = 46
++    IPV6_DEVCONF_ADDR_GEN_MODE                     = 47
++    IPV6_DEVCONF_DISABLE_POLICY                    = 48
++    IPV6_DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN        = 49
++    IPV6_DEVCONF_NDISC_TCLASS                      = 50
++    IPV6_DEVCONF_RPL_SEG_ENABLED                   = 51
++    IPV6_DEVCONF_RA_DEFRTR_METRIC                  = 52
++    IPV6_DEVCONF_IOAM6_ENABLED                     = 53
++    IPV6_DEVCONF_IOAM6_ID                          = 54
++    IPV6_DEVCONF_IOAM6_ID_WIDE                     = 55
++    IPV6_DEVCONF_NDISC_EVICT_NOCARRIER             = 56
++    IPV6_DEVCONF_ACCEPT_UNTRACKED_NA               = 57
++    IPV6_DEVCONF_ACCEPT_RA_MIN_LFT                 = 58
++    IPV6_DEVCONF_FORCE_FORWARDING                  = 59
++
++
+     def __init__(self, atype, string, family, logger):
+         Attribute.__init__(self, atype, string, logger)
+         self.family = family
+@@ -1818,6 +1883,17 @@ class AttributeIFLA_AF_SPEC(Attribute):
           */
  
          """
-+        #only first attributes used in any kernel.
-+        ipv6_devconf = ['forwarding',
-+                        'hop_limit',
-+                        'mtu6',
-+                        'accept_ra',
-+                        'accept_redirects',
-+                        'autoconf',
-+        ]
++
++        # maps IFLA_INET6_CONF index to key name in result
++        ipv6_devconf_map = {
++            self.IPV6_DEVCONF_FORWARDING: 'forwarding',
++            self.IPV6_DEVCONF_HOPLIMIT: 'hop_limit',
++            self.IPV6_DEVCONF_MTU6: 'mtu6',
++            self.IPV6_DEVCONF_ACCEPT_RA: 'accept_ra',
++            self.IPV6_DEVCONF_ACCEPT_REDIRECTS: 'accept_redirects',
++            self.IPV6_DEVCONF_AUTOCONF: 'autoconf',
++        }
 +
          self.decode_length_type(data)
          self.value = {}
  
-@@ -1896,8 +1905,21 @@ class AttributeIFLA_AF_SPEC(Attribute):
+@@ -1896,8 +1972,19 @@ class AttributeIFLA_AF_SPEC(Attribute):
                          (inet6_attr_length, inet6_attr_type) = unpack('=HH', sub_attr_data[:4])
                          inet6_attr_end = padded_length(inet6_attr_length)
  
 +                        if inet6_attr_type == Link.IFLA_INET6_CONF:
 +                            inet6conf_data = sub_attr_data[4:inet6_attr_end]
-+                            index = 0
 +                            result = {}
-+                            while inet6conf_data:
-+                                (value, undef) = unpack('=HH', inet6conf_data[:4])
-+                                result[ipv6_devconf[index]] = value
-+                                inet6conf_data = inet6conf_data[4:]
-+                                index = index + 1
-+                                if index >= len(ipv6_devconf):
-+                                    inet6_attr[inet6_attr_type] = result
-+                                    break
++
++                            for index in ipv6_devconf_map:
++                                offset = index * 4
++                                (value, undef) = unpack('=HH', inet6conf_data[offset:offset + 4])
++                                result[ipv6_devconf_map[index]] = value
++
++                            inet6_attr[inet6_attr_type] = result
 +
                          # 1 byte attr
 -                        if inet6_attr_type == Link.IFLA_INET6_ADDR_GEN_MODE:
@@ -635,5 +707,5 @@ index efc4c4e..95d59dc 100644
  
                              # nlmanager doesn't support multiple kernel version
 -- 
-2.49.0
+2.50.1
 
-- 
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 ` Christoph Heiss [this message]
2025-08-22 12:27 ` [pve-devel] [PATCH ifupdown2 5/5] d/patches: read ipv6 devconf `disable_ipv6` attribute through netlink Christoph Heiss
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-5-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