+ -
当前位置:首页 → 问答吧 → sysctl控制项-请教

sysctl控制项-请教

时间:2010-08-23

来源:互联网

我想在/proc/sys/net/ipv4下建立一个专用的目录sina,然后来存放一些自己设定的一些参数。但是奇怪的是,一些在/proc/sys/net/ipv4目录下的icmp_echo*的东西被复制过来了。闹了半天还是没有头绪。现象如下:
[root@localhost linux-2.6.30]# ll /proc/sys/net/ipv4/icmp_*
icmp_echo_ignore_all               icmp_errors_use_inbound_ifaddr     icmp_ratelimit                     
icmp_echo_ignore_broadcasts        icmp_ignore_bogus_error_responses  icmp_ratemask   

[root@localhost linux-2.6.30]# ll /proc/sys/net/ipv4/sina/
icmp_echo_ignore_all               icmp_ignore_bogus_error_responses  rt_cache_rebuild_count             tcp_passive_threshold
icmp_echo_ignore_broadcasts        icmp_ratelimit                     tcp_active_threshold               tcp_rtt_threshold
icmp_errors_use_inbound_ifaddr     icmp_ratemask                      tcp_est_threshold
在sina目录下一些icmp_*的东西被从 ipv4目录 下复制过来了,而且文件的创建时间也相同。下面是对应的内核代码部分,我修改的用红色标出来了。
net/ipv4/sysctl_net_ipv4.c

....
static struct ctl_table private_table[] = {
        {
                .ctl_name       = NET_IPV4_TCP_RTT_THRESHOLD,
                .procname       = "tcp_rtt_threshold",
                .data           = &sysctl_tcp_rtt_threshold,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec
        },
        {
                .ctl_name       = NET_IPV4_TCP_EST_THRESHOLD,
                .procname       = "tcp_est_threshold",
                .data           = &sysctl_tcp_est_threshold,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec
        },
        {
                .ctl_name       = NET_IPV4_TCP_PASSIVE_THRESHOLD,
                .procname       = "tcp_passive_threshold",
                .data           = &sysctl_tcp_passive_threshold,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec
        },
        {
                .ctl_name       = NET_IPV4_TCP_ACTIVE_THRESHOLD,
                .procname       = "tcp_active_threshold",
                .data           = &sysctl_tcp_active_threshold,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec
        }
};

...
struct ctl_path net_ipv4_sina_ctl_path[] = {
        {.procname = "net",.ctl_name = CTL_NET,},
        {.procname = "ipv4",.ctl_name = NET_IPV4,},
        {.procname = "sina",.ctl_name = IPV4_SINA,},
        {},
};

....

static __init int sysctl_ipv4_init(void)
{
        struct ctl_table_header *hdr;
        struct ctl_table_header *hdr_ex;

        hdr = register_sysctl_paths(net_ipv4_ctl_path, ipv4_table);
        hdr_ex = register_sysctl_paths(net_ipv4_sina_ctl_path, private_table);
        if((hdr == NULL) && (hdr_ex == NULL))
                return -ENOMEM;

        if (register_pernet_subsys(&ipv4_sysctl_ops)) {
                unregister_sysctl_table(hdr_ex);
                unregister_sysctl_table(hdr);
                return -ENOMEM;
        }

        return 0;
}

请高手帮看看,是什么原因导致icmp_**的东西被闹到sina目录下。。。谢谢了。。。

作者: peking_A_Liang   发布时间: 2010-08-23

额,看看进程?

作者: vermouth   发布时间: 2010-08-23