Commit 7fa3f2e9 by 0x0916

replace all lxc.network* with lxc.net*

This patch wipe all references to lxc.network{[i]}.* and replace with lxc.net.{[i]}.* in templates, documentation and configuration files. Signed-off-by: 's avatar0x0916 <w@laoqinren.net>
parent 18ede427
...@@ -83,8 +83,8 @@ LXC is configured via a simple set of keys. For example, ...@@ -83,8 +83,8 @@ LXC is configured via a simple set of keys. For example,
- `lxc.mount.entry` - `lxc.mount.entry`
LXC namespaces configuration keys by using single dots. This means complex LXC namespaces configuration keys by using single dots. This means complex
configuration keys such as `lxc.network` expose various subkeys such as configuration keys such as `lxc.net.0` expose various subkeys such as
`lxc.network.type`, `lxc.network.link`, `lxc.network.ipv6`, and others for even `lxc.net.0.type`, `lxc.net.0.link`, `lxc.net.0.ipv6`, and others for even
more fine-grained configuration. more fine-grained configuration.
LXC is used as the default runtime for [LXD](https://github.com/lxc/lxd), LXC is used as the default runtime for [LXD](https://github.com/lxc/lxd),
......
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.link = virbr0 lxc.net.0.link = virbr0
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.type = empty lxc.net.0.type = empty
...@@ -56,7 +56,7 @@ wait_for_bridge() ...@@ -56,7 +56,7 @@ wait_for_bridge()
local BRNAME try flags br local BRNAME try flags br
[ -f "$sysconfdir"/lxc/default.conf ] || { return 0; } [ -f "$sysconfdir"/lxc/default.conf ] || { return 0; }
BRNAME=`grep '^[ ]*lxc.network.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'` BRNAME=`grep '^[ ]*lxc.net.0.link' "$sysconfdir"/lxc/default.conf | sed 's/^.*=[ ]*//'`
if [ -z "$BRNAME" ]; then if [ -z "$BRNAME" ]; then
return 0 return 0
fi fi
......
# Container with network a complex network mixing macvlan, veth and # Container with network a complex network mixing macvlan, veth and
# physical network devices # physical network devices
lxc.utsname = complex lxc.utsname = complex
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.link = br0 lxc.net.0.link = br0
lxc.network.hwaddr = 4a:49:43:49:79:bf lxc.net.0.hwaddr = 4a:49:43:49:79:bf
lxc.network.ipv4 = 10.2.3.5/24 lxc.net.0.ipv4 = 10.2.3.5/24
lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597 lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
lxc.network.type = macvlan lxc.net.0.type = macvlan
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.link = eth0 lxc.net.0.link = eth0
lxc.network.hwaddr = 4a:49:43:49:79:bd lxc.net.0.hwaddr = 4a:49:43:49:79:bd
lxc.network.ipv4 = 10.2.3.4/24 lxc.net.0.ipv4 = 10.2.3.4/24
lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596 lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
lxc.network.type = phys lxc.net.0.type = phys
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.link = dummy0 lxc.net.0.link = dummy0
lxc.network.hwaddr = 4a:49:43:49:79:ff lxc.net.0.hwaddr = 4a:49:43:49:79:ff
lxc.network.ipv4 = 10.2.3.6/24 lxc.net.0.ipv4 = 10.2.3.6/24
lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297 lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297
# Container with new network withtout network devices # Container with new network withtout network devices
lxc.utsname = omega lxc.utsname = omega
lxc.network.type = empty lxc.net.0.type = empty
lxc.network.flags = up lxc.net.0.flags = up
# Container with network virtualized using the macvlan device driver # Container with network virtualized using the macvlan device driver
lxc.utsname = alpha lxc.utsname = alpha
lxc.network.type = macvlan lxc.net.0.type = macvlan
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.link = eth0 lxc.net.0.link = eth0
lxc.network.hwaddr = 4a:49:43:49:79:bd lxc.net.0.hwaddr = 4a:49:43:49:79:bd
lxc.network.ipv4 = 10.2.3.4/24 lxc.net.0.ipv4 = 10.2.3.4/24
lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596 lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
# Container with non-virtualized network # Container with non-virtualized network
lxc.network.type = none lxc.net.0.type = none
lxc.utsname = delta lxc.utsname = delta
# Container with network virtualized using a physical network device with name # Container with network virtualized using a physical network device with name
# 'eth0' # 'eth0'
lxc.utsname = gamma lxc.utsname = gamma
lxc.network.type = phys lxc.net.0.type = phys
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.link = eth0 lxc.net.0.link = eth0
lxc.network.hwaddr = 4a:49:43:49:79:ff lxc.net.0.hwaddr = 4a:49:43:49:79:ff
lxc.network.ipv4 = 10.2.3.6/24 lxc.net.0.ipv4 = 10.2.3.6/24
lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297 lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297
# Container with network virtualized using a pre-configured bridge named br0 and # Container with network virtualized using a pre-configured bridge named br0 and
# veth pair virtual network devices # veth pair virtual network devices
lxc.utsname = beta lxc.utsname = beta
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.link = br0 lxc.net.0.link = br0
lxc.network.hwaddr = 4a:49:43:49:79:bf lxc.net.0.hwaddr = 4a:49:43:49:79:bf
lxc.network.ipv4 = 10.2.3.5/24 lxc.net.0.ipv4 = 10.2.3.5/24
lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597 lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
# Container with network virtualized using the vlan device driver # Container with network virtualized using the vlan device driver
lxc.utsname = alpha lxc.utsname = alpha
lxc.network.type = vlan lxc.net.0.type = vlan
lxc.network.vlan.id = 1234 lxc.net.0.vlan.id = 1234
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.link = eth0 lxc.net.0.link = eth0
lxc.network.hwaddr = 4a:49:43:49:79:bd lxc.net.0.hwaddr = 4a:49:43:49:79:bd
lxc.network.ipv4 = 10.2.3.4/24 lxc.net.0.ipv4 = 10.2.3.4/24
lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596 lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
...@@ -220,7 +220,7 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp> ...@@ -220,7 +220,7 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>lxc-info -n foo -c lxc.network.0.veth.pair</term> <term>lxc-info -n foo -c lxc.net.0.veth.pair</term>
<listitem> <listitem>
<para> <para>
<!-- <!--
......
...@@ -220,7 +220,7 @@ by Sungbae Yoo <sungbae.yoo at samsung.com> ...@@ -220,7 +220,7 @@ by Sungbae Yoo <sungbae.yoo at samsung.com>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>lxc-info -n foo -c lxc.network.0.veth.pair</term> <term>lxc-info -n foo -c lxc.net.0.veth.pair</term>
<listitem> <listitem>
<para> <para>
<!-- <!--
......
...@@ -175,7 +175,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ...@@ -175,7 +175,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term>lxc-info -n foo -c lxc.network.0.veth.pair</term> <term>lxc-info -n foo -c lxc.net.0.veth.pair</term>
<listitem> <listitem>
<para> <para>
prints the veth pair name of foo. prints the veth pair name of foo.
......
...@@ -12,25 +12,25 @@ lxc.utsname = virtnode ...@@ -12,25 +12,25 @@ lxc.utsname = virtnode
# should be an existing interface, usually it is eth0 # should be an existing interface, usually it is eth0
# * phys : the network will use a physical network device, the specified # * phys : the network will use a physical network device, the specified
# link should be an existing interface # link should be an existing interface
lxc.network.type = macvlan lxc.net.0.type = macvlan
# specify the flags to be used for the network, actually only <up> is allowed # specify the flags to be used for the network, actually only <up> is allowed
# which mean the network should be set up when created. If the network is set # which mean the network should be set up when created. If the network is set
# up, the loopback is automatically set up too. # up, the loopback is automatically set up too.
lxc.network.flags = up lxc.net.0.flags = up
# specify the physical network device which will communicate with the # specify the physical network device which will communicate with the
# outside world # outside world
lxc.network.link = eth0 lxc.net.0.link = eth0
# NIC ethernet mac address # NIC ethernet mac address
lxc.network.hwaddr = 4a:49:43:49:79:bd lxc.net.0.hwaddr = 4a:49:43:49:79:bd
# specify the ipv4 address of the container. Several lines are allowed and # specify the ipv4 address of the container. Several lines are allowed and
# will mean several addresses will be assigned to the interface # will mean several addresses will be assigned to the interface
lxc.network.ipv4 = 1.2.3.5/24 lxc.net.0.ipv4 = 1.2.3.5/24
# specify the ipv6 address of the container. Several lines are allowed and # specify the ipv6 address of the container. Several lines are allowed and
# will mean several addresses will be assigned to the interface # will mean several addresses will be assigned to the interface
lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596 lxc.net.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
...@@ -225,7 +225,7 @@ end ...@@ -225,7 +225,7 @@ end
function test_container_cmd() function test_container_cmd()
log(0, "Test get config from running container...") log(0, "Test get config from running container...")
veth_pair = lxc.cmd_get_config_item(optarg["n"], "lxc.network.0.veth.pair") veth_pair = lxc.cmd_get_config_item(optarg["n"], "lxc.net.0.veth.pair")
log(0, " veth.pair:%s", veth_pair) log(0, " veth.pair:%s", veth_pair)
end end
...@@ -281,7 +281,7 @@ function test_config_network(net_nr) ...@@ -281,7 +281,7 @@ function test_config_network(net_nr)
log(0, "Test network %d config...", net_nr) log(0, "Test network %d config...", net_nr)
local netcfg local netcfg
netcfg = container:get_keys("lxc.network." .. net_nr) netcfg = container:get_keys("lxc.net." .. net_nr)
if (netcfg == nil) then if (netcfg == nil) then
return return
end end
...@@ -289,7 +289,7 @@ function test_config_network(net_nr) ...@@ -289,7 +289,7 @@ function test_config_network(net_nr)
log(0, " %s = %s", k, v or "") log(0, " %s = %s", k, v or "")
end end
assert(netcfg["flags"] == "up") assert(netcfg["flags"] == "up")
assert(container:get_config_item("lxc.network."..net_nr..".type") == "veth") assert(container:get_config_item("lxc.net."..net_nr..".type") == "veth")
end end
......
...@@ -523,7 +523,7 @@ static int lxc_cmd_get_cgroup_callback(int fd, struct lxc_cmd_req *req, ...@@ -523,7 +523,7 @@ static int lxc_cmd_get_cgroup_callback(int fd, struct lxc_cmd_req *req,
* lxc_cmd_get_config_item: Get config item the running container * lxc_cmd_get_config_item: Get config item the running container
* *
* @name : name of container to connect to * @name : name of container to connect to
* @item : the configuration item to retrieve (ex: lxc.network.0.veth.pair) * @item : the configuration item to retrieve (ex: lxc.net.0.veth.pair)
* @lxcpath : the lxcpath in which the container is running * @lxcpath : the lxcpath in which the container is running
* *
* Returns the item on success, NULL on failure. The caller must free() the * Returns the item on success, NULL on failure. The caller must free() the
......
...@@ -114,8 +114,8 @@ union netdev_p { ...@@ -114,8 +114,8 @@ union netdev_p {
/* /*
* Defines a structure to configure a network device * Defines a structure to configure a network device
* @link : lxc.network.link, name of bridge or host iface to attach if any * @link : lxc.net.[i].link, name of bridge or host iface to attach if any
* @name : lxc.network.name, name of iface on the container side * @name : lxc.net.[i].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
......
...@@ -533,7 +533,7 @@ int rand_complete_hwaddr(char *hwaddr) ...@@ -533,7 +533,7 @@ int rand_complete_hwaddr(char *hwaddr)
} }
/* /*
* If we find a lxc.network.hwaddr in the original config file, we expand it in * If we find a lxc.net.hwaddr in the original config file, we expand it in
* the unexpanded_config, so that after a save_config we store the hwaddr for * the unexpanded_config, so that after a save_config we store the hwaddr for
* re-use. * re-use.
* This is only called when reading the config file, not when executing a * This is only called when reading the config file, not when executing a
......
...@@ -2069,7 +2069,7 @@ static int do_lxcapi_get_keys(struct lxc_container *c, const char *key, char *re ...@@ -2069,7 +2069,7 @@ static int do_lxcapi_get_keys(struct lxc_container *c, const char *key, char *re
if (!key) if (!key)
return lxc_listconfigs(retv, inlen); return lxc_listconfigs(retv, inlen);
/* /*
* Support 'lxc.network.<idx>', i.e. 'lxc.network.0' * Support 'lxc.net.<idx>', i.e. 'lxc.net.0'
* This is an intelligent result to show which keys are valid given * This is an intelligent result to show which keys are valid given
* the type of nic it is * the type of nic it is
*/ */
......
...@@ -155,15 +155,15 @@ static void print_net_stats(struct lxc_container *c) ...@@ -155,15 +155,15 @@ static void print_net_stats(struct lxc_container *c)
char buf[256]; char buf[256];
for(netnr = 0; ;netnr++) { for(netnr = 0; ;netnr++) {
sprintf(buf, "lxc.network.%d.type", netnr); sprintf(buf, "lxc.net.%d.type", netnr);
type = c->get_running_config_item(c, buf); type = c->get_running_config_item(c, buf);
if (!type) if (!type)
break; break;
if (!strcmp(type, "veth")) { if (!strcmp(type, "veth")) {
sprintf(buf, "lxc.network.%d.veth.pair", netnr); sprintf(buf, "lxc.net.%d.veth.pair", netnr);
} else { } else {
sprintf(buf, "lxc.network.%d.link", netnr); sprintf(buf, "lxc.net.%d.link", netnr);
} }
free(type); free(type);
ifname = c->get_running_config_item(c, buf); ifname = c->get_running_config_item(c, buf);
......
...@@ -90,7 +90,7 @@ assert(capdrop == container.get_config_item("lxc.cap.drop")) ...@@ -90,7 +90,7 @@ assert(capdrop == container.get_config_item("lxc.cap.drop"))
print("Testing the networking") print("Testing the networking")
# A few basic checks of the current state # A few basic checks of the current state
assert("name" in container.get_keys("lxc.network.0")) assert("name" in container.get_keys("lxc.net.0"))
assert(len(container.network) == 1) assert(len(container.network) == 1)
## Starting the container ## Starting the container
......
...@@ -40,7 +40,7 @@ class ContainerNetwork(object): ...@@ -40,7 +40,7 @@ class ContainerNetwork(object):
self.container = container self.container = container
self.index = index self.index = index
for key in self.container.get_keys("lxc.network.%s" % self.index): for key in self.container.get_keys("lxc.net.%s" % self.index):
if "." in key: if "." in key:
self.props[key.replace(".", "_")] = key self.props[key.replace(".", "_")] = key
else: else:
...@@ -98,18 +98,18 @@ class ContainerNetwork(object): ...@@ -98,18 +98,18 @@ class ContainerNetwork(object):
def __clear_network_item(self, key): def __clear_network_item(self, key):
if key in ("ipv4", "ipv6"): if key in ("ipv4", "ipv6"):
return self.container.clear_config_item("lxc.network.%s.%s" % ( return self.container.clear_config_item("lxc.net.%s.%s" % (
self.index, key)) self.index, key))
else: else:
return self.container.set_config_item("lxc.network.%s.%s" % ( return self.container.set_config_item("lxc.net.%s.%s" % (
self.index, key), "") self.index, key), "")
def __get_network_item(self, key): def __get_network_item(self, key):
return self.container.get_config_item("lxc.network.%s.%s" % ( return self.container.get_config_item("lxc.net.%s.%s" % (
self.index, key)) self.index, key))
def __set_network_item(self, key, value): def __set_network_item(self, key, value):
return self.container.set_config_item("lxc.network.%s.%s" % ( return self.container.set_config_item("lxc.net.%s.%s" % (
self.index, key), value) self.index, key), value)
...@@ -124,7 +124,7 @@ class ContainerNetworkList(): ...@@ -124,7 +124,7 @@ class ContainerNetworkList():
return ContainerNetwork(self.container, index) return ContainerNetwork(self.container, index)
def __len__(self): def __len__(self):
values = self.container.get_config_item("lxc.network") values = self.container.get_config_item("lxc.net")
if values: if values:
return len(values) return len(values)
...@@ -134,7 +134,7 @@ class ContainerNetworkList(): ...@@ -134,7 +134,7 @@ class ContainerNetworkList():
def add(self, network_type): def add(self, network_type):
index = len(self) index = len(self)
return self.container.set_config_item("lxc.network.%s.type" % index, return self.container.set_config_item("lxc.net.%s.type" % index,
network_type) network_type)
def remove(self, index): def remove(self, index):
...@@ -142,7 +142,7 @@ class ContainerNetworkList(): ...@@ -142,7 +142,7 @@ class ContainerNetworkList():
if index >= count: if index >= count:
raise IndexError("list index out of range") raise IndexError("list index out of range")
return self.container.clear_config_item("lxc.network.%s" % index) return self.container.clear_config_item("lxc.net.%s" % index)
class Container(_lxc.Container): class Container(_lxc.Container):
......
...@@ -161,7 +161,7 @@ int main(int argc, char *argv[]) ...@@ -161,7 +161,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "%d: %s thought it was defined\n", __LINE__, MYNAME); fprintf(stderr, "%d: %s thought it was defined\n", __LINE__, MYNAME);
goto err; goto err;
} }
if (!c->set_config_item(c, "lxc.network.type", "empty")) { if (!c->set_config_item(c, "lxc.net.0.type", "empty")) {
fprintf(stderr, "%s: %d: failed to set network type\n", __FILE__, __LINE__); fprintf(stderr, "%s: %d: failed to set network type\n", __FILE__, __LINE__);
goto err; goto err;
} }
......
...@@ -143,7 +143,7 @@ static int test_container(const char *lxcpath, ...@@ -143,7 +143,7 @@ static int test_container(const char *lxcpath,
c->destroy(c); c->destroy(c);
c = lxc_container_new(name, lxcpath); c = lxc_container_new(name, lxcpath);
} }
c->set_config_item(c, "lxc.network.type", "empty"); c->set_config_item(c, "lxc.net.0.type", "empty");
if (!c->createl(c, template, NULL, NULL, 0, NULL)) { if (!c->createl(c, template, NULL, NULL, 0, NULL)) {
TSTERR("creating container %s", name); TSTERR("creating container %s", name);
goto out2; goto out2;
......
...@@ -44,12 +44,12 @@ int main(int argc, char *argv[]) ...@@ -44,12 +44,12 @@ int main(int argc, char *argv[])
goto out; goto out;
} }
if (!c->set_config_item(c, "lxc.network.type", "veth")) { if (!c->set_config_item(c, "lxc.net.0.type", "veth")) {
fprintf(stderr, "%d: failed to set network type\n", __LINE__); fprintf(stderr, "%d: failed to set network type\n", __LINE__);
goto out; goto out;
} }
c->set_config_item(c, "lxc.network.link", "lxcbr0"); c->set_config_item(c, "lxc.net.0.link", "lxcbr0");
c->set_config_item(c, "lxc.network.flags", "up"); c->set_config_item(c, "lxc.net.0.flags", "up");
if (!c->createl(c, "busybox", NULL, NULL, 0, NULL)) { if (!c->createl(c, "busybox", NULL, NULL, 0, NULL)) {
fprintf(stderr, "%d: failed to create a trusty container\n", __LINE__); fprintf(stderr, "%d: failed to create a trusty container\n", __LINE__);
goto out; goto out;
......
...@@ -293,7 +293,7 @@ int main(int argc, char *argv[]) ...@@ -293,7 +293,7 @@ int main(int argc, char *argv[])
printf("%d: get_config_item(lxc.cap.drop) returned %d %s\n", __LINE__, ret, v2); printf("%d: get_config_item(lxc.cap.drop) returned %d %s\n", __LINE__, ret, v2);
ret = c->get_config_item(c, "lxc.network", v2, 255); ret = c->get_config_item(c, "lxc.network", v2, 255);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "%d: get_config_item returned %d\n", __LINE__, ret); fprintf(stderr, "%d: get_config_item(lxc.network) returned %d\n", __LINE__, ret);
goto out; goto out;
} }
printf("%d: get_config_item(lxc.network) returned %d %s\n", __LINE__, ret, v2); printf("%d: get_config_item(lxc.network) returned %d %s\n", __LINE__, ret, v2);
......
...@@ -100,8 +100,8 @@ usermod -v 910000-919999 -w 910000-919999 $TUSER ...@@ -100,8 +100,8 @@ usermod -v 910000-919999 -w 910000-919999 $TUSER
mkdir -p $HDIR/.config/lxc/ mkdir -p $HDIR/.config/lxc/
cat > $HDIR/.config/lxc/default.conf << EOF cat > $HDIR/.config/lxc/default.conf << EOF
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.link = lxcbr0 lxc.net.0.link = lxcbr0
lxc.id_map = u 0 910000 9999 lxc.id_map = u 0 910000 9999
lxc.id_map = g 0 910000 9999 lxc.id_map = g 0 910000 9999
EOF EOF
......
...@@ -48,12 +48,12 @@ cleanup() { ...@@ -48,12 +48,12 @@ cleanup() {
} }
verify_numnics() { verify_numnics() {
verify_unchanged_number lxc.network.type "network defs" verify_unchanged_number lxc.net.0.type "network defs"
} }
verify_hwaddr() { verify_hwaddr() {
verify_unchanged_number lxc.network.hwaddr "hwaddr defs" verify_unchanged_number lxc.net.0.hwaddr "hwaddr defs"
grep ^lxc.network.hwaddr $CONTAINER_PATH/config | while read line; do grep ^lxc.net.0.hwaddr $CONTAINER_PATH/config | while read line; do
addr=`echo $line | awk -F= { print $2 }` addr=`echo $line | awk -F= { print $2 }`
echo "looking for $addr in $CONTAINER2_PATH/config" echo "looking for $addr in $CONTAINER2_PATH/config"
if grep -q $addr $CONTAINER2_PATH/config; then if grep -q $addr $CONTAINER2_PATH/config; then
...@@ -80,20 +80,20 @@ trap cleanup EXIT ...@@ -80,20 +80,20 @@ trap cleanup EXIT
# Simple nic # Simple nic
cat > $s/1.conf << EOF cat > $s/1.conf << EOF
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.link = lxcbr0 lxc.net.0.link = lxcbr0
EOF EOF
# Simple nic with hwaddr; verify hwaddr changed # Simple nic with hwaddr; verify hwaddr changed
cat > $s/2.conf << EOF cat > $s/2.conf << EOF
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.link = lxcbr0 lxc.net.0.link = lxcbr0
EOF EOF
# No nics, but nic from include # No nics, but nic from include
cat > $s/1.include << EOF cat > $s/1.include << EOF
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.link = lxcbr0 lxc.net.0.link = lxcbr0
lxc.hook.start = /bin/bash lxc.hook.start = /bin/bash
EOF EOF
cat > $s/3.conf << EOF cat > $s/3.conf << EOF
......
...@@ -34,8 +34,8 @@ cleanup() { ...@@ -34,8 +34,8 @@ cleanup() {
trap cleanup EXIT trap cleanup EXIT
cat > $f << EOF cat > $f << EOF
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.hwaddr = 00:16:3e:xx:xx:xx lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
EOF EOF
lxc-create -t busybox -f $f -n lxctestc lxc-create -t busybox -f $f -n lxctestc
grep -q "xx:xx" /var/lib/lxc/lxctestc/config && { echo "hwaddr not expanded"; exit 1; } grep -q "xx:xx" /var/lib/lxc/lxctestc/config && { echo "hwaddr not expanded"; exit 1; }
......
...@@ -38,8 +38,8 @@ trap cleanup EXIT SIGHUP SIGINT SIGTERM ...@@ -38,8 +38,8 @@ trap cleanup EXIT SIGHUP SIGINT SIGTERM
mkdir -p /etc/lxc/ mkdir -p /etc/lxc/
cat > /etc/lxc/default.conf << EOF cat > /etc/lxc/default.conf << EOF
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.link = lxcbr0 lxc.net.0.link = lxcbr0
EOF EOF
ARCH=i386 ARCH=i386
......
...@@ -116,8 +116,8 @@ usermod -v 910000-919999 -w 910000-919999 $TUSER ...@@ -116,8 +116,8 @@ usermod -v 910000-919999 -w 910000-919999 $TUSER
mkdir -p $HDIR/.config/lxc/ mkdir -p $HDIR/.config/lxc/
cat > $HDIR/.config/lxc/default.conf << EOF cat > $HDIR/.config/lxc/default.conf << EOF
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.link = lxcbr0 lxc.net.0.link = lxcbr0
lxc.id_map = u 0 910000 9999 lxc.id_map = u 0 910000 9999
lxc.id_map = g 0 910000 9999 lxc.id_map = g 0 910000 9999
EOF EOF
......
...@@ -80,7 +80,7 @@ usermod -v 910000-919999 -w 910000-919999 usernic-user ...@@ -80,7 +80,7 @@ usermod -v 910000-919999 -w 910000-919999 usernic-user
mkdir -p /home/usernic-user/.config/lxc/ mkdir -p /home/usernic-user/.config/lxc/
cat > /home/usernic-user/.config/lxc/default.conf << EOF cat > /home/usernic-user/.config/lxc/default.conf << EOF
lxc.network.type = empty lxc.net.0.type = empty
lxc.id_map = u 0 910000 10000 lxc.id_map = u 0 910000 10000
lxc.id_map = g 0 910000 10000 lxc.id_map = g 0 910000 10000
EOF EOF
......
...@@ -45,12 +45,12 @@ int main(int argc, char *argv[]) ...@@ -45,12 +45,12 @@ int main(int argc, char *argv[])
goto out; goto out;
} }
if (!c->set_config_item(c, "lxc.network.type", "veth")) { if (!c->set_config_item(c, "lxc.net.0.type", "veth")) {
fprintf(stderr, "%d: failed to set network type\n", __LINE__); fprintf(stderr, "%d: failed to set network type\n", __LINE__);
goto out; goto out;
} }
c->set_config_item(c, "lxc.network.link", "lxcbr0"); c->set_config_item(c, "lxc.net.0.link", "lxcbr0");
c->set_config_item(c, "lxc.network.flags", "up"); c->set_config_item(c, "lxc.net.0.flags", "up");
if (!c->createl(c, "busybox", NULL, NULL, 0, NULL)) { if (!c->createl(c, "busybox", NULL, NULL, 0, NULL)) {
fprintf(stderr, "%d: failed to create a container\n", __LINE__); fprintf(stderr, "%d: failed to create a container\n", __LINE__);
goto out; goto out;
......
...@@ -72,7 +72,7 @@ int main(int argc, char *argv[]) ...@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
fprintf(stderr, "%d: %s thought it was defined\n", __LINE__, MYNAME); fprintf(stderr, "%d: %s thought it was defined\n", __LINE__, MYNAME);
(void) c->destroy_with_snapshots(c); (void) c->destroy_with_snapshots(c);
} }
if (!c->set_config_item(c, "lxc.network.type", "empty")) { if (!c->set_config_item(c, "lxc.net.0.type", "empty")) {
fprintf(stderr, "%s: %d: failed to set network type\n", __FILE__, __LINE__); fprintf(stderr, "%s: %d: failed to set network type\n", __FILE__, __LINE__);
goto err; goto err;
} }
......
...@@ -276,30 +276,30 @@ lxc.cap.drop = sys_module mac_admin mac_override sys_time ...@@ -276,30 +276,30 @@ lxc.cap.drop = sys_module mac_admin mac_override sys_time
#lxc.aa_profile = unconfined #lxc.aa_profile = unconfined
#networking #networking
#lxc.network.type = $lxc_network_type #lxc.net.0.type = $lxc_network_type
#lxc.network.flags = up #lxc.net.0.flags = up
#lxc.network.link = $lxc_network_link #lxc.net.0.link = $lxc_network_link
#lxc.network.name = veth0 #lxc.net.0.name = veth0
#lxc.network.mtu = 1500 #lxc.net.0.mtu = 1500
EOF EOF
if [ ! -z ${ipv4} ]; then if [ ! -z ${ipv4} ]; then
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.network.ipv4 = $ipv4 lxc.net.0.ipv4 = $ipv4
EOF EOF
fi fi
if [ ! -z ${gw} ]; then if [ ! -z ${gw} ]; then
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.network.ipv4.gateway = $gw lxc.net.0.ipv4.gateway = $gw
EOF EOF
fi fi
if [ ! -z ${ipv6} ]; then if [ ! -z ${ipv6} ]; then
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.network.ipv6 = $ipv6 lxc.net.0.ipv6 = $ipv6
EOF EOF
fi fi
if [ ! -z ${gw6} ]; then if [ ! -z ${gw6} ]; then
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.network.ipv6.gateway = $gw6 lxc.net.0.ipv6.gateway = $gw6
EOF EOF
fi fi
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
......
...@@ -618,13 +618,13 @@ lxc.rootfs = $rootfs_path ...@@ -618,13 +618,13 @@ lxc.rootfs = $rootfs_path
# Seems that \s doesn't work in brackets. # Seems that \s doesn't work in brackets.
KEY=$(expr "${LINE}" : '\s*\([^ ]*\)\s*=') KEY=$(expr "${LINE}" : '\s*\([^ ]*\)\s*=')
if [[ "${KEY}" != "lxc.network.hwaddr" ]] if [[ "${KEY}" != "lxc.net.0.hwaddr" ]]
then then
echo ${LINE} >> $config_path/config echo ${LINE} >> $config_path/config
if [[ "${KEY}" == "lxc.network.link" ]] if [[ "${KEY}" == "lxc.net.0.link" ]]
then then
echo "lxc.network.hwaddr = $(create_hwaddr)" >> $config_path/config echo "lxc.net.0.hwaddr = $(create_hwaddr)" >> $config_path/config
fi fi
fi fi
done < $config_path/config.def done < $config_path/config.def
...@@ -647,16 +647,16 @@ lxc.utsname = $utsname ...@@ -647,16 +647,16 @@ lxc.utsname = $utsname
#lxc.aa_profile = unconfined #lxc.aa_profile = unconfined
# example simple networking setup, uncomment to enable # example simple networking setup, uncomment to enable
#lxc.network.type = $lxc_network_type #lxc.net.0.type = $lxc_network_type
#lxc.network.flags = up #lxc.net.0.flags = up
#lxc.network.link = $lxc_network_link #lxc.net.0.link = $lxc_network_link
#lxc.network.name = eth0 #lxc.net.0.name = eth0
# Additional example for veth network type # Additional example for veth network type
# static MAC address, # static MAC address,
#lxc.network.hwaddr = 00:16:3e:77:52:20 #lxc.net.0.hwaddr = 00:16:3e:77:52:20
# persistent veth device name on host side # persistent veth device name on host side
# Note: This may potentially collide with other containers of same name! # Note: This may potentially collide with other containers of same name!
#lxc.network.veth.pair = v-$name-e0 #lxc.net.0.veth.pair = v-$name-e0
EOF EOF
......
...@@ -493,9 +493,9 @@ copy_configuration() ...@@ -493,9 +493,9 @@ copy_configuration()
# Generate the configuration file # Generate the configuration file
# if there is exactly one veth network entry, make sure it has an # if there is exactly one veth network entry, make sure it has an
# associated hwaddr. # associated hwaddr.
nics=$(grep -ce '^lxc\.network\.type[ \t]*=[ \t]*veth' "$path/config") nics=$(grep -ce '^lxc\.net\.0\.type[ \t]*=[ \t]*veth' "$path/config")
if [ "$nics" -eq 1 ]; then if [ "$nics" -eq 1 ]; then
grep -q "^lxc.network.hwaddr" "$path/config" || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" "$path/config" grep -q "^lxc.net.0.hwaddr" "$path/config" || sed -i -e "/^lxc\.net\.0\.type[ \t]*=[ \t]*veth/a lxc.net.0.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" "$path/config"
fi fi
## Add all the includes ## Add all the includes
......
...@@ -526,7 +526,7 @@ if [ ! -e $configfile ]; then ...@@ -526,7 +526,7 @@ if [ ! -e $configfile ]; then
fi fi
## Extract all the network config entries ## Extract all the network config entries
sed -i -e "/lxc.network/{w ${LXC_PATH}/config-network" -e "d}" \ sed -i -e "/lxc.net.0/{w ${LXC_PATH}/config-network" -e "d}" \
${LXC_PATH}/config ${LXC_PATH}/config
## Extract any other config entry ## Extract any other config entry
......
...@@ -1104,13 +1104,13 @@ lxc.rootfs = $rootfs_path ...@@ -1104,13 +1104,13 @@ lxc.rootfs = $rootfs_path
# Seems that \s doesn't work in brackets. # Seems that \s doesn't work in brackets.
KEY=$(expr "${LINE}" : '\s*\([^ ]*\)\s*=') KEY=$(expr "${LINE}" : '\s*\([^ ]*\)\s*=')
if [[ "${KEY}" != "lxc.network.hwaddr" ]] if [[ "${KEY}" != "lxc.net.0.hwaddr" ]]
then then
echo "${LINE}" >> $config_path/config echo "${LINE}" >> $config_path/config
if [[ "${KEY}" == "lxc.network.link" ]] if [[ "${KEY}" == "lxc.net.0.link" ]]
then then
echo "lxc.network.hwaddr = $(create_hwaddr)" >> $config_path/config echo "lxc.net.0.hwaddr = $(create_hwaddr)" >> $config_path/config
fi fi
fi fi
done < $config_path/config.def done < $config_path/config.def
...@@ -1133,16 +1133,16 @@ lxc.utsname = $utsname ...@@ -1133,16 +1133,16 @@ lxc.utsname = $utsname
#lxc.aa_profile = unconfined #lxc.aa_profile = unconfined
# example simple networking setup, uncomment to enable # example simple networking setup, uncomment to enable
#lxc.network.type = $lxc_network_type #lxc.net.0.type = $lxc_network_type
#lxc.network.flags = up #lxc.net.0.flags = up
#lxc.network.link = $lxc_network_link #lxc.net.0.link = $lxc_network_link
#lxc.network.name = eth0 #lxc.net.0.name = eth0
# Additional example for veth network type # Additional example for veth network type
# static MAC address, # static MAC address,
#lxc.network.hwaddr = 00:16:3e:77:52:20 #lxc.net.0.hwaddr = 00:16:3e:77:52:20
# persistent veth device name on host side # persistent veth device name on host side
# Note: This may potentially collide with other containers of same name! # Note: This may potentially collide with other containers of same name!
#lxc.network.veth.pair = v-$name-e0 #lxc.net.0.veth.pair = v-$name-e0
EOF EOF
......
...@@ -463,13 +463,13 @@ lxc.rootfs = ${rootfs} ...@@ -463,13 +463,13 @@ lxc.rootfs = ${rootfs}
# Seems that \s doesn't work in brackets. # Seems that \s doesn't work in brackets.
key=$(expr "${line}" : '\s*\([^ ]*\)\s*=') key=$(expr "${line}" : '\s*\([^ ]*\)\s*=')
if [ "${key}" != "lxc.network.hwaddr" ] if [ "${key}" != "lxc.net.0.hwaddr" ]
then then
echo "${line}" >> "${config}" echo "${line}" >> "${config}"
if [ "${key}" == "lxc.network.link" ] if [ "${key}" == "lxc.net.0.link" ]
then then
echo "lxc.network.hwaddr = $(create_hwaddr)" >> "${config}" echo "lxc.net.0.hwaddr = $(create_hwaddr)" >> "${config}"
fi fi
fi fi
done < "${config}.orig" done < "${config}.orig"
...@@ -492,16 +492,16 @@ lxc.utsname = ${utsname} ...@@ -492,16 +492,16 @@ lxc.utsname = ${utsname}
#lxc.aa_profile = unconfined #lxc.aa_profile = unconfined
# example simple networking setup, uncomment to enable # example simple networking setup, uncomment to enable
#lxc.network.type = ${lxc_network_type} #lxc.net.0.type = ${lxc_network_type}
#lxc.network.flags = up #lxc.net.0.flags = up
#lxc.network.link = ${lxc_network_link} #lxc.net.0.link = ${lxc_network_link}
#lxc.network.name = eth0 #lxc.net.0.name = eth0
# Additional example for veth network type # Additional example for veth network type
# static MAC address, # static MAC address,
#lxc.network.hwaddr = $(create_hwaddr) #lxc.net.0.hwaddr = $(create_hwaddr)
# persistent veth device name on host side # persistent veth device name on host side
# Note: This may potentially collide with other containers of same name! # Note: This may potentially collide with other containers of same name!
#lxc.network.veth.pair = v-${name}-e0 #lxc.net.0.veth.pair = v-${name}-e0
EOF EOF
if [ $? -ne 0 ] if [ $? -ne 0 ]
......
...@@ -517,7 +517,7 @@ container_conf_net() ...@@ -517,7 +517,7 @@ container_conf_net()
value=$(echo "${line}" | sed 's/^.*_real_ugly_sep_42_//') value=$(echo "${line}" | sed 's/^.*_real_ugly_sep_42_//')
#new nic ! #new nic !
if [[ "${key}" == "lxc.network.type" ]]; then if [[ "${key}" == "lxc.net.0.type" ]]; then
#we don't know what to do with it. #we don't know what to do with it.
[[ "${value}" == "empty" ]] && continue [[ "${value}" == "empty" ]] && continue
...@@ -535,15 +535,15 @@ container_conf_net() ...@@ -535,15 +535,15 @@ container_conf_net()
nic_type="${value}" nic_type="${value}"
fi fi
if [[ "${key}" == "lxc.network.hwaddr" ]]; then if [[ "${key}" == "lxc.net.0.hwaddr" ]]; then
nic_hwaddr=1 nic_hwaddr=1
fi fi
if [[ "${key}" =~ ^lxc.network.ipv(4|6) ]]; then if [[ "${key}" =~ ^lxc.net.0.ipv(4|6) ]]; then
#tell openrc to not manage this NIC as LXC set there address #tell openrc to not manage this NIC as LXC set there address
nic_conf="null" nic_conf="null"
fi fi
if [[ "${key}" =~ ^lxc.network.name ]]; then if [[ "${key}" =~ ^lxc.net.0.name ]]; then
nic_name="${value}" nic_name="${value}"
let nic_named=nic_named+1 let nic_named=nic_named+1
fi fi
...@@ -583,10 +583,10 @@ container_net() ...@@ -583,10 +583,10 @@ container_net()
store_user_message "No network interface for this container store_user_message "No network interface for this container
It's a pitty, you have bridge, ${bridge}. It's a pitty, you have bridge, ${bridge}.
If it is for Lxc, use it next time by adding this to your default.conf : If it is for Lxc, use it next time by adding this to your default.conf :
lxc.network.type = veth lxc.net.0.type = veth
lxc.network.link = ${bridge} lxc.net.0.link = ${bridge}
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.hwaddr = fe:xx:xx:xx:xx:xx" lxc.net.0.hwaddr = fe:xx:xx:xx:xx:xx"
return 0 return 0
else else
store_user_message "No network interface for this container" store_user_message "No network interface for this container"
...@@ -681,9 +681,9 @@ container_conf() ...@@ -681,9 +681,9 @@ container_conf()
# if there is exactly one veth network entry, make sure it has an # if there is exactly one veth network entry, make sure it has an
# associated hwaddr. # associated hwaddr.
nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' ${conf_file} | wc -l` nics=`grep -e '^lxc\.net\.0\.type[ \t]*=[ \t]*veth' ${conf_file} | wc -l`
if [ $nics -eq 1 ]; then if [ $nics -eq 1 ]; then
grep -q "^lxc.network.hwaddr" ${conf_file} || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" ${conf_file} grep -q "^lxc.net.0.hwaddr" ${conf_file} || sed -i -e "/^lxc\.net\.0\.type[ \t]*=[ \t]*veth/a lxc.net.0.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" ${conf_file}
fi fi
if grep -q "^lxc.rootfs" "${conf_file}" ; then if grep -q "^lxc.rootfs" "${conf_file}" ; then
......
...@@ -238,30 +238,30 @@ lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed ...@@ -238,30 +238,30 @@ lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed
#lxc.aa_profile = unconfined #lxc.aa_profile = unconfined
#networking #networking
lxc.network.type = $lxc_network_type lxc.net.0.type = $lxc_network_type
lxc.network.flags = up lxc.net.0.flags = up
lxc.network.link = $lxc_network_link lxc.net.0.link = $lxc_network_link
lxc.network.name = eth0 lxc.net.0.name = eth0
lxc.network.mtu = 1500 lxc.net.0.mtu = 1500
EOF EOF
if [ ! -z ${ipv4} ]; then if [ ! -z ${ipv4} ]; then
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.network.ipv4 = $ipv4 lxc.net.0.ipv4 = $ipv4
EOF EOF
fi fi
if [ ! -z ${gw} ]; then if [ ! -z ${gw} ]; then
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.network.ipv4.gateway = $gw lxc.net.0.ipv4.gateway = $gw
EOF EOF
fi fi
if [ ! -z ${ipv6} ]; then if [ ! -z ${ipv6} ]; then
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.network.ipv6 = $ipv6 lxc.net.0.ipv6 = $ipv6
EOF EOF
fi fi
if [ ! -z ${gw6} ]; then if [ ! -z ${gw6} ]; then
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
lxc.network.ipv6.gateway = $gw6 lxc.net.0.ipv6.gateway = $gw6
EOF EOF
fi fi
cat <<EOF >> $config_path/config cat <<EOF >> $config_path/config
......
...@@ -327,13 +327,13 @@ lxc.rootfs = $rootfs_path ...@@ -327,13 +327,13 @@ lxc.rootfs = $rootfs_path
# Seems that \s doesn't work in brackets. # Seems that \s doesn't work in brackets.
KEY=$(expr "${LINE}" : '\s*\([^ ]*\)\s*=') KEY=$(expr "${LINE}" : '\s*\([^ ]*\)\s*=')
if [[ "${KEY}" != "lxc.network.hwaddr" ]] if [[ "${KEY}" != "lxc.net.0.hwaddr" ]]
then then
echo "${LINE}" >> $path/config echo "${LINE}" >> $path/config
if [[ "${KEY}" == "lxc.network.link" ]] if [[ "${KEY}" == "lxc.net.0.link" ]]
then then
echo "lxc.network.hwaddr = $(create_hwaddr)" >> $path/config echo "lxc.net.0.hwaddr = $(create_hwaddr)" >> $path/config
fi fi
fi fi
done < $path/config.def done < $path/config.def
...@@ -358,16 +358,16 @@ lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed ...@@ -358,16 +358,16 @@ lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed
lxc.aa_profile = unconfined lxc.aa_profile = unconfined
# example simple networking setup, uncomment to enable # example simple networking setup, uncomment to enable
#lxc.network.type = $lxc_network_type #lxc.net.0.type = $lxc_network_type
#lxc.network.flags = up #lxc.net.0.flags = up
#lxc.network.link = $lxc_network_link #lxc.net.0.link = $lxc_network_link
#lxc.network.name = eth0 #lxc.net.0.name = eth0
# Additional example for veth network type # Additional example for veth network type
# static MAC address, # static MAC address,
#lxc.network.hwaddr = 00:16:3e:77:52:20 #lxc.net.0.hwaddr = 00:16:3e:77:52:20
# persistent veth device name on host side # persistent veth device name on host side
# Note: This may potentially collide with other containers of same name! # Note: This may potentially collide with other containers of same name!
#lxc.network.veth.pair = v-$name-e0 #lxc.net.0.veth.pair = v-$name-e0
EOF EOF
......
...@@ -497,36 +497,36 @@ EOF ...@@ -497,36 +497,36 @@ EOF
echo "# Networking" >>$cfg_dir/config echo "# Networking" >>$cfg_dir/config
# see if the default network settings were already specified # see if the default network settings were already specified
lxc_network_type=`grep '^lxc.network.type' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'` lxc_network_type=`grep '^lxc.net.0.type' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
if [ -z "$lxc_network_type" ]; then if [ -z "$lxc_network_type" ]; then
echo "lxc.network.type = veth" >>$cfg_dir/config echo "lxc.net.0.type = veth" >>$cfg_dir/config
lxc_network_type=veth lxc_network_type=veth
fi fi
lxc_network_link=`grep '^lxc.network.link' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'` lxc_network_link=`grep '^lxc.net.0.link' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
if [ -z "$lxc_network_link" ]; then if [ -z "$lxc_network_link" ]; then
echo "lxc.network.link = lxcbr0" >>$cfg_dir/config echo "lxc.net.0.link = lxcbr0" >>$cfg_dir/config
lxc_network_link=lxcbr0 lxc_network_link=lxcbr0
fi fi
lxc_network_hwaddr=`grep '^lxc.network.hwaddr' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'` lxc_network_hwaddr=`grep '^lxc.net.0.hwaddr' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
if [ -z "$lxc_network_hwaddr" ]; then if [ -z "$lxc_network_hwaddr" ]; then
# generate a hwaddr for the container # generate a hwaddr for the container
# see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303 # see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303
local hwaddr="00:16:3e:`dd if=/dev/urandom bs=8 count=1 2>/dev/null |od -t x8 | \ local hwaddr="00:16:3e:`dd if=/dev/urandom bs=8 count=1 2>/dev/null |od -t x8 | \
head -n1 | awk '{print $2}' | cut -c1-6 | \ head -n1 | awk '{print $2}' | cut -c1-6 | \
sed 's/\(..\)/\1:/g; s/.$//'`" sed 's/\(..\)/\1:/g; s/.$//'`"
echo "lxc.network.hwaddr = $hwaddr" >>$cfg_dir/config echo "lxc.net.0.hwaddr = $hwaddr" >>$cfg_dir/config
fi fi
lxc_network_flags=`grep '^lxc.network.flags' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'` lxc_network_flags=`grep '^lxc.net.0.flags' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
if [ -z "$lxc_network_flags" ]; then if [ -z "$lxc_network_flags" ]; then
echo "lxc.network.flags = up" >>$cfg_dir/config echo "lxc.net.0.flags = up" >>$cfg_dir/config
fi fi
cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config" cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config"
lxc.network.name = eth0 lxc.net.0.name = eth0
lxc.network.mtu = 1500 lxc.net.0.mtu = 1500
EOF EOF
} }
......
...@@ -326,36 +326,36 @@ EOF ...@@ -326,36 +326,36 @@ EOF
echo "# Networking" >>$cfg_dir/config echo "# Networking" >>$cfg_dir/config
# see if the default network settings were already specified # see if the default network settings were already specified
lxc_network_type=`grep '^lxc.network.type' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'` lxc_network_type=`grep '^lxc.net.0.type' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
if [ -z "$lxc_network_type" ]; then if [ -z "$lxc_network_type" ]; then
echo "lxc.network.type = veth" >>$cfg_dir/config echo "lxc.net.0.type = veth" >>$cfg_dir/config
lxc_network_type=veth lxc_network_type=veth
fi fi
lxc_network_link=`grep '^lxc.network.link' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'` lxc_network_link=`grep '^lxc.net.0.link' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
if [ -z "$lxc_network_link" ]; then if [ -z "$lxc_network_link" ]; then
echo "lxc.network.link = lxcbr0" >>$cfg_dir/config echo "lxc.net.0.link = lxcbr0" >>$cfg_dir/config
lxc_network_link=lxcbr0 lxc_network_link=lxcbr0
fi fi
lxc_network_hwaddr=`grep '^lxc.network.hwaddr' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'` lxc_network_hwaddr=`grep '^lxc.net.0.hwaddr' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
if [ -z "$lxc_network_hwaddr" ]; then if [ -z "$lxc_network_hwaddr" ]; then
# generate a hwaddr for the container # generate a hwaddr for the container
# see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303 # see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303
local hwaddr="00:16:3e:`dd if=/dev/urandom bs=8 count=1 2>/dev/null |od -t x8 | \ local hwaddr="00:16:3e:`dd if=/dev/urandom bs=8 count=1 2>/dev/null |od -t x8 | \
head -n1 | awk '{print $2}' | cut -c1-6 | \ head -n1 | awk '{print $2}' | cut -c1-6 | \
sed 's/\(..\)/\1:/g; s/.$//'`" sed 's/\(..\)/\1:/g; s/.$//'`"
echo "lxc.network.hwaddr = $hwaddr" >>$cfg_dir/config echo "lxc.net.0.hwaddr = $hwaddr" >>$cfg_dir/config
fi fi
lxc_network_flags=`grep '^lxc.network.flags' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'` lxc_network_flags=`grep '^lxc.net.0.flags' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
if [ -z "$lxc_network_flags" ]; then if [ -z "$lxc_network_flags" ]; then
echo "lxc.network.flags = up" >>$cfg_dir/config echo "lxc.net.0.flags = up" >>$cfg_dir/config
fi fi
cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config" cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config"
lxc.network.name = eth0 lxc.net.0.name = eth0
lxc.network.mtu = 1500 lxc.net.0.mtu = 1500
EOF EOF
} }
......
...@@ -162,7 +162,7 @@ EOF ...@@ -162,7 +162,7 @@ EOF
fi fi
# if no .ipv4 section in config, then have the container run dhcp # if no .ipv4 section in config, then have the container run dhcp
grep -q "^lxc.network.ipv4" $path/config || touch $rootfs/run-dhcp grep -q "^lxc.net.0.ipv4" $path/config || touch $rootfs/run-dhcp
if [ "$(uname -m)" = "x86_64" ]; then if [ "$(uname -m)" = "x86_64" ]; then
cat <<EOF >> $path/config cat <<EOF >> $path/config
......
...@@ -60,14 +60,14 @@ copy_configuration() ...@@ -60,14 +60,14 @@ copy_configuration()
# if there is exactly one veth network entry, make sure it has an # if there is exactly one veth network entry, make sure it has an
# associated hwaddr. # associated hwaddr.
nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l` nics=`grep -e '^lxc\.net\.0\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
if [ $nics -eq 1 ]; then if [ $nics -eq 1 ]; then
grep -q "^lxc.network.hwaddr" $path/config || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config grep -q "^lxc.net.0.hwaddr" $path/config || sed -i -e "/^lxc\.net\.0\.type[ \t]*=[ \t]*veth/a lxc.net.0.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config
fi fi
# Generate the configuration file # Generate the configuration file
## Relocate all the network config entries ## Relocate all the network config entries
sed -i -e "/lxc.network/{w ${path}/config-network" -e "d}" $path/config sed -i -e "/lxc.net.0/{w ${path}/config-network" -e "d}" $path/config
## Relocate any other config entries ## Relocate any other config entries
sed -i -e "/lxc./{w ${path}/config-auto" -e "d}" $path/config sed -i -e "/lxc./{w ${path}/config-auto" -e "d}" $path/config
......
...@@ -503,14 +503,14 @@ copy_configuration() ...@@ -503,14 +503,14 @@ copy_configuration()
# if there is exactly one veth network entry, make sure it has an # if there is exactly one veth network entry, make sure it has an
# associated hwaddr. # associated hwaddr.
nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l` nics=`grep -e '^lxc\.net\.0\.type[ \t]*=[ \t]*veth' $path/config | wc -l`
if [ $nics -eq 1 ]; then if [ $nics -eq 1 ]; then
grep -q "^lxc.network.hwaddr" $path/config || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config grep -q "^lxc.net.0.hwaddr" $path/config || sed -i -e "/^lxc\.net\.0\.type[ \t]*=[ \t]*veth/a lxc.net.0.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config
fi fi
# Generate the configuration file # Generate the configuration file
## Relocate all the network config entries ## Relocate all the network config entries
sed -i -e "/lxc.network/{w ${path}/config-network" -e "d}" $path/config sed -i -e "/lxc.net.0/{w ${path}/config-network" -e "d}" $path/config
## Relocate any other config entries ## Relocate any other config entries
sed -i -e "/lxc./{w ${path}/config-auto" -e "d}" $path/config sed -i -e "/lxc./{w ${path}/config-auto" -e "d}" $path/config
......
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