]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Introduce per netdev priv structure
authorJamal Hadi Salim <hadi@cyberus.ca>
Tue, 15 Dec 2009 09:14:27 +0000 (10:14 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 15 Dec 2009 09:14:27 +0000 (10:14 +0100)
Some devices like veth or vlans have a bit of extra details that
are specific to them. Example veth.pair and vlan.vlanid.
Separate them from the common so we can update cleanly in the future.

Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Acked-by: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/confile.c

index 3550f386639ee7f31febbf7a2dd2b67ea4303d37..dce57b5770cd978bed91cc0c31ff8284017d5856 100644 (file)
@@ -834,8 +834,8 @@ static int instanciate_veth(struct lxc_netdev *netdev)
        char veth1buf[IFNAMSIZ], *veth1;
        char veth2[IFNAMSIZ];
 
-       if (netdev->pair)
-               veth1 = netdev->pair;
+       if (netdev->priv.pair)
+               veth1 = netdev->priv.pair;
        else {
                snprintf(veth1buf, sizeof(veth1buf), "vethXXXXXX");
                mktemp(veth1buf);
@@ -939,9 +939,9 @@ static int instanciate_vlan(struct lxc_netdev *netdev)
                return -1;
        }
 
-       snprintf(peer, sizeof(peer), "vlan%d",netdev->vlan_attr.vid);
+       snprintf(peer, sizeof(peer), "vlan%d",netdev->priv.vlan_attr.vid);
 
-       if (lxc_vlan_create(netdev->link, peer, netdev->vlan_attr.vid)) {
+       if (lxc_vlan_create(netdev->link, peer, netdev->priv.vlan_attr.vid)) {
                ERROR("failed to create vlan interface '%s' on '%s'",
                      peer, netdev->link);
                return -1;
index 3f9aac0b48b65a4a7e3de475a28becc48bad5cd5..8e01d921fabaf1ad183a02b9e6dba529900e806c 100644 (file)
@@ -78,11 +78,15 @@ struct ifla_vlan {
        ushort   pad;
 };
 
+union netdev_p {
+       char *pair;
+       struct ifla_vlan vlan_attr;
+};
+
 /*
  * Defines a structure to configure a network device
  * @link   : lxc.network.link, name of bridge or host iface to attach if any
  * @name   : lxc.network.name, name of iface on the container side
- * @pair   : lxc.network.pair, name of host-side iface in case of veth etc
  * @flags  : flag of the network device (IFF_UP, ... )
  * @ipv4   : a list of ipv4 addresses to be set on the network device
  * @ipv6   : a list of ipv6 addresses to be set on the network device
@@ -93,10 +97,9 @@ struct lxc_netdev {
        int ifindex;
        char *link;
        char *name;
-       char *pair;
        char *hwaddr;
        char *mtu;
-       struct ifla_vlan vlan_attr;
+       union netdev_p priv;
        struct lxc_list ipv4;
        struct lxc_list ipv6;
 };
index 386af368bb51e6340810d2fc7da156094ced59fe..3593b9a88b2d7ed0d18048991b490e9ef8177006 100644 (file)
@@ -76,10 +76,10 @@ static struct config config[] = {
        { "lxc.network.flags",  config_network_flags  },
        { "lxc.network.link",   config_network_link   },
        { "lxc.network.name",   config_network_name   },
-       { "lxc.network.pair",   config_network_pair   },
+       { "lxc.network.veth.pair",   config_network_pair   },
        { "lxc.network.hwaddr", config_network_hwaddr },
        { "lxc.network.mtu",    config_network_mtu    },
-       { "lxc.network.vlanid", config_network_vlanid },
+       { "lxc.network.vlan.id", config_network_vlanid },
        { "lxc.network.ipv4",   config_network_ipv4   },
        { "lxc.network.ipv6",   config_network_ipv6   },
 };
@@ -237,7 +237,7 @@ static int config_network_pair(const char *key, char *value,
        if (!netdev)
                return -1;
 
-       return network_ifname(&netdev->pair, value);
+       return network_ifname(&netdev->priv.pair, value);
 }
 
 static int config_network_hwaddr(const char *key, char *value,
@@ -267,7 +267,7 @@ static int config_network_vlanid(const char *key, char *value,
        if (!netdev)
                return -1;
 
-       if (get_u16(&netdev->vlan_attr.vid, value, 0))
+       if (get_u16(&netdev->priv.vlan_attr.vid, value, 0))
                return -1;
 
        return 0;