all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH proxmox] fix #7329: proxmox-network-api: add missing `Auto` network config method
@ 2026-03-11 10:11 Shan Shaji
  2026-03-12 14:57 ` Christian Ebner
  0 siblings, 1 reply; 4+ messages in thread
From: Shan Shaji @ 2026-03-11 10:11 UTC (permalink / raw)
  To: pbs-devel

when adding an iface object with network type as inet6 and the config
type as auto, the web UI was showing an error inside the "Network
interfaces" section. This was because the `NetworkParser` failed to
parse the auto method. Inorder to fix the issue, add new `Auto` variant
inside the `NetworkConfigMethod` enum and update the match clause to
handle `Auto` variant.

Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
---

 Reference: https://manpages.debian.org/trixie/ifupdown/interfaces.5.en.html#INET6_ADDRESS_FAMILY

 proxmox-network-api/src/api_types.rs     |  2 ++
 proxmox-network-api/src/config/mod.rs    |  1 +
 proxmox-network-api/src/config/parser.rs | 43 ++++++++++++++++++++++++
 3 files changed, 46 insertions(+)

diff --git a/proxmox-network-api/src/api_types.rs b/proxmox-network-api/src/api_types.rs
index 4860a114..b86f8570 100644
--- a/proxmox-network-api/src/api_types.rs
+++ b/proxmox-network-api/src/api_types.rs
@@ -37,6 +37,8 @@ pub enum NetworkConfigMethod {
     DHCP,
     /// Define the loopback interface.
     Loopback,
+    /// Define interfaces with automatically assigned IPv6 addresses.
+    Auto,
 }
 
 #[api()]
diff --git a/proxmox-network-api/src/config/mod.rs b/proxmox-network-api/src/config/mod.rs
index 9b9f0d50..84fdff86 100644
--- a/proxmox-network-api/src/config/mod.rs
+++ b/proxmox-network-api/src/config/mod.rs
@@ -177,6 +177,7 @@ fn write_iface(iface: &Interface, w: &mut dyn Write) -> Result<(), Error> {
             NetworkConfigMethod::Loopback => "loopback",
             NetworkConfigMethod::Manual => "manual",
             NetworkConfigMethod::DHCP => "dhcp",
+            NetworkConfigMethod::Auto => "auto",
         }
     }
 
diff --git a/proxmox-network-api/src/config/parser.rs b/proxmox-network-api/src/config/parser.rs
index 8cbc6ac8..dafe19f8 100644
--- a/proxmox-network-api/src/config/parser.rs
+++ b/proxmox-network-api/src/config/parser.rs
@@ -461,6 +461,7 @@ impl<R: BufRead> NetworkParser<R> {
                 Token::Static => config_method = Some(NetworkConfigMethod::Static),
                 Token::Manual => config_method = Some(NetworkConfigMethod::Manual),
                 Token::DHCP => config_method = Some(NetworkConfigMethod::DHCP),
+                Token::Auto => config_method = Some(NetworkConfigMethod::Auto),
                 _ => bail!("unknown iface option {}", text),
             }
         }
@@ -742,6 +743,48 @@ mod test {
         Ok(())
     }
 
+    #[test]
+    fn test_network_config_parser_ipv6_variants() -> Result<(), Error> {
+        let input = "auto lo\n\
+                 iface lo inet6 loopback\n\
+                 \n\
+                 auto ens18\n\
+                 iface ens18 inet6 auto\n\
+                 \n\
+                 auto ens20\n\
+                 iface ens20 inet6 static\n\
+                 \taddress 2001:db8:a::1/64\n\
+                 \tgateway 2001:db8:a::fe\n\
+                 \n\
+                 auto ens21\n\
+                 iface ens21 inet6 dhcp\n";
+
+        let mut parser = NetworkParser::new(input.as_bytes());
+
+        let config = parser.parse_interfaces(None)?;
+
+        let output = String::try_from(config)?;
+
+        let expected = "auto lo\n\
+                    iface lo inet6 loopback\n\
+                    \n\
+                    auto ens18\n\
+                    iface ens18 inet6 auto\n\
+                    \n\
+                    auto ens20\n\
+                    iface ens20 inet6 static\n\
+                    \taddress 2001:db8:a::1/64\n\
+                    \tgateway 2001:db8:a::fe\n\
+                    \n\
+                    auto ens21\n\
+                    iface ens21 inet6 dhcp\n\
+                    \n";
+
+        assert_eq!(output, expected);
+
+        Ok(())
+    }
+
     #[test]
     fn test_network_config_parser_no_blank_2() -> Result<(), Error> {
         // Adapted from bug 2926
-- 
2.47.3





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH proxmox] fix #7329: proxmox-network-api: add missing `Auto` network config method
  2026-03-11 10:11 [PATCH proxmox] fix #7329: proxmox-network-api: add missing `Auto` network config method Shan Shaji
@ 2026-03-12 14:57 ` Christian Ebner
  2026-03-13 17:36   ` Shan Shaji
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Ebner @ 2026-03-12 14:57 UTC (permalink / raw)
  To: Shan Shaji, pbs-devel

Thanks for the patch, gave this a quick spin but ran into an issue.

If I do have a network config containing e.g.:
```
auto nic1
iface nic1 inet static
	address 172.16.0.18/24

