FreeBSD/sys/netpfil/ipfw/ip_fw2.c
/*
 * Helper function to enable cached rule lookups using
 * cached_id and cached_pos fields in ipfw rule.
 */
Helper function to enable cached rule lookups using
cached_id and cached_pos fields in ipfw rule.
Helper function to enable cached rule lookups using cached_id and cached_pos fields in ipfw rule .
static int
jump_fast(struct ip_fw_chain *chain, struct ip_fw *f, int num,
    int tablearg, int jump_backwards)
{
	int f_pos;
	if (num != IP_FW_TARG && f->cached_id == chain->id)
		f_pos = f->cached_pos;
	else {
		int i = IP_FW_ARG_TABLEARG(chain, num, skipto);
		if (jump_backwards == 0 && i <= f->rulenum)
			i = f->rulenum + 1;
		if (chain->idxmap != NULL)
			f_pos = chain->idxmap[i];
		else
			f_pos = ipfw_find_rule(chain, i, 0);
		if (num != IP_FW_TARG) {
			f->cached_id = chain->id;
			f->cached_pos = f_pos;
		}
	}
	return (f_pos);
}
static int jump_fast ( struct ip_fw_chain * chain , struct ip_fw * f , int num , int tablearg , int jump_backwards ) { int f_pos ; if ( num != IP_FW_TARG && f -> cached_id == chain -> id ) f_pos = f -> cached_pos ; else { int i = IP_FW_ARG_TABLEARG ( chain , num , skipto ) ; if ( jump_backwards == 0 && i <= f -> rulenum ) i = f -> rulenum + 1 ; if ( chain -> idxmap != NULL ) f_pos = chain -> idxmap [ i ] ; else f_pos = ipfw_find_rule ( chain , i , 0 ) ; if ( num != IP_FW_TARG ) { f -> cached_id = chain -> id ; f -> cached_pos = f_pos ; } } return ( f_pos ) ; }
Helper function to enable cached rule lookups using
 cached_id and cached_pos fields in ipfw rule.
Helper function to enable cached rule lookups using cached_id and cached_pos fields in ipfw rule .
/* If possible use cached f_pos (in f->cached_pos),
	 * whose version is written in f->cached_id
	 * (horrible hacks to avoid changing the ABI).
	 */ /* make sure we do not jump backward */ /* update the cache */