- 论坛徽章:
- 0
|
初次接触netfilter源码, 对这两个返回值的理解不大明白.故向各位大虾请教.\r\n\r\n1. NF_REPEAT:\r\nnetfilter.c中\r\nstatic unsigned int nf_iterate(struct list_head *head,\r\n struct sk_buff **skb,\r\n int hook,\r\n const struct net_device *indev,\r\n const struct net_device *outdev,\r\n struct list_head **i,\r\n int (*okfn)(struct sk_buff *))\r\n{\r\n for (*i = (*i)->next; *i != head; *i = (*i)->next) {\r\n struct nf_hook_ops *elem = (struct nf_hook_ops *)*i;\r\n switch (elem->hook(hook, skb, indev, outdev, okfn)) {\r\n case NF_QUEUE:\r\n return NF_QUEUE;\r\n\r\n case NF_STOLEN:\r\n return NF_STOLEN; \r\n\r\n case NF_DROP:\r\n return NF_DROP;\r\n\r\n case NF_REPEAT:\r\n *i = (*i)->prev;\r\n break;\r\n\r\n#ifdef CONFIG_NETFILTER_DEBUG\r\n case NF_ACCEPT:\r\n break;\r\n\r\n default:\r\n NFDEBUG(\"Evil return from %p(%u).\\n\", \r\n elem->hook, hook);\r\n#endif\r\n }\r\n }\r\n return NF_ACCEPT;\r\n}\r\n\r\n问题1:当前结点的hook如果返回NF_REPEAT,则回到上一个结点继续处理,而如果上一个结点的返回值是一个非法值,则不会break,又回到返回NF_REPEAT的结点,死循环?\r\n问题2:体现在用户空间(iptables)中, NF_REPEAT会由哪个target触发?或者由什么条件触发hook返回该值? \r\n\r\n2.NF_STOLEN:\r\n在网上搜索时,看到某些解释是: NF_STOLEN 忘掉该数据包 NF_DROP 丢弃该数据包\r\n在内核源码中grep它的使用时, 类似以下代码\r\nif (ret != NF_DROP && ret != NF_STOLEN\r\n && ((*pskb)->nh.iph->saddr != saddr\r\n || (*pskb)->nh.iph->daddr != daddr))\r\n return ip_route_me_harder(pskb) == 0 ? ret : NF_DROP;\r\n\r\n我并未看出NF_STOLEN和NF_DROP有何不同, 都是不对数据包进行处理,那么\r\n问题1. 在内核空间中NF_STOLEN和NF_DROP有何区别?\r\n问题2. 在用户空间, NF_STOLEN会由什么条件触发HOOK返回该值? |
|