ifneq ($(USE_NS),)
OPTIONS_CFLAGS += -DCONFIG_HAP_NS
BUILD_OPTIONS += $(call ignore_implicit,USE_NS)
+OPTIONS_OBJS += src/namespace.o
endif
#### Global link options
src/hpack-dec.o src/memory.o src/lb_fwrr.o src/lb_chash.o \
src/lb_fas.o src/hathreads.o src/chunk.o src/lb_map.o \
src/xxhash.o src/regex.o src/shctx.o src/buffer.o src/action.o \
- src/h1.o src/compression.o src/pipe.o src/namespace.o \
+ src/h1.o src/compression.o src/pipe.o \
src/sha1.o src/hpack-tbl.o src/hpack-enc.o src/uri_auth.o \
src/time.o src/proto_udp.o src/arg.o src/signal.o \
src/protocol.o src/lru.o src/hdr_idx.o src/hpack-huff.o \
#include <stdlib.h>
#include <ebistree.h>
-struct netns_entry;
-int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol);
-
#ifdef CONFIG_HAP_NS
struct netns_entry
int fd;
};
+int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol);
struct netns_entry* netns_store_insert(const char *ns_name);
const struct netns_entry* netns_store_lookup(const char *ns_name, size_t ns_name_len);
int netns_init(void);
+
+#else /* no namespace support */
+
+struct netns_entry;
+
+static inline int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol)
+{
+ return socket(domain, type, protocol);
+}
+
#endif /* CONFIG_HAP_NS */
#endif /* _NAMESPACE_H */
#include <proto/log.h>
#include <types/global.h>
-#ifdef CONFIG_HAP_NS
-
/* Opens the namespace <ns_name> and returns the FD or -1 in case of error
* (check errno).
*/
else
return NULL;
}
-#endif
/* Opens a socket in the namespace described by <ns> with the parameters <domain>,
* <type> and <protocol> and returns the FD or -1 in case of error (check errno).
{
int sock;
-#ifdef CONFIG_HAP_NS
if (default_namespace >= 0 && ns && setns(ns->fd, CLONE_NEWNET) == -1)
return -1;
-#endif
+
sock = socket(domain, type, protocol);
-#ifdef CONFIG_HAP_NS
if (default_namespace >= 0 && ns && setns(default_namespace, CLONE_NEWNET) == -1) {
close(sock);
return -1;
}
-#endif
-
return sock;
}