From: Alan T. DeKok Date: Sun, 6 Aug 2017 16:20:10 +0000 (+0200) Subject: move proxy_state random number to main module X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=503fc4f5e3cb6416e626117eb1180f598abf9bf2;p=thirdparty%2Ffreeradius-server.git move proxy_state random number to main module --- diff --git a/src/modules/rlm_radius/rlm_radius.c b/src/modules/rlm_radius/rlm_radius.c index 06d70f53b27..041a29ca017 100644 --- a/src/modules/rlm_radius/rlm_radius.c +++ b/src/modules/rlm_radius/rlm_radius.c @@ -485,6 +485,11 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf) rad_assert(inst->io->bootstrap != NULL); rad_assert(inst->io->instantiate != NULL); + /* + * Get random Proxy-State identifier for this module. + */ + inst->proxy_state = fr_rand(); + /* * Bootstrap the submodule. */ diff --git a/src/modules/rlm_radius/rlm_radius.h b/src/modules/rlm_radius/rlm_radius.h index d0f4a95aa78..5d01edf051c 100644 --- a/src/modules/rlm_radius/rlm_radius.h +++ b/src/modules/rlm_radius/rlm_radius.h @@ -83,6 +83,8 @@ struct rlm_radius_t { void *io_instance; //!< Easy access to the IO instance CONF_SECTION *io_conf; //!< Easy access to the IO config section + uint32_t proxy_state; //!< Unique ID (mostly) of this module. + uint32_t *types; //!< array of allowed packet types int allowed[FR_MAX_PACKET_CODE]; rlm_radius_retry_t retry[FR_MAX_PACKET_CODE]; diff --git a/src/modules/rlm_radius/rlm_radius_udp.c b/src/modules/rlm_radius/rlm_radius_udp.c index 4aa934145b5..f54db896c38 100644 --- a/src/modules/rlm_radius/rlm_radius_udp.c +++ b/src/modules/rlm_radius/rlm_radius_udp.c @@ -86,7 +86,6 @@ typedef struct rlm_radius_udp_connection_t { fr_connection_t *conn; //!< Connection to our destination. char const *name; //!< from IP PORT to IP PORT - uint32_t proxy_state; //!< ID of this connection fr_dlist_t entry; //!< in the linked list of connections int heap_id; //!< for the active heap rlm_radius_udp_connection_state_t state; //!< state of the connection @@ -719,7 +718,7 @@ static int conn_write(rlm_radius_udp_connection_t *c, rlm_radius_udp_request_t * attr[0] = FR_PROXY_STATE; attr[1] = 6; - memcpy(attr + 2, &c->proxy_state, 4); + memcpy(attr + 2, &c->inst->parent->proxy_state, 4); hdr_len = (c->buffer[2] << 8) | (c->buffer[3]); hdr_len += 6; @@ -728,7 +727,7 @@ static int conn_write(rlm_radius_udp_connection_t *c, rlm_radius_udp_request_t * if (radlog_debug_enabled(L_DBG, L_DBG_LVL_2, request)) { RINDENT(); - RDEBUG2("&Proxy-State := 0x%08x", c->proxy_state); + RDEBUG2("&Proxy-State := 0x%08x", c->inst->parent->proxy_state); REXDENT(); } @@ -940,7 +939,6 @@ static fr_connection_state_t conn_open(UNUSED fr_event_list_t *el, UNUSED int fd c->name = talloc_asprintf(c, "proto udp local %s port %u remote %s port %u", src_buf, c->src_port, dst_buf, c->dst_port); - c->proxy_state = fr_rand(); c->state = CONN_OPENING; /*