Create 'vs' and put it into NS in one command
authorRobert Swiecki <swiecki@google.com>
Mon, 29 Feb 2016 16:59:49 +0000 (17:59 +0100)
committerRobert Swiecki <swiecki@google.com>
Mon, 29 Feb 2016 16:59:49 +0000 (17:59 +0100)
net.c

diff --git a/net.c b/net.c
index c8139d0eb6d661a63bf9f56b1546334f5b3ac2e4..00f153f21421f74255c598b8ae0ad9ab1c1a168f 100644 (file)
--- a/net.c
+++ b/net.c
@@ -93,30 +93,17 @@ bool netCloneMacVtapAndNS(struct nsjconf_t *nsjconf, int pid)
                return true;
        }
 
-       char iface[IF_NAMESIZE];
-       snprintf(iface, sizeof(iface), "NS.TAP.%d", pid);
+       char pid_str[256];
+       snprintf(pid_str, sizeof(pid_str), "%d", pid);
 
        char *const argv_add[] =
-           { "ip", "link", "add", "link", (char *)nsjconf->iface, "name", iface, "type", "macvlan",
-"mode",
-               "bridge", NULL
-       };
+           { "ip", "link", "add", "link", (char *)nsjconf->iface, "name", IFACE_NAME, "netns",
+pid_str, "type", "macvlan", "mode", "bridge", NULL };
        if (netSystemSbinIp(nsjconf, argv_add) == false) {
                LOG_E("Couldn't create MACVTAP interface for '%s'", nsjconf->iface);
                return false;
        }
 
-       char pid_str[256];
-       snprintf(pid_str, sizeof(pid_str), "%d", pid);
-       char *const argv_netns[] =
-           { "ip", "link", "set", "dev", iface, "netns", pid_str, "name", IFACE_NAME,
-               NULL
-       };
-       if (netSystemSbinIp(nsjconf, argv_netns) == false) {
-               LOG_E("Couldn't put interface '%s' into NS of PID '%d'", iface, pid);
-               return false;
-       }
-
        return true;
 }