Skip to contentSkip to conversation

Recoed destination IP in userspace before DNAT ??

DISCUSSION time 1 participant 1 message May 20, 2003 netfilter

lore
Share & tools
lore

time

author
#0 lore raw

Hi my dear friend,
I am an engineer , and I am developing a special system need to record the destination IP before doing DNAT, and the Application will use the destination IP to do something in user space.
I have choose the ip_queue to mangle the packet to userspace, And use the sharememory to record all destination IP of the connections( sync ).
I hvave tried to extend my netlink recieve buffer, I have tried to copy a shorter length to userspace, I also tried to minize my userspace application to handle the packet from kernel..... In a normal condition ( not too many connections ) , it works, and the flow just like this ( I use printk and printf )

1. nf_hook: Verdict = QUEUE.
2. enqueue!
3. going to send
4. status > 0
5. ipq receive
6. com!
7. Dequeue a packet if matched by cmp!
8. user space receive here

But when I use some test tool to make a lot of connections in a short time ( maybe 500 or 1000 connections ), I found that the flow changed. It looks like this

1. nf_hook: Verdict = QUEUE.
2. enqueue!
3. going to send
4. nf_hook: Verdict = QUEUE.
5. enqueue!
6. going to send

7.  ....
8.  ....
9.  .... (all the same as 1->2->3)

....
n. user space receive here
n+1. read(): Failed to receive netlink message: No buffer space available

the queue will not send one by one ..... and will send at one time to make my netlink buffer full .... I have setsockoption to 655350, <- it's quite huge !

May I ask you.... Is the ip_queue working like this ?
Where can I tune in the ip_queue ?
Or, is there any other method to record the destination IP before DNAT in userspace ?

If I parse the /proc/net/ip_conntrack, will it make sense ?

I hope someone can help me, My god, It makes me mad !

By the way, thanks you at first , when you can be patient to read this letter. Thanks !!

time