From 23459b9b701748b2f0c003df4ed404bfeef5e25f Mon Sep 17 00:00:00 2001 From: fli Date: Thu, 21 Apr 2016 19:20:38 -0700 Subject: meta-virtualization: enable lxc-start support wlan0 Cherry picked patch from lxc upstream commit: f2e206ff47 to enable lxc-start command support wlan0 device and make cube-essential support paththrough wlan device from host to lxc containers. Signed-off-by: fli Signed-off-by: Bruce Ashfield --- .../lxc-let-lxc-start-support-wlan-phys.patch | 72 ++++++++++++++++++++++ recipes-containers/lxc/lxc_1.1.5.bb | 1 + 2 files changed, 73 insertions(+) create mode 100644 recipes-containers/lxc/files/lxc-let-lxc-start-support-wlan-phys.patch diff --git a/recipes-containers/lxc/files/lxc-let-lxc-start-support-wlan-phys.patch b/recipes-containers/lxc/files/lxc-let-lxc-start-support-wlan-phys.patch new file mode 100644 index 00000000..9146fd07 --- /dev/null +++ b/recipes-containers/lxc/files/lxc-let-lxc-start-support-wlan-phys.patch @@ -0,0 +1,72 @@ +From 4acc7a24e098445de502a6f59a8b3dff2cd8536d Mon Sep 17 00:00:00 2001 +From: fli +Date: Thu, 21 Apr 2016 19:07:10 -0700 +Subject: [PATCH] lxc: let lxc-start support wlan phys + +The commit: e5848d395cb only +made netdev_move_by_name support wlan, instead of netdev_move_by_index. + +Given netdev_move_by_name is a wrapper of netdev_move_by_index, so here +replacing all of the call to lxc_netdev_move_by_index with lxc_netdev_move_by_name +to let lxc-start support wlan phys. + +Signed-off-by: fli +--- + src/lxc/conf.c | 20 ++++++++++++++++---- + 1 file changed, 16 insertions(+), 4 deletions(-) + +diff --git a/src/lxc/conf.c b/src/lxc/conf.c +index 034bdff..bcba0f1 100644 +--- a/src/lxc/conf.c ++++ b/src/lxc/conf.c +@@ -2623,6 +2623,7 @@ void restore_phys_nics_to_netns(int netnsfd, struct lxc_conf *conf) + { + int i, ret, oldfd; + char path[MAXPATHLEN]; ++ char ifname[IFNAMSIZ]; + + if (netnsfd < 0) + return; +@@ -2643,9 +2644,13 @@ void restore_phys_nics_to_netns(int netnsfd, struct lxc_conf *conf) + } + for (i=0; inum_savednics; i++) { + struct saved_nic *s = &conf->saved_nics[i]; +- if (lxc_netdev_move_by_index(s->ifindex, 1, NULL)) +- WARN("Error moving nic index:%d back to host netns", +- s->ifindex); ++ /* retrieve the name of the interface */ ++ if (!if_indextoname(s->ifindex, ifname)) { ++ WARN("no interface corresponding to index '%d'", s->ifindex); ++ continue; ++ } ++ if (lxc_netdev_move_by_name(ifname, 1, NULL)) ++ WARN("Error moving nic name:%s back to host netns", ifname); + } + if (setns(oldfd, 0) != 0) + SYSERROR("Failed to re-enter monitor's netns"); +@@ -3208,6 +3213,7 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid) + { + struct lxc_list *iterator; + struct lxc_netdev *netdev; ++ char ifname[IFNAMSIZ]; + int am_root = (getuid() == 0); + int err; + +@@ -3228,7 +3234,13 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid) + if (!netdev->ifindex) + continue; + +- err = lxc_netdev_move_by_index(netdev->ifindex, pid, NULL); ++ /* retrieve the name of the interface */ ++ if (!if_indextoname(netdev->ifindex, ifname)) { ++ ERROR("no interface corresponding to index '%d'", netdev->ifindex); ++ return -1; ++ } ++ ++ err = lxc_netdev_move_by_name(ifname, pid, NULL); + if (err) { + ERROR("failed to move '%s' to the container : %s", + netdev->link, strerror(-err)); +-- +2.7.4 + diff --git a/recipes-containers/lxc/lxc_1.1.5.bb b/recipes-containers/lxc/lxc_1.1.5.bb index 0f6d0b85..67ad93a9 100644 --- a/recipes-containers/lxc/lxc_1.1.5.bb +++ b/recipes-containers/lxc/lxc_1.1.5.bb @@ -40,6 +40,7 @@ SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \ file://open_without_symlink-Don-t-SYSERROR-on-something-els.patch \ file://lxc-busybox-Touch-etc-fstab-in-the-container-rootfs.patch \ file://lxc-busybox-Remove-warning-for-dynamically-linked-Bu.patch \ + file://lxc-let-lxc-start-support-wlan-phys.patch \ " SRC_URI[md5sum] = "dd9684dde0a58ed13f4f49c855b79a1a" -- cgit v1.2.3-54-g00ecf