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 4D1581FF15E for ; Mon, 24 Nov 2025 01:43:40 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 088C014D84; Mon, 24 Nov 2025 01:43:48 +0100 (CET) To: pve-devel@lists.proxmox.com Date: Sun, 23 Nov 2025 16:43:01 -0800 In-Reply-To: <20251124004302.498297-1-alex@goodkind.io> References: <20251124004302.498297-1-alex@goodkind.io> MIME-Version: 1.0 Message-ID: List-Id: Proxmox VE development discussion List-Post: From: Alex Goodkind via pve-devel Precedence: list Cc: Alex Goodkind , tarick@bedeir.com X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Proxmox VE development discussion List-Help: Subject: [pve-devel] [PATCH container 1/2] lxc: add DHCPv6 DUID retrieval to get_interfaces Content-Type: multipart/mixed; boundary="===============4615144043343322048==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============4615144043343322048== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: X-Original-To: pve-devel@lists.proxmox.com Delivered-To: pve-devel@lists.proxmox.com Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 7599CD0461 for ; Mon, 24 Nov 2025 01:43:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4A10014C52 for ; Mon, 24 Nov 2025 01:43:46 +0100 (CET) Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 24 Nov 2025 01:43:44 +0100 (CET) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-7b80fed1505so4236181b3a.3 for ; Sun, 23 Nov 2025 16:43:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=goodkind.io; s=google; t=1763945018; x=1764549818; darn=lists.proxmox.com; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l5oNfFm45SyX83gz1g4BhZ3xhSmYfsBqNX4r24N6im8=; b=IjAUSmWZezVxiE+a1jbyvLZOJIMzbXt7+3fS5OJ9Q7048CruujfPNg2q9VOazqWl8U bdTUcFz98f73285yynXHkuBLB8SEa/aDHPHUVxE8AGObvWqbsgDkKPs4JKlbUa9gQxRg mt+EfaKUd9h9INuab4kmNa23mga8JYRSeS+NkANiAL8zhsfhV63eQmjYeB1tjfpQCt8A FFQpgTnOG5IysB39GLZPH2C+9yLkm6xiv5u81bHSPP6PnM2fJ+vvwZTkhj10DZM0PK8w ERx9Jx7qVuIEVgXDhFRJ0/dFFBnbstr+kU+p00z7yW95B1633X9MRGYhnTn6L5jOCB6U Dp8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763945018; x=1764549818; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=l5oNfFm45SyX83gz1g4BhZ3xhSmYfsBqNX4r24N6im8=; b=DgfHOTYESCo+vdCcfWQOYbXXIDJnzxSrZ46hgv5b33iL3Y2yckF+GkFc6rPLEF9tGO mCNJeQ5jlMfxg857SVYbFp2rFAsY8FLnIlVVkuHh/YK9QCJb8kmSuMcXEO4HoHzLJwWt htbmeyGK38cFC/BYW+kFim4FS+vKOxuL90oimTUXkQ58EU0CrYACY7fgGlcIoFSHg6c/ 5ZPXM5N9RrKSAChFRR2yr9zEuveo2lloS3kqhcLoYhgSIqW1QY4bsBsB0p1Y2t+tzI2Q FxEHbluQcQnHVBc2aYc97wZr/jcPVOjJ60l2REh6xSF9V0YTUBm++3sxFQ/8RnTAbZZh z99A== X-Gm-Message-State: AOJu0YyDziL9oFkjUjuRmhZ0St/IP0ZEYyNUqxEQ0ZljcVR+Wl5xPwcf eJe1yFc1vuzxzlhqvQC7Jj6Vw042lCxDzCdB4Guhfh/xDu8HnuL94wQkHnLo5k0ulyw= X-Gm-Gg: ASbGnctrg0jhTvdbMjDnwwb8e/9Nkh0i6yLC2T8m14ecurT7h0yiaXZXbJfnV+EY8rn yXA//bixZ3oFtbq3iPI4/d7P28WvZaiACfNFMfICl9P4jH1jsn9+hsmN7JbeTUzqGvAcP31wvmO 8YookBOobidcpJlgOC5jivde6NGqoQjf6TtduPJ0yIRukQZzZ4c1myvOKmzMaKTFs11W0hkNLd6 j6xkS/XxaRl/iPfHIBzF++XcrHM5chnm9+oxaqTluvPPPgCg6Dz7mNIcfl1PhVdXDQfDFn1WzD2 DlvnFEGiAmn2ML8k13G5RRuyv7g9XzRgVrpTFUyX/8gptq/OvrhUVKOiv2rdTesLi7exsNnNFnb vs0zjSVJeN88abjueZIEceQMIwQt34oDBKwDFqcuPN/3DMz1LhweynzVpCAt3SIBvbdCrE8Dkuz ywxcH19y5teh4ygjb3wmaEG2fD2ddNkBibR8BUBF/LnRiqdccq7EE= X-Google-Smtp-Source: AGHT+IGWKYZLgZ541a7lO1gmFNwZgDBc/QIZwJVkJCsPyUO1bBjC6TYFxn9e6SKxdzCHuUpad1d1PQ== X-Received: by 2002:a05:7022:90f:b0:11a:61ef:7949 with SMTP id a92af1059eb24-11c9d61261fmr6531124c88.9.1763945017758; Sun, 23 Nov 2025 16:43:37 -0800 (PST) Received: from mini.home.goodkind.io ([2600:1700:2f71:c81::2]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11c93db4a23sm65237078c88.2.2025.11.23.16.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Nov 2025 16:43:37 -0800 (PST) Received: by mini.home.goodkind.io (Postfix, from userid 1000) id ABED85A0011; Sun, 23 Nov 2025 16:43:36 -0800 (PST) From: Alex Goodkind To: pve-devel@lists.proxmox.com Cc: tarick@bedeir.com, Alex Goodkind Subject: [PATCH container 1/2] lxc: add DHCPv6 DUID retrieval to get_interfaces Date: Sun, 23 Nov 2025 16:43:01 -0800 Message-ID: <20251124004302.498297-2-alex@goodkind.io> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251124004302.498297-1-alex@goodkind.io> References: <20251124004302.498297-1-alex@goodkind.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lxc.pm] Extend get_interfaces function to retrieve DHCPv6 DUID from networkctl. The DUID is parsed and formatted according to RFC 8415 with proper type prefix (DUID-LLT, DUID-EN/Vendor, DUID-LL, UUID). The formatted DUID is added to the interface object. Signed-off-by: Alex Goodkind --- src/PVE/LXC.pm | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index de54a0d..d5f059b 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -1310,6 +1310,78 @@ sub get_interfaces { # TODO: remove on next major release $obj->{hwaddr} = $interface->{address}; + # Get DUID from networkctl (supports all DUID types) + eval { + my $duid_output; + run_command( + [ + 'nsenter', + '-t', + $pid, + '--all', # networkctl fails in partial namespace entry + '--', + 'networkctl', + 'status', + $interface->{ifname}, + ], + outfunc => sub { $duid_output .= shift; }, + errfunc => sub { }, # Ignore errors (networkctl might not be available) + ); + + # Parse DUID from networkctl output + # Format: "DHCP6 Client DUID: :" + # Possible types: DUID-LLT, DUID-EN/Vendor, DUID-LL, UUID, or hex for unknown types + # Examples: + # "DHCP6 Client DUID: DUID-EN/Vendor:0000ab113f93f63a9e558dfb" + # "DHCP6 Client DUID: DUID-LLT:0001000123456789abcdef..." + # "DHCP6 Client DUID: DUID-LL:0003bc2411304fd2" + # "DHCP6 Client DUID: UUID:1234567890abcdef..." + # Note: networkctl outputs the DUID data WITHOUT the type prefix bytes + # We need to prepend the 2-byte type code to form the complete DUID + if ( + $duid_output + && $duid_output =~ /DHCP6\s+Client\s+DUID:\s+([^:]+):([0-9a-f:]+)/i + ) { + my $duid_type = $1; + my $duid_value = $2; + + # Map type string to numeric type code (RFC 8415) + my $type_code; + if ($duid_type =~ /^DUID-LLT$/i) { + $type_code = 1; # 0x0001 + } elsif ($duid_type =~ /^DUID-EN\/Vendor$/i) { + $type_code = 2; # 0x0002 + } elsif ($duid_type =~ /^DUID-LL$/i) { + $type_code = 3; # 0x0003 + } elsif ($duid_type =~ /^UUID$/i) { + $type_code = 4; # 0x0004 + } else { + # Unknown type - try to parse as hex + if ($duid_type =~ /^([0-9a-f]{1,4})$/i) { + $type_code = hex($duid_type); + } else { + # Fallback: skip adding prefix for unknown types + $type_code = undef; + } + } + + # Normalize format: remove existing colons and rebuild with proper formatting + $duid_value =~ s/://g; + # Add colons every 2 hex digits + $duid_value =~ s/([0-9a-f]{2})(?=[0-9a-f]{2})/$1:/gi; + + # Prepend type prefix (2 bytes, big-endian) if we have a valid type code + my $full_duid = $duid_value; + if (defined($type_code)) { + my $type_prefix = sprintf("%04x", $type_code); + $type_prefix =~ s/([0-9a-f]{2})(?=[0-9a-f]{2})/$1:/gi; + $full_duid = lc("$type_prefix:$duid_value"); + } + + $obj->{'duid'} = lc($full_duid); + } + }; + push @$res, $obj; } -- 2.43.0 --===============4615144043343322048== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============4615144043343322048==--