For netfilter ipt_ops, init() and nf_register_hook()
Hi, guys,
When I read the source of netfilter(withe kernel 2.4.18), something pullzed me.
net/ipv4/netfilter/Iptable_filter.c
....
static struct nf_hook_ops ipt_ops[]
= { { { NULL, NULL }, ipt_hook, PF_INET, NF_IP_LOCAL_IN, NF_IP_PRI_FILTER },
{ { NULL, NULL }, ipt_hook, PF_INET, NF_IP_FORWARD, NF_IP_PRI_FILTER }, { { NULL, NULL }, ipt_local_out_hook, PF_INET, NF_IP_LOCAL_OUT,
NF_IP_PRI_FILTER }
};
...
static int __init init(void)
{
...
ret = nf_register_hook(&ipt_ops[0]);
...
}
net\core\Netfilter.c
int nf_register_hook(struct nf_hook_ops *reg)
{
struct list_head *i;
br_write_lock_bh(BR_NETPROTO_LOCK);
for (i = nf_hooks[reg->pf][reg->hooknum].next;
i != &nf_hooks[reg->pf][reg->hooknum];
i = i->next) { if (reg->priority < ((struct nf_hook_ops *)i)->priority)
break;
}list_add(®->list, i->prev); br_write_unlock_bh(BR_NETPROTO_LOCK);
return 0;
}
It seems that in list_add(®->list, i->prev), only a {NULL, NULL} list head is added, so how it run?
Regards.
Paul.
2002.10.23
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/lccn/
Quoted 4 lines · Shen Qiyu
list_add(®->list, i->prev);It seems that in
list_add(®->list, i->prev), only a {NULL, NULL} list head is added, so how it run?
a {NULL, NULL} list head is added to i->prev, an already-existing list head.
Quoted 2 lines
Regards.
Signature · 5 lines
Live long and prosper - Harald Welte / [email protected] http://www.gnumonks.org/ ============================================================================ "If this were a dictatorship, it'd be a heck of a lot easier, just so long as I'm the dictator." -- George W. Bush Dec 18, 2000