From 7a00efbe439c439cf2a1187a5ece199f16d81fce Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 2 Jun 2020 17:02:59 +0200 Subject: [PATCH] REORG: include: move common/namespace.h to haproxy/namespace{,-t}.h The type was moved out as it's used by standard.h for netns_entry. Instead of just being a forward declaration when not used, it's an empty struct, which makes gdb happier (the resulting stripped executable is the same). --- include/common/namespace.h | 33 ------------------------ include/common/standard.h | 2 +- include/haproxy/namespace-t.h | 39 +++++++++++++++++++++++++++++ include/haproxy/namespace.h | 47 +++++++++++++++++++++++++++++++++++ src/backend.c | 2 +- src/cfgparse.c | 2 +- src/connection.c | 2 +- src/filters.c | 2 +- src/haproxy.c | 2 +- src/namespace.c | 2 +- src/proto_tcp.c | 2 +- src/server.c | 2 +- src/standard.c | 1 + 13 files changed, 96 insertions(+), 42 deletions(-) delete mode 100644 include/common/namespace.h create mode 100644 include/haproxy/namespace-t.h create mode 100644 include/haproxy/namespace.h diff --git a/include/common/namespace.h b/include/common/namespace.h deleted file mode 100644 index 596aac344e..0000000000 --- a/include/common/namespace.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _NAMESPACE_H -#define _NAMESPACE_H - -#include -#include - -#ifdef USE_NS - -struct netns_entry -{ - struct ebpt_node node; - size_t name_len; - 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 /* USE_NS */ - -#endif /* _NAMESPACE_H */ diff --git a/include/common/standard.h b/include/common/standard.h index d2231d8032..fdaa2a8ae8 100644 --- a/include/common/standard.h +++ b/include/common/standard.h @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/haproxy/namespace-t.h b/include/haproxy/namespace-t.h new file mode 100644 index 0000000000..3a9733644e --- /dev/null +++ b/include/haproxy/namespace-t.h @@ -0,0 +1,39 @@ +/* + * include/haproxy/namespace-t.h + * Linux network namespaces types definitions + * + * Copyright (C) 2014 Tamas Kovacs, Sarkozi Laszlo, Krisztian Kovacs + * Copyright (C) 2015-2020 Willy Tarreau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _HAPROXY_NAMESPACE_T_H +#define _HAPROXY_NAMESPACE_T_H + +#include +#include + +/* the struct is just empty if namespaces are not supported */ +struct netns_entry +{ +#ifdef USE_NS + struct ebpt_node node; + size_t name_len; + int fd; +#endif +}; + +#endif /* _HAPROXY_NAMESPACE_T_H */ diff --git a/include/haproxy/namespace.h b/include/haproxy/namespace.h new file mode 100644 index 0000000000..ad52cb1397 --- /dev/null +++ b/include/haproxy/namespace.h @@ -0,0 +1,47 @@ +/* + * include/haproxy/namespace.h + * Linux network namespaces management + * + * Copyright (C) 2014 Tamas Kovacs, Sarkozi Laszlo, Krisztian Kovacs + * Copyright (C) 2015-2020 Willy Tarreau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _HAPROXY_NAMESPACE_H +#define _HAPROXY_NAMESPACE_H + +#include +#include +#include +#include + +#ifdef USE_NS + +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 */ + +static inline int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol) +{ + return socket(domain, type, protocol); +} + +#endif /* USE_NS */ + +#endif /* _HAPROXY_NAMESPACE_H */ diff --git a/src/backend.c b/src/backend.c index c9abbc7ab3..9f87a3c0b8 100644 --- a/src/backend.c +++ b/src/backend.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include diff --git a/src/cfgparse.c b/src/cfgparse.c index 205f4fbee4..8cdfb15a4b 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/connection.c b/src/connection.c index a74585a157..688be9a556 100644 --- a/src/connection.c +++ b/src/connection.c @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include diff --git a/src/filters.c b/src/filters.c index 1b71573530..50d1c8a4cf 100644 --- a/src/filters.c +++ b/src/filters.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/haproxy.c b/src/haproxy.c index 8e5342043f..36f669419a 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -88,7 +88,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/namespace.c b/src/namespace.c index 6165994ec9..4f82c62037 100644 --- a/src/namespace.c +++ b/src/namespace.c @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 9d87515377..973a4d3138 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/server.c b/src/server.c index d06c46502e..29919ee415 100644 --- a/src/server.c +++ b/src/server.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include diff --git a/src/standard.c b/src/standard.c index 2b32429eb2..8e9722e349 100644 --- a/src/standard.c +++ b/src/standard.c @@ -38,6 +38,7 @@ #include #include +#include #include #include #include -- 2.47.2