Skip to contentSkip to conversation

NF_STOLEN

DISCUSSION 赵磊 2 participants 3 messages Nov 25, 2008 – Nov 27, 2008 1 message not in the archive netfilter

lore
Share & tools
lore

赵磊

author
#0 lore raw

Hi,

Thank you for your reply.

As per your advice, I call ip_rcv_finish (referenced by the argument okfn) in my NF_IP_PRE_ROUTING hook function. But I got segmentation fault. Could you explain in a little more detail what should I do or what was the problem with the above method? I'm a newbie in netfilter and linux kernel programming.

Thanks a lot.

从: Jan Engelhardt <[email protected]>
主题: Re: NF_STOLEN

Quoted 17 lines · 赵磊
Quoted 4 lines

Hi,

I register a NF_IP_PRE_ROUTING hook that check the incoming

packets. I’m

Quoted 1 line

trying to return NF_STOLEN on particular TCP packets and later

pass them

Quoted 1 line

to the TCP module of the kernel. Any advice about how this can be

achieved?

PREROUTING is invoked from here:

net/ipv4/ip_input.c:
return NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, skb, dev,
NULL,

Quoted 8 lines
                      ip_rcv_finish);
or here, net/ipv6/ip6_input.c:
       return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, skb, dev,
NULL,
                      ip6_rcv_finish);

(or whichever other protocol you use)
So you just call the appropriate functions (ip{,6}_rcv_finish).

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw
Quoted 9 lines · 赵磊

Hi,

Thank you for your reply.

As per your advice, I call ip_rcv_finish (referenced by the argument okfn) in my NF_IP_PRE_ROUTING hook function. But I got segmentation fault. Could you explain in a little more detail what should I do or what was the problem with the above method? I'm a newbie in netfilter and linux kernel programming.

It may be that your skb, if created from scratch, is missing
some initialized fields. It is best to find the line where it crashed.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 000601c9503c$15770030$40650090$@[email protected]

#3 lore raw
Quoted 3 lines · Zhao Lei

Thank you for your reply. My problem has been solved. It turns out that if I use skb_copy function to create a new skb instead of using the exsiting one, the program runs perfectly well.

I do not see a problem with just holding the skb. Maybe it is just that a refcount needs to be increased (skb_get).

Alternatively, skb_clone might work in pleace of skb_copy for a cheap operation.