- 论坛徽章:
- 0
|
回复 #22 Godbach 的帖子
Godbach 兄,我有个关于netfilter的问题想请教你。就是netfilter中的规则ipt_entry和ipt_entry_match是如何联系在一起的?
首先在ipt_do_table函数中对sk_buff依照规则ipt_entry进行匹配match,然后调用其target函数。其中宏IPT_MATCH_ITERATE(e, do_match,*pskb, in, out, offset, &hotdrop)是用来根据ipt_entry来遍历其ipt_entry_match的,遍历的同时调用do_match函数进行实际的match。
后来我看了ipt_register_match(ipt_match XXX)函数,这个函数完成对match的注册,但是它的注册实际上是把这个ipt_match添加到一个struct xt_af {
struct mutex mutex;
struct list_head match;
struct list_head target;
struct list_head tables;
struct mutex compat_mutex;
};
的 match 中,跟规则ipt_entry无关啊。。。。
ipt_entry遍历ipt_entry_match是依靠其内部的target_offset等偏移量来实现的,可是偏移量是在哪里设置好的?我没找到相关的函数。。。
上面有可能讲得不对,望同志们看看哪里我理解错了。我其实就是想知道新建一个规则ipt_entry时,它的ipt_entry_match是如何设置的,是怎么跟target_offset这些偏移量对应的。。。 |
|