From c3ff91455948d76452d73cbea3ec1511c7839699 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Wed, 31 Mar 2021 09:05:16 -0400 Subject: [PATCH] add and use separate function for sending to a proxy listener --- src/include/listen.h | 10 ++++++++++ src/main/listen.c | 5 +++-- src/main/process.c | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/include/listen.h b/src/include/listen.h index 2d83016882..a97511db83 100644 --- a/src/include/listen.h +++ b/src/include/listen.h @@ -85,6 +85,16 @@ struct rad_listen { rad_listen_recv_t recv; rad_listen_send_t send; + + /* + * We don't need a proxy_recv, because the main loop in + * process.c calls listener->recv(), and we don't know + * what kind of packet we're receiving until we receive + * it. + */ + rad_listen_send_t proxy_send; + + rad_listen_encode_t encode; rad_listen_decode_t decode; rad_listen_encode_t proxy_encode; diff --git a/src/main/listen.c b/src/main/listen.c index 705b569964..6bc90e5426 100644 --- a/src/main/listen.c +++ b/src/main/listen.c @@ -1445,7 +1445,7 @@ static int acct_socket_send(rad_listen_t *listener, REQUEST *request) static int proxy_socket_send(rad_listen_t *listener, REQUEST *request) { rad_assert(request->proxy_listener == listener); - rad_assert(listener->send == proxy_socket_send); + rad_assert(listener->proxy_send == proxy_socket_send); if (rad_send(request->proxy, NULL, request->home_server->secret) < 0) { @@ -2832,6 +2832,7 @@ static rad_listen_t *listen_alloc(TALLOC_CTX *ctx, RAD_LISTEN_TYPE type) this->encode = master_listen[this->type].encode; this->decode = master_listen[this->type].decode; } else { + this->proxy_send = master_listen[this->type].send; this->proxy_encode = master_listen[this->type].encode; this->proxy_decode = master_listen[this->type].decode; } @@ -2932,7 +2933,7 @@ rad_listen_t *proxy_new_listener(TALLOC_CTX *ctx, home_server_t *home, uint16_t } this->recv = proxy_tls_recv; - this->send = proxy_tls_send; + this->proxy_send = proxy_tls_send; } #endif #endif diff --git a/src/main/process.c b/src/main/process.c index d1d03ac771..a32a934ce2 100644 --- a/src/main/process.c +++ b/src/main/process.c @@ -3478,7 +3478,7 @@ static int request_proxy(REQUEST *request) /* * And send the packet. */ - request->proxy_listener->send(request->proxy_listener, request); + request->proxy_listener->proxy_send(request->proxy_listener, request); return 1; } -- 2.47.3