{
int i, ret, oldfd;
char path[MAXPATHLEN];
+ char ifname[IFNAMSIZ];
if (netnsfd < 0)
return;
}
for (i=0; i<conf->num_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");
{
struct lxc_list *iterator;
struct lxc_netdev *netdev;
+ char ifname[IFNAMSIZ];
int am_root = (getuid() == 0);
int err;
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));