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: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Michael Tokarev 2009-11-19 15:06:02 +01:00 committed by Daniel Lezcano
parent 0f71d073ee
commit 9d0834025e
3 changed files with 18 additions and 17 deletions

View File

@ -709,11 +709,11 @@ static int setup_netdev(struct lxc_netdev *netdev)
}
/* default: let the system to choose one interface name */
if (!netdev->newname)
netdev->newname = "eth%d";
if (!netdev->name)
netdev->name = "eth%d";
/* 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);
return -1;
}
@ -846,7 +846,7 @@ static int instanciate_veth(struct lxc_netdev *netdev)
if (lxc_veth_create(veth1, veth2)) {
ERROR("failed to create %s-%s/%s",
veth1, veth2, netdev->ifname);
veth1, veth2, netdev->link);
goto out;
}
@ -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'",
veth1, netdev->ifname);
veth1, netdev->link);
goto out_delete;
}
@ -908,9 +908,9 @@ static int instanciate_macvlan(struct lxc_netdev *netdev)
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'",
peer, netdev->ifname);
peer, netdev->link);
goto out;
}
@ -933,9 +933,9 @@ out_delete:
static int instanciate_phys(struct lxc_netdev *netdev)
{
netdev->ifindex = if_nametoindex(netdev->ifname);
netdev->ifindex = if_nametoindex(netdev->link);
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;
}
@ -983,11 +983,11 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
if (lxc_device_move(netdev->ifindex, pid)) {
ERROR("failed to move '%s' to the container",
netdev->ifname);
netdev->link);
return -1;
}
DEBUG("move '%s' to '%d'", netdev->ifname, pid);
DEBUG("move '%s' to '%d'", netdev->link, pid);
}
return 0;

View File

@ -71,7 +71,8 @@ struct lxc_route6 {
};
/*
* 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, ... )
* @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
@ -80,8 +81,8 @@ struct lxc_netdev {
int type;
int flags;
int ifindex;
char *ifname;
char *newname;
char *link;
char *name;
char *hwaddr;
char *mtu;
struct lxc_list ipv4;

View File

@ -187,7 +187,7 @@ static int config_network_link(const char *key, char *value, struct lxc_conf *lx
return -1;
}
netdev->ifname = strdup(value);
netdev->link = strdup(value);
return 0;
}
@ -212,7 +212,7 @@ static int config_network_name(const char *key, char *value, struct lxc_conf *lx
return -1;
}
netdev->newname = strdup(value);
netdev->name = strdup(value);
return 0;
}