Skip to contentSkip to conversation

L2 NAT

DISCUSSION ivan 3 participants 5 messages Dec 3, 2008 – Dec 4, 2008 netfilter

lore
Share & tools
lore

ivan

author
#0 lore raw

Hi,

After having a lot of help of Grant Taylor in order to analyze if I was able to achieve my idea using the available iptables features, and getting as result the fact that I had to develop my own kernel module. I'm writing to this list because my question is related to the linux kernel programing.

I would like to pass parameters to the kernel module in run time from user space. These parameters could be IP address and MAC. Somebody know how I can do this??

I was thinking about passing this parameters thorough a sysctl syscall or using /proc filesystem, but I beleave that this is not the correct way.

Also I was taking a look to iptables source code and analyzing the source code of iptables and libiptc lib, but I could not find any clue how to these ones change the kernel parameters.

Could you pleas help me???

thanks!

#1 lore raw
Quoted 3 lines · ivan

I would like to pass parameters to the kernel module in run time from user space. These parameters could be IP address and MAC. Somebody know how I can do this??

Use the module_param functions (you probably want the string variant).
See http://tldp.org/LDP/lkmpg/2.6/html/x323.html for examples.

Quoted 3 lines

I was thinking about passing this parameters thorough a sysctl syscall or using /proc filesystem, but I beleave that this is not the correct way.

Depends on if you need to be able to modify it after the module has already been loaded. If not, a module parameter should suffice.

HTH,
James

author
#2 lore raw

James,

Thanks for your soon reply!

I think that your answer is a good approach, but I would like to pass/modify the module parameters while this one is running. I believe this way allows to the user more flexibility to add/configure the module behavior.

Please, let me know if you have any idea.

Thanks again.

ivan.

Quoted 19 lines · James King
Quoted 3 lines · ivan

I would like to pass parameters to the kernel module in run time from user space. These parameters could be IP address and MAC. Somebody know how I can do this??

Use the module_param functions (you probably want the string variant).
See http://tldp.org/LDP/lkmpg/2.6/html/x323.html for examples.

Quoted 3 lines

I was thinking about passing this parameters thorough a sysctl syscall or using /proc filesystem, but I beleave that this is not the correct way.

Depends on if you need to be able to modify it after the module has already been loaded. If not, a module parameter should suffice.

HTH,
James

#3 lore raw
Quoted 5 lines · ivan

I think that your answer is a good approach, but I would like to pass/modify the module parameters while this one is running. I believe this way allows to the user more flexibility to add/configure the module behavior.

You can do that with module parameters, they appears as files in /sys/module/<module-name>/parameters and, given the right permissions, you can modify them as you see fit.

jch

author
#4 lore raw

Thanks jch,

I will try doing this!
My module works changing the IP address of a package according to its MAC address, so I would like to add diferents <MAC-IP> couples while the module is running.

Thanks!!

Quoted 14 lines · John Haxby
Quoted 6 lines · ivan

I think that your answer is a good approach, but I would like to pass/modify the module parameters while this one is running. I believe this way allows to the user more flexibility to add/configure the module behavior.

You can do that with module parameters, they appears as files in /sys/module/<module-name>/parameters and, given the right permissions, you can modify them as you see fit.

jch