CLEANUP: build: rename some build macros to use the USE_* ones
We still have quite a number of build macros which are mapped 1:1 to a
USE_something setting in the makefile but which have a different name.
This patch cleans this up by renaming them to use the USE_something
one, allowing to clean up the makefile and make it more obvious when
reading the code what build option needs to be added.
The following renames were done :
ENABLE_POLL -> USE_POLL
ENABLE_EPOLL -> USE_EPOLL
ENABLE_KQUEUE -> USE_KQUEUE
ENABLE_EVPORTS -> USE_EVPORTS
TPROXY -> USE_TPROXY
NETFILTER -> USE_NETFILTER
NEED_CRYPT_H -> USE_CRYPT_H
CONFIG_HAP_CRYPT -> USE_LIBCRYPT
CONFIG_HAP_NS -> DUSE_NS
CONFIG_HAP_LINUX_SPLICE -> USE_LINUX_SPLICE
CONFIG_HAP_LINUX_TPROXY -> USE_LINUX_TPROXY
CONFIG_HAP_LINUX_VSYSCALL -> USE_LINUX_VSYSCALL
diff --git a/src/auth.c b/src/auth.c
index 8d1da3e..0232b56 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -10,15 +10,15 @@
*
*/
-#ifdef CONFIG_HAP_CRYPT
+#ifdef USE_LIBCRYPT
/* This is to have crypt() defined on Linux */
#define _GNU_SOURCE
-#ifdef NEED_CRYPT_H
+#ifdef USE_CRYPT_H
/* some platforms such as Solaris need this */
#include <crypt.h>
#endif
-#endif /* CONFIG_HAP_CRYPT */
+#endif /* USE_LIBCRYPT */
#include <stdio.h>
#include <stdlib.h>
@@ -39,7 +39,7 @@
struct userlist *userlist = NULL; /* list of all existing userlists */
-#ifdef CONFIG_HAP_CRYPT
+#ifdef USE_LIBCRYPT
#ifdef HA_HAVE_CRYPT_R
/* context for crypt_r() */
static THREAD_LOCAL struct crypt_data crypt_data = { .initialized = 0 };
@@ -256,7 +256,7 @@
#endif
if (!(u->flags & AU_O_INSECURE)) {
-#ifdef CONFIG_HAP_CRYPT
+#ifdef USE_LIBCRYPT
#ifdef HA_HAVE_CRYPT_R
ep = crypt_r(pass, u->pass, &crypt_data);
#else
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index 9e2f44c..f96f154 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -3320,7 +3320,7 @@
goto out;
}
}
-#ifdef TPROXY
+#ifdef USE_TPROXY
else if (!strcmp(args[0], "transparent")) {
/* enable transparent proxy connections */
curproxy->options |= PR_O_TRANSP;
diff --git a/src/cfgparse.c b/src/cfgparse.c
index a16628a..c8918a9 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -10,15 +10,15 @@
*
*/
-#ifdef CONFIG_HAP_CRYPT
+#ifdef USE_LIBCRYPT
/* This is to have crypt() defined on Linux */
#define _GNU_SOURCE
-#ifdef NEED_CRYPT_H
+#ifdef USE_CRYPT_H
/* some platforms such as Solaris need this */
#include <crypt.h>
#endif
-#endif /* CONFIG_HAP_CRYPT */
+#endif /* USE_LIBCRYPT */
#include <stdio.h>
#include <stdlib.h>
@@ -1505,7 +1505,7 @@
int
cfg_parse_netns(const char *file, int linenum, char **args, int kwm)
{
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
const char *err;
const char *item = args[0];
@@ -1701,7 +1701,7 @@
while (*args[cur_arg]) {
if (!strcmp(args[cur_arg], "password")) {
-#ifdef CONFIG_HAP_CRYPT
+#ifdef USE_LIBCRYPT
if (!crypt("", args[cur_arg + 1])) {
ha_alert("parsing [%s:%d]: the encrypted password used for user '%s' is not supported by crypt(3).\n",
file, linenum, newuser->user);
diff --git a/src/cli.c b/src/cli.c
index 23ab57b..4b430a9 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -1654,7 +1654,7 @@
memcpy(&tmpfd[i % MAX_SEND_FD], &l->fd, sizeof(l->fd));
if (!l->netns)
tmpbuf[curoff++] = 0;
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
else {
char *name = l->netns->node.key;
unsigned char len = l->netns->name_len;
diff --git a/src/connection.c b/src/connection.c
index 908d098..4b4a314 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -694,7 +694,7 @@
goto bad_header;
break;
}
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
case PP2_TYPE_NETNS: {
const struct netns_entry *ns;
ns = netns_store_lookup((char*)tlv_packet->value, tlv_len);
@@ -1228,7 +1228,7 @@
}
#endif
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
if (remote && (remote->proxy_netns)) {
if ((buf_len - ret) < sizeof(struct tlv))
return 0;
diff --git a/src/fd.c b/src/fd.c
index d924155..d87dddc 100644
--- a/src/fd.c
+++ b/src/fd.c
@@ -151,7 +151,7 @@
#include <sys/types.h>
#include <sys/resource.h>
-#if defined(ENABLE_POLL)
+#if defined(USE_POLL)
#include <poll.h>
#include <errno.h>
#endif
@@ -477,7 +477,7 @@
closefrom(start);
}
-#elif defined(ENABLE_POLL)
+#elif defined(USE_POLL)
/* This is a portable implementation of closefrom(). It closes all open file
* descriptors starting at <start> and above. It relies on the fact that poll()
* will return POLLNVAL for each invalid (hence close) file descriptor passed
@@ -534,7 +534,7 @@
}
}
-#else // defined(ENABLE_POLL)
+#else // defined(USE_POLL)
/* This is a portable implementation of closefrom(). It closes all open file
* descriptors starting at <start> and above. This is a naive version for use
@@ -556,7 +556,7 @@
while (start < nbfds)
close(start++);
}
-#endif // defined(ENABLE_POLL)
+#endif // defined(USE_POLL)
/* disable the specified poller */
void disable_poller(const char *poller_name)
diff --git a/src/haproxy.c b/src/haproxy.c
index 33b30b1..306c34f 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -502,19 +502,19 @@
" -N sets the default, per-proxy maximum # of connections (%d)\n"
" -L set local peer name (default to hostname)\n"
" -p writes pids of all children to this file\n"
-#if defined(ENABLE_EPOLL)
+#if defined(USE_EPOLL)
" -de disables epoll() usage even when available\n"
#endif
-#if defined(ENABLE_KQUEUE)
+#if defined(USE_KQUEUE)
" -dk disables kqueue() usage even when available\n"
#endif
-#if defined(ENABLE_EVPORTS)
+#if defined(USE_EVPORTS)
" -dv disables event ports usage even when available\n"
#endif
-#if defined(ENABLE_POLL)
+#if defined(USE_POLL)
" -dp disables poll() usage even when available\n"
#endif
-#if defined(CONFIG_HAP_LINUX_SPLICE)
+#if defined(USE_LINUX_SPLICE)
" -dS disables splice usage (broken on old kernels)\n"
#endif
#if defined(USE_GETADDRINFO)
@@ -1394,19 +1394,19 @@
vars_init(&global.vars, SCOPE_PROC);
global.tune.options |= GTUNE_USE_SELECT; /* select() is always available */
-#if defined(ENABLE_POLL)
+#if defined(USE_POLL)
global.tune.options |= GTUNE_USE_POLL;
#endif
-#if defined(ENABLE_EPOLL)
+#if defined(USE_EPOLL)
global.tune.options |= GTUNE_USE_EPOLL;
#endif
-#if defined(ENABLE_KQUEUE)
+#if defined(USE_KQUEUE)
global.tune.options |= GTUNE_USE_KQUEUE;
#endif
-#if defined(ENABLE_EVPORTS)
+#if defined(USE_EVPORTS)
global.tune.options |= GTUNE_USE_EVPORTS;
#endif
-#if defined(CONFIG_HAP_LINUX_SPLICE)
+#if defined(USE_LINUX_SPLICE)
global.tune.options |= GTUNE_USE_SPLICE;
#endif
#if defined(USE_GETADDRINFO)
@@ -1438,23 +1438,23 @@
display_build_opts();
exit(0);
}
-#if defined(ENABLE_EPOLL)
+#if defined(USE_EPOLL)
else if (*flag == 'd' && flag[1] == 'e')
global.tune.options &= ~GTUNE_USE_EPOLL;
#endif
-#if defined(ENABLE_POLL)
+#if defined(USE_POLL)
else if (*flag == 'd' && flag[1] == 'p')
global.tune.options &= ~GTUNE_USE_POLL;
#endif
-#if defined(ENABLE_KQUEUE)
+#if defined(USE_KQUEUE)
else if (*flag == 'd' && flag[1] == 'k')
global.tune.options &= ~GTUNE_USE_KQUEUE;
#endif
-#if defined(ENABLE_EVPORTS)
+#if defined(USE_EVPORTS)
else if (*flag == 'd' && flag[1] == 'v')
global.tune.options &= ~GTUNE_USE_EVPORTS;
#endif
-#if defined(CONFIG_HAP_LINUX_SPLICE)
+#if defined(USE_LINUX_SPLICE)
else if (*flag == 'd' && flag[1] == 'S')
global.tune.options &= ~GTUNE_USE_SPLICE;
#endif
@@ -1770,7 +1770,7 @@
#endif
}
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
err_code |= netns_init();
if (err_code & (ERR_ABORT|ERR_FATAL)) {
ha_alert("Failed to initialize namespace support.\n");
diff --git a/src/mux_h1.c b/src/mux_h1.c
index 918985e..111e262 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -2273,7 +2273,7 @@
return total;
}
-#if defined(CONFIG_HAP_LINUX_SPLICE)
+#if defined(USE_LINUX_SPLICE)
/* Send and get, using splicing */
static int h1_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int count)
{
@@ -2379,7 +2379,7 @@
.used_streams = h1_used_streams,
.rcv_buf = h1_rcv_buf,
.snd_buf = h1_snd_buf,
-#if defined(CONFIG_HAP_LINUX_SPLICE)
+#if defined(USE_LINUX_SPLICE)
.rcv_pipe = h1_rcv_pipe,
.snd_pipe = h1_snd_pipe,
#endif
diff --git a/src/mux_pt.c b/src/mux_pt.c
index 18bc96e..1c1dd7f 100644
--- a/src/mux_pt.c
+++ b/src/mux_pt.c
@@ -297,7 +297,7 @@
return (cs->conn->xprt->unsubscribe(cs->conn, cs->conn->xprt_ctx, event_type, param));
}
-#if defined(CONFIG_HAP_LINUX_SPLICE)
+#if defined(USE_LINUX_SPLICE)
/* Send and get, using splicing */
static int mux_pt_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int count)
{
@@ -325,7 +325,7 @@
.snd_buf = mux_pt_snd_buf,
.subscribe = mux_pt_subscribe,
.unsubscribe = mux_pt_unsubscribe,
-#if defined(CONFIG_HAP_LINUX_SPLICE)
+#if defined(USE_LINUX_SPLICE)
.rcv_pipe = mux_pt_rcv_pipe,
.snd_pipe = mux_pt_snd_pipe,
#endif
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 95068ee..f595029 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -246,7 +246,7 @@
{
const struct netns_entry *ns = NULL;
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
if (objt_server(conn->target)) {
if (__objt_server(conn->target)->flags & SRV_F_USE_NS_FROM_PP)
ns = conn->proxy_netns;
@@ -632,7 +632,7 @@
if (ret < 0)
return ret;
-#if defined(TPROXY) && defined(SO_ORIGINAL_DST)
+#if defined(USE_TPROXY) && defined(SO_ORIGINAL_DST)
/* For TPROXY and Netfilter's NAT, we can retrieve the original
* IPv4 address before DNAT/REDIRECT. We must not do that with
* other families because v6-mapped IPv4 addresses are still
@@ -778,7 +778,7 @@
(xfer_sock->options & LI_MANDATORY_FLAGS)) {
if ((xfer_sock->namespace == NULL &&
l->netns == NULL)
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
|| (xfer_sock->namespace != NULL &&
l->netns != NULL &&
!strcmp(xfer_sock->namespace,
@@ -1862,7 +1862,7 @@
}
#endif
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
/* parse the "namespace" bind keyword */
static int bind_parse_namespace(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
{
@@ -1979,7 +1979,7 @@
{ "v4v6", bind_parse_v4v6, 0 }, /* force socket to bind to IPv4+IPv6 */
{ "v6only", bind_parse_v6only, 0 }, /* force socket to bind to IPv6 only */
#endif
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
{ "namespace", bind_parse_namespace, 1 },
#endif
/* the versions with the NULL parse function*/
diff --git a/src/proxy.c b/src/proxy.c
index 7b8e294..9fda6e2 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -77,7 +77,7 @@
{ "nolinger", PR_O_TCP_NOLING, PR_CAP_FE | PR_CAP_BE, 0, 0 },
{ "persist", PR_O_PERSIST, PR_CAP_BE, 0, 0 },
{ "srvtcpka", PR_O_TCP_SRV_KA, PR_CAP_BE, 0, 0 },
-#ifdef TPROXY
+#ifdef USE_TPROXY
{ "transparent", PR_O_TRANSP, PR_CAP_BE, 0, 0 },
#else
{ "transparent", 0, 0, 0, 0 },
@@ -89,7 +89,7 @@
/* proxy->options2 */
const struct cfg_opt cfg_opts2[] =
{
-#ifdef CONFIG_HAP_LINUX_SPLICE
+#ifdef USE_LINUX_SPLICE
{ "splice-request", PR_O2_SPLIC_REQ, PR_CAP_FE|PR_CAP_BE, 0, 0 },
{ "splice-response", PR_O2_SPLIC_RTR, PR_CAP_FE|PR_CAP_BE, 0, 0 },
{ "splice-auto", PR_O2_SPLIC_AUT, PR_CAP_FE|PR_CAP_BE, 0, 0 },
diff --git a/src/raw_sock.c b/src/raw_sock.c
index 6dde3f8..59a7cbc 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -42,7 +42,7 @@
#include <types/global.h>
-#if defined(CONFIG_HAP_LINUX_SPLICE)
+#if defined(USE_LINUX_SPLICE)
#include <common/splice.h>
/* A pipe contains 16 segments max, and it's common to see segments of 1448 bytes
@@ -237,7 +237,7 @@
return done;
}
-#endif /* CONFIG_HAP_LINUX_SPLICE */
+#endif /* USE_LINUX_SPLICE */
/* Receive up to <count> bytes from connection <conn>'s socket and store them
@@ -435,7 +435,7 @@
.rcv_buf = raw_sock_to_buf,
.subscribe = raw_sock_subscribe,
.unsubscribe = raw_sock_unsubscribe,
-#if defined(CONFIG_HAP_LINUX_SPLICE)
+#if defined(USE_LINUX_SPLICE)
.rcv_pipe = raw_sock_to_pipe,
.snd_pipe = raw_sock_from_pipe,
#endif
diff --git a/src/server.c b/src/server.c
index b88ab30..52c71a6 100644
--- a/src/server.c
+++ b/src/server.c
@@ -454,7 +454,7 @@
static int srv_parse_namespace(char **args, int *cur_arg,
struct proxy *curproxy, struct server *newsrv, char **err)
{
-#ifdef CONFIG_HAP_NS
+#ifdef USE_NS
char *arg;
arg = args[*cur_arg + 1];