Lines Matching +full:reset +full:- +full:related

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2016-2025 Yandex LLC
5 * Copyright (c) 2016-2025 Andrey V. Elsukov <ae@FreeBSD.org>
73 * For the O_EXTERNAL_INSTANCE opcode the cmd->kidx contains index of named
74 * object related to an instance of external action.
81 * must be in the (ipfw_insn *)(cmd - 2)). By kidx from O_EXTERNAL_ACTION
84 * the type of named_object related to external action instance.
97 ((struct eaction_obj *)SRV_OBJECT((ch), insntod((cmd), kidx)->kidx))
129 EACTION_DEBUG("opcode %u, kidx %u", cmd0->opcode, cmd->kidx); in eaction_classify()
130 *puidx = cmd->kidx; in eaction_classify()
141 cmd->kidx = idx; in eaction_update()
142 EACTION_DEBUG("opcode %u, kidx -> %u", cmd0->opcode, cmd->kidx); in eaction_update()
151 if (ti->tlvs == NULL) in eaction_findbyname()
155 ntlv = ipfw_find_name_tlv_type(ti->tlvs, ti->tlen, ti->uidx, in eaction_findbyname()
159 EACTION_DEBUG("name %s, uidx %u, type %u", ntlv->name, in eaction_findbyname()
160 ti->uidx, ti->type); in eaction_findbyname()
163 * Since eaction objects are global - ignore the set value in eaction_findbyname()
167 0, IPFW_TLV_EACTION, ntlv->name); in eaction_findbyname()
203 obj->no.name = obj->name; in create_eaction_obj()
204 obj->no.etlv = IPFW_TLV_EACTION; in create_eaction_obj()
205 obj->handler = handler; in create_eaction_obj()
206 strlcpy(obj->name, name, sizeof(obj->name)); in create_eaction_obj()
221 if (ipfw_objhash_alloc_idx(ni, &obj->no.kidx) != 0) { in create_eaction_obj()
227 ipfw_objhash_add(ni, &obj->no); in create_eaction_obj()
229 SRV_OBJECT(ch, obj->no.kidx) = obj; in create_eaction_obj()
231 obj->no.refcnt++; in create_eaction_obj()
235 *eaction_id = obj->no.kidx; in create_eaction_obj()
249 obj = SRV_OBJECT(ch, no->kidx); in destroy_eaction_obj()
250 SRV_OBJECT(ch, no->kidx) = NULL; in destroy_eaction_obj()
253 ipfw_objhash_free_idx(ni, no->kidx); in destroy_eaction_obj()
273 if (eaction_id == no->kidx) in reset_eaction_rules()
276 EACTION_DEBUG("Going to replace id %u with %u", eaction_id, no->kidx); in reset_eaction_rules()
279 * Reset eaction objects only if it is referenced by rules. in reset_eaction_rules()
280 * But always reset objects for orphaned dynamic states. in reset_eaction_rules()
283 for (i = 0; i < ch->n_rules; i++) { in reset_eaction_rules()
290 if (ipfw_reset_eaction(ch, ch->map[i], eaction_id, in reset_eaction_rules()
291 no->kidx, instance_id) != 0) in reset_eaction_rules()
292 no->refcnt++; in reset_eaction_rules()
296 * Reset eaction opcodes for orphaned dynamic states. in reset_eaction_rules()
300 ipfw_dyn_reset_eaction(ch, eaction_id, no->kidx, instance_id); in reset_eaction_rules()
342 * On success it returns eaction id, otherwise - zero.
369 if (no == NULL || no->etlv != IPFW_TLV_EACTION) { in ipfw_del_eaction()
373 reset_eaction_rules(ch, eaction_id, 0, (no->refcnt > 1)); in ipfw_del_eaction()
375 no->name, eaction_id); in ipfw_del_eaction()
396 if (cmd->opcode != O_EXTERNAL_ACTION || in ipfw_reset_eaction()
397 insntod(cmd, kidx)->kidx != eaction_id) in ipfw_reset_eaction()
407 l = rule->cmd + rule->cmd_len - cmd; in ipfw_reset_eaction()
411 if (icmd->opcode == O_EXTERNAL_INSTANCE && in ipfw_reset_eaction()
413 insntod(icmd, kidx)->kidx != instance_id) in ipfw_reset_eaction()
416 * Since named_object related to this instance will be in ipfw_reset_eaction()
421 EACTION_DEBUG("truncate rule %u: len %u -> %u", in ipfw_reset_eaction()
422 rule->rulenum, rule->cmd_len, in ipfw_reset_eaction()
423 rule->cmd_len - F_LEN(icmd)); in ipfw_reset_eaction()
424 rule->cmd_len -= F_LEN(icmd); in ipfw_reset_eaction()
425 MPASS(((uint32_t *)icmd - in ipfw_reset_eaction()
426 (uint32_t *)rule->cmd) == rule->cmd_len); in ipfw_reset_eaction()
429 insntod(cmd, kidx)->kidx = default_id; /* Set to default id */ in ipfw_reset_eaction()
431 * Return 1 when reset successfully happened. in ipfw_reset_eaction()
438 * destroyed. It will reset eaction_id to default_id for rules, where
449 if (no == NULL || no->etlv != IPFW_TLV_EACTION) in ipfw_reset_eaction_instance()
462 return (EACTION_OBJ(ch, cmd)->handler(ch, args, cmd, done)); in ipfw_run_eaction()