Re: [PATCH]: Check for duplicated conflicting proxies

From: Willy Tarreau <w#1wt.eu>
Date: Sun, 21 Oct 2007 10:09:46 +0200


On Sun, Oct 21, 2007 at 02:55:17AM +0200, Krzysztof Oledzki wrote:
> Currently haproxy accepts a config with duplicated proxies
> (listen/fronted/backed/ruleset). This patch fix this, so the application
> will complain when there is an error.
>
> With this modification it is still possible to use the same name for two
> proxies (for example frontend&backend) as long there is no conflict:
>
> listen backend frontend ruleset
> listen - - - -
> backend - - OK -
> frontend - OK - -
> ruleset - - - -
>
> Best regards,
>
> Krzysztof Ol?dzki

Thanks, merged.

BTW, in last mail I was speaking about minor style adaptations. I have added braces in the "for" block. It's far easier to track what begins where when blocks are embedded or when they span over multiple lines such as below.

Best regards,
Willy

> + for (curproxy = proxy; curproxy != NULL; curproxy = curproxy->next) {
> + /*
> + * If there are two proxies with the same name only following
> + * combinations are allowed:
> + *
> + * listen backend frontend ruleset
> + * listen - - - -
> + * backend - - OK -
> + * frontend - OK - -
> + * ruleset - - - -
> + */
> +
> + if (!strcmp(curproxy->id, args[1]) &&
> + (rc!=(PR_CAP_FE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_BE|PR_CAP_RS)) &&
> + (rc!=(PR_CAP_BE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_FE|PR_CAP_RS))) {
> + Alert("parsing %s: duplicated proxy %s with conflicting capabilities: %X/%X!\n",
> + file, args[1], curproxy->cap, rc);
> + return -1;
> + }
> + }
>
> if ((curproxy = (struct proxy *)calloc(1, sizeof(struct proxy))) == NULL) {
> Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
Received on 2007/10/21 10:09

This archive was generated by hypermail 2.2.0 : 2007/11/04 19:21 CET