mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 17:17:06 +02:00
MINOR: protocols: use is_inet_addr() when only INET addresses are desired
We used to have is_addr() in place to validate sometimes the existence of an address, sometimes a valid IPv4 or IPv6 address. Replace them carefully so that is_inet_addr() is used wherever we can only use an IPv4/IPv6 address.
This commit is contained in:
parent
18ca2d48bf
commit
9cf8d3f46b
@ -753,7 +753,8 @@ int assign_server_address(struct session *s)
|
|||||||
if (!is_addr(&srv_conn->addr.to) && cli_conn) {
|
if (!is_addr(&srv_conn->addr.to) && cli_conn) {
|
||||||
/* if the server has no address, we use the same address
|
/* if the server has no address, we use the same address
|
||||||
* the client asked, which is handy for remapping ports
|
* the client asked, which is handy for remapping ports
|
||||||
* locally on multiple addresses at once.
|
* locally on multiple addresses at once. Nothing is done
|
||||||
|
* for AF_UNIX addresses.
|
||||||
*/
|
*/
|
||||||
conn_get_to_addr(cli_conn);
|
conn_get_to_addr(cli_conn);
|
||||||
|
|
||||||
|
@ -4813,7 +4813,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
|||||||
if (!strcmp(args[cur_arg], "usesrc")) { /* address to use outside */
|
if (!strcmp(args[cur_arg], "usesrc")) { /* address to use outside */
|
||||||
#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_TRANSPARENT)
|
#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_TRANSPARENT)
|
||||||
#if !defined(CONFIG_HAP_TRANSPARENT)
|
#if !defined(CONFIG_HAP_TRANSPARENT)
|
||||||
if (!is_addr(&curproxy->conn_src.source_addr)) {
|
if (!is_inet_addr(&curproxy->conn_src.source_addr)) {
|
||||||
Alert("parsing [%s:%d] : '%s' requires an explicit 'source' address.\n",
|
Alert("parsing [%s:%d] : '%s' requires an explicit 'source' address.\n",
|
||||||
file, linenum, "usesrc");
|
file, linenum, "usesrc");
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
@ -201,14 +201,14 @@ int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct so
|
|||||||
|
|
||||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||||
if (foreign_ok) {
|
if (foreign_ok) {
|
||||||
if (is_addr(&bind_addr)) {
|
if (is_inet_addr(&bind_addr)) {
|
||||||
ret = bind(fd, (struct sockaddr *)&bind_addr, get_addr_len(&bind_addr));
|
ret = bind(fd, (struct sockaddr *)&bind_addr, get_addr_len(&bind_addr));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (is_addr(local)) {
|
if (is_inet_addr(local)) {
|
||||||
ret = bind(fd, (struct sockaddr *)local, get_addr_len(local));
|
ret = bind(fd, (struct sockaddr *)local, get_addr_len(local));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return 1;
|
return 1;
|
||||||
@ -367,7 +367,7 @@ int tcp_connect_server(struct connection *conn, int data, int delack)
|
|||||||
if (src) {
|
if (src) {
|
||||||
int ret, flags = 0;
|
int ret, flags = 0;
|
||||||
|
|
||||||
if (is_addr(&conn->addr.from)) {
|
if (is_inet_addr(&conn->addr.from)) {
|
||||||
switch (src->opts & CO_SRC_TPROXY_MASK) {
|
switch (src->opts & CO_SRC_TPROXY_MASK) {
|
||||||
case CO_SRC_TPROXY_ADDR:
|
case CO_SRC_TPROXY_ADDR:
|
||||||
case CO_SRC_TPROXY_CLI:
|
case CO_SRC_TPROXY_CLI:
|
||||||
|
@ -829,7 +829,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
|
|||||||
if (!strcmp(args[cur_arg], "usesrc")) { /* address to use outside */
|
if (!strcmp(args[cur_arg], "usesrc")) { /* address to use outside */
|
||||||
#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_TRANSPARENT)
|
#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_TRANSPARENT)
|
||||||
#if !defined(CONFIG_HAP_TRANSPARENT)
|
#if !defined(CONFIG_HAP_TRANSPARENT)
|
||||||
if (!is_addr(&newsrv->conn_src.source_addr)) {
|
if (!is_inet_addr(&newsrv->conn_src.source_addr)) {
|
||||||
Alert("parsing [%s:%d] : '%s' requires an explicit '%s' address.\n",
|
Alert("parsing [%s:%d] : '%s' requires an explicit '%s' address.\n",
|
||||||
file, linenum, "usesrc", "source");
|
file, linenum, "usesrc", "source");
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user