Skip to contentSkip to conversation

accounting module design questions

DISCUSSION Thomas Jarosch 1 participant 1 message Apr 9, 2004 netfilter

lore
Share & tools
lore
#0 lore raw

Hi!

I'm currently developing a high performance accounting target module for local networks. It scales pretty well from 8 bit (CLASS C) networks to 24 bit (CLASS A) networks, consuming memory for active IPs only. Data transfer from the kernel to userspace is done via get/setsockopt. After I've polished the code a bit more, I'm going to release it into public. (+ a userspace library for querying the data)

I've some design questions left I can't clear myself:

- Is it valid to modify target data in the checkentry function? Accounting information can be stored in user-named tables. To avoid a strcmp() for every packet, I convert the table name in target_checkentry to a number and store it in the target information.
Is it allowed to modify the supplied target information from kernel space? It doesn't crash or act strange so far, but I want to be on the safe side.

- When returning the data, I'm currently calling copy_to_user for every IP. The space used for every IP entry is 20 bytes. I somehow imagine copy_to_user is a very expensive function and shouldn't be called too often. For 1000 active clients it would be called 1000 times copying 20 bytes -> Not good

I thought about adding a small buffer of f.e. 4096 (PAGE_SIZE) bytes. Once it's filled up, I'll call copy_to_user. Is there a better way to transfer the data to userspace? mmaping the data is not available, as some of the data structures have pointers to other kernel space memory blocks.

Thanks in advance for any help.

Cheers,
Thomas

Signature · 9 lines
Intra2net AG
Moempelgarder Weg 8
72072 Tuebingen
Germany

Tel: +49-7071-56510-0
Fax: +49-7071-56510-50
[email protected]
http://www.intra2net.com