]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: config: enumerate full list of registered "bind" keywords upon error
authorWilly Tarreau <w@1wt.eu>
Tue, 18 Sep 2012 16:01:17 +0000 (18:01 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 18 Sep 2012 16:27:14 +0000 (18:27 +0200)
When an unknown "bind" keyword is detected, dump the list of all
registered keywords. Unsupported default alternatives are also reported
as "not supported".

include/proto/listener.h
src/cfgparse.c
src/listener.c

index e570a9bb0e8c0a813f8a2908cdfa08eaf345b5d6..bd571890c0b59469e92449d1ee3eeee842265e54 100644 (file)
@@ -114,6 +114,9 @@ void bind_register_keywords(struct bind_kw_list *kwl);
 /* Return a pointer to the bind keyword <kw>, or NULL if not found. */
 struct bind_kw *bind_find_kw(const char *kw);
 
+/* Dumps all registered "bind" keywords to the <out> string pointer. */
+void bind_dump_kws(char **out);
+
 /* allocate an bind_conf struct for a bind line, and chain it to list head <lh>.
  * If <arg> is not NULL, it is duplicated into ->arg to store useful config
  * information for error reporting.
index 08780ff04673dfeb9d091ad120484dc8ac080f74..6a12d4028f856515a6053e17fb13d553f4a7e12b 100644 (file)
@@ -1709,7 +1709,10 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                }
                cur_arg = 2;
                while (*(args[cur_arg])) {
+                       static int bind_dumped;
                        struct bind_kw *kw;
+                       char *err;
+
                        kw = bind_find_kw(args[cur_arg]);
                        if (kw) {
                                char *err = NULL;
@@ -1745,8 +1748,18 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                                continue;
                        }
 
-                       Alert("parsing [%s:%d] : '%s %s' only supports the 'transparent', 'accept-proxy', 'defer-accept', 'name', 'id', 'mss', 'mode', 'uid', 'gid', 'user', 'group' and 'interface' options.\n",
-                             file, linenum, args[0], args[1]);
+                       err = NULL;
+                       if (!bind_dumped) {
+                               bind_dump_kws(&err);
+                               indent_msg(&err, 4);
+                               bind_dumped = 1;
+                       }
+
+                       Alert("parsing [%s:%d] : '%s %s' unknown keyword '%s'.%s%s\n",
+                             file, linenum, args[0], args[1], args[cur_arg],
+                             err ? " Registered keywords :" : "", err ? err : "");
+                       free(err);
+
                        err_code |= ERR_ALERT | ERR_FATAL;
                        goto out;
                }
index 91c0308584e839fb3b0632a7706a0436a9fe9da3..2667fd4fd737e212abe083e32a9e0dc792a5de5f 100644 (file)
@@ -455,6 +455,28 @@ struct bind_kw *bind_find_kw(const char *kw)
        return ret;
 }
 
+/* Dumps all registered "bind" keywords to the <out> string pointer. The
+ * unsupported keywords are only dumped if their supported form was not
+ * found.
+ */
+void bind_dump_kws(char **out)
+{
+       struct bind_kw_list *kwl;
+       int index;
+
+       *out = NULL;
+       list_for_each_entry(kwl, &bind_keywords.list, list) {
+               for (index = 0; kwl->kw[index].kw != NULL; index++) {
+                       if (kwl->kw[index].parse ||
+                           bind_find_kw(kwl->kw[index].kw) == &kwl->kw[index]) {
+                               memprintf(out, "%s%s %s\n", *out ? *out : "",
+                                         kwl->kw[index].kw,
+                                         kwl->kw[index].parse ? "" : "(not supported)");
+                       }
+               }
+       }
+}
+
 /************************************************************************/
 /*           All supported ACL keywords must be declared here.          */
 /************************************************************************/