On Wed, Jun 25, 2025 at 10:26:20AM +0200, Wolfgang Bumiller wrote:
> On Wed, Jun 11, 2025 at 04:48:58PM +0200, Filip Schauer wrote:
> > When a container uses the default `/sbin/init` entrypoint, network
> 
> I'm not a fan of this logic, also because it does not support 'dhcp' (in
> which case it should IMO fail instead).

(Missed that there will be a dhcp patch - that one could revert the
error message then - I'd still prefer to have an error initially here.
Anyway, the point about having a property to control this behavior still
stands.)

> But maybe we can figure out an IP if SDN is in use to support the dhcp
> case if there are static/permanent leases? (@Stefan?)
> 
> I think this should be handled with a separate key in the containers
> network configuration. Maybe a "setup" property which defaults to
> "container" and can be set to "host" (not sure if we ever need more,
> if we know we don't, it could be a boolean...)
> 
> > interface configuration is usually managed by processes within the
> > container. However, containers with a different entrypoint might not
> > have any internal network management process. Consequently, IP addresses
> > might not be assigned.
> > 
> > This change ensures that a static IP address is explicitly set in the
> > LXC config for the container.
> > 
> > Signed-off-by: Filip Schauer <f.scha...@proxmox.com>
> > ---
> >  src/PVE/LXC.pm | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> > 
> > diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
> > index b2be27e..0131ac3 100644
> > --- a/src/PVE/LXC.pm
> > +++ b/src/PVE/LXC.pm
> > @@ -818,6 +818,18 @@ sub update_lxc_config {
> >     if ($lxc_major >= 4) {
> >         $raw .= "lxc.net.$ind.script.up = /usr/share/lxc/lxcnetaddbr\n";
> >     }
> > +
> > +   if (!defined($d->{link_down}) || $d->{link_down} != 1
> > +       && PVE::LXC::Config->get_entrypoint($conf) ne "/sbin/init"
> > +   ) {
> > +       $raw .= "lxc.net.$ind.ipv4.address = $d->{ip}\n"
> > +           if defined($d->{ip}) && $d->{ip} !~ /^(dhcp|manual)$/;
> > +       $raw .= "lxc.net.$ind.ipv4.gateway = $d->{gw}\n" if 
> > defined($d->{gw});
> > +       $raw .= "lxc.net.$ind.ipv6.address = $d->{ip6}\n"
> > +           if defined($d->{ip6}) && $d->{ip6} !~ /^(auto|dhcp|manual)$/;
> > +       $raw .= "lxc.net.$ind.ipv6.gateway = $d->{gw6}\n" if 
> > defined($d->{gw6});
> > +       $raw .= "lxc.net.$ind.flags = up\n";
> > +   }
> >      }
> >  
> >      my $had_cpuset = 0;
> > -- 
> > 2.39.5


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to