Commit 9d083402 by Michael Tokarev Committed by Daniel Lezcano

rename struct lxc_netdev fields to match reality

struct lxc_netdev is used to hold information from cnfig file about a network device/configuration. Make the fields of this structure to be named similarily with the config file keywords, namely: s/ifname/link/ - host-side link for the device (bridge or eth0) s/newname/name/ - container-side ifname It is insane to have completely different names in config file and in structure/variable names :) Signed-off-by: 's avatarMichael Tokarev <mjt@tls.msk.ru> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 0f71d073
...@@ -709,11 +709,11 @@ static int setup_netdev(struct lxc_netdev *netdev) ...@@ -709,11 +709,11 @@ static int setup_netdev(struct lxc_netdev *netdev)
} }
/* default: let the system to choose one interface name */ /* default: let the system to choose one interface name */
if (!netdev->newname) if (!netdev->name)
netdev->newname = "eth%d"; netdev->name = "eth%d";
/* rename the interface name */ /* rename the interface name */
if (lxc_device_rename(ifname, netdev->newname)) { if (lxc_device_rename(ifname, netdev->name)) {
ERROR("failed to rename %s->%s", ifname, current_ifname); ERROR("failed to rename %s->%s", ifname, current_ifname);
return -1; return -1;
} }
...@@ -846,7 +846,7 @@ static int instanciate_veth(struct lxc_netdev *netdev) ...@@ -846,7 +846,7 @@ static int instanciate_veth(struct lxc_netdev *netdev)
if (lxc_veth_create(veth1, veth2)) { if (lxc_veth_create(veth1, veth2)) {
ERROR("failed to create %s-%s/%s", ERROR("failed to create %s-%s/%s",
veth1, veth2, netdev->ifname); veth1, veth2, netdev->link);
goto out; goto out;
} }
...@@ -864,9 +864,9 @@ static int instanciate_veth(struct lxc_netdev *netdev) ...@@ -864,9 +864,9 @@ static int instanciate_veth(struct lxc_netdev *netdev)
} }
} }
if (lxc_bridge_attach(netdev->ifname, veth1)) { if (lxc_bridge_attach(netdev->link, veth1)) {
ERROR("failed to attach '%s' to the bridge '%s'", ERROR("failed to attach '%s' to the bridge '%s'",
veth1, netdev->ifname); veth1, netdev->link);
goto out_delete; goto out_delete;
} }
...@@ -908,9 +908,9 @@ static int instanciate_macvlan(struct lxc_netdev *netdev) ...@@ -908,9 +908,9 @@ static int instanciate_macvlan(struct lxc_netdev *netdev)
return -1; return -1;
} }
if (lxc_macvlan_create(netdev->ifname, peer)) { if (lxc_macvlan_create(netdev->link, peer)) {
ERROR("failed to create macvlan interface '%s' on '%s'", ERROR("failed to create macvlan interface '%s' on '%s'",
peer, netdev->ifname); peer, netdev->link);
goto out; goto out;
} }
...@@ -933,9 +933,9 @@ out_delete: ...@@ -933,9 +933,9 @@ out_delete:
static int instanciate_phys(struct lxc_netdev *netdev) static int instanciate_phys(struct lxc_netdev *netdev)
{ {
netdev->ifindex = if_nametoindex(netdev->ifname); netdev->ifindex = if_nametoindex(netdev->link);
if (!netdev->ifindex) { if (!netdev->ifindex) {
ERROR("failed to retrieve the index for %s", netdev->ifname); ERROR("failed to retrieve the index for %s", netdev->link);
return -1; return -1;
} }
...@@ -983,11 +983,11 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid) ...@@ -983,11 +983,11 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
if (lxc_device_move(netdev->ifindex, pid)) { if (lxc_device_move(netdev->ifindex, pid)) {
ERROR("failed to move '%s' to the container", ERROR("failed to move '%s' to the container",
netdev->ifname); netdev->link);
return -1; return -1;
} }
DEBUG("move '%s' to '%d'", netdev->ifname, pid); DEBUG("move '%s' to '%d'", netdev->link, pid);
} }
return 0; return 0;
......
...@@ -71,7 +71,8 @@ struct lxc_route6 { ...@@ -71,7 +71,8 @@ struct lxc_route6 {
}; };
/* /*
* Defines a structure to configure a network device * Defines a structure to configure a network device
* @ifname : network device name * @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
* @flags : flag of the network device (IFF_UP, ... ) * @flags : flag of the network device (IFF_UP, ... )
* @ipv4 : a list of ipv4 addresses to be set on the network device * @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 * @ipv6 : a list of ipv6 addresses to be set on the network device
...@@ -80,8 +81,8 @@ struct lxc_netdev { ...@@ -80,8 +81,8 @@ struct lxc_netdev {
int type; int type;
int flags; int flags;
int ifindex; int ifindex;
char *ifname; char *link;
char *newname; char *name;
char *hwaddr; char *hwaddr;
char *mtu; char *mtu;
struct lxc_list ipv4; struct lxc_list ipv4;
......
...@@ -187,7 +187,7 @@ static int config_network_link(const char *key, char *value, struct lxc_conf *lx ...@@ -187,7 +187,7 @@ static int config_network_link(const char *key, char *value, struct lxc_conf *lx
return -1; return -1;
} }
netdev->ifname = strdup(value); netdev->link = strdup(value);
return 0; return 0;
} }
...@@ -212,7 +212,7 @@ static int config_network_name(const char *key, char *value, struct lxc_conf *lx ...@@ -212,7 +212,7 @@ static int config_network_name(const char *key, char *value, struct lxc_conf *lx
return -1; return -1;
} }
netdev->newname = strdup(value); netdev->name = strdup(value);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment