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