Commit f2e206ff by fli Committed by Stéphane Graber

lxc: let lxc-start support wlan phys

The commit: e5848d39 <netdev_move_by_index: support wlan> 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: 's avatarfupan li <fupan.li@windriver.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 6039eaa2
...@@ -2623,6 +2623,7 @@ void restore_phys_nics_to_netns(int netnsfd, struct lxc_conf *conf) ...@@ -2623,6 +2623,7 @@ void restore_phys_nics_to_netns(int netnsfd, struct lxc_conf *conf)
{ {
int i, ret, oldfd; int i, ret, oldfd;
char path[MAXPATHLEN]; char path[MAXPATHLEN];
char ifname[IFNAMSIZ];
if (netnsfd < 0) if (netnsfd < 0)
return; return;
...@@ -2643,9 +2644,13 @@ void restore_phys_nics_to_netns(int netnsfd, struct lxc_conf *conf) ...@@ -2643,9 +2644,13 @@ void restore_phys_nics_to_netns(int netnsfd, struct lxc_conf *conf)
} }
for (i=0; i<conf->num_savednics; i++) { for (i=0; i<conf->num_savednics; i++) {
struct saved_nic *s = &conf->saved_nics[i]; struct saved_nic *s = &conf->saved_nics[i];
if (lxc_netdev_move_by_index(s->ifindex, 1, NULL)) /* retrieve the name of the interface */
WARN("Error moving nic index:%d back to host netns", if (!if_indextoname(s->ifindex, ifname)) {
s->ifindex); 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) if (setns(oldfd, 0) != 0)
SYSERROR("Failed to re-enter monitor's netns"); SYSERROR("Failed to re-enter monitor's netns");
...@@ -3225,6 +3230,7 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid) ...@@ -3225,6 +3230,7 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
{ {
struct lxc_list *iterator; struct lxc_list *iterator;
struct lxc_netdev *netdev; struct lxc_netdev *netdev;
char ifname[IFNAMSIZ];
int am_root = (getuid() == 0); int am_root = (getuid() == 0);
int err; int err;
...@@ -3245,7 +3251,13 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid) ...@@ -3245,7 +3251,13 @@ int lxc_assign_network(struct lxc_list *network, pid_t pid)
if (!netdev->ifindex) if (!netdev->ifindex)
continue; 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) { if (err) {
ERROR("failed to move '%s' to the container : %s", ERROR("failed to move '%s' to the container : %s",
netdev->link, strerror(-err)); netdev->link, strerror(-err));
......
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