]> git.proxmox.com Git - mirror_iproute2.git/blame - include/namespace.h
rdma: Properly mark RDMAtool license
[mirror_iproute2.git] / include / namespace.h
CommitLineData
6054c1eb 1/* SPDX-License-Identifier: GPL-2.0 */
eb67e449
VK
2#ifndef __NAMESPACE_H__
3#define __NAMESPACE_H__ 1
4
5#include <sched.h>
6#include <sys/mount.h>
b765eda9 7#include <unistd.h>
1ff6b16e 8#include <sys/syscall.h>
eb67e449
VK
9#include <errno.h>
10
e2f5cecc 11#ifndef NETNS_RUN_DIR
eb67e449 12#define NETNS_RUN_DIR "/var/run/netns"
e2f5cecc
PM
13#endif
14
15#ifndef NETNS_ETC_DIR
eb67e449 16#define NETNS_ETC_DIR "/etc/netns"
e2f5cecc 17#endif
eb67e449
VK
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
ffff6931 41static inline int setns(int fd, int nstype)
eb67e449
VK
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
892e2124
SH
52int netns_switch(char *netns);
53int netns_get_fd(const char *netns);
54int netns_foreach(int (*func)(char *nsname, void *arg), void *arg);
e998e118
VK
55
56struct netns_func {
57 int (*func)(char *nsname, void *arg);
58 void *arg;
59};
eb67e449
VK
60
61#endif /* __NAMESPACE_H__ */