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.
This commit is contained in:
Willy Tarreau 2020-09-03 07:18:55 +02:00
parent 6e459d7f92
commit e26993c098
9 changed files with 32 additions and 32 deletions

View File

@ -173,14 +173,14 @@ struct bind_conf {
int level; /* stats access level (ACCESS_LVL_*) */ int level; /* stats access level (ACCESS_LVL_*) */
int severity_output; /* default severity output format in cli feedback messages */ int severity_output; /* default severity output format in cli feedback messages */
struct list listeners; /* list of listeners using this bind config */ 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 */ uint32_t ns_cip_magic; /* Excepted NetScaler Client IP magic number */
struct list by_fe; /* next binding for the same frontend, or NULL */ struct list by_fe; /* next binding for the same frontend, or NULL */
char *arg; /* argument passed to "bind" for better error reporting */ char *arg; /* argument passed to "bind" for better error reporting */
char *file; /* file where the section appears */ char *file; /* file where the section appears */
int line; /* line where the section appears */ int line; /* line where the section appears */
struct { 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 */ struct { /* UNIX socket permissions */
uid_t uid; /* -1 to leave unchanged */ uid_t uid; /* -1 to leave unchanged */
gid_t gid; /* -1 to leave unchanged */ gid_t gid; /* -1 to leave unchanged */

View File

@ -2323,7 +2323,7 @@ int check_config_validity()
#endif #endif
/* detect and address thread affinity inconsistencies */ /* 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)) { if (!(mask & all_threads_mask)) {
unsigned long new_mask = 0; unsigned long new_mask = 0;
@ -2332,27 +2332,27 @@ int check_config_validity()
mask >>= global.nbthread; 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", 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); curproxy->id, bind_conf->arg, bind_conf->file, bind_conf->line, new_mask);
} }
/* detect process and nbproc affinity inconsistencies */ /* 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)) { if (!(mask & all_proc_mask)) {
mask = proc_mask(curproxy->bind_proc) & all_proc_mask; mask = proc_mask(curproxy->bind_proc) & all_proc_mask;
nbproc = my_popcountl(bind_conf->bind_proc); nbproc = my_popcountl(bind_conf->settings.bind_proc);
bind_conf->bind_proc = proc_mask(bind_conf->bind_proc) & mask; 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", 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); 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", 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); 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 @@ int check_config_validity()
unsigned long mask; unsigned long mask;
mask = proc_mask(global.stats_fe->bind_proc) && all_proc_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 */ /* stop here if more than one process is used */
if (atleast2(mask)) if (atleast2(mask))
@ -3660,7 +3660,7 @@ int check_config_validity()
list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) { list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) {
unsigned long mask; 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 |= mask;
} }
curproxy->bind_proc = proc_mask(curproxy->bind_proc); curproxy->bind_proc = proc_mask(curproxy->bind_proc);
@ -3670,7 +3670,7 @@ int check_config_validity()
list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) { list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
unsigned long mask; 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 |= mask;
} }
global.stats_fe->bind_proc = proc_mask(global.stats_fe->bind_proc); global.stats_fe->bind_proc = proc_mask(global.stats_fe->bind_proc);
@ -3716,7 +3716,7 @@ int check_config_validity()
int nbproc; int nbproc;
nbproc = my_popcountl(curproxy->bind_proc & 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); all_proc_mask);
if (!nbproc) /* no intersection between listener and frontend */ if (!nbproc) /* no intersection between listener and frontend */
@ -3787,7 +3787,7 @@ int check_config_validity()
int count, maxproc = 0; int count, maxproc = 0;
list_for_each_entry(bind_conf, &curproxy->conf.bind, by_fe) { 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) if (count > maxproc)
maxproc = count; maxproc = count;
} }

View File

