public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: Shan Shaji <s.shaji@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH proxmox] fix #7329: proxmox-network-api: add missing `Auto` network config method
Date: Thu, 12 Mar 2026 15:57:48 +0100	[thread overview]
Message-ID: <829e80ef-1274-4ac7-9ebf-1c8fa0b55108@proxmox.com> (raw)
In-Reply-To: <20260311101109.116215-1-s.shaji@proxmox.com>

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





  reply	other threads:[~2026-03-12 14:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-11 10:11 Shan Shaji
2026-03-12 14:57 ` Christian Ebner [this message]
2026-03-13 17:36   ` Shan Shaji
2026-03-16 15:23     ` Shan Shaji

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=829e80ef-1274-4ac7-9ebf-1c8fa0b55108@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=s.shaji@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