iface nic1 inet6 auto
```
and I go about to edit this NIC via the WebUI, e.g. adding a comment, 
the suggested diff would drop this, suggesting the following diff:

``` auto nic1
  iface nic1 inet static
  	address 172.16.0.18/24
-
-iface nic1 inet6 auto
+#comment
```

Can this easily be avoided?

On 3/11/26 11:10 AM, Shan Shaji wrote:
> when adding an iface object with network type as inet6 and the config
> type as auto, the web UI was showing an error inside the "Network
> interfaces" section. This was because the `NetworkParser` failed to
> parse the auto method. Inorder to fix the issue, add new `Auto` variant

typo: s/Inorder/In order/

> inside the `NetworkConfigMethod` enum and update the match clause to
> handle `Auto` variant.
> 

Please include a `Fixes` trailer pointing to the bugtracker issue, thanks!

> Signed-off-by: Shan Shaji <s.shaji@proxmox.com>
> ---
> 
>   Reference: https://manpages.debian.org/trixie/ifupdown/interfaces.5.en.html#INET6_ADDRESS_FAMILY
> 
>   proxmox-network-api/src/api_types.rs     |  2 ++
>   proxmox-network-api/src/config/mod.rs    |  1 +
>   proxmox-network-api/src/config/parser.rs | 43 ++++++++++++++++++++++++
>   3 files changed, 46 insertions(+)
> 
> diff --git a/proxmox-network-api/src/api_types.rs b/proxmox-network-api/src/api_types.rs
> index 4860a114..b86f8570 100644
> --- a/proxmox-network-api/src/api_types.rs
> +++ b/proxmox-network-api/src/api_types.rs
> @@ -37,6 +37,8 @@ pub enum NetworkConfigMethod {
>       DHCP,
>       /// Define the loopback interface.
>       Loopback,
> +    /// Define interfaces with automatically assigned IPv6 addresses.
> +    Auto,
>   }
>   
>   #[api()]
> diff --git a/proxmox-network-api/src/config/mod.rs b/proxmox-network-api/src/config/mod.rs
> index 9b9f0d50..84fdff86 100644
> --- a/proxmox-network-api/src/config/mod.rs
> +++ b/proxmox-network-api/src/config/mod.rs
> @@ -177,6 +177,7 @@ fn write_iface(iface: &Interface, w: &mut dyn Write) -> Result<(), Error> {
>               NetworkConfigMethod::Loopback => "loopback",
>               NetworkConfigMethod::Manual => "manual",
>               NetworkConfigMethod::DHCP => "dhcp",
> +            NetworkConfigMethod::Auto => "auto",
>           }
>       }
>   
> diff --git a/proxmox-network-api/src/config/parser.rs b/proxmox-network-api/src/config/parser.rs
> index 8cbc6ac8..dafe19f8 100644
> --- a/proxmox-network-api/src/config/parser.rs
> +++ b/proxmox-network-api/src/config/parser.rs
> @@ -461,6 +461,7 @@ impl<R: BufRead> NetworkParser<R> {
>                   Token::Static => config_method = Some(NetworkConfigMethod::Static),
>                   Token::Manual => config_method = Some(NetworkConfigMethod::Manual),
>                   Token::DHCP => config_method = Some(NetworkConfigMethod::DHCP),
> +                Token::Auto => config_method = Some(NetworkConfigMethod::Auto),
>                   _ => bail!("unknown iface option {}", text),
>               }
>           }
> @@ -742,6 +743,48 @@ mod test {
>           Ok(())
>       }
>   
> +    #[test]
> +    fn test_network_config_parser_ipv6_variants() -> Result<(), Error> {
> +        let input = "auto lo\n\
> +                 iface lo inet6 loopback\n\
> +                 \n\
> +                 auto ens18\n\
> +                 iface ens18 inet6 auto\n\
> +                 \n\
> +                 auto ens20\n\
> +                 iface ens20 inet6 static\n\
> +                 \taddress 2001:db8:a::1/64\n\
> +                 \tgateway 2001:db8:a::fe\n\
> +                 \n\
> +                 auto ens21\n\
> +                 iface ens21 inet6 dhcp\n";
> +
> +        let mut parser = NetworkParser::new(input.as_bytes());
> +
> +        let config = parser.parse_interfaces(None)?;
> +
> +        let output = String::try_from(config)?;
> +
> +        let expected = "auto lo\n\
> +                    iface lo inet6 loopback\n\
> +                    \n\
> +                    auto ens18\n\
> +                    iface ens18 inet6 auto\n\
> +                    \n\
> +                    auto ens20\n\
> +                    iface ens20 inet6 static\n\
> +                    \taddress 2001:db8:a::1/64\n\
> +                    \tgateway 2001:db8:a::fe\n\
> +                    \n\
> +                    auto ens21\n\
> +                    iface ens21 inet6 dhcp\n\
> +                    \n";
> +
> +        assert_eq!(output, expected);
> +
> +        Ok(())
> +    }
> +
>       #[test]
>       fn test_network_config_parser_no_blank_2() -> Result<(), Error> {
>           // Adapted from bug 2926





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH proxmox] fix #7329: proxmox-network-api: add missing `Auto` network config method
  2026-03-12 14:57 ` Christian Ebner
