]> git.proxmox.com Git - mirror_iproute2.git/blob - include/namespace.h
Merge branch 'master' into net-next
[mirror_iproute2.git] / include / namespace.h
1 #ifndef __NAMESPACE_H__
2 #define __NAMESPACE_H__ 1
3
4 #include <sched.h>
5 #include <sys/mount.h>
6 #include <sys/syscall.h>
7 #include <errno.h>
8
9 #define NETNS_RUN_DIR "/var/run/netns"
10 #define NETNS_ETC_DIR "/etc/netns"
11
12 #ifndef CLONE_NEWNET
13 #define CLONE_NEWNET 0x40000000 /* New network namespace (lo, device, names sockets, etc) */
14 #endif
15
16 #ifndef MNT_DETACH
17 #define MNT_DETACH 0x00000002 /* Just detach from the tree */
18 #endif /* MNT_DETACH */
19
20 /* sys/mount.h may be out too old to have these */
21 #ifndef MS_REC
22 #define MS_REC 16384
23 #endif
24
25 #ifndef MS_SLAVE
26 #define MS_SLAVE (1 << 19)
27 #endif
28
29 #ifndef MS_SHARED
30 #define MS_SHARED (1 << 20)
31 #endif
32
33 #ifndef HAVE_SETNS
34 static inline int setns(int fd, int nstype)
35 {
36 #ifdef __NR_setns
37 return syscall(__NR_setns, fd, nstype);
38 #else
39 errno = ENOSYS;
40 return -1;
41 #endif
42 }
43 #endif /* HAVE_SETNS */
44
45 extern int netns_switch(char *netns);
46 extern int netns_get_fd(const char *netns);
47
48 #endif /* __NAMESPACE_H__ */