mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 06:11:32 +02:00
MINOR: listener: pass the chosen protocol to create_listeners()
The function will need to use more than just a family, let's pass it the selected protocol. The caller will then be able to do all the fancy stuff required to pick the best protocol.
This commit is contained in:
parent
5e1779abbf
commit
9b3178df23
@ -85,13 +85,13 @@ void unbind_listener_no_close(struct listener *listener);
|
|||||||
|
|
||||||
/* creates one or multiple listeners for bind_conf <bc> on sockaddr <ss> on port
|
/* 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
|
* 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
|
* allocation). The address family is taken from ss->ss_family, and the protocol
|
||||||
* jobs and listeners is automatically increased by the number of listeners
|
* passed in <proto> must be usable on this family. The number of jobs and
|
||||||
* created. It returns non-zero on success, zero on error with the error message
|
* listeners is automatically increased by the number of listeners created. It
|
||||||
* set in <err>.
|
* 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 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
|
/* 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
|
* state is automatically updated from LI_ASSIGNED to LI_INIT. The protocol's
|
||||||
|
@ -111,6 +111,7 @@ struct cfg_kw_list cfg_keywords = {
|
|||||||
*/
|
*/
|
||||||
int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf, const char *file, int line, char **err)
|
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;
|
char *next, *dupstr;
|
||||||
int port, end;
|
int port, end;
|
||||||
|
|
||||||
@ -133,8 +134,14 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
|||||||
if (!ss2)
|
if (!ss2)
|
||||||
goto fail;
|
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 */
|
/* 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);
|
memprintf(err, "%s for address '%s'.\n", *err, str);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -160,6 +167,7 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
|||||||
*/
|
*/
|
||||||
int str2receiver(char *str, struct proxy *curproxy, struct bind_conf *bind_conf, const char *file, int line, char **err)
|
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;
|
char *next, *dupstr;
|
||||||
int port, end;
|
int port, end;
|
||||||
|
|
||||||
@ -182,8 +190,14 @@ int str2receiver(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
|||||||
if (!ss2)
|
if (!ss2)
|
||||||
goto fail;
|
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 */
|
/* 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);
|
memprintf(err, "%s for address '%s'.\n", *err, str);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -535,23 +535,17 @@ void unbind_listener_no_close(struct listener *listener)
|
|||||||
|
|
||||||
/* creates one or multiple listeners for bind_conf <bc> on sockaddr <ss> on port
|
/* 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
|
* 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
|
* allocation). The address family is taken from ss->ss_family, and the protocol
|
||||||
* jobs and listeners is automatically increased by the number of listeners
|
* passed in <proto> must be usable on this family. The number of jobs and
|
||||||
* created. It returns non-zero on success, zero on error with the error message
|
* listeners is automatically increased by the number of listeners created. It
|
||||||
* set in <err>.
|
* 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 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;
|
struct listener *l;
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
if (!proto) {
|
|
||||||
memprintf(err, "unsupported protocol family %d", ss->ss_family);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (port = portl; port <= porth; port++) {
|
for (port = portl; port <= porth; port++) {
|
||||||
l = calloc(1, sizeof(*l));
|
l = calloc(1, sizeof(*l));
|
||||||
if (!l) {
|
if (!l) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user