From 0367b4cf63b7a8a071507aa3abaaaa11a9769877 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 2 May 2022 17:51:51 +0200 Subject: [PATCH] MINOR: session: get rid of the now unused SESS_FL_ADDR_*_SET flags That's similar to what was done for conn_streams and connections. The flags were only set exactly when the relevant pointers were allocated, so better test the pointer than the flag and stop setting the flag. --- include/haproxy/session-t.h | 2 -- include/haproxy/session.h | 10 ++++------ src/connection.c | 8 -------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/include/haproxy/session-t.h b/include/haproxy/session-t.h index 1afb3c857..e7a989962 100644 --- a/include/haproxy/session-t.h +++ b/include/haproxy/session-t.h @@ -39,8 +39,6 @@ enum { SESS_FL_NONE = 0x00000000, /* nothing */ SESS_FL_PREFER_LAST = 0x00000001, /* NTML authent, we should reuse last conn */ - SESS_FL_ADDR_FROM_SET = 0x00000002, - SESS_FL_ADDR_TO_SET = 0x00000004, }; /* max number of idle server connections kept attached to a session */ diff --git a/include/haproxy/session.h b/include/haproxy/session.h index 695f5ed4b..ab4f28a01 100644 --- a/include/haproxy/session.h +++ b/include/haproxy/session.h @@ -241,7 +241,7 @@ static inline const struct sockaddr_storage *sess_src(struct session *sess) { struct connection *cli_conn = objt_conn(sess->origin); - if (sess->flags & SESS_FL_ADDR_FROM_SET) + if (sess->src) return sess->src; if (cli_conn && conn_get_src(cli_conn)) return conn_src(cli_conn); @@ -256,7 +256,7 @@ static inline const struct sockaddr_storage *sess_dst(struct session *sess) { struct connection *cli_conn = objt_conn(sess->origin); - if (sess->flags & SESS_FL_ADDR_TO_SET) + if (sess->dst) return sess->dst; if (cli_conn && conn_get_dst(cli_conn)) return conn_dst(cli_conn); @@ -274,7 +274,7 @@ static inline int sess_get_src(struct session *sess) struct connection *cli_conn = objt_conn(sess->origin); const struct sockaddr_storage *src = NULL; - if (sess->flags & SESS_FL_ADDR_FROM_SET) + if (sess->src) return 1; if (cli_conn && conn_get_src(cli_conn)) @@ -285,7 +285,6 @@ static inline int sess_get_src(struct session *sess) if (!sockaddr_alloc(&sess->src, src, sizeof(*src))) return 0; - sess->flags |= SESS_FL_ADDR_FROM_SET; return 1; } @@ -300,7 +299,7 @@ static inline int sess_get_dst(struct session *sess) struct connection *cli_conn = objt_conn(sess->origin); const struct sockaddr_storage *dst = NULL; - if (sess->flags & SESS_FL_ADDR_TO_SET) + if (sess->dst) return 1; if (cli_conn && conn_get_dst(cli_conn)) @@ -311,7 +310,6 @@ static inline int sess_get_dst(struct session *sess) if (!sockaddr_alloc(&sess->dst, dst, sizeof(*dst))) return 0; - sess->flags |= SESS_FL_ADDR_TO_SET; return 1; } diff --git a/src/connection.c b/src/connection.c index e3e1bc876..e92089e09 100644 --- a/src/connection.c +++ b/src/connection.c @@ -885,7 +885,6 @@ int conn_recv_proxy(struct connection *conn, int flag) ((struct sockaddr_in *)sess->dst)->sin_family = AF_INET; ((struct sockaddr_in *)sess->dst)->sin_addr.s_addr = htonl(dst3); ((struct sockaddr_in *)sess->dst)->sin_port = htons(dport); - sess->flags |= SESS_FL_ADDR_FROM_SET | SESS_FL_ADDR_TO_SET; } else if (memcmp(line, "TCP6 ", 5) == 0) { u32 sport, dport; @@ -949,7 +948,6 @@ int conn_recv_proxy(struct connection *conn, int flag) ((struct sockaddr_in6 *)sess->dst)->sin6_family = AF_INET6; memcpy(&((struct sockaddr_in6 *)sess->dst)->sin6_addr, &dst3, sizeof(struct in6_addr)); ((struct sockaddr_in6 *)sess->dst)->sin6_port = htons(dport); - sess->flags |= SESS_FL_ADDR_FROM_SET | SESS_FL_ADDR_TO_SET; } else if (memcmp(line, "UNKNOWN\r\n", 9) == 0) { /* This can be a UNIX socket forwarded by an haproxy upstream */ @@ -997,7 +995,6 @@ int conn_recv_proxy(struct connection *conn, int flag) ((struct sockaddr_in *)sess->dst)->sin_family = AF_INET; ((struct sockaddr_in *)sess->dst)->sin_addr.s_addr = hdr_v2->addr.ip4.dst_addr; ((struct sockaddr_in *)sess->dst)->sin_port = hdr_v2->addr.ip4.dst_port; - sess->flags |= SESS_FL_ADDR_FROM_SET | SESS_FL_ADDR_TO_SET; tlv_offset = PP2_HEADER_LEN + PP2_ADDR_LEN_INET; break; case 0x21: /* TCPv6 */ @@ -1013,7 +1010,6 @@ int conn_recv_proxy(struct connection *conn, int flag) ((struct sockaddr_in6 *)sess->dst)->sin6_family = AF_INET6; memcpy(&((struct sockaddr_in6 *)sess->dst)->sin6_addr, hdr_v2->addr.ip6.dst_addr, 16); ((struct sockaddr_in6 *)sess->dst)->sin6_port = hdr_v2->addr.ip6.dst_port; - sess->flags |= SESS_FL_ADDR_FROM_SET | SESS_FL_ADDR_TO_SET; tlv_offset = PP2_HEADER_LEN + PP2_ADDR_LEN_INET6; break; } @@ -1372,8 +1368,6 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag) ((struct sockaddr_in *)sess->dst)->sin_family = AF_INET; ((struct sockaddr_in *)sess->dst)->sin_addr.s_addr = hdr_ip4->ip_dst.s_addr; ((struct sockaddr_in *)sess->dst)->sin_port = hdr_tcp->dest; - - sess->flags |= SESS_FL_ADDR_FROM_SET | SESS_FL_ADDR_TO_SET; } else if (ip_ver == 6) { struct ip6_hdr *hdr_ip6; @@ -1405,8 +1399,6 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag) ((struct sockaddr_in6 *)sess->dst)->sin6_family = AF_INET6; ((struct sockaddr_in6 *)sess->dst)->sin6_addr = hdr_ip6->ip6_dst; ((struct sockaddr_in6 *)sess->dst)->sin6_port = hdr_tcp->dest; - - sess->flags |= SESS_FL_ADDR_FROM_SET | SESS_FL_ADDR_TO_SET; } else { /* The protocol does not match something known (IPv4/IPv6) */