/* creates one or multiple listeners for bind_conf <bc> on sockaddr <ss> on port
* range <portl> to <porth>, and possibly attached to fd <fd> (or -1 for auto
- * allocation). The address family is taken from ss->ss_family. The number of
- * jobs and listeners is automatically increased by the number of listeners
- * created. It returns non-zero on success, zero on error with the error message
- * set in <err>.
+ * allocation). The address family is taken from ss->ss_family, and the protocol
+ * passed in <proto> must be usable on this family. The number of jobs and
+ * listeners is automatically increased by the number of listeners created. It
+ * returns non-zero on success, zero on error with the error message set in <err>.
*/
int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss,
- int portl, int porth, int fd, char **err);
+ int portl, int porth, int fd, struct protocol *proto, char **err);
/* Delete a listener from its protocol's list of listeners. The listener's
* state is automatically updated from LI_ASSIGNED to LI_INIT. The protocol's
*/
int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf, const char *file, int line, char **err)
{
+ struct protocol *proto;
char *next, *dupstr;
int port, end;
if (!ss2)
goto fail;
+ proto = protocol_by_family(ss2->ss_family);
+ if (!proto) {
+ memprintf(err, "unsupported protocol family %d fr address '%s'", ss2->ss_family, str);
+ goto fail;
+ }
+
/* OK the address looks correct */
- if (!create_listeners(bind_conf, ss2, port, end, fd, err)) {
+ if (!create_listeners(bind_conf, ss2, port, end, fd, proto, err)) {
memprintf(err, "%s for address '%s'.\n", *err, str);
goto fail;
}
*/
int str2receiver(char *str, struct proxy *curproxy, struct bind_conf *bind_conf, const char *file, int line, char **err)
{
+ struct protocol *proto;
char *next, *dupstr;
int port, end;
if (!ss2)
goto fail;
+ proto = protocol_by_family(ss2->ss_family);
+ if (!proto) {
+ memprintf(err, "unsupported protocol family %d fr address '%s'", ss2->ss_family, str);
+ goto fail;
+ }
+
/* OK the address looks correct */
- if (!create_listeners(bind_conf, ss2, port, end, fd, err)) {
+ if (!create_listeners(bind_conf, ss2, port, end, fd, proto, err)) {
memprintf(err, "%s for address '%s'.\n", *err, str);
goto fail;
}
/* creates one or multiple listeners for bind_conf <bc> on sockaddr <ss> on port
* range <portl> to <porth>, and possibly attached to fd <fd> (or -1 for auto
- * allocation). The address family is taken from ss->ss_family. The number of
- * jobs and listeners is automatically increased by the number of listeners
- * created. It returns non-zero on success, zero on error with the error message
- * set in <err>.
+ * allocation). The address family is taken from ss->ss_family, and the protocol
+ * passed in <proto> must be usable on this family. The number of jobs and
+ * listeners is automatically increased by the number of listeners created. It
+ * returns non-zero on success, zero on error with the error message set in <err>.
*/
int create_listeners(struct bind_conf *bc, const struct sockaddr_storage *ss,
- int portl, int porth, int fd, char **err)
+ int portl, int porth, int fd, struct protocol *proto, char **err)
{
- struct protocol *proto = protocol_by_family(ss->ss_family);
struct listener *l;
int port;
- if (!proto) {
- memprintf(err, "unsupported protocol family %d", ss->ss_family);
- return 0;
- }
-
for (port = portl; port <= porth; port++) {
l = calloc(1, sizeof(*l));
if (!l) {