From: Hannes Laimer <h.laimer@proxmox.com>
To: Daniel Herzig <d.herzig@proxmox.com>
Cc: pve-devel@lists.proxmox.com
Subject: Re: [pve-network v2 1/4] vnets: introduce get_subnets_with_config
Date: Tue, 1 Sep 2026 09:14:36 +0200 [thread overview]
Message-ID: <apZ61aLSJUDuRW4y@nana.intra.proxmox.com> (raw)
In-Reply-To: <87ecfe1hd3.fsf@proxmox.com>
On 2026-08-31 16:42, Daniel Herzig wrote:
>
>
> Hannes Laimer <h.laimer@proxmox.com> writes:
>
> > On 2026-08-31 13:01, Daniel Herzig wrote:
> >> Add 'get_subnets_with_config' to return the subnets of a vnet with
> >> certain subnet configuration and integrate into the current
> >> 'get_subnets'.
> >>
> >> This allows to keep the original behaviour of 'get_subnets' --
> >> retrieving subnet configurations (retreiving it either from the
> >> running sdn-config, or from the 'subnets.cfg' config file) when it's
> >> not available to the caller -- without doubling doubling up the code
> >> to to loop through the subnet ids to handle the other case (subnet
> >> configuration already present at the callsite).
> >>
> >> Suggested-by: Gabriel Goller <g.goller@proxmox.com>
> >> Suggested-by: Hannes Laimer <h.laimer@proxmox.com>
> >> Signed-off-by: Daniel Herzig <d.herzig@proxmox.com>
> >> ---
> >> src/PVE/Network/SDN/Vnets.pm | 8 +++++++-
> >> 1 file changed, 7 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/src/PVE/Network/SDN/Vnets.pm b/src/PVE/Network/SDN/Vnets.pm
> >> index c327a4b..aa2e842 100644
> >> --- a/src/PVE/Network/SDN/Vnets.pm
> >> +++ b/src/PVE/Network/SDN/Vnets.pm
> >> @@ -70,9 +70,15 @@ sub get_vnet {
> >> sub get_subnets {
> >> my ($vnetid, $running) = @_;
> >>
> >> - my $subnets = undef;
> >> my $subnets_cfg = PVE::Network::SDN::Subnets::config($running);
> >> + return get_subnets_with_config($vnetid, $subnets_cfg);
> >> +
> >> +}
> >>
> >> +sub get_subnets_with_config {
> >> + my ($vnetid, $subnets_cfg) = @_;
> >> +
> >
> > we should probably `die` here if the passed cfg is undef, for the
> > deletion `ids` will be empty, and an empty conf will be generated,
> > that's fine. but we dont want undef here..
>
> I guess we could possibly also fall back to re-reading
> `/etc/pve/sdn/subnets.cfg` in case anything got lost in transmission, or
> in a disaster-situation, where the file got lost alltogether, fall back
> to get the values from `.running-config` and issue a warning instead of
> `die`-ing here. I need to wrap my head around it, but I'm not sure if
> this is a good place to `die`.
>
not really, at least i don't think we should. the premis of this sub is,
'give me a config, and ill get you its subnets', the assertion here is
'you give me a config'. this should not go and fetch its own..
> > on that note, the guard in
> > Dhcp.pm should maybe be updated
> >
>
> I've sent a separate answer regarding the patch in Dhcp.pm -- in a
> nutshell, we could possibly just skip that one (also, because it's not
> really related to the dry-run topic).
>
>
> >> + my $subnets = undef;
> >> foreach my $subnetid (sort keys %{ $subnets_cfg->{ids} }) {
> >> my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($subnets_cfg, $subnetid);
> >> next if !$subnet->{vnet} || ($vnetid && $subnet->{vnet} ne $vnetid);
> >> --
> >> 2.47.3
> >>
> >>
next prev parent reply other threads:[~2026-09-01 7:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 11:01 [pve-network v2 0/4] make sure to use subnet config if available at point Daniel Herzig
2026-08-31 11:01 ` [pve-network v2 1/4] vnets: introduce get_subnets_with_config Daniel Herzig
2026-08-31 12:55 ` Hannes Laimer
2026-08-31 14:42 ` Daniel Herzig
2026-09-01 7:14 ` Hannes Laimer [this message]
2026-08-31 11:01 ` [pve-network v2 2/4] fix #7837: simpleplugin: make use of get_subnets_with_config Daniel Herzig
2026-08-31 11:01 ` [pve-network v2 3/4] evpnplugin: " Daniel Herzig
2026-08-31 11:01 ` [pve-network v2 4/4] dhcp: " Daniel Herzig
2026-08-31 12:33 ` Hannes Laimer
2026-08-31 13:54 ` Daniel Herzig
2026-09-01 7:17 ` Hannes Laimer
2026-09-01 8:03 ` [pve-network v2 0/4] make sure to use subnet config if available at point Gabriel Goller
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=apZ61aLSJUDuRW4y@nana.intra.proxmox.com \
--to=h.laimer@proxmox.com \
--cc=d.herzig@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