gpt4 book ai didi

c - 使用内核模块中的 sysctl 接口(interface)

转载 作者:太空宇宙 更新时间:2023-11-04 12:13:28 25 4
gpt4 key购买 nike

我正在尝试从内核模块访问 tcp_input.c 中定义的 tcp_pacing_ss_ratio。可以在用户空间使用 sysctl 命令修改该变量。但是,它不会导出,也不能直接从模块中引用。

从内核模块访问 sysctl 条目的最简单方法是什么?

最佳答案

来自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.

在您的情况下,这将是 /proc/sys/net/ipv4/tcp_pacing_ss_ratio,您可以使用 kernel_write 编写。查看sysctl(2)'s implementation for example usage .

关于c - 使用内核模块中的 sysctl 接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48150155/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com