Re: [PATCHv3 09/16] LXC: use the new net devices gateway definition

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

 



On Fri, Oct 10, 2014 at 02:04:01PM +0200, Cédric Bosdonnat wrote:
> When a gateway is set on a network device, a new default route via this
> gateway through the devoce will be added in the container.
> ---
>  src/lxc/lxc_container.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 608d39f..bbab4af 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -480,6 +480,35 @@ lxcContainerGetNetDef(virDomainDefPtr vmDef, const char *devName)
>      return NULL;
>  }
>  
> +static int
> +lxcContainerAddDefaultRoute(const char *ifname,
> +                            const char *gateway,
> +                            int family)
> +{
> +    virSocketAddr address;
> +    virSocketAddr network;
> +
> +    VIR_DEBUG("Adding default route via %s on dev %s", gateway, ifname);
> +    if (virSocketAddrParse(&address, gateway, family) < 0)
> +        return -1;
> +
> +    if (family == AF_INET) {
> +        if (virSocketAddrParseIPv4(&network, "0.0.0.0") < 0)
> +            return -1;
> +    } else {
> +        if (virSocketAddrParseIPv6(&network, "::") < 0)
> +            return -1;
> +    }

I wouldn't mind us defining constants for the two strings

  VIR_SOCKET_ADDR_IPV4_ALL "0.0.0.0"
  VIR_SOCKET_ADDR_IPV6_ALL "::"


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
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]