Statistics
| Branch: | Tag: | Revision:

mininet / netns.c @ 54037995

History | View | Annotate | Download (377 Bytes)

1 98d4f189 Bob Lantz
/* netns: run a command in a network namespace.
2
 * Simplified from netunshare.c on lxc.sf.net
3
*/
4
5
#include <stdio.h>
6 6a30c394 Bob Lantz
#include <linux/sched.h>
7 98d4f189 Bob Lantz
#include <unistd.h>
8
9
int main(int argc, char *argv[])
10
{        
11
        if (unshare(CLONE_NEWNET) == -1) {
12
                perror("unshare");
13
                return 1;
14
        } 
15
        
16
        if (argc) {
17
                execve(argv[1], &argv[1], __environ);
18
                perror("execve");
19
                return 1;
20
        }
21
22
        return 0;
23
}