]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Move server_id into proto_radius_auth
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 22 Jun 2018 00:13:43 +0000 (20:13 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Fri, 22 Jun 2018 00:16:25 +0000 (20:16 -0400)
This is a super secret config option that is pretty RADIUS specific

src/include/radiusd.h
src/include/state.h
src/main/mainconfig.c
src/main/state.c
src/main/unit_test_module.c
src/modules/proto_radius/proto_radius_auth.c

index 2956260af21300499265097530203118b35c9d1d..4739a20922bd68c90e7c1fc9cec6475a42824e4e 100644 (file)
@@ -126,10 +126,6 @@ typedef struct main_config {
 
        size_t          talloc_pool_size;               //!< Size of pool to allocate to hold each #REQUEST.
 
-       uint8_t         state_server_id;                //!< Sets a specific byte in the state to allow the
-                                                       //!< authenticating server to be identified in packet
-                                                       //!< captures.
-
        bool            write_pid;                      //!< write the PID file
 
 #ifdef HAVE_SETUID
index 57bd8843584cf8f30b55718551a8768b5ac0685d..66717c6b49292553dcfbeece533c9fcd61364e12 100644 (file)
@@ -32,7 +32,8 @@ extern "C" {
 
 typedef struct fr_state_tree_t fr_state_tree_t;
 
-fr_state_tree_t *fr_state_tree_init(TALLOC_CTX *ctx, fr_dict_attr_t const *da, uint32_t max_sessions, uint32_t timeout);
+fr_state_tree_t *fr_state_tree_init(TALLOC_CTX *ctx, fr_dict_attr_t const *da,
+                                   uint32_t max_sessions, uint32_t timeout, uint8_t server_id);
 
 void fr_state_discard(fr_state_tree_t *state, REQUEST *request);
 
index 976bc76dc2887afb2889405d23eb2e84c6e28128..0d4be005c4a74d4ff9205de250832cca2bbde8aa 100644 (file)
@@ -221,7 +221,6 @@ static const CONF_PARSER security_config[] = {
 #ifdef ENABLE_OPENSSL_VERSION_CHECK
        { FR_CONF_POINTER("allow_vulnerable_openssl", FR_TYPE_STRING, &main_config.allow_vulnerable_openssl), .dflt = "no" },
 #endif
-       { FR_CONF_POINTER("server_id", FR_TYPE_UINT8, &main_config.state_server_id) },
 
        CONF_PARSER_TERMINATOR
 };
index d25ab9fdd177019103c12744832b30bb30889cc3..80333802b7220331955fb033f4fb134c9f77f733 100644 (file)
@@ -119,6 +119,8 @@ struct fr_state_tree_t {
        uint32_t                timeout;                        //!< How long to wait before cleaning up state entires.
        pthread_mutex_t         mutex;                          //!< Synchronisation mutex.
 
+       uint8_t                 server_id;                      //!< ID to use for load balancing.
+
        fr_dict_attr_t const    *da;                            //!< State attribute used.
 };
 
@@ -175,12 +177,13 @@ static int _state_tree_free(fr_state_tree_t *state)
  * @param[in] da               Attribute used to store and retrieve state from.
  * @param[in] max_sessions     we track state for.
  * @param[in] timeout          How long to wait before cleaning up entries.
+ * @param[in] server_id                ID byte to use in load-balancing operations.
  * @return
  *     - A new state tree.
  *     - NULL on failure.
  */
 fr_state_tree_t *fr_state_tree_init(TALLOC_CTX *ctx, fr_dict_attr_t const *da,
-                                   uint32_t max_sessions, uint32_t timeout)
+                                   uint32_t max_sessions, uint32_t timeout, uint8_t server_id)
 {
        fr_state_tree_t *state;
 
@@ -218,6 +221,7 @@ fr_state_tree_t *fr_state_tree_init(TALLOC_CTX *ctx, fr_dict_attr_t const *da,
        talloc_set_destructor(state, _state_tree_free);
 
        state->da = da;         /* Remember which attribute we use to load/store state */
+       state->tree = server_id;
 
        return state;
 }
@@ -454,7 +458,7 @@ static fr_state_entry_t *state_entry_create(fr_state_tree_t *state, REQUEST *req
                 *      Allow a portion of the State attribute to be set,
                 *      this is useful for debugging purposes.
                 */
-               entry->state_comp.server_id = main_config.state_server_id;
+               entry->state_comp.server_id = state->server_id;
 
                vp = fr_pair_afrom_da(packet, state->da);
                fr_pair_value_memcpy(vp, entry->state, sizeof(entry->state));
index 08a6c4b2b9d1de4317fdadbe53d7d86f556390d5..2d4573728b0dc5dd70f21aa52f7b279bf4561048 100644 (file)
@@ -944,7 +944,7 @@ int main(int argc, char *argv[])
        if (modules_thread_instantiate(thread_ctx, main_config.config, el) < 0) goto exit_failure;
        if (xlat_thread_instantiate(thread_ctx) < 0) goto exit_failure;
 
-       state = fr_state_tree_init(autofree, attr_state, 256, 10);
+       state = fr_state_tree_init(autofree, attr_state, 256, 10, 0);
 
        /*
         *  Set the panic action (if required)
index 6ee73cd9ae61f1201d74529fa9f5481b2966cbaf..11f8a43a94efd50d15e86f5d36907218d46acbd7 100644 (file)
@@ -48,12 +48,17 @@ typedef struct {
        uint32_t        session_timeout;                //!< Maximum time between the last response and next request.
        uint32_t        max_session;                    //!< Maximum ongoing session allowed.
 
+       uint8_t         state_server_id;                //!< Sets a specific byte in the state to allow the
+                                                       //!< authenticating server to be identified in packet
+                                                       //!< captures.
+
        fr_state_tree_t *state_tree;                    //!< State tree to link multiple requests/responses.
 } proto_radius_auth_t;
 
 static const CONF_PARSER session_config[] = {
        { FR_CONF_OFFSET("timeout", FR_TYPE_UINT32, proto_radius_auth_t, session_timeout), .dflt = "15" },
        { FR_CONF_OFFSET("max", FR_TYPE_UINT32, proto_radius_auth_t, max_session), .dflt = "4096" },
+       { FR_CONF_OFFSET("state_server_id", FR_TYPE_UINT8, proto_radius_auth_t, state_server_id) },
 
        CONF_PARSER_TERMINATOR
 };
@@ -658,7 +663,8 @@ static int mod_instantiate(void *instance, CONF_SECTION *process_app_cs)
                }
        }
 
-       inst->state_tree = fr_state_tree_init(inst, attr_state, inst->max_session, inst->session_timeout);
+       inst->state_tree = fr_state_tree_init(inst, attr_state, inst->max_session,
+                                             inst->session_timeout, inst->state_server_id);
 
        return 0;
 }