- 论坛徽章:
- 0
|
原帖由 platinum 于 2010-1-19 10:42 发表 ![]()
和 module 前后顺序有关
iptables 匹配时会根据 modules 的链表逐一使用模块匹配
如果 m1 m2 m3 所耗 CPU 不同,建议把最耗 CPU 的放在最后面,把最可能过滤掉数据的放在最前面
例如有 3 个模块,time、la ...
iptables 匹配时会根据 modules 的链表逐一使用模块匹配,应该是没有错的,但不一定是m1 m2 m3, 因为m2可能在m1之前先加载了,那么匹配时的顺序应该是
m2 m1 m3。
另外我在2.4内核,iptables-1.2.*中测试,具体的匹配顺序跟iptables中一个叫initext.c的文件相关。各位大侠能帮我说明一下吗。(我的iptables在编译时不生成共享库)
后查找发现:
...
#ifdef NO_SHARED_LIBS
init_extensions();
#endif
以上代码为没有定义共享库的话,要执行init_extensions()。这里我们假设不使用共享库,所以调用该函数。该函数实在执行make的时候extensions/自动生成的initext.c中的函数。在该函数里调用了所有扩展模块的init函数。
注册所有的match,以及标准和扩展的target。
所有的match和target都加入到iptables.c中对应的全局链表之中。以后find_match和find_target是就是搜索的这两个链表。
/* Keeping track of external matches and targets: linked lists. */
struct iptables_match *iptables_matches = NULL;
struct iptables_target *iptables_targets = NULL;
这样在不使用共享库的情况下,每次下命令之前都要初始化一下全局的链表,当然已经存在的话,就不会再次register的。
....
[ 本帖最后由 ok_lin 于 2010-1-20 11:21 编辑 ] |
|