diff options
-rw-r--r-- | recipes-containers/lxc/files/network-restore-ability-to-move-nl80211-devices.patch | 94 | ||||
-rw-r--r-- | recipes-containers/lxc/lxc_3.2.1.bb | 1 |
2 files changed, 95 insertions, 0 deletions
diff --git a/recipes-containers/lxc/files/network-restore-ability-to-move-nl80211-devices.patch b/recipes-containers/lxc/files/network-restore-ability-to-move-nl80211-devices.patch new file mode 100644 index 00000000..aa1aecd4 --- /dev/null +++ b/recipes-containers/lxc/files/network-restore-ability-to-move-nl80211-devices.patch | |||
@@ -0,0 +1,94 @@ | |||
1 | From 3dd7829433f63b2ec1323a1f237efa7d67ea6e2b Mon Sep 17 00:00:00 2001 | ||
2 | From: Christian Brauner <christian.brauner@ubuntu.com> | ||
3 | Date: Fri, 26 Jul 2019 08:20:02 +0200 | ||
4 | Subject: [PATCH] network: restore ability to move nl80211 devices | ||
5 | |||
6 | Closes #3105. | ||
7 | Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com> | ||
8 | --- | ||
9 | src/lxc/network.c | 31 +++++++++++++++++-------------- | ||
10 | 1 file changed, 17 insertions(+), 14 deletions(-) | ||
11 | |||
12 | diff --git a/src/lxc/network.c b/src/lxc/network.c | ||
13 | index 9755116..7684f95 100644 | ||
14 | --- a/src/lxc/network.c | ||
15 | +++ b/src/lxc/network.c | ||
16 | @@ -1248,22 +1248,21 @@ static int lxc_netdev_rename_by_name_in_netns(pid_t pid, const char *old, | ||
17 | static int lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid, | ||
18 | const char *newname) | ||
19 | { | ||
20 | - char *cmd; | ||
21 | + __do_free char *cmd = NULL; | ||
22 | pid_t fpid; | ||
23 | - int err = -1; | ||
24 | |||
25 | /* Move phyN into the container. TODO - do this using netlink. | ||
26 | * However, IIUC this involves a bit more complicated work to talk to | ||
27 | * the 80211 module, so for now just call out to iw. | ||
28 | */ | ||
29 | cmd = on_path("iw", NULL); | ||
30 | - if (!cmd) | ||
31 | - goto out1; | ||
32 | - free(cmd); | ||
33 | + if (!cmd) { | ||
34 | + return -1; | ||
35 | + } | ||
36 | |||
37 | fpid = fork(); | ||
38 | if (fpid < 0) | ||
39 | - goto out1; | ||
40 | + return -1; | ||
41 | |||
42 | if (fpid == 0) { | ||
43 | char pidstr[30]; | ||
44 | @@ -1274,21 +1273,18 @@ static int lxc_netdev_move_wlan(char *physname, const char *ifname, pid_t pid, | ||
45 | } | ||
46 | |||
47 | if (wait_for_pid(fpid)) | ||
48 | - goto out1; | ||
49 | + return -1; | ||
50 | |||
51 | - err = 0; | ||
52 | if (newname) | ||
53 | - err = lxc_netdev_rename_by_name_in_netns(pid, ifname, newname); | ||
54 | + return lxc_netdev_rename_by_name_in_netns(pid, ifname, newname); | ||
55 | |||
56 | -out1: | ||
57 | - free(physname); | ||
58 | - return err; | ||
59 | + return 0; | ||
60 | } | ||
61 | |||
62 | int lxc_netdev_move_by_name(const char *ifname, pid_t pid, const char* newname) | ||
63 | { | ||
64 | + __do_free char *physname = NULL; | ||
65 | int index; | ||
66 | - char *physname; | ||
67 | |||
68 | if (!ifname) | ||
69 | return -EINVAL; | ||
70 | @@ -3279,13 +3275,20 @@ int lxc_network_move_created_netdev_priv(struct lxc_handler *handler) | ||
71 | return 0; | ||
72 | |||
73 | lxc_list_for_each(iterator, network) { | ||
74 | + __do_free char *physname = NULL; | ||
75 | int ret; | ||
76 | struct lxc_netdev *netdev = iterator->elem; | ||
77 | |||
78 | if (!netdev->ifindex) | ||
79 | continue; | ||
80 | |||
81 | - ret = lxc_netdev_move_by_index(netdev->ifindex, pid, NULL); | ||
82 | + if (netdev->type == LXC_NET_PHYS) | ||
83 | + physname = is_wlan(netdev->link); | ||
84 | + | ||
85 | + if (physname) | ||
86 | + ret = lxc_netdev_move_wlan(physname, netdev->link, pid, NULL); | ||
87 | + else | ||
88 | + ret = lxc_netdev_move_by_index(netdev->ifindex, pid, NULL); | ||
89 | if (ret) { | ||
90 | errno = -ret; | ||
91 | SYSERROR("Failed to move network device \"%s\" with ifindex %d to network namespace %d", | ||
92 | -- | ||
93 | 2.7.4 | ||
94 | |||
diff --git a/recipes-containers/lxc/lxc_3.2.1.bb b/recipes-containers/lxc/lxc_3.2.1.bb index 585ab8fc..4b8f10b0 100644 --- a/recipes-containers/lxc/lxc_3.2.1.bb +++ b/recipes-containers/lxc/lxc_3.2.1.bb | |||
@@ -43,6 +43,7 @@ SRC_URI = "http://linuxcontainers.org/downloads/${BPN}-${PV}.tar.gz \ | |||
43 | file://template-make-busybox-template-compatible-with-core-.patch \ | 43 | file://template-make-busybox-template-compatible-with-core-.patch \ |
44 | file://tests-our-init-is-not-busybox.patch \ | 44 | file://tests-our-init-is-not-busybox.patch \ |
45 | file://tests-add-no-validate-when-using-download-template.patch \ | 45 | file://tests-add-no-validate-when-using-download-template.patch \ |
46 | file://network-restore-ability-to-move-nl80211-devices.patch \ | ||
46 | file://dnsmasq.conf \ | 47 | file://dnsmasq.conf \ |
47 | file://lxc-net \ | 48 | file://lxc-net \ |
48 | " | 49 | " |