From: Alan T. DeKok Date: Mon, 25 Sep 2017 15:13:33 +0000 (-0400) Subject: move client src_ipaddr mangling to proto_radius X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=355f37ce2dc172a4467651cd496dea0d2116ee04;p=thirdparty%2Ffreeradius-server.git move client src_ipaddr mangling to proto_radius so that the process functions are entirely protocol agnostic almost... they still print src/dst IP information for debugging --- diff --git a/src/modules/proto_radius/proto_radius.c b/src/modules/proto_radius/proto_radius.c index 417b17b4029..bee7261bd62 100644 --- a/src/modules/proto_radius/proto_radius.c +++ b/src/modules/proto_radius/proto_radius.c @@ -219,6 +219,18 @@ static ssize_t mod_encode(void const *instance, REQUEST *request, uint8_t *buffe client = inst->app_io_private->client(inst->app_io, request->async->packet_ctx); rad_assert(client); +#ifdef WITH_UDPFROMTO + /* + * Overwrite the src ip address on the outbound packet + * with the one specified by the client. This is useful + * to work around broken DSR implementations and other + * routing issues. + */ + if (client->src_ipaddr.af != AF_UNSPEC) { + request->reply->src_ipaddr = client->src_ipaddr; + } +#endif + if (fr_radius_packet_encode(request->reply, request->packet, client->secret) < 0) { RDEBUG("Failed encoding RADIUS reply: %s", fr_strerror()); return -1; diff --git a/src/modules/proto_radius/proto_radius_acct.c b/src/modules/proto_radius/proto_radius_acct.c index 358448fe3a0..77909658c15 100644 --- a/src/modules/proto_radius/proto_radius_acct.c +++ b/src/modules/proto_radius/proto_radius_acct.c @@ -165,18 +165,6 @@ static fr_io_final_t mod_process(REQUEST *request, fr_io_action_t action) return FR_IO_DONE; } -#ifdef WITH_UDPFROMTO - /* - * Overwrite the src ip address on the outbound packet - * with the one specified by the client. - * This is useful to work around broken DSR implementations - * and other routing issues. - */ - if (request->client->src_ipaddr.af != AF_UNSPEC) { - request->reply->src_ipaddr = request->client->src_ipaddr; - } -#endif - if (RDEBUG_ENABLED) common_packet_debug(request, request->reply, false); break; diff --git a/src/modules/proto_radius/proto_radius_auth.c b/src/modules/proto_radius/proto_radius_auth.c index 78dd25761ec..047c0b25302 100644 --- a/src/modules/proto_radius/proto_radius_auth.c +++ b/src/modules/proto_radius/proto_radius_auth.c @@ -501,18 +501,6 @@ static fr_io_final_t mod_process(REQUEST *request, fr_io_action_t action) return FR_IO_REPLY; } -#ifdef WITH_UDPFROMTO - /* - * Overwrite the src ip address on the outbound packet - * with the one specified by the client. - * This is useful to work around broken DSR implementations - * and other routing issues. - */ - if (request->client->src_ipaddr.af != AF_UNSPEC) { - request->reply->src_ipaddr = request->client->src_ipaddr; - } -#endif - if (RDEBUG_ENABLED) common_packet_debug(request, request->reply, false); break; diff --git a/src/modules/proto_radius/proto_radius_coa.c b/src/modules/proto_radius/proto_radius_coa.c index 557f3927f16..13e1bc87020 100644 --- a/src/modules/proto_radius/proto_radius_coa.c +++ b/src/modules/proto_radius/proto_radius_coa.c @@ -213,18 +213,6 @@ static fr_io_final_t mod_process(REQUEST *request, fr_io_action_t action) return FR_IO_DONE; } -#ifdef WITH_UDPFROMTO - /* - * Overwrite the src ip address on the outbound packet - * with the one specified by the client. - * This is useful to work around broken DSR implementations - * and other routing issues. - */ - if (request->client->src_ipaddr.af != AF_UNSPEC) { - request->reply->src_ipaddr = request->client->src_ipaddr; - } -#endif - if (RDEBUG_ENABLED) common_packet_debug(request, request->reply, false); break; diff --git a/src/modules/proto_radius/proto_radius_status.c b/src/modules/proto_radius/proto_radius_status.c index 32137e104db..6064b4fde9f 100644 --- a/src/modules/proto_radius/proto_radius_status.c +++ b/src/modules/proto_radius/proto_radius_status.c @@ -178,18 +178,6 @@ static fr_io_final_t mod_process(REQUEST *request, fr_io_action_t action) return FR_IO_DONE; } -#ifdef WITH_UDPFROMTO - /* - * Overwrite the src ip address on the outbound packet - * with the one specified by the client. - * This is useful to work around broken DSR implementations - * and other routing issues. - */ - if (request->client && (request->client->src_ipaddr.af != AF_UNSPEC)) { - request->reply->src_ipaddr = request->client->src_ipaddr; - } -#endif - if (RDEBUG_ENABLED) common_packet_debug(request, request->reply, false); break;