[lxc-devel] [PATCH 1/3] rename struct lxc_netdev fields to match reality

Michael Tokarev mjt at tls.msk.ru
Tue Nov 17 22:30:30 UTC 2009


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 at tls.msk.ru>
---
 src/lxc/conf.c    |   24 ++++++++++++------------
 src/lxc/conf.h    |    7 ++++---
 src/lxc/confile.c |    4 ++--
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index b4e3a3e..a930f85 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -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;
diff --git a/src/lxc/conf.h b/src/lxc/conf.h
index 215f1e5..0b8d732 100644
--- a/src/lxc/conf.h
+++ b/src/lxc/conf.h
@@ -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;
diff --git a/src/lxc/confile.c b/src/lxc/confile.c
index 43bede4..699eafe 100644
--- a/src/lxc/confile.c
+++ b/src/lxc/confile.c
@@ -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;
 }
 
-- 
1.6.3.3





More information about the lxc-devel mailing list