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