diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index b1c8d94bd..7b54e8e00 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -559,7 +559,32 @@ enum term_event_loc { tevt_loc_strm = 6, }; -/* Types for termination event logs (4-bits) */ +/* Types for termination event logs (4-bits) per location */ +enum fd_term_event_type { + fd_tevt_type_shutw = 1, + fd_tevt_type_shutr = 2, + fd_tevt_type_rcv_err = 3, + fd_tevt_type_snd_err = 4, + /* unused: 5, 6 */ + fd_tevt_type_connect_err = 7, + fd_tevt_type_intercepted = 8, +}; + +enum hs_term_event_type { + /* unused: 1, 2, 3 */ + hs_tevt_type_snd_err = 4, + hs_tevt_type_truncated_shutr = 5, + hs_tevt_type_truncated_rcv_err = 6, +}; + +enum xprt_term_event_type { + xprt_tevt_type_shutw = 1, + xprt_tevt_type_shutr = 2, + xprt_tevt_type_rcv_err = 3, + xprt_tevt_type_snd_err = 4, +}; + + enum term_event_type { /* Events emitted by haproxy */ tevt_type_shutw = 1, diff --git a/include/haproxy/connection.h b/include/haproxy/connection.h index a5f032785..c0ed51e5d 100644 --- a/include/haproxy/connection.h +++ b/include/haproxy/connection.h @@ -107,7 +107,7 @@ const char *conn_err_code_str(struct connection *c); int xprt_add_hs(struct connection *conn); void register_mux_proto(struct mux_proto_list *list); -static inline void conn_report_term_evt(struct connection *conn, enum term_event_loc loc, enum term_event_type type); +static inline void conn_report_term_evt(struct connection *conn, enum term_event_loc loc, unsigned char type); extern struct idle_conns idle_conns[MAX_THREADS]; @@ -256,7 +256,7 @@ static inline void conn_sock_shutw(struct connection *c, int clean) if (!(c->flags & CO_FL_SOCK_RD_SH) && clean) shutdown(c->handle.fd, SHUT_WR); } - conn_report_term_evt(c, tevt_loc_fd, tevt_type_shutw); + conn_report_term_evt(c, tevt_loc_fd, fd_tevt_type_shutw); } static inline void conn_xprt_shutw(struct connection *c) @@ -790,7 +790,7 @@ static inline const char *tevt_evts2str(uint32_t evts) } /* Report a connection event. may be "tevt_loc_fd", "tevt_loc_hs" or "tevt_loc_xprt" */ -static inline void conn_report_term_evt(struct connection *conn, enum term_event_loc loc, enum term_event_type type) +static inline void conn_report_term_evt(struct connection *conn, enum term_event_loc loc, unsigned char type) { if (conn_is_back(conn)) loc |= 0x08; diff --git a/src/connection.c b/src/connection.c index 759f96877..6a9829993 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1373,14 +1373,14 @@ int conn_recv_proxy(struct connection *conn, int flag) goto fail; recv_abort: - conn_report_term_evt(conn, tevt_loc_hs, tevt_type_truncated_shutr); + conn_report_term_evt(conn, tevt_loc_hs, hs_tevt_type_truncated_shutr); conn->err_code = CO_ER_PRX_ABORT; conn->flags |= CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH; goto fail; fail: if (!(conn->flags & CO_FL_SOCK_RD_SH)) - conn_report_term_evt(conn, tevt_loc_hs, tevt_type_truncated_rcv_err); + conn_report_term_evt(conn, tevt_loc_hs, hs_tevt_type_truncated_rcv_err); conn->flags |= CO_FL_ERROR; return 0; } @@ -1474,7 +1474,7 @@ int conn_send_proxy(struct connection *conn, unsigned int flag) out_error: /* Write error on the file descriptor */ - conn_report_term_evt(conn, tevt_loc_hs, tevt_type_snd_err); + conn_report_term_evt(conn, tevt_loc_hs, hs_tevt_type_snd_err); conn->flags |= CO_FL_ERROR; return 0; @@ -1677,14 +1677,14 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag) goto fail; recv_abort: - conn_report_term_evt(conn, tevt_loc_hs, tevt_type_truncated_shutr); + conn_report_term_evt(conn, tevt_loc_hs, hs_tevt_type_truncated_shutr); conn->err_code = CO_ER_CIP_ABORT; conn->flags |= CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH; goto fail; fail: if (!(conn->flags & CO_FL_SOCK_RD_SH)) - conn_report_term_evt(conn, tevt_loc_hs, tevt_type_truncated_rcv_err); + conn_report_term_evt(conn, tevt_loc_hs, hs_tevt_type_truncated_rcv_err); conn->flags |= CO_FL_ERROR; return 0; } @@ -1758,7 +1758,7 @@ int conn_send_socks4_proxy_request(struct connection *conn) out_error: /* Write error on the file descriptor */ - conn_report_term_evt(conn, tevt_loc_hs, tevt_type_snd_err); + conn_report_term_evt(conn, tevt_loc_hs, hs_tevt_type_snd_err); conn->flags |= CO_FL_ERROR; if (conn->err_code == CO_ER_NONE) { conn->err_code = CO_ER_SOCKS4_SEND; @@ -1879,7 +1879,7 @@ int conn_recv_socks4_proxy_response(struct connection *conn) return 0; recv_abort: - conn_report_term_evt(conn, tevt_loc_hs, tevt_type_truncated_shutr); + conn_report_term_evt(conn, tevt_loc_hs, hs_tevt_type_truncated_shutr); if (conn->err_code == CO_ER_NONE) { conn->err_code = CO_ER_SOCKS4_ABORT; } @@ -1888,7 +1888,7 @@ int conn_recv_socks4_proxy_response(struct connection *conn) fail: if (!(conn->flags & CO_FL_SOCK_RD_SH)) - conn_report_term_evt(conn, tevt_loc_hs, tevt_type_truncated_rcv_err); + conn_report_term_evt(conn, tevt_loc_hs, hs_tevt_type_truncated_rcv_err); conn->flags |= CO_FL_ERROR; return 0; } diff --git a/src/raw_sock.c b/src/raw_sock.c index 401e4cee9..255a8c01a 100644 --- a/src/raw_sock.c +++ b/src/raw_sock.c @@ -77,7 +77,7 @@ int raw_sock_to_pipe(struct connection *conn, void *xprt_ctx, struct pipe *pipe, /* report error on POLL_ERR before connection establishment */ if ((fdtab[conn->handle.fd].state & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) { - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_rcv_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_rcv_err); conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH; conn_set_errcode(conn, CO_ER_POLLERR); errno = 0; /* let the caller do a getsockopt() if it wants it */ @@ -128,7 +128,7 @@ int raw_sock_to_pipe(struct connection *conn, void *xprt_ctx, struct pipe *pipe, continue; } /* here we have another error */ - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_rcv_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_rcv_err); conn->flags |= CO_FL_ERROR; conn_set_errno(conn, errno); break; @@ -157,7 +157,7 @@ int raw_sock_to_pipe(struct connection *conn, void *xprt_ctx, struct pipe *pipe, return retval; out_read0: - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_shutr); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_shutr); conn_sock_read0(conn); conn->flags &= ~CO_FL_WAIT_L4_CONN; goto leave; @@ -179,7 +179,7 @@ int raw_sock_from_pipe(struct connection *conn, void *xprt_ctx, struct pipe *pip if (conn->flags & CO_FL_SOCK_WR_SH) { /* it's already closed */ - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_snd_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_snd_err); conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH; errno = EPIPE; conn_set_errno(conn, errno); @@ -203,7 +203,7 @@ int raw_sock_from_pipe(struct connection *conn, void *xprt_ctx, struct pipe *pip continue; /* here we have another error */ - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_snd_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_snd_err); conn->flags |= CO_FL_ERROR; conn_set_errno(conn, errno); break; @@ -256,7 +256,7 @@ static size_t raw_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu /* report error on POLL_ERR before connection establishment */ if ((fdtab[conn->handle.fd].state & FD_POLL_ERR) && (conn->flags & CO_FL_WAIT_L4_CONN)) { - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_rcv_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_rcv_err); conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH; conn_set_errcode(conn, CO_ER_POLLERR); goto leave; @@ -316,7 +316,7 @@ static size_t raw_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu break; } else if (errno != EINTR) { - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_rcv_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_rcv_err); conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH; conn_set_errno(conn, errno); break; @@ -330,7 +330,7 @@ static size_t raw_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu return done; read0: - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_shutr); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_shutr); conn_sock_read0(conn); conn->flags &= ~CO_FL_WAIT_L4_CONN; @@ -342,7 +342,7 @@ static size_t raw_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu * an error without checking. */ if (unlikely(!done && fdtab[conn->handle.fd].state & FD_POLL_ERR)) { - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_rcv_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_rcv_err); conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH; conn_set_errcode(conn, CO_ER_POLLERR); } @@ -377,7 +377,7 @@ static size_t raw_sock_from_buf(struct connection *conn, void *xprt_ctx, const s if (unlikely(fdtab[conn->handle.fd].state & FD_POLL_ERR)) { /* an error was reported on the FD, we can't send anymore */ - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_snd_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_snd_err); conn->flags |= CO_FL_ERROR | CO_FL_SOCK_WR_SH | CO_FL_SOCK_RD_SH; conn_set_errcode(conn, CO_ER_POLLERR); errno = EPIPE; @@ -386,7 +386,7 @@ static size_t raw_sock_from_buf(struct connection *conn, void *xprt_ctx, const s if (conn->flags & CO_FL_SOCK_WR_SH) { /* it's already closed */ - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_snd_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_snd_err); conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH; errno = EPIPE; conn_set_errno(conn, errno); @@ -427,7 +427,7 @@ static size_t raw_sock_from_buf(struct connection *conn, void *xprt_ctx, const s break; } else if (errno != EINTR) { - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_snd_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_snd_err); conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH; conn_set_errno(conn, errno); break; diff --git a/src/sock.c b/src/sock.c index 6750c1ac9..160016e65 100644 --- a/src/sock.c +++ b/src/sock.c @@ -1007,7 +1007,7 @@ int sock_conn_check(struct connection *conn) /* Write error on the file descriptor. Report it to the connection * and disable polling on this FD. */ - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_truncated_rcv_err); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_connect_err); conn->flags |= CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH; HA_ATOMIC_AND(&fdtab[fd].state, ~FD_LINGER_RISK); fd_stop_both(fd); diff --git a/src/ssl_sock.c b/src/ssl_sock.c index a76232fae..15ca095e9 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -5533,7 +5533,7 @@ reneg_ok: /* Report an HS error only on SSL error */ if (!(conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH))) - conn_report_term_evt(conn, tevt_loc_hs, tevt_type_truncated_rcv_err); + conn_report_term_evt(conn, tevt_loc_hs, hs_tevt_type_truncated_rcv_err); /* Fail on all other handshake errors */ conn->flags |= CO_FL_ERROR; @@ -5886,12 +5886,12 @@ static size_t ssl_sock_to_buf(struct connection *conn, void *xprt_ctx, struct bu ssl_sock_dump_errors(conn, NULL); ERR_clear_error(); read0: - conn_report_term_evt(conn, tevt_loc_xprt, tevt_type_shutr); + conn_report_term_evt(conn, tevt_loc_xprt, xprt_tevt_type_shutr); conn_sock_read0(conn); goto leave; out_error: - conn_report_term_evt(conn, tevt_loc_xprt, tevt_type_rcv_err); + conn_report_term_evt(conn, tevt_loc_xprt, xprt_tevt_type_rcv_err); conn->flags |= CO_FL_ERROR; /* Clear openssl global errors stack */ ssl_sock_dump_errors(conn, NULL); @@ -6058,7 +6058,7 @@ static size_t ssl_sock_from_buf(struct connection *conn, void *xprt_ctx, const s ssl_sock_dump_errors(conn, NULL); ERR_clear_error(); - conn_report_term_evt(conn, tevt_loc_xprt, tevt_type_snd_err); + conn_report_term_evt(conn, tevt_loc_xprt, xprt_tevt_type_snd_err); conn->flags |= CO_FL_ERROR; goto leave; } @@ -6149,7 +6149,7 @@ static void ssl_sock_shutw(struct connection *conn, void *xprt_ctx, int clean) if (conn->flags & (CO_FL_WAIT_XPRT | CO_FL_SSL_WAIT_HS)) return; - conn_report_term_evt(conn, tevt_loc_xprt, tevt_type_shutw); + conn_report_term_evt(conn, tevt_loc_xprt, xprt_tevt_type_shutw); if (!clean) /* don't sent notify on SSL_shutdown */ SSL_set_quiet_shutdown(ctx->ssl, 1); diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 2a7d0d6ed..8771b32e8 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -579,7 +579,7 @@ int tcp_exec_l4_rules(struct session *sess) } end: if (!result) - conn_report_term_evt(conn, tevt_loc_fd, tevt_type_intercepted); + conn_report_term_evt(conn, tevt_loc_fd, fd_tevt_type_intercepted); return result; }