diff options
| author | Bogdan Purcareata <bogdan.purcareata@freescale.com> | 2013-11-14 18:04:40 +0200 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2013-11-15 00:00:27 -0500 |
| commit | ad150f5655400fbc020ff56d79005365f4819f10 (patch) | |
| tree | c9336d61845c3dda0a6af77a5256d0640e2340d0 | |
| parent | a626d480cf9b0e12ad17ba476f89aa18e2b72d07 (diff) | |
| download | meta-virtualization-ad150f5655400fbc020ff56d79005365f4819f10.tar.gz | |
LXC: setup_netdev: re-read ifindex in LXC_NET_PHYS case
Patch to fix interface netns transition when
assigning a physical interface to a container.
Pushed to the upstream LXC repo, to be included
in future versions of LXC.
Further details in included patch description.
Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
| -rw-r--r-- | recipes-containers/lxc/files/lxc-0.9.0-setup_netdev-re-read-ifindex-in-LXC_NET_PHYS-case.patch | 49 | ||||
| -rw-r--r-- | recipes-containers/lxc/lxc_0.9.0.bb | 5 |
2 files changed, 52 insertions, 2 deletions
diff --git a/recipes-containers/lxc/files/lxc-0.9.0-setup_netdev-re-read-ifindex-in-LXC_NET_PHYS-case.patch b/recipes-containers/lxc/files/lxc-0.9.0-setup_netdev-re-read-ifindex-in-LXC_NET_PHYS-case.patch new file mode 100644 index 00000000..767e3894 --- /dev/null +++ b/recipes-containers/lxc/files/lxc-0.9.0-setup_netdev-re-read-ifindex-in-LXC_NET_PHYS-case.patch | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | From 8712c58ab896f072cf95e3ffa3ceac1fa10f6295 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Bogdan Purcareata <bogdan.purcareata@freescale.com> | ||
| 3 | Date: Thu, 14 Nov 2013 12:31:55 +0200 | ||
| 4 | Subject: [PATCH] setup_netdev: re-read ifindex in LXC_NET_PHYS case | ||
| 5 | |||
| 6 | When moving an interface from the host netns to a container's, | ||
| 7 | the ifindex might not remain the same. This happens when the | ||
| 8 | index of the host interface is already assigned to another interface | ||
| 9 | in the new netns. | ||
| 10 | |||
| 11 | For veth/vlan/macvlan, virtual interfaces are first created on the host, | ||
| 12 | and then moved in the container. Since they are created after all other | ||
| 13 | interfaces are discovered, there is no chance for its assigned ifindex | ||
| 14 | to be already present in a freshly created netns, since its a greater | ||
| 15 | number. | ||
| 16 | |||
| 17 | However, when moving a physical interface, there is a chance that its | ||
| 18 | ifindex in the host netns is not free in the new netns. The patch | ||
| 19 | forces ifindex re-read for the LXC_NET_PHYS case to update the | ||
| 20 | lxc_netdev structure. | ||
| 21 | |||
| 22 | Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com> | ||
| 23 | Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> | ||
| 24 | --- | ||
| 25 | src/lxc/conf.c | 8 ++++++++ | ||
| 26 | 1 file changed, 8 insertions(+) | ||
| 27 | |||
| 28 | diff --git a/src/lxc/conf.c b/src/lxc/conf.c | ||
| 29 | index 6b3f318..08b0d0f 100644 | ||
| 30 | --- a/src/lxc/conf.c | ||
| 31 | +++ b/src/lxc/conf.c | ||
| 32 | @@ -1846,6 +1846,14 @@ static int setup_netdev(struct lxc_netdev *netdev) | ||
| 33 | return 0; | ||
| 34 | } | ||
| 35 | |||
| 36 | + /* get the new ifindex in case of physical netdev */ | ||
| 37 | + if (netdev->type == LXC_NET_PHYS) | ||
| 38 | + if (!(netdev->ifindex = if_nametoindex(netdev->link))) { | ||
| 39 | + ERROR("failed to get ifindex for %s", | ||
| 40 | + netdev->link); | ||
| 41 | + return -1; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | /* retrieve the name of the interface */ | ||
| 45 | if (!if_indextoname(netdev->ifindex, current_ifname)) { | ||
| 46 | ERROR("no interface corresponding to index '%d'", | ||
| 47 | -- | ||
| 48 | 1.7.11.7 | ||
| 49 | |||
diff --git a/recipes-containers/lxc/lxc_0.9.0.bb b/recipes-containers/lxc/lxc_0.9.0.bb index 8f7736b7..03d4589e 100644 --- a/recipes-containers/lxc/lxc_0.9.0.bb +++ b/recipes-containers/lxc/lxc_0.9.0.bb | |||
| @@ -24,8 +24,9 @@ RDEPENDS_${PN} = " \ | |||
| 24 | SRC_URI = "http://linuxcontainers.org/downloads/${PN}-${PV}.tar.gz \ | 24 | SRC_URI = "http://linuxcontainers.org/downloads/${PN}-${PV}.tar.gz \ |
| 25 | file://lxc-0.9.0-disable-udhcp-from-busybox-template.patch \ | 25 | file://lxc-0.9.0-disable-udhcp-from-busybox-template.patch \ |
| 26 | file://lxc-0.9.0-enable-chroot-chpasswd-functionality-for-busybox-hosts.patch \ | 26 | file://lxc-0.9.0-enable-chroot-chpasswd-functionality-for-busybox-hosts.patch \ |
| 27 | file://lxc-0.9.0-check-when-bind-mounting-libdirs.patch \ | 27 | file://lxc-0.9.0-check-when-bind-mounting-libdirs.patch \ |
| 28 | file://lxc-0.9.0-don-t-let-LXC_PATH-end-in-failure.patch \ | 28 | file://lxc-0.9.0-don-t-let-LXC_PATH-end-in-failure.patch \ |
| 29 | file://lxc-0.9.0-setup_netdev-re-read-ifindex-in-LXC_NET_PHYS-case.patch \ | ||
| 29 | " | 30 | " |
| 30 | SRC_URI[md5sum] = "8552a4479090616f4bc04d8473765fc9" | 31 | SRC_URI[md5sum] = "8552a4479090616f4bc04d8473765fc9" |
| 31 | SRC_URI[sha256sum] = "1e1767eae6cc5fbf892c0e193d25da420ba19f2db203716c38f7cdea3b654120" | 32 | SRC_URI[sha256sum] = "1e1767eae6cc5fbf892c0e193d25da420ba19f2db203716c38f7cdea3b654120" |
