MINOR: log: provide source address information in syslog_process_message()

provide struct sockaddr_storage pointer from the message sender in
syslog_process_message()
This commit is contained in:
Aurelien DARRAGON 2025-03-10 21:08:57 +01:00
parent bc76f6dde9
commit 2de62d0461

View File

@ -5711,10 +5711,14 @@ bad_format:
return; return;
} }
/* helper function for syslog handlers: process input message stored /* helper function for syslog handlers: process input message sent by
* in <buf> according to <frontend> options, and send it to frontend loggers * <saddr> and stored in <buf> according to <frontend> options, and send
* it to frontend loggers
*
* <saddr> may be NULL if sender information is not available.
*/ */
static void syslog_process_message(struct proxy *frontend, struct listener *l, static void syslog_process_message(struct proxy *frontend, struct listener *l,
const struct sockaddr_storage *saddr,
struct buffer *buf) struct buffer *buf)
{ {
static THREAD_LOCAL struct ist metadata[LOG_META_FIELDS]; static THREAD_LOCAL struct ist metadata[LOG_META_FIELDS];
@ -5773,7 +5777,7 @@ void syslog_fd_handler(int fd)
} }
buf->data = ret; buf->data = ret;
syslog_process_message(frontend, l, buf); syslog_process_message(frontend, l, &saddr, buf);
} while (--max_accept); } while (--max_accept);
} }
@ -5791,6 +5795,7 @@ static void syslog_io_handler(struct appctx *appctx)
struct proxy *frontend = strm_fe(s); struct proxy *frontend = strm_fe(s);
struct listener *l = strm_li(s); struct listener *l = strm_li(s);
struct buffer *buf = get_trash_chunk(); struct buffer *buf = get_trash_chunk();
struct connection *conn;
int max_accept; int max_accept;
int to_skip; int to_skip;
@ -5801,6 +5806,7 @@ static void syslog_io_handler(struct appctx *appctx)
max_accept = l->bind_conf->maxaccept ? l->bind_conf->maxaccept : 1; max_accept = l->bind_conf->maxaccept ? l->bind_conf->maxaccept : 1;
while (1) { while (1) {
const struct sockaddr_storage *saddr = NULL;
char c; char c;
if (max_accept <= 0) if (max_accept <= 0)
@ -5873,7 +5879,11 @@ static void syslog_io_handler(struct appctx *appctx)
co_skip(sc_oc(sc), to_skip); co_skip(sc_oc(sc), to_skip);
syslog_process_message(frontend, l, buf); conn = sc_conn(s->scf);
if (conn && conn_get_src(conn))
saddr = conn_src(conn);
syslog_process_message(frontend, l, saddr, buf);
} }
missing_data: missing_data: