Skip to content
Advertisement

Using sysctl interface from kernel module

I am trying to access tcp_pacing_ss_ratio defined in tcp_input.c from a kernel module. The variable can be modified using the sysctl command in user space. It is however not exported and cannot be referenced directly from the module.

What is the simplest way to access a sysctl entry from a kernel module?

Advertisement

Answer

From the sysctl(2) manpage:

use of this system call has long been discouraged, and it is so unloved that it is likely to disappear in a future kernel version. Since Linux 2.6.24, uses of this system call result in warnings in the kernel log. Remove it from your programs now; use the /proc/sys interface instead.

This would be /proc/sys/net/ipv4/tcp_pacing_ss_ratio in your case, which you can write with kernel_write. Check out sysctl(2)‘s implementation for example usage.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement