From e26993c098be16cb28971b0843ff48afb58d598a Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 3 Sep 2020 07:18:55 +0200 Subject: [PATCH] MINOR: listener: move bind_proc and bind_thread to struct settings As mentioned previously, these two fields come under the settings struct since they'll be used to bind receivers as well. --- include/haproxy/listener-t.h | 4 ++-- src/cfgparse.c | 28 ++++++++++++++-------------- src/cli.c | 8 ++++---- src/haproxy.c | 2 +- src/listener.c | 14 +++++++------- src/proto_sockpair.c | 2 +- src/proto_tcp.c | 2 +- src/proto_udp.c | 2 +- src/proto_uxst.c | 2 +- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index 97ef5dde4c..45f30d3872 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -173,14 +173,14 @@ struct bind_conf { int level; /* stats access level (ACCESS_LVL_*) */ int severity_output; /* default severity output format in cli feedback messages */ struct list listeners; /* list of listeners using this bind config */ - unsigned long bind_proc; /* bitmask of processes allowed to use these listeners */ - unsigned long bind_thread; /* bitmask of threads allowed to use these listeners */ uint32_t ns_cip_magic; /* Excepted NetScaler Client IP magic number */ struct list by_fe; /* next binding for the same frontend, or NULL */ char *arg; /* argument passed to "bind" for better error reporting */ char *file; /* file where the section appears */ int line; /* line where the section appears */ struct { + unsigned long bind_proc; /* bitmask of processes allowed to use these listeners */ + unsigned long bind_thread; /* bitmask of threads allowed to use these listeners */ struct { /* UNIX socket permissions */ uid_t uid; /* -1 to leave unchanged */ gid_t gid; /* -1 to leave unchanged */ diff --git a/src/cfgparse.c b/src/cfgparse.c index c5b2b20dd4..cc787b2dee 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -2323,7 +2323,7 @@ int check_config_validity() #endif /* detect and address thread affinity inconsistencies */ - mask = thread_mask(bind_conf->bind_thread); + mask = thread_mask(bind_conf->settings.bind_thread); if (!(mask & all_threads_mask)) { unsigned long new_mask = 0; @@ -2332,27 +2332,27 @@ int check_config_validity() mask >>= global.nbthread; } - bind_conf->bind_thread = new_mask; + bind_conf->settings.bind_thread = new_mask; ha_warning("Proxy '%s': the thread range specified on the 'process' directive of 'bind %s' at [%s:%d] only refers to thread numbers out of the range defined by the global 'nbthread' directive. The thread numbers were remapped to existing threads instead (mask 0x%lx).\n", curproxy->id, bind_conf->arg, bind_conf->file, bind_conf->line, new_mask); } /* detect process and nbproc affinity inconsistencies */ - mask = proc_mask(bind_conf->bind_proc) & proc_mask(curproxy->bind_proc); + mask = proc_mask(bind_conf->settings.bind_proc) & proc_mask(curproxy->bind_proc); if (!(mask & all_proc_mask)) { mask = proc_mask(curproxy->bind_proc) & all_proc_mask; - nbproc = my_popcountl(bind_conf->bind_proc); - bind_conf->bind_proc = proc_mask(bind_conf->bind_proc) & mask; + nbproc = my_popcountl(bind_conf->settings.bind_proc); + bind_conf->settings.bind_proc = proc_mask(bind_conf->settings.bind_proc) & mask; - if (!bind_conf->bind_proc && nbproc == 1) { + if (!bind_conf->settings.bind_proc && nbproc == 1) { ha_warning("Proxy '%s': the process number specified on the 'process' directive of 'bind %s' at [%s:%d] refers to a process not covered by the proxy. This has been fixed by forcing it to run on the proxy's first process only.\n", curproxy->id, bind_conf->arg, bind_conf->file, bind_conf->line); - bind_conf->bind_proc = mask & ~(mask - 1); + bind_conf->settings.bind_proc = mask & ~(mask - 1); } - else if (!bind_conf->bind_proc && nbproc > 1) { + else if (!bind_conf->settings.bind_proc && nbproc > 1) { ha_warning("Proxy '%s': the process range specified on the 'process' directive of 'bind %s' at [%s:%d] only refers to processes not covered by the proxy. The directive was ignored so that all of the proxy's processes are used.\n", curproxy->id, bind_conf->arg, bind_conf->file, bind_conf->line); - bind_conf->bind_proc = 0; + bind_conf->settings.bind_proc = 0; } } } @@ -3641,7 +3641,7 @@ out_uri_auth_compat: unsigned long mask; mask = proc_mask(global.stats_fe->bind_proc) && all_proc_mask; - mask &= proc_mask(bind_conf->bind_proc); + mask &= proc_mask(bind_conf->settings.bind_proc); /* stop here if more than one process is used */ if (atleast2(mask)) @@ -3660,7 +3660,7 @@ out_uri_auth_compat: list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) { unsigned long mask; - mask = proc_mask(bind_conf->bind_proc); + mask = proc_mask(bind_conf->settings.bind_proc); curproxy->bind_proc |= mask; } curproxy->bind_proc = proc_mask(curproxy->bind_proc); @@ -3670,7 +3670,7 @@ out_uri_auth_compat: list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) { unsigned long mask; - mask = bind_conf->bind_proc ? bind_conf->bind_proc : 0; + mask = bind_conf->settings.bind_proc ? bind_conf->settings.bind_proc : 0; global.stats_fe->bind_proc |= mask; } global.stats_fe->bind_proc = proc_mask(global.stats_fe->bind_proc); @@ -3716,7 +3716,7 @@ out_uri_auth_compat: int nbproc; nbproc = my_popcountl(curproxy->bind_proc & - (listener->bind_conf->bind_proc ? listener->bind_conf->bind_proc : curproxy->bind_proc) & + (listener->bind_conf->settings.bind_proc ? listener->bind_conf->settings.bind_proc : curproxy->bind_proc) & all_proc_mask); if (!nbproc) /* no intersection between listener and frontend */ @@ -3787,7 +3787,7 @@ out_uri_auth_compat: int count, maxproc = 0; list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) { - count = my_popcountl(bind_conf->bind_proc); + count = my_popcountl(bind_conf->settings.bind_proc); if (count > maxproc) maxproc = count; } diff --git a/src/cli.c b/src/cli.c index 673e173e04..a455be148d 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1270,10 +1270,10 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx) else chunk_appendf(&trash, " "); - if (bind_conf->bind_proc != 0) { + if (bind_conf->settings.bind_proc != 0) { int pos; - for (pos = 0; pos < 8 * sizeof(bind_conf->bind_proc); pos++) { - if (bind_conf->bind_proc & (1UL << pos)) { + for (pos = 0; pos < 8 * sizeof(bind_conf->settings.bind_proc); pos++) { + if (bind_conf->settings.bind_proc & (1UL << pos)) { chunk_appendf(&trash, "%d,", pos+1); } } @@ -2650,7 +2650,7 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc) bind_conf->level &= ~ACCESS_LVL_MASK; bind_conf->level |= ACCESS_LVL_ADMIN; /* TODO: need to lower the rights with a CLI keyword*/ - bind_conf->bind_proc = 1UL << proc; + bind_conf->settings.bind_proc = 1UL << proc; global.stats_fe->bind_proc = 0; /* XXX: we should be careful with that, it can be removed by configuration */ if (!memprintf(&path, "sockpair@%d", mworker_proc->ipc_fd[1])) { diff --git a/src/haproxy.c b/src/haproxy.c index 588ca1a86c..0f72d5ad8f 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3464,7 +3464,7 @@ int main(int argc, char **argv) list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) { if (bind_conf->level & ACCESS_FD_LISTENERS) { - if (!bind_conf->bind_proc || bind_conf->bind_proc & (1UL << proc)) { + if (!bind_conf->settings.bind_proc || bind_conf->settings.bind_proc & (1UL << proc)) { global.tune.options |= GTUNE_SOCKET_TRANSFER; break; } diff --git a/src/listener.c b/src/listener.c index 42ab3f2a39..b0efa93813 100644 --- a/src/listener.c +++ b/src/listener.c @@ -235,7 +235,7 @@ static void enable_listener(struct listener *listener) HA_SPIN_LOCK(LISTENER_LOCK, &listener->lock); if (listener->state == LI_LISTEN) { if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) && - !(proc_mask(listener->bind_conf->bind_proc) & pid_bit)) { + !(proc_mask(listener->bind_conf->settings.bind_proc) & pid_bit)) { /* we don't want to enable this listener and don't * want any fd event to reach it. */ @@ -342,7 +342,7 @@ int resume_listener(struct listener *l) goto end; if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) && - !(proc_mask(l->bind_conf->bind_proc) & pid_bit)) + !(proc_mask(l->bind_conf->settings.bind_proc) & pid_bit)) goto end; if (l->state == LI_ASSIGNED) { @@ -383,11 +383,11 @@ int resume_listener(struct listener *l) goto end; } - if (!(thread_mask(l->bind_conf->bind_thread) & tid_bit)) { + if (!(thread_mask(l->bind_conf->settings.bind_thread) & tid_bit)) { /* we're not allowed to touch this listener's FD, let's requeue * the listener into one of its owning thread's queue instead. */ - int first_thread = my_flsl(thread_mask(l->bind_conf->bind_thread) & all_threads_mask) - 1; + int first_thread = my_flsl(thread_mask(l->bind_conf->settings.bind_thread) & all_threads_mask) - 1; work_list_add(&local_listener_queue[first_thread], &l->wait_queue); goto end; } @@ -874,7 +874,7 @@ void listener_accept(int fd) next_actconn = 0; #if defined(USE_THREAD) - mask = thread_mask(l->bind_conf->bind_thread) & all_threads_mask; + mask = thread_mask(l->bind_conf->settings.bind_thread) & all_threads_mask; if (atleast2(mask) && (global.tune.options & GTUNE_LISTENER_MQ) && !stopping) { struct accept_queue_ring *ring; unsigned int t, t0, t1, t2; @@ -1472,8 +1472,8 @@ static int bind_parse_process(char **args, int cur_arg, struct proxy *px, struct *slash = '/'; } - conf->bind_proc |= proc; - conf->bind_thread |= thread; + conf->settings.bind_proc |= proc; + conf->settings.bind_thread |= thread; return 0; } diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index 18fa77029f..ff7c0a2512 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -126,7 +126,7 @@ static int sockpair_bind_listener(struct listener *listener, char *errmsg, int e listener->state = LI_LISTEN; fd_insert(fd, listener, listener->proto->accept, - thread_mask(listener->bind_conf->bind_thread) & all_threads_mask); + thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask); return err; diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 56e93916ec..57bef86007 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -768,7 +768,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen) listener->state = LI_LISTEN; fd_insert(fd, listener, listener->proto->accept, - thread_mask(listener->bind_conf->bind_thread) & all_threads_mask); + thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask); /* for now, all regularly bound TCP listeners are exportable */ if (!(listener->options & LI_O_INHERITED)) diff --git a/src/proto_udp.c b/src/proto_udp.c index be100b54c0..5ec8bc742a 100644 --- a/src/proto_udp.c +++ b/src/proto_udp.c @@ -279,7 +279,7 @@ int udp_bind_listener(struct listener *listener, char *errmsg, int errlen) if (listener->bind_conf->frontend->mode == PR_MODE_SYSLOG) fd_insert(fd, listener, syslog_fd_handler, - thread_mask(listener->bind_conf->bind_thread) & all_threads_mask); + thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask); else { err |= ERR_FATAL | ERR_ALERT; msg = "UDP is not yet supported on this proxy mode"; diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 8be2219f2f..ac2fb536eb 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -263,7 +263,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle listener->state = LI_LISTEN; fd_insert(fd, listener, listener->proto->accept, - thread_mask(listener->bind_conf->bind_thread) & all_threads_mask); + thread_mask(listener->bind_conf->settings.bind_thread) & all_threads_mask); /* for now, all regularly bound UNIX listeners are exportable */ if (!(listener->options & LI_O_INHERITED)) -- 2.47.3