mirror of
git://git.yoctoproject.org/meta-virtualization.git
synced 2025-07-19 20:59:41 +02:00
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>
This commit is contained in:
parent
a626d480cf
commit
ad150f5655
|
@ -0,0 +1,49 @@
|
||||||
|
From 8712c58ab896f072cf95e3ffa3ceac1fa10f6295 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Bogdan Purcareata <bogdan.purcareata@freescale.com>
|
||||||
|
Date: Thu, 14 Nov 2013 12:31:55 +0200
|
||||||
|
Subject: [PATCH] setup_netdev: re-read ifindex in LXC_NET_PHYS case
|
||||||
|
|
||||||
|
When moving an interface from the host netns to a container's,
|
||||||
|
the ifindex might not remain the same. This happens when the
|
||||||
|
index of the host interface is already assigned to another interface
|
||||||
|
in the new netns.
|
||||||
|
|
||||||
|
For veth/vlan/macvlan, virtual interfaces are first created on the host,
|
||||||
|
and then moved in the container. Since they are created after all other
|
||||||
|
interfaces are discovered, there is no chance for its assigned ifindex
|
||||||
|
to be already present in a freshly created netns, since its a greater
|
||||||
|
number.
|
||||||
|
|
||||||
|
However, when moving a physical interface, there is a chance that its
|
||||||
|
ifindex in the host netns is not free in the new netns. The patch
|
||||||
|
forces ifindex re-read for the LXC_NET_PHYS case to update the
|
||||||
|
lxc_netdev structure.
|
||||||
|
|
||||||
|
Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
|
||||||
|
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
|
||||||
|
---
|
||||||
|
src/lxc/conf.c | 8 ++++++++
|
||||||
|
1 file changed, 8 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
|
||||||
|
index 6b3f318..08b0d0f 100644
|
||||||
|
--- a/src/lxc/conf.c
|
||||||
|
+++ b/src/lxc/conf.c
|
||||||
|
@@ -1846,6 +1846,14 @@ static int setup_netdev(struct lxc_netdev *netdev)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /* get the new ifindex in case of physical netdev */
|
||||||
|
+ if (netdev->type == LXC_NET_PHYS)
|
||||||
|
+ if (!(netdev->ifindex = if_nametoindex(netdev->link))) {
|
||||||
|
+ ERROR("failed to get ifindex for %s",
|
||||||
|
+ netdev->link);
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/* retrieve the name of the interface */
|
||||||
|
if (!if_indextoname(netdev->ifindex, current_ifname)) {
|
||||||
|
ERROR("no interface corresponding to index '%d'",
|
||||||
|
--
|
||||||
|
1.7.11.7
|
||||||
|
|
|
@ -24,8 +24,9 @@ RDEPENDS_${PN} = " \
|
||||||
SRC_URI = "http://linuxcontainers.org/downloads/${PN}-${PV}.tar.gz \
|
SRC_URI = "http://linuxcontainers.org/downloads/${PN}-${PV}.tar.gz \
|
||||||
file://lxc-0.9.0-disable-udhcp-from-busybox-template.patch \
|
file://lxc-0.9.0-disable-udhcp-from-busybox-template.patch \
|
||||||
file://lxc-0.9.0-enable-chroot-chpasswd-functionality-for-busybox-hosts.patch \
|
file://lxc-0.9.0-enable-chroot-chpasswd-functionality-for-busybox-hosts.patch \
|
||||||
file://lxc-0.9.0-check-when-bind-mounting-libdirs.patch \
|
file://lxc-0.9.0-check-when-bind-mounting-libdirs.patch \
|
||||||
file://lxc-0.9.0-don-t-let-LXC_PATH-end-in-failure.patch \
|
file://lxc-0.9.0-don-t-let-LXC_PATH-end-in-failure.patch \
|
||||||
|
file://lxc-0.9.0-setup_netdev-re-read-ifindex-in-LXC_NET_PHYS-case.patch \
|
||||||
"
|
"
|
||||||
SRC_URI[md5sum] = "8552a4479090616f4bc04d8473765fc9"
|
SRC_URI[md5sum] = "8552a4479090616f4bc04d8473765fc9"
|
||||||
SRC_URI[sha256sum] = "1e1767eae6cc5fbf892c0e193d25da420ba19f2db203716c38f7cdea3b654120"
|
SRC_URI[sha256sum] = "1e1767eae6cc5fbf892c0e193d25da420ba19f2db203716c38f7cdea3b654120"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user