FreeBSD/sys/netpfil/ipfw/ip_fw_sockopt.c
/*
 * Remove references from every object used in @rule.
 * Used at rule removal code.
 */
Remove references from every object used in @rule.
Used at rule removal code.
Remove references from every object used in @rule . Used at rule removal code .
static void
unref_rule_objects(struct ip_fw_chain *ch, struct ip_fw *rule)
{
	struct opcode_obj_rewrite *rw;
	struct named_object *no;
	ipfw_insn *cmd;
	int cmdlen, l;
	uint16_t kidx;
	uint8_t subtype;
	IPFW_UH_WLOCK_ASSERT(ch);
	l = rule->cmd_len;
	cmd = rule->cmd;
	cmdlen = 0;
	for ( ;	l > 0 ; l -= cmdlen, cmd += cmdlen) {
		cmdlen = F_LEN(cmd);
		rw = find_op_rw(cmd, &kidx, &subtype);
		if (rw == NULL)
			continue;
		no = rw->find_bykidx(ch, kidx);
		KASSERT(no != NULL, ("table id %d not found", kidx));
		KASSERT(no->subtype == subtype,
		    ("wrong type %d (%d) for table id %d",
		    no->subtype, subtype, kidx));
		KASSERT(no->refcnt > 0, ("refcount for table %d is %d",
		    kidx, no->refcnt));
		if (no->refcnt == 1 && rw->destroy_object != NULL)
			rw->destroy_object(ch, no);
		else
			no->refcnt--;
	}
}
static void unref_rule_objects ( struct ip_fw_chain * ch , struct ip_fw * rule ) { struct opcode_obj_rewrite * rw ; struct named_object * no ; ipfw_insn * cmd ; int cmdlen , l ; uint16_t kidx ; uint8_t subtype ; IPFW_UH_WLOCK_ASSERT ( ch ) ; l = rule -> cmd_len ; cmd = rule -> cmd ; cmdlen = 0 ; for ( ; l > 0 ; l -= cmdlen , cmd += cmdlen ) { cmdlen = F_LEN ( cmd ) ; rw = find_op_rw ( cmd , & kidx , & subtype ) ; if ( rw == NULL ) continue ; no = rw -> find_bykidx ( ch , kidx ) ; KASSERT ( no != NULL , ( " " , kidx ) ) ; KASSERT ( no -> subtype == subtype , ( " " , no -> subtype , subtype , kidx ) ) ; KASSERT ( no -> refcnt > 0 , ( " " , kidx , no -> refcnt ) ) ; if ( no -> refcnt == 1 && rw -> destroy_object != NULL ) rw -> destroy_object ( ch , no ) ; else no -> refcnt -- ; } }
Remove references from every object used in @rule.
Remove references from every object used in @rule .