From: Alan T. DeKok Date: Sat, 12 Apr 2025 18:44:00 +0000 (-0400) Subject: move request->dict to proto_dict and local_dict X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc7f360c334199963524cdee7776455d1ed9d922;p=thirdparty%2Ffreeradius-server.git move request->dict to proto_dict and local_dict in order to split uses of base protocol dictionary, and dictionary with local variables. The protocol dictionary is used for encoding / decoding, including xlats, and attributes read from external modules such as SQL or LDAP. The local dictionary is used for local variables it is saved, updated, and restored every time the interpreter defines a local attribute update request_init() to set dict to internal if it isn't passed in. update nearly all references to run-time parsing from request->dict to request->local_dict. Only the protocol encoders are left unchanged. this means that maps, %debug() etc. can now reference local attributes, which they couldn't before. update %eval() to use the local dict, too. update fr_listen_t to have a dict, so the worker thread can use it. and don't set request->dict in the listen decode any more. --- diff --git a/src/bin/unit_test_module.c b/src/bin/unit_test_module.c index ee6a98a971b..6adcaf6713e 100644 --- a/src/bin/unit_test_module.c +++ b/src/bin/unit_test_module.c @@ -190,35 +190,28 @@ static request_t *request_from_file(TALLOC_CTX *ctx, FILE *fp, fr_client_t *clie static int number = 0; - /* - * Create and initialize the new request. - */ - request = request_local_alloc_external(ctx, NULL); - - /* - * FIXME - Should be less RADIUS centric, but everything - * else assumes RADIUS at the moment so we can fix this later. - */ - request->dict = dict_protocol; - if (!request->dict) { + if (!dict_protocol) { fr_strerror_printf_push("%s dictionary failed to load", PROTOCOL_NAME); - error: - talloc_free(request); return NULL; } + /* + * Create and initialize the new request. + */ + request = request_local_alloc_external(ctx, (&(request_init_args_t){ .namespace = dict_protocol })); + request->packet = fr_packet_alloc(request, false); if (!request->packet) { + oom: fr_strerror_const("No memory"); - goto error; + error: + talloc_free(request); + return NULL; } request->packet->timestamp = fr_time(); request->reply = fr_packet_alloc(request, false); - if (!request->reply) { - fr_strerror_const("No memory"); - goto error; - } + if (!request->reply) goto oom; request->client = client; request->number = number++; @@ -606,7 +599,7 @@ static request_t *request_clone(request_t *old, int number, CONF_SECTION *server { request_t *request; - request = request_alloc_internal(NULL, NULL); + request = request_alloc_internal(NULL, (&(request_init_args_t){ .namespace = old->proto_dict })); if (!request) return NULL; if (!request->packet) request->packet = fr_packet_alloc(request, false); @@ -621,7 +614,6 @@ static request_t *request_clone(request_t *old, int number, CONF_SECTION *server unlang_call_push(request, server_cs, UNLANG_TOP_FRAME); request->master_state = REQUEST_ACTIVE; - request->dict = old->dict; return request; } diff --git a/src/lib/io/listen.h b/src/lib/io/listen.h index e4f5948994e..b75586f50a3 100644 --- a/src/lib/io/listen.h +++ b/src/lib/io/listen.h @@ -27,6 +27,7 @@ struct fr_listen { int fd; //!< file descriptor for this socket - set by open char const *name; //!< printable name for this socket - set by open + fr_dict_t const *dict; //!< dictionary for this listener fr_app_io_t const *app_io; //!< I/O path functions. void const *app_io_instance; //!< I/O path configuration context. diff --git a/src/lib/io/network.c b/src/lib/io/network.c index b74c422b5df..f7828609b9a 100644 --- a/src/lib/io/network.c +++ b/src/lib/io/network.c @@ -237,6 +237,18 @@ int fr_network_listen_add(fr_network_t *nr, fr_listen_t *li) { fr_ring_buffer_t *rb; + /* + * Associate the protocol dictionary with the listener, so that the decode functions can check / + * use it. + * + * A virtual server may start off with a "dictionary" block, and therefore define a local + * dictionary. So the "root" dictionary of a virtual server may not be a protocol dict. + */ + fr_assert(li->server_cs != NULL); + li->dict = fr_dict_proto_dict(virtual_server_dict_by_cs(li->server_cs)); + + fr_assert(li->dict != NULL); + /* * Skip a bunch of work if we're already in the network thread. */ diff --git a/src/lib/io/worker.c b/src/lib/io/worker.c index cc85dfffb0e..fdc60ca29b8 100644 --- a/src/lib/io/worker.c +++ b/src/lib/io/worker.c @@ -803,11 +803,17 @@ static void worker_request_bootstrap(fr_worker_t *worker, fr_channel_data_t *cd, int ret = -1; request_t *request; TALLOC_CTX *ctx; - fr_listen_t const *listen; + fr_listen_t *listen = cd->listen; if (fr_minmax_heap_num_elements(worker->time_order) >= (uint32_t) worker->config.max_requests) goto nak; - ctx = request = request_alloc_external(NULL, NULL); + /* + * Receive a message to the worker queue, and decode it + * to a request. + */ + fr_assert(listen != NULL); + + ctx = request = request_alloc_external(NULL, (&(request_init_args_t){ .namespace = listen->dict })); if (!request) goto nak; worker_request_init(worker, request, now); @@ -820,12 +826,6 @@ static void worker_request_bootstrap(fr_worker_t *worker, fr_channel_data_t *cd, request->packet->timestamp = cd->request.recv_time; /* Legacy - Remove once everything looks at request->async */ - /* - * Receive a message to the worker queue, and decode it - * to a request. - */ - fr_assert(cd->listen != NULL); - /* * Update the transport-specific fields. */ @@ -833,10 +833,9 @@ static void worker_request_bootstrap(fr_worker_t *worker, fr_channel_data_t *cd, request->async->recv_time = cd->request.recv_time; - request->async->listen = cd->listen; + request->async->listen = listen; request->async->packet_ctx = cd->packet_ctx; request->async->priority = cd->priority; - listen = request->async->listen; /* * Now that the "request" structure has been initialized, go decode the packet. diff --git a/src/lib/ldap/map.c b/src/lib/ldap/map.c index 7c2fb9d628d..956b436c0f2 100644 --- a/src/lib/ldap/map.c +++ b/src/lib/ldap/map.c @@ -67,7 +67,7 @@ int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reques tmpl_rules_t lhs_rules = { .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .request_def = tmpl_request(map->lhs), .list_def = tmpl_list(map->lhs), }, @@ -79,7 +79,7 @@ int fr_ldap_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *reques tmpl_rules_t rhs_rules = { .attr = { - .dict_def = request->dict + .dict_def = request->local_dict }, .xlat = { .runtime_el = lhs_rules.xlat.runtime_el, @@ -341,7 +341,7 @@ int fr_ldap_map_do(request_t *request, char const *check_attr, int count, i; tmpl_rules_t const parse_rules = { .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_request, }, .xlat = { @@ -452,7 +452,7 @@ int fr_ldap_map_do(request_t *request, char const *check_attr, tmpl_rules_t const parse_rules = { .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_request, }, .xlat = { diff --git a/src/lib/redis/redis.c b/src/lib/redis/redis.c index 7c5beedf6a2..d340c86e25d 100644 --- a/src/lib/redis/redis.c +++ b/src/lib/redis/redis.c @@ -395,7 +395,7 @@ int fr_redis_reply_to_map(TALLOC_CTX *ctx, map_list_t *out, request_t *request, slen = tmpl_afrom_attr_str(map, NULL, &map->lhs, key->str, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_request } }); diff --git a/src/lib/server/log.c b/src/lib/server/log.c index afe1599db87..80c525d6123 100644 --- a/src/lib/server/log.c +++ b/src/lib/server/log.c @@ -860,7 +860,7 @@ void log_request_proto_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_list_foreach(vps, vp) { PAIR_VERIFY(vp); - if (!fr_dict_attr_common_parent(fr_dict_root(request->dict), vp->da, true)) continue; + if (!fr_dict_attr_common_parent(fr_dict_root(request->proto_dict), vp->da, true)) continue; log_request_pair(lvl, request, parent, vp, prefix); } diff --git a/src/lib/server/map.c b/src/lib/server/map.c index e7bd83afc2c..1110c9aff26 100644 --- a/src/lib/server/map.c +++ b/src/lib/server/map.c @@ -1921,7 +1921,7 @@ int map_to_request(request_t *request, map_t const *map, radius_map_getvalue_t f slen = tmpl_afrom_attr_str(tmp_ctx, NULL, &exp_lhs, attr_str, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = request_attr_request, } }); diff --git a/src/lib/server/map_async.c b/src/lib/server/map_async.c index e40ffd2e362..9370df2aa12 100644 --- a/src/lib/server/map_async.c +++ b/src/lib/server/map_async.c @@ -320,7 +320,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, slen = tmpl_afrom_attr_str(tmp_ctx, NULL, &map_tmp.lhs, lhs_result_head->vb_strvalue, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = request_attr_request, } }); @@ -709,7 +709,7 @@ int map_to_list_mod(TALLOC_CTX *ctx, vp_list_mod_t **out, /* * Parse the VPs from the RHS. */ - fr_pair_list_afrom_box(ctx, &vp_head, request->dict, rhs_result_head); + fr_pair_list_afrom_box(ctx, &vp_head, request->proto_dict, rhs_result_head); if (fr_pair_list_empty(&vp_head)) { talloc_free(n); RDEBUG2("No pairs returned by exec"); diff --git a/src/lib/server/pair_server_tests.c b/src/lib/server/pair_server_tests.c index 8bd74fc53c1..c60c31c0301 100644 --- a/src/lib/server/pair_server_tests.c +++ b/src/lib/server/pair_server_tests.c @@ -79,7 +79,7 @@ static request_t *request_fake_alloc(void) /* * Create and initialize the new request. */ - request = request_local_alloc_external(autofree, NULL); + request = request_local_alloc_external(autofree, (&(request_init_args_t){ .namespace = test_dict })); request->packet = fr_packet_alloc(request, false); TEST_CHECK(request->packet != NULL); diff --git a/src/lib/server/request.c b/src/lib/server/request.c index 91cfebee5ad..6fd2371ef81 100644 --- a/src/lib/server/request.c +++ b/src/lib/server/request.c @@ -31,8 +31,6 @@ RCSID("$Id$") #include #include -static request_init_args_t default_args; - static fr_dict_t const *dict_freeradius; extern fr_dict_autoload_t request_dict[]; @@ -198,7 +196,10 @@ static inline CC_HINT(always_inline) int request_detachable_init(request_t *chil static inline CC_HINT(always_inline) int request_child_init(request_t *child, request_t *parent) { child->number = parent->child_number++; - if (!child->dict) child->dict = parent->dict; + if (!child->proto_dict) { + child->proto_dict = parent->proto_dict; + child->local_dict = parent->proto_dict; + } if ((parent->seq_start == 0) || (parent->number == parent->seq_start)) { child->name = talloc_typed_asprintf(child, "%s.%" PRIu64, parent->name, child->number); @@ -243,16 +244,28 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line request_t *request, request_type_t type, request_init_args_t const *args) { + fr_dict_t const *dict; /* * Sanity checks for different requests types */ switch (type) { case REQUEST_TYPE_EXTERNAL: + fr_assert(args); + if (!fr_cond_assert_msg(!args->parent, "External requests must NOT have a parent")) return -1; + + fr_assert(args->namespace); + + dict = args->namespace; break; case REQUEST_TYPE_INTERNAL: + if (!args || !args->namespace) { + dict = fr_dict_internal(); + } else { + dict = args->namespace; + } break; case REQUEST_TYPE_DETACHED: @@ -267,10 +280,11 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line #endif .type = type, .master_state = REQUEST_ACTIVE, - .dict = args->namespace, + .proto_dict = fr_dict_proto_dict(dict), + .local_dict = dict, .component = "", .flags = { - .detachable = args->detachable + .detachable = args && args->detachable, }, .alloc_file = file, .alloc_line = line @@ -306,7 +320,7 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line * the any uninitialised lists and * create them locally. */ - memcpy(&request->pair_list, &args->pair_list, sizeof(request->pair_list)); + if (args) memcpy(&request->pair_list, &args->pair_list, sizeof(request->pair_list)); #define list_init(_ctx, _list) \ do { \ @@ -337,7 +351,7 @@ static inline CC_HINT(always_inline) int request_init(char const *file, int line * fields if this is going to be a * child request. */ - if (args->parent) { + if (args && args->parent) { if (request_child_init(request, args->parent) < 0) return -1; if (args->detachable) { @@ -504,8 +518,6 @@ request_t *_request_alloc(char const *file, int line, TALLOC_CTX *ctx, request_t *request; fr_dlist_head_t *free_list; - if (!args) args = &default_args; - /* * Setup the free list, or return the free * list for this thread. @@ -610,8 +622,6 @@ request_t *_request_local_alloc(char const *file, int line, TALLOC_CTX *ctx, { request_t *request; - if (!args) args = &default_args; - request = request_alloc_pool(ctx); if (request_init(file, line, request, type, args) < 0) return NULL; @@ -814,6 +824,9 @@ void request_verify(char const *file, int line, request_t const *request) fr_pair_list_verify(file, line, request->session_state_ctx, &request->session_state_pairs); fr_pair_list_verify(file, line, request->local_ctx, &request->local_pairs); + fr_assert(request->proto_dict != NULL); + fr_assert(request->local_dict != NULL); + if (request->packet) { packet_verify(file, line, request, request->packet, &request->request_pairs, "request"); } diff --git a/src/lib/server/request.h b/src/lib/server/request.h index 1b2934f4a4f..e628da9a8b2 100644 --- a/src/lib/server/request.h +++ b/src/lib/server/request.h @@ -183,7 +183,8 @@ struct request_s { uint64_t seq_start; //!< State sequence ID. Stable identifier for a sequence of requests //!< and responses. - fr_dict_t const *dict; //!< Dictionary of the protocol that this request belongs to. + fr_dict_t const *proto_dict; //!< Dictionary of the protocol that this request belongs to. + fr_dict_t const *local_dict; //!< dictionary for local variables fr_pair_t *pair_root; //!< Root attribute which contains the ///< other list attributes as children. diff --git a/src/lib/server/tmpl_dcursor_tests.c b/src/lib/server/tmpl_dcursor_tests.c index 3af9b6f487c..6571a421021 100644 --- a/src/lib/server/tmpl_dcursor_tests.c +++ b/src/lib/server/tmpl_dcursor_tests.c @@ -41,7 +41,7 @@ static request_t *request_fake_alloc(void) /* * Create and initialize the new request. */ - request = request_local_alloc_external(autofree, NULL); + request = request_local_alloc_external(autofree, (&(request_init_args_t){ .namespace = test_dict })); request->packet = fr_packet_alloc(request, false); TEST_CHECK(request->packet != NULL); diff --git a/src/lib/server/trigger.c b/src/lib/server/trigger.c index c8ce80e625a..26925d4511c 100644 --- a/src/lib/server/trigger.c +++ b/src/lib/server/trigger.c @@ -92,8 +92,7 @@ xlat_action_t trigger_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, head = request_data_reference(request, &trigger_exec_main, REQUEST_INDEX_TRIGGER_ARGS); - da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict ? request->dict : fr_dict_internal()), - in_head->vb_strvalue); + da = fr_dict_attr_by_name(NULL, fr_dict_root(request->local_dict), in_head->vb_strvalue); if (!da) { ERROR("Unknown attribute \"%pV\"", in_head); return XLAT_ACTION_FAIL; @@ -386,7 +385,7 @@ int trigger_exec(unlang_interpret_t *intp, &FR_SBUFF_IN(trigger->command, talloc_array_length(trigger->command) - 1), NULL, NULL, &(tmpl_rules_t) { .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = request_attr_request, .allow_unresolved = false, }, diff --git a/src/lib/tls/cache.c b/src/lib/tls/cache.c index a129c23a50a..96caa992877 100644 --- a/src/lib/tls/cache.c +++ b/src/lib/tls/cache.c @@ -261,7 +261,7 @@ static int tls_cache_app_data_get(request_t *request, SSL_SESSION *sess) */ while (fr_dbuff_remaining(&dbuff) > 0) { if (fr_internal_decode_pair_dbuff(request->session_state_ctx, &tmp, - fr_dict_root(request->dict), &dbuff, NULL) < 0) { + fr_dict_root(request->proto_dict), &dbuff, NULL) < 0) { SESSION_ID(sess_id, sess); fr_pair_list_free(&tmp); diff --git a/src/lib/unlang/caller.c b/src/lib/unlang/caller.c index d9b3394996f..ab049242057 100644 --- a/src/lib/unlang/caller.c +++ b/src/lib/unlang/caller.c @@ -40,7 +40,7 @@ static unlang_action_t unlang_caller(rlm_rcode_t *p_result, request_t *request, /* * No parent, or the dictionaries don't match. Ignore it. */ - if (!request->parent || (request->parent->dict != gext->dict)) { + if (!request->parent || (request->parent->proto_dict != gext->dict)) { RDEBUG2("..."); return UNLANG_ACTION_EXECUTE_NEXT; } diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index 4bb99e6ffde..2604704b019 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -4076,10 +4076,19 @@ static unlang_t *compile_subrequest(unlang_t *parent, unlang_compile_t *unlang_c dict = unlang_ctx->rules->attr.dict_def; packet_name = NULL; +get_packet_type: + /* + * Local attributes cannot be used in a subrequest. They belong to the parent. Local attributes + * are NOT copied to the subrequest. + * + * @todo - maybe we want to copy local variables, too? But there may be multiple nested local + * variables, each with their own dictionary. + */ + dict = fr_dict_proto_dict(dict); + /* * Use dict name instead of "namespace", because "namespace" can be omitted. */ -get_packet_type: da = fr_dict_attr_by_name(NULL, fr_dict_root(dict), "Packet-Type"); if (!da) { cf_log_err(cs, "No such attribute 'Packet-Type' in namespace '%s'", fr_dict_root(dict)->name); diff --git a/src/lib/unlang/edit.c b/src/lib/unlang/edit.c index 9e15bd8a53d..f6260ac28cb 100644 --- a/src/lib/unlang/edit.c +++ b/src/lib/unlang/edit.c @@ -129,7 +129,7 @@ static int tmpl_attr_from_result(TALLOC_CTX *ctx, map_t const *map, edit_result_ slen = tmpl_afrom_attr_str(ctx, NULL, &out->to_free, box->vb_strvalue, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = request_attr_request, } }); @@ -328,7 +328,7 @@ static int apply_edits_to_list(request_t *request, unlang_frame_state_edit_t *st * point. The ones which aren't moved will get deleted in this function. */ da = tmpl_attr_tail_da(current->lhs.vpt); - if (fr_type_is_group(da->type)) da = fr_dict_root(request->dict); + if (fr_type_is_group(da->type)) da = fr_dict_root(request->proto_dict); root = (fr_pair_parse_t) { .ctx = current->ctx, diff --git a/src/lib/unlang/interpret.c b/src/lib/unlang/interpret.c index c3a98af7297..8e6cd1cb0ce 100644 --- a/src/lib/unlang/interpret.c +++ b/src/lib/unlang/interpret.c @@ -213,8 +213,8 @@ int unlang_interpret_push(request_t *request, unlang_t const *instruction, } typedef struct { - fr_dict_t const *dict; - request_t *request; + fr_dict_t const *old_dict; //!< the previous dictionary for the request + request_t *request; //!< the request } unlang_variable_ref_t; static int _local_variables_free(unlang_variable_ref_t *ref) @@ -228,7 +228,7 @@ static int _local_variables_free(unlang_variable_ref_t *ref) vp = fr_pair_list_tail(&ref->request->local_pairs); while (vp) { prev = fr_pair_list_prev(&ref->request->local_pairs, vp); - if (vp->da->dict != ref->dict) { + if (vp->da->dict != ref->request->local_dict) { break; } @@ -236,6 +236,8 @@ static int _local_variables_free(unlang_variable_ref_t *ref) vp = prev; } + ref->request->local_dict = ref->old_dict; + return 0; } @@ -295,8 +297,9 @@ unlang_action_t unlang_interpret_push_children(rlm_rcode_t *p_result, request_t /* * Set the destructor to clean up local variables. */ - ref->dict = g->variables->dict; ref->request = request; + ref->old_dict = request->local_dict; + request->local_dict = g->variables->dict; talloc_set_destructor(ref, _local_variables_free); return UNLANG_ACTION_PUSHED_CHILD; diff --git a/src/lib/unlang/io.c b/src/lib/unlang/io.c index ca1fdd5f672..c2d761fa75e 100644 --- a/src/lib/unlang/io.c +++ b/src/lib/unlang/io.c @@ -40,6 +40,11 @@ request_t *unlang_io_subrequest_alloc(request_t *parent, fr_dict_t const *namesp { request_t *child; + /* + * A child cannot refer to local variables in the parent context. + */ + fr_assert(fr_dict_proto_dict(namespace) == namespace); + child = request_alloc_internal(detachable ? NULL : parent, (&(request_init_args_t){ .parent = parent, diff --git a/src/lib/unlang/parallel.c b/src/lib/unlang/parallel.c index f3ec4650a1b..22c2c0cc8da 100644 --- a/src/lib/unlang/parallel.c +++ b/src/lib/unlang/parallel.c @@ -275,7 +275,7 @@ static unlang_action_t unlang_parallel_process(rlm_rcode_t *p_result, request_t for (i = 0; i < state->num_children; i++) { fr_assert(state->children[i].instruction != NULL); child = unlang_io_subrequest_alloc(request, - request->dict, state->detach); + request->proto_dict, state->detach); child->packet->code = request->packet->code; RDEBUG3("parallel - child %s (%d/%d) INIT", diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index 00d9bd5973f..87121458f25 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -284,7 +284,7 @@ static xlat_action_t xlat_func_debug_attr(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcur if (tmpl_afrom_attr_str(request, NULL, &vpt, fmt, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = request_attr_request, .allow_wildcard = true, } @@ -933,7 +933,7 @@ static xlat_action_t xlat_func_immutable_attr(UNUSED TALLOC_CTX *ctx, UNUSED fr_ if (tmpl_afrom_attr_str(request, NULL, &vpt, fmt, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = request_attr_request, .allow_wildcard = true, } @@ -1294,7 +1294,7 @@ static xlat_action_t xlat_func_map(TALLOC_CTX *ctx, fr_dcursor_t *out, tmpl_rules_t attr_rules = { .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = request_attr_request, }, .xlat = { @@ -1463,19 +1463,6 @@ static xlat_action_t xlat_eval_resume(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor_ return xa; } -typedef struct { - fr_dict_t const *namespace; //!< Namespace we use for evaluating runtime expansions -} xlat_eval_inst_t; - -static int xlat_eval_instantiate(xlat_inst_ctx_t const *xctx) -{ - xlat_eval_inst_t *inst = talloc_get_type_abort(xctx->inst, xlat_eval_inst_t); - - inst->namespace = xctx->ex->call.dict; - - return 0; -} - static xlat_arg_parser_t const xlat_func_eval_arg[] = { { .required = true, .concat = true, .type = FR_TYPE_STRING }, XLAT_ARG_PARSER_TERMINATOR @@ -1486,11 +1473,9 @@ static xlat_arg_parser_t const xlat_func_eval_arg[] = { * @ingroup xlat_functions */ static xlat_action_t xlat_func_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, - xlat_ctx_t const *xctx, + UNUSED xlat_ctx_t const *xctx, request_t *request, fr_value_box_list_t *args) { - xlat_eval_inst_t const *inst = talloc_get_type_abort_const(xctx->inst, xlat_eval_inst_t); - /* * These are escaping rules applied to the * input string. They're mostly here to @@ -1528,7 +1513,7 @@ static xlat_action_t xlat_func_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, }, &(tmpl_rules_t){ .attr = { - .dict_def = inst->namespace, + .dict_def = request->local_dict, .list_def = request_attr_request, .allow_unknown = false, .allow_unresolved = false, @@ -2443,7 +2428,7 @@ static xlat_action_t xlat_func_pairs(TALLOC_CTX *ctx, fr_dcursor_t *out, if (tmpl_afrom_attr_str(ctx, NULL, &vpt, in_head->vb_strvalue, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = request_attr_request, .allow_wildcard = true, } @@ -3912,7 +3897,7 @@ static xlat_action_t protocol_decode_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, fr_test_point_pair_decode_t const *tp_decode = *(void * const *)xctx->inst; if (tp_decode->test_ctx) { - if (tp_decode->test_ctx(&decode_ctx, ctx, request->dict) < 0) { + if (tp_decode->test_ctx(&decode_ctx, ctx, request->proto_dict) < 0) { return XLAT_ACTION_FAIL; } } @@ -4033,7 +4018,7 @@ static xlat_action_t protocol_encode_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, if (tmpl_afrom_attr_str(ctx, NULL, &vpt, in_head->vb_strvalue, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, /* we can't encode local attributes */ .list_def = request_attr_request, .allow_wildcard = true, } @@ -4046,7 +4031,7 @@ static xlat_action_t protocol_encode_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, * Create the encoding context. */ if (tp_encode->test_ctx) { - if (tp_encode->test_ctx(&encode_ctx, vpt, request->dict) < 0) { + if (tp_encode->test_ctx(&encode_ctx, vpt, request->proto_dict) < 0) { talloc_free(vpt); return XLAT_ACTION_FAIL; } @@ -4062,7 +4047,7 @@ static xlat_action_t protocol_encode_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, /* * Don't check the dictionaries. By definition, - * vp->da->dict==request->dict, OR else we're + * vp->da->dict==request->proto_dict, OR else we're * using the internal encoder and encoding a real * protocol. * @@ -4397,7 +4382,6 @@ do { \ XLAT_REGISTER_PURE("urlquote", xlat_func_urlquote, FR_TYPE_STRING, xlat_func_urlquote_arg); XLAT_REGISTER_PURE("urlunquote", xlat_func_urlunquote, FR_TYPE_STRING, xlat_func_urlunquote_arg); XLAT_REGISTER_PURE("eval", xlat_func_eval, FR_TYPE_VOID, xlat_func_eval_arg); - xlat_func_instantiate_set(xlat, xlat_eval_instantiate, xlat_eval_inst_t, NULL, NULL); return xlat_register_expressions(); } diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index f991fad364f..c6b99c20172 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -1658,7 +1658,7 @@ ssize_t _xlat_eval(TALLOC_CTX *ctx, char **out, size_t outlen, request_t *reques NULL, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = request_attr_request, }, .xlat = { diff --git a/src/lib/unlang/xlat_pair.c b/src/lib/unlang/xlat_pair.c index 35ef2f520c4..e3fd6c6b9d9 100644 --- a/src/lib/unlang/xlat_pair.c +++ b/src/lib/unlang/xlat_pair.c @@ -93,7 +93,7 @@ int xlat_decode_value_box_list(TALLOC_CTX *ctx, fr_pair_list_t *out, { int decoded = 0; fr_pair_t *vp = NULL; - fr_dict_attr_t const *parent = fr_dict_root(request->dict); + fr_dict_attr_t const *parent = fr_dict_root(request->proto_dict); fr_pair_list_t head; fr_pair_list_init(&head); diff --git a/src/lib/unlang/xlat_purify.c b/src/lib/unlang/xlat_purify.c index a21c262b73c..4ab494da959 100644 --- a/src/lib/unlang/xlat_purify.c +++ b/src/lib/unlang/xlat_purify.c @@ -231,21 +231,7 @@ static int xlat_purify_list_internal(xlat_exp_head_t *head, request_t *request, */ if (!node->flags.pure) { if (node->call.func->purify) { - fr_dict_t const *dict = request->dict; - - /* - * Swap in the node specific dictionary. - * - * The previous code stored the dictionary in the xlat_exp_head_t, - * and whilst this wasn't wrong, it was duplicative. - * - * This allows future code to create inline definitions of local - * attributes, and have them work correctly, as more deeply nested - * expressions would swap in the correct dictionary. - */ - request->dict = node->call.dict; if (node->call.func->purify(node, node->call.inst->data, request) < 0) return -1; - request->dict = dict; } else { if (xlat_purify_list_internal(node->call.args, request, T_BARE_WORD) < 0) return -1; } @@ -321,7 +307,7 @@ int xlat_purify(xlat_exp_head_t *head, unlang_interpret_t *intp) if (!head->flags.can_purify) return 0; - request = request_alloc_internal(NULL, (&(request_init_args_t){ .namespace = fr_dict_internal() })); + request = request_alloc_internal(NULL, NULL); if (!request) return -1; if (intp) unlang_interpret_set(request, intp); diff --git a/src/lib/util/dict.h b/src/lib/util/dict.h index e3885cec999..e523405a3a2 100644 --- a/src/lib/util/dict.h +++ b/src/lib/util/dict.h @@ -748,6 +748,8 @@ fr_dict_t const *fr_dict_by_protocol_num(unsigned int num); fr_dict_attr_t const *fr_dict_unlocal(fr_dict_attr_t const *da) CC_HINT(nonnull); +fr_dict_t const *fr_dict_proto_dict(fr_dict_t const *dict) CC_HINT(nonnull); + fr_dict_t const *fr_dict_by_da(fr_dict_attr_t const *da) CC_HINT(nonnull); fr_dict_t const *fr_dict_by_attr_name(fr_dict_attr_t const **found, char const *name); diff --git a/src/lib/util/dict_util.c b/src/lib/util/dict_util.c index 06e59c30594..403378346e8 100644 --- a/src/lib/util/dict_util.c +++ b/src/lib/util/dict_util.c @@ -4958,7 +4958,7 @@ fr_dict_protocol_t const *fr_dict_protocol(fr_dict_t const *dict) } /* - * Get the real protocol dictionary behind the local one. + * Get the real protocol namespace behind a local one. */ fr_dict_attr_t const *fr_dict_unlocal(fr_dict_attr_t const *da) { @@ -4973,6 +4973,16 @@ fr_dict_attr_t const *fr_dict_unlocal(fr_dict_attr_t const *da) return da; } +/* + * Get the real protocol dictionary behind a local one. + */ +fr_dict_t const *fr_dict_proto_dict(fr_dict_t const *dict) +{ + while (dict->next) dict = dict->next; + + return dict; +} + int fr_dict_attr_set_group(fr_dict_attr_t **da_p) { if ((*da_p)->type == FR_TYPE_GROUP) { diff --git a/src/listen/arp/proto_arp.c b/src/listen/arp/proto_arp.c index 714962d09bf..e753063b1b4 100644 --- a/src/listen/arp/proto_arp.c +++ b/src/listen/arp/proto_arp.c @@ -67,13 +67,6 @@ static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t * // proto_arp_t const *inst = talloc_get_type_abort_const(instance, proto_arp_t); fr_arp_packet_t const *arp; - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = dict_arp; - if (fr_arp_decode(request->request_ctx, &request->request_pairs, data, data_len) < 0) { RPEDEBUG("Failed decoding packet"); return -1; diff --git a/src/listen/bfd/proto_bfd.c b/src/listen/bfd/proto_bfd.c index 6444f297487..ed276a6abdc 100644 --- a/src/listen/bfd/proto_bfd.c +++ b/src/listen/bfd/proto_bfd.c @@ -150,13 +150,6 @@ static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t * bfd_wrapper_t const *wrapper = (bfd_wrapper_t const *) data; bfd_packet_t const *bfd = (bfd_packet_t const *) wrapper->packet; - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = dict_bfd; - client = address->radclient; /* diff --git a/src/listen/cron/proto_cron.c b/src/listen/cron/proto_cron.c index 5b1561ca753..628a2061010 100644 --- a/src/listen/cron/proto_cron.c +++ b/src/listen/cron/proto_cron.c @@ -129,7 +129,6 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d { proto_cron_t const *inst = talloc_get_type_abort_const(instance, proto_cron_t); - request->dict = inst->dict; request->packet->code = inst->code; /* diff --git a/src/listen/cron/proto_cron_crontab.c b/src/listen/cron/proto_cron_crontab.c index 6f91ce88ddb..d3a0eb8f0c6 100644 --- a/src/listen/cron/proto_cron_crontab.c +++ b/src/listen/cron/proto_cron_crontab.c @@ -434,13 +434,6 @@ static int mod_decode(void const *instance, request_t *request, UNUSED uint8_t * fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t); fr_io_address_t const *address = track->address; - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = inst->dict; - /* * Hacks for now until we have a lower-level decode routine. */ diff --git a/src/listen/detail/proto_detail.c b/src/listen/detail/proto_detail.c index 20e537c6789..c30487d8078 100644 --- a/src/listen/detail/proto_detail.c +++ b/src/listen/detail/proto_detail.c @@ -90,7 +90,6 @@ static fr_dict_attr_t const *attr_packet_dst_port; static fr_dict_attr_t const *attr_packet_original_timestamp; static fr_dict_attr_t const *attr_packet_src_ip_address; static fr_dict_attr_t const *attr_packet_src_port; -static fr_dict_attr_t const *attr_protocol; extern fr_dict_attr_autoload_t proto_detail_dict_attr[]; fr_dict_attr_autoload_t proto_detail_dict_attr[] = { @@ -99,7 +98,6 @@ fr_dict_attr_autoload_t proto_detail_dict_attr[] = { { .out = &attr_packet_original_timestamp, .name = "Packet-Original-Timestamp", .type = FR_TYPE_DATE, .dict = &dict_freeradius }, { .out = &attr_packet_src_ip_address, .name = "Net.Src.IP", .type = FR_TYPE_COMBO_IP_ADDR, .dict = &dict_freeradius }, { .out = &attr_packet_src_port, .name = "Net.Src.Port", .type = FR_TYPE_UINT16, .dict = &dict_freeradius }, - { .out = &attr_protocol, .name = "Protocol", .type = FR_TYPE_UINT32, .dict = &dict_freeradius }, { NULL } }; @@ -227,7 +225,6 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d RHEXDUMP3(data, data_len, "proto_detail decode packet"); - request->dict = inst->dict; request->packet->code = inst->code; /* @@ -280,7 +277,6 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d */ if ((*p != '\0') && (*p != '\t')) { REDEBUG("Malformed line %d", lineno); - error: fr_dcursor_free_list(&cursor); return -1; } @@ -355,7 +351,7 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d */ root = (fr_pair_parse_t) { .ctx = request->request_ctx, - .da = fr_dict_root(request->dict), + .da = fr_dict_root(request->proto_dict), .list = &tmp_list, }; relative = (fr_pair_parse_t) { }; @@ -381,12 +377,6 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d request->packet->socket.inet.src_port = vp->vp_uint16; } else if (vp->da == attr_packet_dst_port) { request->packet->socket.inet.dst_port = vp->vp_uint16; - } else if (vp->da == attr_protocol) { - request->dict = fr_dict_by_protocol_num(vp->vp_uint32); - if (!request->dict) { - REDEBUG("Invalid protocol: %pP", vp); - goto error; - } } } diff --git a/src/listen/dhcpv4/proto_dhcpv4.c b/src/listen/dhcpv4/proto_dhcpv4.c index 90746d8af34..981780daca4 100644 --- a/src/listen/dhcpv4/proto_dhcpv4.c +++ b/src/listen/dhcpv4/proto_dhcpv4.c @@ -170,13 +170,6 @@ static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t * fr_client_t const *client; fr_packet_t *packet = request->packet; - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = dict_dhcpv4; - RHEXDUMP3(data, data_len, "proto_dhcpv4 decode packet"); client = address->radclient; diff --git a/src/listen/dhcpv6/proto_dhcpv6.c b/src/listen/dhcpv6/proto_dhcpv6.c index c42cb32546b..c24aa8e2474 100644 --- a/src/listen/dhcpv6/proto_dhcpv6.c +++ b/src/listen/dhcpv6/proto_dhcpv6.c @@ -170,13 +170,6 @@ static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t * fr_client_t const *client; fr_packet_t *packet = request->packet; - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = dict_dhcpv6; - RHEXDUMP3(data, data_len, "proto_dhcpv6 decode packet"); client = address->radclient; diff --git a/src/listen/dns/proto_dns.c b/src/listen/dns/proto_dns.c index 0bf01224f19..37a2e81bd5f 100644 --- a/src/listen/dns/proto_dns.c +++ b/src/listen/dns/proto_dns.c @@ -145,13 +145,6 @@ static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t * fr_dns_packet_t const *packet = (fr_dns_packet_t const *) data; fr_dns_ctx_t packet_ctx; - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = dict_dns; - RHEXDUMP3(data, data_len, "proto_dns decode packet"); client = address->radclient; diff --git a/src/listen/ldap_sync/proto_ldap_sync.c b/src/listen/ldap_sync/proto_ldap_sync.c index dfe9ae5938e..68e24157df4 100644 --- a/src/listen/ldap_sync/proto_ldap_sync.c +++ b/src/listen/ldap_sync/proto_ldap_sync.c @@ -126,7 +126,7 @@ static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t * ssize_t ret; fr_pair_t *vp = NULL; - request->dict = dict_ldap_sync; + fr_assert(request->proto_dict == dict_ldap_sync); fr_dbuff_init(&dbuff, data, data_len); @@ -134,7 +134,7 @@ static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t * * Extract attributes from the passed data */ ret = fr_internal_decode_list_dbuff(request->pair_list.request, &request->request_pairs, - fr_dict_root(request->dict), &dbuff, NULL); + fr_dict_root(request->proto_dict), &dbuff, NULL); if (ret < 0) return -1; vp = fr_pair_find_by_da(&request->request_pairs, NULL, attr_packet_type); diff --git a/src/listen/load/proto_load.c b/src/listen/load/proto_load.c index 4e2849bfeac..7c78e7fab41 100644 --- a/src/listen/load/proto_load.c +++ b/src/listen/load/proto_load.c @@ -129,7 +129,6 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d { proto_load_t const *inst = talloc_get_type_abort_const(instance, proto_load_t); - request->dict = inst->dict; request->packet->code = inst->code; /* diff --git a/src/listen/load/proto_load_step.c b/src/listen/load/proto_load_step.c index 47110347907..9fa0aa78f90 100644 --- a/src/listen/load/proto_load_step.c +++ b/src/listen/load/proto_load_step.c @@ -259,13 +259,6 @@ static int mod_decode(void const *instance, request_t *request, UNUSED uint8_t * fr_io_track_t const *track = talloc_get_type_abort_const(request->async->packet_ctx, fr_io_track_t); fr_io_address_t const *address = track->address; - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = inst->dict; - /* * Hacks for now until we have a lower-level decode routine. */ diff --git a/src/listen/radius/proto_radius.c b/src/listen/radius/proto_radius.c index 129cc9359a7..ee52328a3f9 100644 --- a/src/listen/radius/proto_radius.c +++ b/src/listen/radius/proto_radius.c @@ -205,13 +205,6 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d fr_assert(data[0] < FR_RADIUS_CODE_MAX); - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = dict_radius; - common_ctx = (fr_radius_ctx_t) { .secret = client->secret, .secret_length = talloc_array_length(client->secret) - 1, @@ -679,7 +672,7 @@ static xlat_action_t packet_vector_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, { fr_value_box_t *vb; - if (request->dict != dict_radius) return XLAT_ACTION_FAIL; + if (request->proto_dict != dict_radius) return XLAT_ACTION_FAIL; MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_OCTETS, NULL)); if (fr_value_box_memdup(vb, vb, NULL, request->packet->vector, sizeof(request->packet->vector), true) < 0) { diff --git a/src/listen/tacacs/proto_tacacs.c b/src/listen/tacacs/proto_tacacs.c index 0d9a0852c4e..af067ed4ff4 100644 --- a/src/listen/tacacs/proto_tacacs.c +++ b/src/listen/tacacs/proto_tacacs.c @@ -161,13 +161,6 @@ static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t * RHEXDUMP3(data, data_len, "proto_tacacs decode packet"); - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = dict_tacacs; - client = address->radclient; /* diff --git a/src/listen/vmps/proto_vmps.c b/src/listen/vmps/proto_vmps.c index 751b7447f68..5c149899b2d 100644 --- a/src/listen/vmps/proto_vmps.c +++ b/src/listen/vmps/proto_vmps.c @@ -152,13 +152,6 @@ static int mod_decode(UNUSED void const *instance, request_t *request, uint8_t * RHEXDUMP3(data, data_len, "proto_vmps decode packet"); - /* - * Set the request dictionary so that we can do - * generic->protocol attribute conversions as - * the request runs through the server. - */ - request->dict = dict_vmps; - client = address->radclient; /* diff --git a/src/modules/rlm_cache/drivers/rlm_cache_memcached/rlm_cache_memcached.c b/src/modules/rlm_cache/drivers/rlm_cache_memcached/rlm_cache_memcached.c index ea2657f1181..52014aa5d13 100644 --- a/src/modules/rlm_cache/drivers/rlm_cache_memcached/rlm_cache_memcached.c +++ b/src/modules/rlm_cache/drivers/rlm_cache_memcached/rlm_cache_memcached.c @@ -190,7 +190,7 @@ static cache_status_t cache_entry_find(rlm_cache_entry_t **out, MEM(c = talloc_zero(NULL, rlm_cache_entry_t)); map_list_init(&c->maps); - ret = cache_deserialize(request, c, request->dict, from_store, len); + ret = cache_deserialize(request, c, request->proto_dict, from_store, len); free(from_store); if (ret < 0) { RPERROR("Invalid entry"); diff --git a/src/modules/rlm_cache/rlm_cache.c b/src/modules/rlm_cache/rlm_cache.c index 9a86ef6b4ae..335a06c0ea0 100644 --- a/src/modules/rlm_cache/rlm_cache.c +++ b/src/modules/rlm_cache/rlm_cache.c @@ -908,7 +908,7 @@ xlat_action_t cache_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, NULL, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_request, } }); diff --git a/src/modules/rlm_client/rlm_client.c b/src/modules/rlm_client/rlm_client.c index f2279a0b3ff..44c8058856f 100644 --- a/src/modules/rlm_client/rlm_client.c +++ b/src/modules/rlm_client/rlm_client.c @@ -69,7 +69,7 @@ static int _map_proc_client_get_vp(TALLOC_CTX *ctx, fr_pair_list_t *out, request return -1; } - da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict), attr); + da = fr_dict_attr_by_name(NULL, fr_dict_root(request->local_dict), attr); if (!da) { RWDEBUG("No such attribute '%s'", attr); talloc_free(attr); diff --git a/src/modules/rlm_csv/rlm_csv.c b/src/modules/rlm_csv/rlm_csv.c index 8db4253365c..aa97808a62f 100644 --- a/src/modules/rlm_csv/rlm_csv.c +++ b/src/modules/rlm_csv/rlm_csv.c @@ -857,7 +857,7 @@ static int csv_map_getvalue(TALLOC_CTX *ctx, fr_pair_list_t *out, request_t *req } - da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict), attr); + da = fr_dict_attr_by_name(NULL, fr_dict_root(request->local_dict), attr); if (!da) { RWDEBUG("No such attribute '%s'", attr); talloc_free(attr); diff --git a/src/modules/rlm_dict/rlm_dict.c b/src/modules/rlm_dict/rlm_dict.c index 6edb366690f..7837207b4bf 100644 --- a/src/modules/rlm_dict/rlm_dict.c +++ b/src/modules/rlm_dict/rlm_dict.c @@ -52,7 +52,7 @@ static int xlat_fmt_get_vp(fr_pair_t **out, request_t *request, char const *name if (tmpl_afrom_attr_str(request, NULL, &vpt, name, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_request, } }) <= 0) return -4; @@ -81,7 +81,7 @@ static xlat_action_t xlat_dict_attr_by_num(TALLOC_CTX *ctx, fr_dcursor_t *out, fr_value_box_t *attr = fr_value_box_list_head(in); fr_value_box_t *vb; - da = fr_dict_attr_child_by_num(fr_dict_root(request->dict), attr->vb_uint32); + da = fr_dict_attr_child_by_num(fr_dict_root(request->proto_dict), attr->vb_uint32); if (!da) { REDEBUG("No attribute found with number %pV", attr); return XLAT_ACTION_FAIL; @@ -112,7 +112,7 @@ static xlat_action_t xlat_dict_attr_by_oid(TALLOC_CTX *ctx, fr_dcursor_t *out, request_t *request, fr_value_box_list_t *in) { unsigned int attr = 0; - fr_dict_attr_t const *parent = fr_dict_root(request->dict); + fr_dict_attr_t const *parent = fr_dict_root(request->proto_dict); fr_dict_attr_t const *da; ssize_t ret; fr_value_box_t *attr_vb = fr_value_box_list_head(in); diff --git a/src/modules/rlm_eap/rlm_eap.c b/src/modules/rlm_eap/rlm_eap.c index 05233068c48..696b97a5c74 100644 --- a/src/modules/rlm_eap/rlm_eap.c +++ b/src/modules/rlm_eap/rlm_eap.c @@ -795,7 +795,7 @@ static unlang_action_t eap_method_select(rlm_rcode_t *p_result, module_ctx_t con MEM(eap_session->subrequest = unlang_subrequest_alloc(request, method->submodule->namespace ? *(method->submodule->namespace) : - request->dict)); + request->proto_dict)); if (method->submodule->clone_parent_lists) { if (fr_pair_list_copy(eap_session->subrequest->control_ctx, diff --git a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c index e91e6639336..07405f9cf84 100644 --- a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c +++ b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c @@ -498,7 +498,7 @@ unlang_action_t eap_peap_process(rlm_rcode_t *p_result, request_t *request, goto finish; } - MEM(child = unlang_subrequest_alloc(request, request->dict)); + MEM(child = unlang_subrequest_alloc(request, request->proto_dict)); fr_assert(fr_pair_list_empty(&child->request_pairs)); switch (t->status) { diff --git a/src/modules/rlm_exec/rlm_exec.c b/src/modules/rlm_exec/rlm_exec.c index e829f062d36..c39c5c4c202 100644 --- a/src/modules/rlm_exec/rlm_exec.c +++ b/src/modules/rlm_exec/rlm_exec.c @@ -300,7 +300,7 @@ static unlang_action_t mod_exec_oneshot_wait_resume(rlm_rcode_t *p_result, modul fr_sbuff_t in = FR_SBUFF_IN(box->vb_strvalue, box->vb_length); tmpl_rules_t lhs_rules = (tmpl_rules_t) { .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = tmpl_list(inst->output_list), .list_presence = TMPL_ATTR_LIST_ALLOW, diff --git a/src/modules/rlm_json/rlm_json.c b/src/modules/rlm_json/rlm_json.c index e99873e68d9..bd324f98c86 100644 --- a/src/modules/rlm_json/rlm_json.c +++ b/src/modules/rlm_json/rlm_json.c @@ -243,7 +243,7 @@ static xlat_action_t json_encode_xlat(TALLOC_CTX *ctx, fr_dcursor_t *out, .attr = { .list_def = request_attr_request, .allow_wildcard = true, - .dict_def = request->dict, + .dict_def = request->proto_dict, } }); if (slen <= 0) { diff --git a/src/modules/rlm_ldap/groups.c b/src/modules/rlm_ldap/groups.c index 5834934e47e..05a012c776d 100644 --- a/src/modules/rlm_ldap/groups.c +++ b/src/modules/rlm_ldap/groups.c @@ -815,7 +815,7 @@ unlang_action_t rlm_ldap_check_groupobj_dynamic(rlm_rcode_t *p_result, request_t t_rules = (tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_request, }, .xlat = { diff --git a/src/modules/rlm_ldap/profile.c b/src/modules/rlm_ldap/profile.c index 7ae822c98bc..ed1b03879fd 100644 --- a/src/modules/rlm_ldap/profile.c +++ b/src/modules/rlm_ldap/profile.c @@ -123,7 +123,7 @@ static unlang_action_t ldap_map_profile_resume(UNUSED rlm_rcode_t *p_result, UNU tmpl_rules_t const parse_rules = { .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_request, }, .xlat = { diff --git a/src/modules/rlm_linelog/rlm_linelog.c b/src/modules/rlm_linelog/rlm_linelog.c index 3de1f3cfa82..6638df15e08 100644 --- a/src/modules/rlm_linelog/rlm_linelog.c +++ b/src/modules/rlm_linelog/rlm_linelog.c @@ -765,7 +765,7 @@ static unlang_action_t CC_HINT(nonnull) mod_do_linelog(rlm_rcode_t *p_result, mo &(tmpl_rules_t){ .attr = { .list_def = request_attr_request, - .dict_def = request->dict, + .dict_def = request->local_dict, .allow_unknown = true, .allow_unresolved = false, }, diff --git a/src/modules/rlm_lua/lua.c b/src/modules/rlm_lua/lua.c index 40c93863c0c..2a31c1a7550 100644 --- a/src/modules/rlm_lua/lua.c +++ b/src/modules/rlm_lua/lua.c @@ -544,7 +544,7 @@ static int _lua_pair_accessor_init(lua_State *L) return -1; } - da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict), attr); + da = fr_dict_attr_by_name(NULL, fr_dict_root(request->proto_dict), attr); if (!da) { REDEBUG("Unknown or invalid attribute name \"%s\"", attr); return -1; diff --git a/src/modules/rlm_mruby/rlm_mruby.c b/src/modules/rlm_mruby/rlm_mruby.c index d9b81ff1519..10c806645c3 100644 --- a/src/modules/rlm_mruby/rlm_mruby.c +++ b/src/modules/rlm_mruby/rlm_mruby.c @@ -361,7 +361,7 @@ static void add_vp_tuple(TALLOC_CTX *ctx, request_t *request, fr_pair_list_t *vp if (tmpl_afrom_attr_str(request, NULL, &dst, ckey, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_reply, } }) <= 0) { diff --git a/src/modules/rlm_passwd/rlm_passwd.c b/src/modules/rlm_passwd/rlm_passwd.c index 727587dc4ad..cd23bc2975f 100644 --- a/src/modules/rlm_passwd/rlm_passwd.c +++ b/src/modules/rlm_passwd/rlm_passwd.c @@ -521,7 +521,7 @@ static void result_add(TALLOC_CTX *ctx, rlm_passwd_t const *inst, request_t *req if (inst->pwd_fmt->field[i] && *inst->pwd_fmt->field[i] && pw->field[i] && (i != inst->key_field) && inst->pwd_fmt->listflag[i] == when) { if (!inst->ignore_empty || pw->field[i][0] != 0 ) { /* if value in key/value pair is not empty */ - fr_dict_attr_t const *da = fr_dict_attr_by_name(NULL, fr_dict_root(request->dict), inst->pwd_fmt->field[i]); + fr_dict_attr_t const *da = fr_dict_attr_by_name(NULL, fr_dict_root(request->proto_dict), inst->pwd_fmt->field[i]); size_t len; if (!da) { diff --git a/src/modules/rlm_perl/rlm_perl.c b/src/modules/rlm_perl/rlm_perl.c index 376354d83c6..eb7e4e16d1c 100644 --- a/src/modules/rlm_perl/rlm_perl.c +++ b/src/modules/rlm_perl/rlm_perl.c @@ -914,28 +914,28 @@ static unlang_action_t do_perl(rlm_rcode_t *p_result, module_ctx_t const *mctx, fr_pair_list_init(&vps); if (inst->replace.request && (get_hv_content(request->request_ctx, request, rad_request_hv, &vps, "request", - fr_dict_root(request->dict), true)) > 0) { + fr_dict_root(request->proto_dict), true)) > 0) { fr_pair_list_free(&request->request_pairs); fr_pair_list_append(&request->request_pairs, &vps); } if (inst->replace.reply && (get_hv_content(request->reply_ctx, request, rad_reply_hv, &vps, "reply", - fr_dict_root(request->dict), true)) > 0) { + fr_dict_root(request->proto_dict), true)) > 0) { fr_pair_list_free(&request->reply_pairs); fr_pair_list_append(&request->reply_pairs, &vps); } if (inst->replace.control && (get_hv_content(request->control_ctx, request, rad_config_hv, &vps, "control", - fr_dict_root(request->dict), true)) > 0) { + fr_dict_root(request->proto_dict), true)) > 0) { fr_pair_list_free(&request->control_pairs); fr_pair_list_append(&request->control_pairs, &vps); } if (inst->replace.session && (get_hv_content(request->session_state_ctx, request, rad_state_hv, &vps, "session-state", - fr_dict_root(request->dict), true)) > 0) { + fr_dict_root(request->proto_dict), true)) > 0) { fr_pair_list_free(&request->session_state_pairs); fr_pair_list_append(&request->session_state_pairs, &vps); } diff --git a/src/modules/rlm_python/rlm_python.c b/src/modules/rlm_python/rlm_python.c index 169eff683b5..e9ab8d27fa1 100644 --- a/src/modules/rlm_python/rlm_python.c +++ b/src/modules/rlm_python/rlm_python.c @@ -338,7 +338,7 @@ static void mod_vptuple(TALLOC_CTX *ctx, module_ctx_t const *mctx, request_t *re if (tmpl_afrom_attr_str(ctx, NULL, &dst, s1, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_reply, } }) <= 0) { diff --git a/src/modules/rlm_radius/bio.c b/src/modules/rlm_radius/bio.c index 57b7d626537..53cc19f4157 100644 --- a/src/modules/rlm_radius/bio.c +++ b/src/modules/rlm_radius/bio.c @@ -250,7 +250,7 @@ static void CC_HINT(nonnull) status_check_alloc(bio_handle_t *h) fr_assert(!h->status_u && !h->status_request); - MEM(request = request_local_alloc_external(h, NULL)); + MEM(request = request_local_alloc_external(h, (&(request_init_args_t){ .namespace = dict_radius }))); MEM(u = talloc_zero(request, bio_request_t)); talloc_set_destructor(u, _bio_request_free); @@ -2343,7 +2343,7 @@ static int mod_enqueue(bio_request_t **p_u, fr_retry_config_t const **p_retry_co if (!request->parent) { u->proxied = (request->client->cs != NULL); - } else if (!fr_dict_compatible(request->parent->dict, request->dict)) { + } else if (!fr_dict_compatible(request->parent->proto_dict, request->proto_dict)) { u->proxied = false; } else { diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index ec936891dfb..0ae119dac46 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -735,7 +735,7 @@ static int rest_decode_post(UNUSED rlm_rest_t const *instance, UNUSED rlm_rest_s if (tmpl_afrom_attr_str(request, NULL, &dst, name, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_reply } }) <= 0) { @@ -1025,7 +1025,7 @@ static int json_pair_alloc(rlm_rest_t const *instance, rlm_rest_section_t const if (tmpl_afrom_attr_str(request, NULL, &dst, name, &(tmpl_rules_t){ .attr = { - .dict_def = request->dict, + .dict_def = request->proto_dict, .list_def = request_attr_reply } }) <= 0) { diff --git a/src/modules/rlm_sql/sql.c b/src/modules/rlm_sql/sql.c index df5e4f53ad7..575863a3824 100644 --- a/src/modules/rlm_sql/sql.c +++ b/src/modules/rlm_sql/sql.c @@ -297,7 +297,7 @@ static unlang_action_t sql_get_map_list_resume(rlm_rcode_t *p_result, UNUSED int fr_sql_map_ctx_t *map_ctx = talloc_get_type_abort(uctx, fr_sql_map_ctx_t); tmpl_rules_t lhs_rules = (tmpl_rules_t) { .attr = { - .dict_def = request->dict, + .dict_def = request->local_dict, .list_def = map_ctx->list, .list_presence = TMPL_ATTR_LIST_ALLOW } diff --git a/src/modules/rlm_stats/rlm_stats.c b/src/modules/rlm_stats/rlm_stats.c index 9ba0b55ce72..26ae2676a71 100644 --- a/src/modules/rlm_stats/rlm_stats.c +++ b/src/modules/rlm_stats/rlm_stats.c @@ -49,7 +49,7 @@ typedef struct { /* * @todo - MULTI_PROTOCOL - make this protocol agnostic. - * Perhaps keep stats in a hash table by (request->dict, request->code) ? + * Perhaps keep stats in a hash table by (request->proto_dict, request->code) ? */ typedef struct { @@ -173,7 +173,7 @@ static unlang_action_t CC_HINT(nonnull) mod_stats_inc(rlm_rcode_t *p_result, mod rlm_stats_data_t *stats; rlm_stats_data_t mydata; - if (request->dict != dict_radius) { + if (request->proto_dict != dict_radius) { RWARN("%s can only be called in RADIUS virtual servers", mctx->mi->name); RETURN_MODULE_NOOP; } @@ -260,7 +260,7 @@ static unlang_action_t CC_HINT(nonnull) mod_stats_read(rlm_rcode_t *p_result, mo rlm_stats_data_t mydata; uint64_t local_stats[NUM_ELEMENTS(inst->mutable->stats)]; - if (request->dict != dict_radius) { + if (request->proto_dict != dict_radius) { RWARN("%s can only be called in RADIUS virtual servers", mctx->mi->name); RETURN_MODULE_NOOP; } diff --git a/src/modules/rlm_yubikey/rlm_yubikey.c b/src/modules/rlm_yubikey/rlm_yubikey.c index dcdcf76cb93..9de87aacb02 100644 --- a/src/modules/rlm_yubikey/rlm_yubikey.c +++ b/src/modules/rlm_yubikey/rlm_yubikey.c @@ -294,7 +294,7 @@ static unlang_action_t CC_HINT(nonnull) mod_authorize(rlm_rcode_t *p_result, mod * Don't print out debugging messages if we know * they're useless. */ - if ((request->dict == dict_radius) && request->packet->code != FR_RADIUS_CODE_ACCESS_CHALLENGE) { + if ((request->proto_dict == dict_radius) && request->packet->code != FR_RADIUS_CODE_ACCESS_CHALLENGE) { RDEBUG2("No cleartext password in the request. Can't do Yubikey authentication"); } diff --git a/src/process/arp/base.c b/src/process/arp/base.c index c2b8cabf9d1..86103cbdc59 100644 --- a/src/process/arp/base.c +++ b/src/process/arp/base.c @@ -187,7 +187,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "arp"; request->module = NULL; - fr_assert(request->dict == dict_arp); + fr_assert(request->proto_dict == dict_arp); UPDATE_STATE(packet); diff --git a/src/process/bfd/base.c b/src/process/bfd/base.c index 1e63dbf0a51..2c306d1a33a 100644 --- a/src/process/bfd/base.c +++ b/src/process/bfd/base.c @@ -237,7 +237,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "bfd"; request->module = NULL; - fr_assert(request->dict == dict_bfd); + fr_assert(request->proto_dict == dict_bfd); wrapper = (bfd_wrapper_t const *) request->packet->data; diff --git a/src/process/dhcpv4/base.c b/src/process/dhcpv4/base.c index 104d1181c94..7ea92aa2788 100644 --- a/src/process/dhcpv4/base.c +++ b/src/process/dhcpv4/base.c @@ -400,7 +400,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "dhcpv4"; request->module = NULL; - fr_assert(request->dict == dict_dhcpv4); + fr_assert(request->proto_dict == dict_dhcpv4); UPDATE_STATE(packet); diff --git a/src/process/dhcpv6/base.c b/src/process/dhcpv6/base.c index f937cc678ed..dfc4f7387c4 100644 --- a/src/process/dhcpv6/base.c +++ b/src/process/dhcpv6/base.c @@ -527,7 +527,7 @@ void status_code_add(process_dhcpv6_t const *inst, request_t *request, fr_value_ * Move the module failure messages upwards * if requested to by the user. */ - if (inst->move_failure_message_to_parent && request->parent && (request->parent->dict == request->dict)) { + if (inst->move_failure_message_to_parent && request->parent && (request->parent->proto_dict == request->proto_dict)) { fr_pair_t const *prev = NULL; while ((failure_message = fr_pair_find_by_da(&request->request_pairs, @@ -724,7 +724,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "dhcpv6"; request->module = NULL; - fr_assert(request->dict == dict_dhcpv6); + fr_assert(request->proto_dict == dict_dhcpv6); UPDATE_STATE(packet); diff --git a/src/process/dns/base.c b/src/process/dns/base.c index 95990c7207d..93f621eedb3 100644 --- a/src/process/dns/base.c +++ b/src/process/dns/base.c @@ -480,7 +480,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "dns"; request->module = NULL; - fr_assert(request->dict == dict_dns); + fr_assert(request->proto_dict == dict_dns); UPDATE_STATE(packet); diff --git a/src/process/ldap_sync/base.c b/src/process/ldap_sync/base.c index 9d12db58e54..d9f7fc2bcd4 100644 --- a/src/process/ldap_sync/base.c +++ b/src/process/ldap_sync/base.c @@ -113,7 +113,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "ldap_sync"; request->module = NULL; - fr_assert(request->dict == dict_ldap_sync); + fr_assert(request->proto_dict == dict_ldap_sync); UPDATE_STATE(packet); diff --git a/src/process/radius/base.c b/src/process/radius/base.c index 40432311200..20e8eb71363 100644 --- a/src/process/radius/base.c +++ b/src/process/radius/base.c @@ -799,7 +799,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "radius"; request->module = NULL; - fr_assert(request->dict == dict_radius); + fr_assert(request->proto_dict == dict_radius); fr_assert(FR_RADIUS_PACKET_CODE_VALID(request->packet->code)); @@ -845,7 +845,7 @@ static xlat_action_t xlat_func_radius_secret_verify(TALLOC_CTX *ctx, fr_dcursor_ XLAT_ARGS(args, &secret); - if (request->dict != dict_radius) return XLAT_ACTION_FAIL; + if (request->proto_dict != dict_radius) return XLAT_ACTION_FAIL; MEM(vb = fr_value_box_alloc(ctx, FR_TYPE_BOOL, NULL)); diff --git a/src/process/tacacs/base.c b/src/process/tacacs/base.c index 4dad0bd7e58..cc8531da43f 100644 --- a/src/process/tacacs/base.c +++ b/src/process/tacacs/base.c @@ -1041,7 +1041,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "tacacs"; request->module = NULL; - fr_assert(request->dict == dict_tacacs); + fr_assert(request->proto_dict == dict_tacacs); UPDATE_STATE(packet); diff --git a/src/process/test/base.c b/src/process/test/base.c index f4793ccc83e..dbbf67b4ac8 100644 --- a/src/process/test/base.c +++ b/src/process/test/base.c @@ -96,7 +96,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "test"; request->module = NULL; - fr_assert(request->dict == dict_test); + fr_assert(request->proto_dict == dict_test); UPDATE_STATE(packet); diff --git a/src/process/tls/base.c b/src/process/tls/base.c index 9f3020c0517..753049bf91c 100644 --- a/src/process/tls/base.c +++ b/src/process/tls/base.c @@ -178,7 +178,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "tls"; request->module = NULL; - fr_assert(request->dict == dict_tls); + fr_assert(request->proto_dict == dict_tls); UPDATE_STATE(packet); diff --git a/src/process/ttls/base.c b/src/process/ttls/base.c index cb0dcbfc38d..ea38ec1923b 100644 --- a/src/process/ttls/base.c +++ b/src/process/ttls/base.c @@ -494,7 +494,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "radius"; request->module = NULL; - fr_assert(request->dict == dict_radius); + fr_assert(request->proto_dict == dict_radius); UPDATE_STATE(packet); diff --git a/src/process/vmps/base.c b/src/process/vmps/base.c index 8947eee3063..8d47e3f59e0 100644 --- a/src/process/vmps/base.c +++ b/src/process/vmps/base.c @@ -212,7 +212,7 @@ static unlang_action_t mod_process(rlm_rcode_t *p_result, module_ctx_t const *mc request->component = "vmps"; request->module = NULL; - fr_assert(request->dict == dict_vmps); + fr_assert(request->proto_dict == dict_vmps); UPDATE_STATE(packet);