]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: cfgparse: parse only "global" section in MODE_DISCOVERY
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Tue, 1 Oct 2024 14:11:01 +0000 (16:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2024 20:02:39 +0000 (22:02 +0200)
This commit is a part of the series to add a support of discovery mode in the
configuration parser and in initialization sequence.

So, in discovery mode, when we read the configuration the first time, we
parse for the moment only the "global" section. Unknown section names will be
ignored.

src/cfgparse.c

index 85b74f0d6b7f3db08f5add398dd5237b48aaf2c3..c53e48def520690b8227c29ee741478ed07236b5 100644 (file)
@@ -2565,6 +2565,10 @@ next_line:
                if (pcs && pcs->post_section_parser) {
                        int status;
 
+                       /* for the moment don't call post_section_parser in MODE_DISCOVERY */
+                       if (global.mode & MODE_DISCOVERY)
+                               continue;
+
                        status = pcs->post_section_parser();
                        err_code |= status;
                        if (status & ERR_FATAL)
@@ -2576,12 +2580,19 @@ next_line:
                pcs = NULL;
 
                if (!cs) {
+                       /* ignore unknown section names during the first read in MODE_DISCOVERY */
+                       if (global.mode & MODE_DISCOVERY)
+                               continue;
                        ha_alert("parsing [%s:%d]: unknown keyword '%s' out of section.\n", file, linenum, args[0]);
                        err_code |= ERR_ALERT | ERR_FATAL;
                        fatal++;
                } else {
                        int status;
 
+                       /* for the moment read only the "global" section in MODE_DISCOVERY */
+                       if ((global.mode & MODE_DISCOVERY) && (strcmp(cs->section_name, "global") != 0))
+                               continue;
+
                        status = cs->section_parser(file, linenum, args, kwm);
                        err_code |= status;
                        if (status & ERR_FATAL)