From: Konstantin Khlebnikov Date: Tue, 1 Apr 2008 13:55:52 +0000 (+0400) Subject: Add per-VE /proc/net/{udp,udp6,udplite,udplite6} X-Git-Url: http://git.openvz.org/?p=linux-2.6.24-openvz;a=commitdiff_plain;h=452bdf6ea996f2e9e030822d87d9106bf33e0677 Add per-VE /proc/net/{udp,udp6,udplite,udplite6} Show only connections of current VE (already implemented). Required for netstat. http://bugzilla.openvz.org/show_bug.cgi?id=860 --- diff --git a/include/net/udp.h b/include/net/udp.h index 71967e3..20bc0ab 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -180,8 +180,8 @@ struct udp_iter_state { }; #ifdef CONFIG_PROC_FS -extern int udp_proc_register(struct udp_seq_afinfo *afinfo); -extern void udp_proc_unregister(struct udp_seq_afinfo *afinfo); +extern int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo); +extern void udp_proc_unregister(struct net *net, struct udp_seq_afinfo *afinfo); extern int udp4_proc_init(void); extern void udp4_proc_exit(void); diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 32fddac..a27ed8a 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1576,7 +1576,7 @@ out_kfree: } /* ------------------------------------------------------------------------ */ -int udp_proc_register(struct udp_seq_afinfo *afinfo) +int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo) { struct proc_dir_entry *p; int rc = 0; @@ -1589,7 +1589,7 @@ int udp_proc_register(struct udp_seq_afinfo *afinfo) afinfo->seq_fops->llseek = seq_lseek; afinfo->seq_fops->release = seq_release_private; - p = proc_net_fops_create(&init_net, afinfo->name, S_IRUGO, afinfo->seq_fops); + p = proc_net_fops_create(net, afinfo->name, S_IRUGO, afinfo->seq_fops); if (p) p->data = afinfo; else @@ -1597,11 +1597,11 @@ int udp_proc_register(struct udp_seq_afinfo *afinfo) return rc; } -void udp_proc_unregister(struct udp_seq_afinfo *afinfo) +void udp_proc_unregister(struct net *net, struct udp_seq_afinfo *afinfo) { if (!afinfo) return; - proc_net_remove(&init_net, afinfo->name); + proc_net_remove(net, afinfo->name); memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops)); } @@ -1651,14 +1651,29 @@ static struct udp_seq_afinfo udp4_seq_afinfo = { .seq_fops = &udp4_seq_fops, }; +static int udp4_proc_net_init(struct net *net) +{ + return udp_proc_register(net, &udp4_seq_afinfo); +} + +static void udp4_proc_net_exit(struct net *net) +{ + udp_proc_unregister(net, &udp4_seq_afinfo); +} + +static struct pernet_operations udp4_proc_net_ops = { + .init = udp4_proc_net_init, + .exit = udp4_proc_net_exit, +}; + int __init udp4_proc_init(void) { - return udp_proc_register(&udp4_seq_afinfo); + return register_pernet_subsys(&udp4_proc_net_ops); } void udp4_proc_exit(void) { - udp_proc_unregister(&udp4_seq_afinfo); + unregister_pernet_subsys(&udp4_proc_net_ops); } #endif /* CONFIG_PROC_FS */ diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index f5baeb3..c66933b 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c @@ -92,6 +92,21 @@ static struct udp_seq_afinfo udplite4_seq_afinfo = { .seq_show = udp4_seq_show, .seq_fops = &udplite4_seq_fops, }; + +static int udplite4_proc_net_init(struct net *net) +{ + return udp_proc_register(net, &udplite4_seq_afinfo); +} + +static void udplite4_proc_net_exit(struct net *net) +{ + udp_proc_unregister(net, &udplite4_seq_afinfo); +} + +static struct pernet_operations udplite4_proc_net_ops = { + .init = udplite4_proc_net_init, + .exit = udplite4_proc_net_exit, +}; #endif void __init udplite4_register(void) @@ -105,7 +120,7 @@ void __init udplite4_register(void) inet_register_protosw(&udplite4_protosw); #ifdef CONFIG_PROC_FS - if (udp_proc_register(&udplite4_seq_afinfo)) /* udplite4_proc_init() */ + if (register_pernet_subsys(&udplite4_proc_net_ops)) /* udplite4_proc_init() */ printk(KERN_ERR "%s: Cannot register /proc!\n", __FUNCTION__); #endif return; diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index a28f405..bf170a8 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -961,13 +961,28 @@ static struct udp_seq_afinfo udp6_seq_afinfo = { .seq_fops = &udp6_seq_fops, }; +static int udp6_proc_net_init(struct net *net) +{ + return udp_proc_register(net, &udp6_seq_afinfo); +} + +static void udp6_proc_net_exit(struct net *net) +{ + udp_proc_unregister(net, &udp6_seq_afinfo); +} + +static struct pernet_operations udp6_proc_net_ops = { + .init = udp6_proc_net_init, + .exit = udp6_proc_net_exit, +}; + int __init udp6_proc_init(void) { - return udp_proc_register(&udp6_seq_afinfo); + return register_pernet_subsys(&udp6_proc_net_ops); } void udp6_proc_exit(void) { - udp_proc_unregister(&udp6_seq_afinfo); + unregister_pernet_subsys(&udp6_proc_net_ops); } #endif /* CONFIG_PROC_FS */ diff --git a/net/ipv6/udplite.c b/net/ipv6/udplite.c index 5a0379f..992e677 100644 --- a/net/ipv6/udplite.c +++ b/net/ipv6/udplite.c @@ -96,13 +96,28 @@ static struct udp_seq_afinfo udplite6_seq_afinfo = { .seq_fops = &udplite6_seq_fops, }; +static int udplite6_proc_net_init(struct net *net) +{ + return udp_proc_register(net, &udplite6_seq_afinfo); +} + +static void udplite6_proc_net_exit(struct net *net) +{ + udp_proc_unregister(net, &udplite6_seq_afinfo); +} + +static struct pernet_operations udplite6_proc_net_ops = { + .init = udplite6_proc_net_init, + .exit = udplite6_proc_net_exit, +}; + int __init udplite6_proc_init(void) { - return udp_proc_register(&udplite6_seq_afinfo); + return register_pernet_subsys(&udplite6_proc_net_ops); } void udplite6_proc_exit(void) { - udp_proc_unregister(&udplite6_seq_afinfo); + unregister_pernet_subsys(&udplite6_proc_net_ops); } #endif From: Konstantin Khlebnikov Date: Tue, 1 Apr 2008 14:19:20 +0000 (+0400) Subject: Add per-VE /proc/net/tcp6 X-Git-Url: http://git.openvz.org/?p=linux-2.6.24-openvz;a=commitdiff_plain;h=ae2649d1f4e2249b3854be0570ea5074aa1836cb Add per-VE /proc/net/tcp6 Required for netstat. http://bugzilla.openvz.org/show_bug.cgi?id=860 --- diff --git a/include/net/tcp.h b/include/net/tcp.h index bac8599..7de5423 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1355,8 +1355,8 @@ struct tcp_iter_state { struct seq_operations seq_ops; }; -extern int tcp_proc_register(struct tcp_seq_afinfo *afinfo); -extern void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo); +extern int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo); +extern void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo); extern struct request_sock_ops tcp_request_sock_ops; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 54a95e9..1a83482 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -2289,7 +2289,7 @@ out_kfree: goto out; } -int tcp_proc_register(struct tcp_seq_afinfo *afinfo) +int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo) { int rc = 0; struct proc_dir_entry *p; @@ -2302,7 +2302,7 @@ int tcp_proc_register(struct tcp_seq_afinfo *afinfo) afinfo->seq_fops->llseek = seq_lseek; afinfo->seq_fops->release = seq_release_private; - p = proc_net_fops_create(current->nsproxy->net_ns, afinfo->name, S_IRUGO, afinfo->seq_fops); + p = proc_net_fops_create(net, afinfo->name, S_IRUGO, afinfo->seq_fops); if (p) p->data = afinfo; else @@ -2310,12 +2310,12 @@ int tcp_proc_register(struct tcp_seq_afinfo *afinfo) return rc; } -void tcp_proc_unregister(struct tcp_seq_afinfo *afinfo) +void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo) { if (!afinfo) return; - proc_net_remove(current->nsproxy->net_ns, afinfo->name); + proc_net_remove(net, afinfo->name); memset(afinfo->seq_fops, 0, sizeof(*afinfo->seq_fops)); } @@ -2456,12 +2456,12 @@ static struct tcp_seq_afinfo tcp4_seq_afinfo = { static int tcp4_proc_net_init(struct net *net) { - return tcp_proc_register(&tcp4_seq_afinfo); + return tcp_proc_register(net, &tcp4_seq_afinfo); } static void tcp4_proc_net_exit(struct net *net) { - tcp_proc_unregister(&tcp4_seq_afinfo); + tcp_proc_unregister(net, &tcp4_seq_afinfo); } static struct pernet_operations tcp4_proc_net_ops = { diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index d5d8c0b..d2cf1f0 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -2107,14 +2107,29 @@ static struct tcp_seq_afinfo tcp6_seq_afinfo = { .seq_fops = &tcp6_seq_fops, }; +static int tcp6_proc_net_init(struct net *net) +{ + return tcp_proc_register(net, &tcp6_seq_afinfo); +} + +static void tcp6_proc_net_exit(struct net *net) +{ + tcp_proc_unregister(net, &tcp6_seq_afinfo); +} + +static struct pernet_operations tcp6_proc_net_ops = { + .init = tcp6_proc_net_init, + .exit = tcp6_proc_net_exit, +}; + int __init tcp6_proc_init(void) { - return tcp_proc_register(&tcp6_seq_afinfo); + return register_pernet_subsys(&tcp6_proc_net_ops); } void tcp6_proc_exit(void) { - tcp_proc_unregister(&tcp6_seq_afinfo); + unregister_pernet_subsys(&tcp6_proc_net_ops); } #endif From: Konstantin Khlebnikov Date: Tue, 1 Apr 2008 14:28:28 +0000 (+0400) Subject: Add per-VE /proc/net/raw6 X-Git-Url: http://git.openvz.org/?p=linux-2.6.24-openvz;a=commitdiff_plain;h=2670e872531c35866f12598970ee812456c0e9ee Add per-VE /proc/net/raw6 Show only connections of current VE (already implemented) Required for netstat http://bugzilla.openvz.org/show_bug.cgi?id=860 and fix small bug in v4 raw socket proc -- call unregister_pernet_subsys instead of remove_proc_entry(). --- diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 8e0df71..abf5873 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c @@ -953,6 +953,6 @@ int __init raw_proc_init(void) void __init raw_proc_exit(void) { - proc_net_remove(&init_net, "raw"); + unregister_pernet_subsys(&raw_net_ops); } #endif /* CONFIG_PROC_FS */ diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index f6dcbe4..1cc3e0f 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c @@ -1314,15 +1314,30 @@ static const struct file_operations raw6_seq_fops = { .release = seq_release_private, }; -int __init raw6_proc_init(void) +static int raw6_net_init(struct net *net) { - if (!proc_net_fops_create(&init_net, "raw6", S_IRUGO, &raw6_seq_fops)) + if (!proc_net_fops_create(net, "raw6", S_IRUGO, &raw6_seq_fops)) return -ENOMEM; return 0; } +static void raw6_net_exit(struct net *net) +{ + proc_net_remove(net, "raw6"); +} + +static struct pernet_operations raw6_net_ops = { + .init = raw6_net_init, + .exit = raw6_net_exit, +}; + +int __init raw6_proc_init(void) +{ + return register_pernet_subsys(&raw6_net_ops); +} + void raw6_proc_exit(void) { - proc_net_remove(&init_net, "raw6"); + unregister_pernet_subsys(&raw6_net_ops); } #endif /* CONFIG_PROC_FS */