Re: [PATCHv3 10/16] LXC: honour network devices link state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 22 October 2014 11:15:57 Daniel P. Berrange wrote:
> On Fri, Oct 10, 2014 at 02:04:02PM +0200, Cédric Bosdonnat wrote:
> > Don't activate LXC network device if <link state='down'/> has been set
> > in its configuration.
> > ---
> > 
> >  src/lxc/lxc_container.c | 28 +++++++++++++++-------------
> >  1 file changed, 15 insertions(+), 13 deletions(-)
> > 
> > diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> > index bbab4af..4378b3d 100644
> > --- a/src/lxc/lxc_container.c
> > +++ b/src/lxc/lxc_container.c
> > @@ -568,21 +568,23 @@ static int
> > lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef,> 
> >              }
> >          
> >          }
> > 
> > -        VIR_DEBUG("Enabling %s", newname);
> > -        rc = virNetDevSetOnline(newname, true);
> > -        if (rc < 0)
> > -            goto error_out;
> > +        if (netDef->linkstate !=
> > VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) { +           
> > VIR_DEBUG("Enabling %s", newname);
> > +            rc = virNetDevSetOnline(newname, true);
> > +            if (rc < 0)
> > +                goto error_out;
> > 
> > -        /* Set the gateways */
> > -        if (netDef->gateway_ipv4 &&
> > -            lxcContainerAddDefaultRoute(newname, netDef->gateway_ipv4,
> > -                                        AF_INET) < 0)
> > -            goto error_out;
> > +            /* Set the gateways */
> > +            if (netDef->gateway_ipv4 &&
> > +                lxcContainerAddDefaultRoute(newname,
> > netDef->gateway_ipv4,
> > +                                            AF_INET) < 0)
> > +                goto error_out;
> > 
> > -        if (netDef->gateway_ipv6 &&
> > -            lxcContainerAddDefaultRoute(newname, netDef->gateway_ipv6,
> > -                                        AF_INET6) < 0)
> > -            goto error_out;
> > +            if (netDef->gateway_ipv6 &&
> > +                lxcContainerAddDefaultRoute(newname,
> > netDef->gateway_ipv6,
> > +                                            AF_INET6) < 0)
> > +                goto error_out;
> > +        }
> > 
> >          VIR_FREE(newname);
> >      
> >      }
> 
> ACK makes sense, we can't configure addresses if the device is
> down.
> 

We can, but it doesn't have much sense:

[root@kir1 libvirt]# ip l set eth0 down
[root@kir1 libvirt]# ip a s eth0
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:19:d1:a3:bf:95 brd ff:ff:ff:ff:ff:ff
[root@kir1 libvirt]# ip a a 192.168.11.1/24 dev eth0
[root@kir1 libvirt]# ip a s eth0
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:19:d1:a3:bf:95 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.1/24 scope global eth0
[root@kir1 libvirt]# ip l set eth0 up
[root@kir1 libvirt]# ip a s eth0
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state 
DOWN qlen 1000
    link/ether 00:19:d1:a3:bf:95 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.1/24 scope global eth0

> Regards,
> Daniel

-- 
Dmitry Guryanov

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]