mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-07-25 07:41:19 +00:00
Introduce per netdev priv structure
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>
This commit is contained in:
parent
26c390288b
commit
f6cc1de1a9
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user