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).
This commit is contained in:
Willy Tarreau 2020-06-02 17:02:59 +02:00
parent 6131d6a731
commit 7a00efbe43
13 changed files with 96 additions and 42 deletions

View File

@ -1,33 +0,0 @@
#ifndef _NAMESPACE_H
#define _NAMESPACE_H
#include <stdlib.h>
#include <import/ebistree.h>
#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 */

View File

@ -40,7 +40,7 @@
#include <haproxy/api.h>
#include <haproxy/intops.h>
#include <haproxy/chunk.h>
#include <common/namespace.h>
#include <haproxy/namespace-t.h>
#include <import/eb32tree.h>
#include <import/eb32sctree.h>
#include <types/protocol.h>

View File

@ -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 <stddef.h>
#include <import/ebpttree.h>
/* 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 */

View File

@ -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 <sys/types.h>
#include <sys/socket.h>
#include <haproxy/namespace-t.h>
#include <import/ebistree.h>
#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 */

View File

@ -24,7 +24,7 @@
#include <common/htx.h>
#include <common/ticks.h>
#include <haproxy/time.h>
#include <common/namespace.h>
#include <haproxy/namespace.h>
#include <types/global.h>

View File

@ -41,7 +41,7 @@
#include <common/standard.h>
#include <haproxy/time.h>
#include <common/uri_auth.h>
#include <common/namespace.h>
#include <haproxy/namespace.h>
#include <haproxy/thread.h>
#include <types/capture.h>

View File

@ -14,7 +14,7 @@
#include <haproxy/api.h>
#include <common/cfgparse.h>
#include <common/namespace.h>
#include <haproxy/namespace.h>
#include <haproxy/hash.h>
#include <haproxy/net_helper.h>

View File

@ -15,7 +15,7 @@
#include <common/cfgparse.h>
#include <haproxy/errors.h>
#include <common/htx.h>
#include <common/namespace.h>
#include <haproxy/namespace.h>
#include <common/standard.h>
#include <types/filters.h>

View File

@ -88,7 +88,7 @@
#include <haproxy/errors.h>
#include <haproxy/pool.h>
#include <haproxy/list.h>
#include <common/namespace.h>
#include <haproxy/namespace.h>
#include <haproxy/net_helper.h>
#include <haproxy/openssl-compat.h>
#include <common/regex.h>

View File

@ -11,7 +11,7 @@
#include <string.h>
#include <haproxy/api.h>
#include <common/namespace.h>
#include <haproxy/namespace.h>
#include <haproxy/hash.h>
#include <haproxy/errors.h>
#include <proto/log.h>

View File

@ -34,7 +34,7 @@
#include <haproxy/errors.h>
#include <haproxy/list.h>
#include <common/standard.h>
#include <common/namespace.h>
#include <haproxy/namespace.h>
#include <types/action.h>
#include <types/connection.h>

View File

@ -19,7 +19,7 @@
#include <common/cfgparse.h>
#include <haproxy/errors.h>
#include <common/namespace.h>
#include <haproxy/namespace.h>
#include <haproxy/time.h>
#include <types/applet.h>

View File

@ -38,6 +38,7 @@
#include <haproxy/api.h>
#include <haproxy/chunk.h>
#include <haproxy/namespace.h>
#include <common/standard.h>
#include <types/global.h>
#include <proto/applet.h>