]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: add a new capability PR_CAP_DEF
authorWilly Tarreau <w@1wt.eu>
Fri, 12 Feb 2021 08:43:33 +0000 (09:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 12 Feb 2021 15:23:46 +0000 (16:23 +0100)
In order to more easily distinguish a default proxy from a standard one,
let's introduce a new capability PR_CAP_DEF.

include/haproxy/proxy-t.h
src/cfgparse-listen.c
src/proxy.c

index 247028460a644efbbaf789f6589a0f2f2b5389ec..3fdd09d625419313838041a9b01a3b122dfaee80 100644 (file)
@@ -66,6 +66,7 @@ enum PR_SRV_STATE_FILE {
 #define PR_CAP_FE      0x0001
 #define PR_CAP_BE      0x0002
 #define PR_CAP_LISTEN  (PR_CAP_FE|PR_CAP_BE)
+#define PR_CAP_DEF     0x0004           /* defaults section */
 
 /* bits for proxy->options */
 #define PR_O_REDISP     0x00000001      /* allow reconnection to dispatch in case of errors */
index ffe793156344d2889ae3650782c55b9e3cfa2771..176025933ec1b375d0c0067e70f5964483a89374 100644 (file)
@@ -192,10 +192,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                rc = PR_CAP_FE;
        else if (strcmp(args[0], "backend") == 0)
                rc = PR_CAP_BE;
+       else if (strcmp(args[0], "defaults") == 0)
+               rc = PR_CAP_DEF;
        else
                rc = PR_CAP_NONE;
 
-       if (rc != PR_CAP_NONE) {  /* new proxy */
+       if (rc & PR_CAP_LISTEN) {  /* new proxy */
                if (!*args[1]) {
                        ha_alert("parsing [%s:%d] : '%s' expects an <id> argument\n",
                                 file, linenum, args[0]);
@@ -257,7 +259,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                curproxy = &defproxy;
                curproxy->conf.args.file = curproxy->conf.file = strdup(file);
                curproxy->conf.args.line = curproxy->conf.line = linenum;
-               defproxy.cap = PR_CAP_LISTEN; /* all caps for now */
+               defproxy.cap = PR_CAP_DEF | PR_CAP_LISTEN; /* all caps for now */
                goto out;
        }
        else if (curproxy == NULL) {
index 370e759e843e431ea13e35429294cea41bf56f89..a0aaa5ca635b7b3fb14a79d530aa79286587a4ee 100644 (file)
@@ -116,11 +116,15 @@ const struct cfg_opt cfg_opts2[] =
 /*
  * This function returns a string containing a name describing capabilities to
  * report comprehensible error messages. Specifically, it will return the words
- * "frontend", "backend" when appropriate, or "proxy" for all other
- * cases including the proxies declared in "listen" mode.
+ * "frontend", "backend" when appropriate, "defaults" if it corresponds to a
+ * defaults section, or "proxy" for all other cases including the proxies
+ * declared in "listen" mode.
  */
 const char *proxy_cap_str(int cap)
 {
+       if (cap & PR_CAP_DEF)
+               return "defaults";
+
        if ((cap & PR_CAP_LISTEN) != PR_CAP_LISTEN) {
                if (cap & PR_CAP_FE)
                        return "frontend";