@ 2026-03-13 17:36   ` Shan Shaji
  2026-03-16 15:23     ` Shan Shaji
  0 siblings, 1 reply; 4+ messages in thread
From: Shan Shaji @ 2026-03-13 17:36 UTC (permalink / raw)
  To: Christian Ebner, pbs-devel

On Thu Mar 12, 2026 at 3:57 PM CET, Christian Ebner wrote:
> Thanks for the patch, gave this a quick spin but ran into an issue.
>
> If I do have a network config containing e.g.:
> ```
> auto nic1
> iface nic1 inet static
> 	address 172.16.0.18/24
>
> iface nic1 inet6 auto
> ```
> and I go about to edit this NIC via the WebUI, e.g. adding a comment, 
> the suggested diff would drop this, suggesting the following diff:
>
> ``` auto nic1
>   iface nic1 inet static
>   	address 172.16.0.18/24
> -
> -iface nic1 inet6 auto
> +#comment
> ```

Hi Chris, Thank you very much for catching that.

After digging into this a bit more, it looks like this happens in the interface
update handler on the API side. If the inet6 address family's cidr6/gateway6 values are
not set, interface.method6 value is mutated with `NetworkConfigMethod::Manual`:

```
if interface.cidr6.is_some() || interface.gateway6.is_some() {
        interface.method6 = Some(NetworkConfigMethod::Static);
    } else {
        interface.method6 = Some(NetworkConfigMethod::Manual);
}
```

Later, when writing the config back, if the method6 value is `NetworkConfigMethod::Manual`
and there are no IPv6 specific attributes present, the inet6 stanza gets skipped:  

```
fn write_iface(iface: &Interface, w: &mut dyn Write) -> Result<(), Error> {

[...]

    if let Some(method6) = iface.method6 {
        let mut skip_v6 = false; // avoid empty inet6 manual entry
        if iface.method.is_some()
            && method6 == NetworkConfigMethod::Manual
            && iface.comments6.is_none()
            && iface.options6.is_empty()
        {
            skip_v6 = true;
        }

        if !skip_v6 {
            writeln!(w, "iface {} inet6 {}", iface.name, method_to_str(method6))?;
            write_iface_attributes_v6(iface, w, method6)?;
            if iface.method.is_none() {
                // only write common attributes once
                write_iface_attributes(iface, w)?;
            }
            writeln!(w)?;
        }
    }

    Ok(())
}

```

> Can this easily be avoided?

I was able to avoid this by changing the API-side update logic so that
method6 is only set to `NetworkConfigMethod::Manual` if interface.method6 is
not already set. I still want to do a bit more testing to make sure i am
not missing anything. 




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH proxmox] fix #7329: proxmox-network-api: add missing `Auto` network config method
  2026-03-13 17:36   ` Shan Shaji
@ 2026-03-16 15:23     ` Shan Shaji
  0 siblings, 0 replies; 4+ messages in thread
From: Shan Shaji @ 2026-03-16 15:23 UTC (permalink / raw)
  To: Shan Shaji, Christian Ebner, pbs-devel

superseded by v2: https://lore.proxmox.com/pbs-devel/20260316152101.207406-1-s.shaji@proxmox.com/T/#t




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-16 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-11 10:11 [PATCH proxmox] fix #7329: proxmox-network-api: add missing `Auto` network config method Shan Shaji
2026-03-12 14:57 ` Christian Ebner
2026-03-13 17:36   ` Shan Shaji
2026-03-16 15:23     ` Shan Shaji

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal