+/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __NAMESPACE_H__
#define __NAMESPACE_H__ 1
#include <sched.h>
#include <sys/mount.h>
+#include <unistd.h>
+#include <sys/syscall.h>
#include <errno.h>
+#ifndef NETNS_RUN_DIR
#define NETNS_RUN_DIR "/var/run/netns"
+#endif
+
+#ifndef NETNS_ETC_DIR
#define NETNS_ETC_DIR "/etc/netns"
+#endif
#ifndef CLONE_NEWNET
#define CLONE_NEWNET 0x40000000 /* New network namespace (lo, device, names sockets, etc) */
#endif
#ifndef HAVE_SETNS
-static int setns(int fd, int nstype)
+static inline int setns(int fd, int nstype)
{
#ifdef __NR_setns
return syscall(__NR_setns, fd, nstype);
}
#endif /* HAVE_SETNS */
-extern int netns_switch(char *netns);
-extern int netns_get_fd(const char *netns);
+int netns_switch(char *netns);
+int netns_get_fd(const char *netns);
+int netns_foreach(int (*func)(char *nsname, void *arg), void *arg);
+
+struct netns_func {
+ int (*func)(char *nsname, void *arg);
+ void *arg;
+};
#endif /* __NAMESPACE_H__ */