]> git.proxmox.com Git - mirror_iproute2.git/blob - include/namespace.h
Merge branch 'master' of git://git.kernel.org/pub/scm/network/iproute2/iproute2-next
[mirror_iproute2.git] / include / namespace.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NAMESPACE_H__
3 #define __NAMESPACE_H__ 1
4
5 #include <sched.h>
6 #include <sys/mount.h>
7 #include <unistd.h>
8 #include <sys/syscall.h>
9 #include <errno.h>
10
11 #ifndef NETNS_RUN_DIR
12 #define NETNS_RUN_DIR "/var/run/netns"
13 #endif
14
15 #ifndef NETNS_ETC_DIR
16 #define NETNS_ETC_DIR "/etc/netns"
17 #endif
18
19 #ifndef CLONE_NEWNET
20 #define CLONE_NEWNET 0x40000000 /* New network namespace (lo, device, names sockets, etc) */
21 #endif
22
23 #ifndef MNT_DETACH
24 #define MNT_DETACH 0x00000002 /* Just detach from the tree */
25 #endif /* MNT_DETACH */
26
27 /* sys/mount.h may be out too old to have these */
28 #ifndef MS_REC
29 #define MS_REC 16384
30 #endif
31
32 #ifndef MS_SLAVE
33 #define MS_SLAVE (1 << 19)
34 #endif
35
36 #ifndef MS_SHARED
37 #define MS_SHARED (1 << 20)
38 #endif
39
40 #ifndef HAVE_SETNS
41 static inline int setns(int fd, int nstype)
42 {
43 #ifdef __NR_setns
44 return syscall(__NR_setns, fd, nstype);
45 #else
46 errno = ENOSYS;
47 return -1;
48 #endif
49 }
50 #endif /* HAVE_SETNS */
51
52 int netns_switch(char *netns);
53 int netns_get_fd(const char *netns);
54 int netns_foreach(int (*func)(char *nsname, void *arg), void *arg);
55
56 struct netns_func {
57 int (*func)(char *nsname, void *arg);
58 void *arg;
59 };
60
61 #endif /* __NAMESPACE_H__ */