mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-28 14:21:00 +01:00
MINOR: protocols: always pass a "port" argument to the listener creation
It's a shame that cfgparse() has to make special cases of each protocol just to cast the port to the target address family. Let's pass the port in argument to the function. The unix listener simply ignores it.
This commit is contained in:
parent
20814ff1fc
commit
3228238c73
@ -28,8 +28,8 @@
|
|||||||
#include <proto/stick_table.h>
|
#include <proto/stick_table.h>
|
||||||
|
|
||||||
int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct sockaddr_storage *remote);
|
int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct sockaddr_storage *remote);
|
||||||
void tcpv4_add_listener(struct listener *listener);
|
void tcpv4_add_listener(struct listener *listener, int port);
|
||||||
void tcpv6_add_listener(struct listener *listener);
|
void tcpv6_add_listener(struct listener *listener, int port);
|
||||||
int tcp_pause_listener(struct listener *l);
|
int tcp_pause_listener(struct listener *l);
|
||||||
int tcp_connect_server(struct connection *conn, int data, int delack);
|
int tcp_connect_server(struct connection *conn, int data, int delack);
|
||||||
int tcp_connect_probe(struct connection *conn);
|
int tcp_connect_probe(struct connection *conn);
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
#include <types/stream.h>
|
#include <types/stream.h>
|
||||||
#include <types/task.h>
|
#include <types/task.h>
|
||||||
|
|
||||||
void uxst_add_listener(struct listener *listener);
|
void uxst_add_listener(struct listener *listener, int port);
|
||||||
int uxst_pause_listener(struct listener *l);
|
int uxst_pause_listener(struct listener *l);
|
||||||
int uxst_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
|
int uxst_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
|
||||||
int uxst_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
|
int uxst_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
|
||||||
|
|||||||
@ -299,15 +299,13 @@ int str2listener(char *str, struct proxy *curproxy, struct bind_conf *bind_conf,
|
|||||||
l->state = LI_INIT;
|
l->state = LI_INIT;
|
||||||
|
|
||||||
if (ss.ss_family == AF_INET) {
|
if (ss.ss_family == AF_INET) {
|
||||||
((struct sockaddr_in *)(&l->addr))->sin_port = htons(port);
|
tcpv4_add_listener(l, port);
|
||||||
tcpv4_add_listener(l);
|
|
||||||
}
|
}
|
||||||
else if (ss.ss_family == AF_INET6) {
|
else if (ss.ss_family == AF_INET6) {
|
||||||
((struct sockaddr_in6 *)(&l->addr))->sin6_port = htons(port);
|
tcpv6_add_listener(l, port);
|
||||||
tcpv6_add_listener(l);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
uxst_add_listener(l);
|
uxst_add_listener(l, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
jobs++;
|
jobs++;
|
||||||
|
|||||||
@ -1137,30 +1137,32 @@ static int tcp_bind_listeners(struct protocol *proto, char *errmsg, int errlen)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add listener to the list of tcpv4 listeners. The listener's state
|
/* Add <listener> to the list of tcpv4 listeners, on port <port>. The
|
||||||
* is automatically updated from LI_INIT to LI_ASSIGNED. The number of
|
* listener's state is automatically updated from LI_INIT to LI_ASSIGNED.
|
||||||
* listeners is updated. This is the function to use to add a new listener.
|
* The number of listeners for the protocol is updated.
|
||||||
*/
|
*/
|
||||||
void tcpv4_add_listener(struct listener *listener)
|
void tcpv4_add_listener(struct listener *listener, int port)
|
||||||
{
|
{
|
||||||
if (listener->state != LI_INIT)
|
if (listener->state != LI_INIT)
|
||||||
return;
|
return;
|
||||||
listener->state = LI_ASSIGNED;
|
listener->state = LI_ASSIGNED;
|
||||||
listener->proto = &proto_tcpv4;
|
listener->proto = &proto_tcpv4;
|
||||||
|
((struct sockaddr_in *)(&listener->addr))->sin_port = htons(port);
|
||||||
LIST_ADDQ(&proto_tcpv4.listeners, &listener->proto_list);
|
LIST_ADDQ(&proto_tcpv4.listeners, &listener->proto_list);
|
||||||
proto_tcpv4.nb_listeners++;
|
proto_tcpv4.nb_listeners++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add listener to the list of tcpv4 listeners. The listener's state
|
/* Add <listener> to the list of tcpv6 listeners, on port <port>. The
|
||||||
* is automatically updated from LI_INIT to LI_ASSIGNED. The number of
|
* listener's state is automatically updated from LI_INIT to LI_ASSIGNED.
|
||||||
* listeners is updated. This is the function to use to add a new listener.
|
* The number of listeners for the protocol is updated.
|
||||||
*/
|
*/
|
||||||
void tcpv6_add_listener(struct listener *listener)
|
void tcpv6_add_listener(struct listener *listener, int port)
|
||||||
{
|
{
|
||||||
if (listener->state != LI_INIT)
|
if (listener->state != LI_INIT)
|
||||||
return;
|
return;
|
||||||
listener->state = LI_ASSIGNED;
|
listener->state = LI_ASSIGNED;
|
||||||
listener->proto = &proto_tcpv6;
|
listener->proto = &proto_tcpv6;
|
||||||
|
((struct sockaddr_in *)(&listener->addr))->sin_port = htons(port);
|
||||||
LIST_ADDQ(&proto_tcpv6.listeners, &listener->proto_list);
|
LIST_ADDQ(&proto_tcpv6.listeners, &listener->proto_list);
|
||||||
proto_tcpv6.nb_listeners++;
|
proto_tcpv6.nb_listeners++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -365,11 +365,11 @@ static int uxst_unbind_listener(struct listener *listener)
|
|||||||
return ERR_NONE;
|
return ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a listener to the list of unix stream listeners. The listener's state
|
/* Add <listener> to the list of unix stream listeners (port is ignored). The
|
||||||
* is automatically updated from LI_INIT to LI_ASSIGNED. The number of
|
* listener's state is automatically updated from LI_INIT to LI_ASSIGNED.
|
||||||
* listeners is updated. This is the function to use to add a new listener.
|
* The number of listeners for the protocol is updated.
|
||||||
*/
|
*/
|
||||||
void uxst_add_listener(struct listener *listener)
|
void uxst_add_listener(struct listener *listener, int port)
|
||||||
{
|
{
|
||||||
if (listener->state != LI_INIT)
|
if (listener->state != LI_INIT)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user