@ -1270,10 +1270,10 @@ static int cli_io_handler_show_cli_sock(struct appctx *appctx)
else else
chunk_appendf(&trash, " "); chunk_appendf(&trash, " ");
if (bind_conf->bind_proc != 0) { if (bind_conf->settings.bind_proc != 0) {
int pos; int pos;
for (pos = 0; pos < 8 * sizeof(bind_conf->bind_proc); pos++) { for (pos = 0; pos < 8 * sizeof(bind_conf->settings.bind_proc); pos++) {
if (bind_conf->bind_proc & (1UL << pos)) { if (bind_conf->settings.bind_proc & (1UL << pos)) {
chunk_appendf(&trash, "%d,", pos+1); 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_MASK;
bind_conf->level |= ACCESS_LVL_ADMIN; /* TODO: need to lower the rights with a CLI keyword*/ 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 */ 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])) { if (!memprintf(&path, "sockpair@%d", mworker_proc->ipc_fd[1])) {

View File

@ -3464,7 +3464,7 @@ int main(int argc, char **argv)
list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) { list_for_each_entry(bind_conf, &global.stats_fe->conf.bind, by_fe) {
if (bind_conf->level & ACCESS_FD_LISTENERS) { 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; global.tune.options |= GTUNE_SOCKET_TRANSFER;
break; break;
} }

View File

@ -235,7 +235,7 @@ static void enable_listener(struct listener *listener)
HA_SPIN_LOCK(LISTENER_LOCK, &listener->lock); HA_SPIN_LOCK(LISTENER_LOCK, &listener->lock);
if (listener->state == LI_LISTEN) { if (listener->state == LI_LISTEN) {
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) && 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 /* we don't want to enable this listener and don't
* want any fd event to reach it. * want any fd event to reach it.
*/ */
@ -342,7 +342,7 @@ int resume_listener(struct listener *l)
goto end; goto end;
if ((global.mode & (MODE_DAEMON | MODE_MWORKER)) && 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; goto end;
if (l->state == LI_ASSIGNED) { if (l->state == LI_ASSIGNED) {
@ -383,11 +383,11 @@ int resume_listener(struct listener *l)
goto end; 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 /* we're not allowed to touch this listener's FD, let's requeue
* the listener into one of its owning thread's queue instead. * 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); work_list_add(&local_listener_queue[first_thread], &l->wait_queue);
goto end; goto end;
} }
@ -874,7 +874,7 @@ void listener_accept(int fd)
next_actconn = 0; next_actconn = 0;
#if defined(USE_THREAD) #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) { if (atleast2(mask) && (global.tune.options & GTUNE_LISTENER_MQ) && !stopping) {
struct accept_queue_ring *ring; struct accept_queue_ring *ring;
unsigned int t, t0, t1, t2; 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 = '/'; *slash = '/';
} }
conf->bind_proc |= proc; conf->settings.bind_proc |= proc;
conf->bind_thread |= thread; conf->settings.bind_thread |= thread;
return 0; return 0;
} }

View File

@ -126,7 +126,7 @@ static int sockpair_bind_listener(struct listener *listener, char *errmsg, int e
listener->state = LI_LISTEN; listener->state = LI_LISTEN;
fd_insert(fd, listener, listener->proto->accept, 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; return err;

View File

@ -768,7 +768,7 @@ int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen)
listener->state = LI_LISTEN; listener->state = LI_LISTEN;
fd_insert(fd, listener, listener->proto->accept, 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 */ /* for now, all regularly bound TCP listeners are exportable */
if (!(listener->options & LI_O_INHERITED)) if (!(listener->options & LI_O_INHERITED))

View File

@ -279,7 +279,7 @@ int udp_bind_listener(struct listener *listener, char *errmsg, int errlen)
if (listener->bind_conf->frontend->mode == PR_MODE_SYSLOG) if (listener->bind_conf->frontend->mode == PR_MODE_SYSLOG)
fd_insert(fd, listener, syslog_fd_handler, 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 { else {
err |= ERR_FATAL | ERR_ALERT; err |= ERR_FATAL | ERR_ALERT;
msg = "UDP is not yet supported on this proxy mode"; msg = "UDP is not yet supported on this proxy mode";

View File

@ -263,7 +263,7 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
listener->state = LI_LISTEN; listener->state = LI_LISTEN;
fd_insert(fd, listener, listener->proto->accept, 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 */ /* for now, all regularly bound UNIX listeners are exportable */
if (!(listener->options & LI_O_INHERITED)) if (!(listener->options & LI_O_INHERITED))