]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: listener: move bind_proc and bind_thread to struct settings
authorWilly Tarreau <w@1wt.eu>
Thu, 3 Sep 2020 05:18:55 +0000 (07:18 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Sep 2020 18:13:13 +0000 (20:13 +0200)
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
src/cfgparse.c
src/cli.c
src/haproxy.c
src/listener.c
src/proto_sockpair.c
src/proto_tcp.c
src/proto_udp.c
src/proto_uxst.c

index 97ef5dde4c66d2377cfedbcd8b9ee7825a13f31c..45f30d38723dbab4dfaec7d89754c0e1a4136b89 100644 (file)
@@ -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 */
index c5b2b20dd4e69ee0f20a8cef20240dd70a969f1d..cc787b2dee02e9773bcdc3c88c561df57d5b9857 100644 (file)
@@ -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;
                                }
index 673e173e04944b5802bc6e3d0b89320cb4ed88e0..a455be148dfcd53ccb33ac0210ee46da949616d0 100644 (file)
--- 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])) {
index 588ca1a86c07d04e2175208c628a1bc7a980624a..0f72d5ad8ffb05a36fb7e9081a76029186c6bdf7 100644 (file)
@@ -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;
                                        }
index 42ab3f2a393dc74725bf8432cccc5741ebd095d1..b0efa93813bfa3b65ec43cc6422d95df5fc0ce6e 100644 (file)
@@ -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;
 }
 
index 18fa77029f100bff4bd5f6e25d19d83da991a701..ff7c0a251222937e4333182245d00fbfb393646c 100644 (file)
@@ -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;
 
index 56e93916ecef32399935a6eb9d1b0085a316913c..57bef860076821ee5686c4a87fd6d36a253aed20 100644 (file)
@@ -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))
index be100b54c07df73227035301a8788450924bf797..5ec8bc742a23795a23652024312f6adde4290649 100644 (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)
                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";
index 8be2219f2ff6ea71e5d89af8bce45eae3feee4e6..ac2fb536eb411be5f8e9d4eb01022d9b5b072d9a 100644 (file)
@@ -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))