mib: finish with ipv4 mibs netnsization
Subsystems (6)
cover mib: finish with ipv4 mibs netnsization
This is the notorious "finalizing set" - after this all the ipv4 stats are isolated from each other. The ipv6, dccp and sctp I touched with previous sets deserve special handling and will be done in 2.6.28
No *new* stuff for 2.6.27 from me, thank you Dave for your patience :)
PATCH 1/16 mib: add netns/mib.h file
The only structure declared within is the netns_mib, which will carry all our mibs within. I didn't put the mibs in the existing netns_xxx structures to make it possible to mark this one as properly aligned and get in a separate "read-mostly" cache-line.
--- include/net/net_namespace.h | 2 ++ include/net/netns/mib.h | 9 +++++++++ 2 files changed, 11 insertions(+), 0 deletions(-) create mode 100644 include/net/netns/mib.h
include/net/net_namespace.h +2 -0
@@ -9,6 +9,7 @@#include <linux/list.h> #include <net/netns/core.h> +#include <net/netns/mib.h> #include <net/netns/unix.h> #include <net/netns/packet.h> #include <net/netns/ipv4.h>
@@ -52,6 +53,7 @@ struct net {struct sock *rtnl;/* rtnetlink socket */ struct netns_core core; +struct netns_mib mib;struct netns_packet packet;struct netns_unix unx;struct netns_ipv4 ipv4;
include/net/netns/mib.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef __NETNS_MIB_H__ +#define __NETNS_MIB_H__ + +#include <net/snmp.h> + +struct netns_mib { +}; + +#endif
Signature · 1 line
1.5.5.1
PATCH 2/16 ipv4: add pernet mib operations
In reply to Pavel EmelyanovThese ones are currently empty, but stuff from init_ipv4_mibs will sequentially migrate there.
--- net/ipv4/af_inet.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-)
net/ipv4/af_inet.c +20 -0
@@ -110,6 +110,7 @@#include <net/ipip.h> #include <net/inet_common.h> #include <net/xfrm.h> +#include <net/net_namespace.h> #ifdef CONFIG_IP_MROUTE #include <linux/mroute.h> #endif
@@ -1339,6 +1340,20 @@ static struct net_protocol icmp_protocol = { .netns_ok = 1, }; +static __net_init int ipv4_mib_init_net (struct net *net) +{ +return 0 ; +} + +static __net_exit void ipv4_mib_exit_net(struct net *net) +{ +} + +static __net_initdata struct pernet_operations ipv4_mib_ops = { + .init = ipv4_mib_init_net, + .exit = ipv4_mib_exit_net, +}; +static int __init init_ipv4_mibs (void ) { if (snmp_mib_init((void **)net_statistics,
@@ -1365,8 +1380,13 @@ static int __init init_ipv4_mibs(void)tcp_mib_init (&init_net); +if (register_pernet_subsys (&ipv4_mib_ops)) + goto err_net; +return 0 ; +err_net: +snmp_mib_free ((void **)udplite_statistics); err_udplite_mib:snmp_mib_free ((void **)udp_statistics); err_udp_mib:
Signature · 1 line
1.5.5.1
PATCH 3/16 mib: put tcp statistics on struct net
In reply to Pavel EmelyanovProc temporary uses stats from init_net.
BTW, TCP_XXX_STATS are beautiful (w/o do { } while (0) facing) again :)
--- include/net/netns/mib.h | 1 + include/net/tcp.h | 9 ++++----- net/ipv4/af_inet.c | 16 +++++++++------- net/ipv4/proc.c | 4 ++-- net/ipv4/tcp.c | 3 --- 5 files changed, 16 insertions(+), 17 deletions(-)
include/net/netns/mib.h +1 -0
@@ -4,6 +4,7 @@#include <net/snmp.h> struct netns_mib { + DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); };#endif
include/net/tcp.h +4 -5
@@ -265,11 +265,10 @@ static inline int tcp_too_many_orphans(struct sock *sk, int num)extern struct proto tcp_prot; -DECLARE_SNMP_STAT(struct tcp_mib, tcp_statistics); -#define TCP_INC_STATS (net, field) do { (void)net; SNMP_INC_STATS(tcp_statistics, field); } while (0) -#define TCP_INC_STATS_BH (net, field) do { (void)net; SNMP_INC_STATS_BH(tcp_statistics, field); } while (0) -#define TCP_DEC_STATS (net, field) do { (void)net; SNMP_DEC_STATS(tcp_statistics, field); } while (0) -#define TCP_ADD_STATS_USER (net, field, val) do { (void)net; SNMP_ADD_STATS_USER(tcp_statistics, field, val); } while (0) +#define TCP_INC_STATS (net, field) SNMP_INC_STATS((net)->mib.tcp_statistics, field) +#define TCP_INC_STATS_BH (net, field) SNMP_INC_STATS_BH((net)->mib.tcp_statistics, field) +#define TCP_DEC_STATS (net, field) SNMP_DEC_STATS((net)->mib.tcp_statistics, field) +#define TCP_ADD_STATS_USER (net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val)extern void tcp_v4_err (struct sk_buff *skb,u32 );
net/ipv4/af_inet.c +9 -7
@@ -1342,11 +1342,20 @@ static struct net_protocol icmp_protocol = {static __net_init int ipv4_mib_init_net (struct net *net) { +if (snmp_mib_init ((void **)net->mib.tcp_statistics, +sizeof (struct tcp_mib )) <0 ) + goto err_tcp_mib; + +tcp_mib_init (net);return 0 ; + +err_tcp_mib: +return -ENOMEM ; } static __net_exit void ipv4_mib_exit_net(struct net *net) { +snmp_mib_free ((void **)net->mib.tcp_statistics); }static __net_initdata struct pernet_operations ipv4_mib_ops = {
@@ -1368,9 +1377,6 @@ static int __init init_ipv4_mibs(void)if (snmp_mib_init ((void **)icmpmsg_statistics,sizeof (struct icmpmsg_mib )) <0 ) goto err_icmpmsg_mib; -if (snmp_mib_init ((void **)tcp_statistics, -sizeof (struct tcp_mib )) <0 ) - goto err_tcp_mib;if (snmp_mib_init ((void **)udp_statistics,sizeof (struct udp_mib )) <0 ) goto err_udp_mib;
@@ -1378,8 +1384,6 @@ static int __init init_ipv4_mibs(void) sizeof(struct udp_mib)) < 0) goto err_udplite_mib; -tcp_mib_init (&init_net); -if (register_pernet_subsys (&ipv4_mib_ops)) goto err_net;
@@ -1390,8 +1394,6 @@ err_net: err_udplite_mib:snmp_mib_free ((void **)udp_statistics); err_udp_mib: -snmp_mib_free ((void **)tcp_statistics); -err_tcp_mib:snmp_mib_free ((void **)icmpmsg_statistics); err_icmpmsg_mib:snmp_mib_free ((void **)icmp_statistics);
net/ipv4/proc.c +2 -2
@@ -359,11 +359,11 @@ static int snmp_seq_show(struct seq_file *seq, void *v)/* MaxConn field is signed, RFC 2012 */ if (snmp4_tcp_list[i].entry ==TCP_MIB_MAXCONN )seq_printf (seq," %ld" , -snmp_fold_field ((void **)tcp_statistics, +snmp_fold_field ((void **)init_net.mib.tcp_statistics, snmp4_tcp_list[i].entry));else seq_printf (seq," %lu" , -snmp_fold_field ((void **)tcp_statistics, +snmp_fold_field ((void **)init_net.mib.tcp_statistics, snmp4_tcp_list[i].entry)); }
net/ipv4/tcp.c +0 -3
@@ -277,8 +277,6 @@int sysctl_tcp_fin_timeout__read_mostly =TCP_FIN_TIMEOUT ; -DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics) __read_mostly; -atomic_t tcp_orphan_count =ATOMIC_INIT (0 );EXPORT_SYMBOL_GPL (tcp_orphan_count);
@@ -2802,4 +2800,3 @@ EXPORT_SYMBOL(tcp_splice_read);EXPORT_SYMBOL (tcp_sendpage);EXPORT_SYMBOL (tcp_setsockopt);EXPORT_SYMBOL (tcp_shutdown); -EXPORT_SYMBOL (tcp_statistics);
Signature · 1 line
1.5.5.1
PATCH 4/16 mib: put ip statistics on struct net
In reply to Pavel EmelyanovSimilar to tcp one.
--- include/net/ip.h | 7 +++---- include/net/netns/mib.h | 1 + net/ipv4/af_inet.c | 11 ++++++----- net/ipv4/ip_input.c | 8 -------- net/ipv4/proc.c | 4 ++-- 5 files changed, 12 insertions(+), 19 deletions(-)
include/net/ip.h +3 -4
@@ -156,10 +156,9 @@ struct ipv4_config };extern struct ipv4_config ipv4_config; -DECLARE_SNMP_STAT(struct ipstats_mib, ip_statistics); -#define IP_INC_STATS (net, field) do { (void)net; SNMP_INC_STATS(ip_statistics, field); } while (0) -#define IP_INC_STATS_BH (net, field) do { (void)net; SNMP_INC_STATS_BH(ip_statistics, field); } while (0) -#define IP_ADD_STATS_BH (net, field, val) SNMP_ADD_STATS_BH(ip_statistics, field, val) +#define IP_INC_STATS (net, field) SNMP_INC_STATS((net)->mib.ip_statistics, field) +#define IP_INC_STATS_BH (net, field) SNMP_INC_STATS_BH((net)->mib.ip_statistics, field) +#define IP_ADD_STATS_BH (net, field, val) SNMP_ADD_STATS_BH((net)->mib.ip_statistics, field, val) DECLARE_SNMP_STAT(struct linux_mib, net_statistics);#define NET_INC_STATS (net, field) do { (void)net; SNMP_INC_STATS(net_statistics, field); } while (0)#define NET_INC_STATS_BH (net, field) do { (void)net; SNMP_INC_STATS_BH(net_statistics, field); } while (0)
include/net/netns/mib.h +1 -0
@@ -5,6 +5,7 @@struct netns_mib { DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); + DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics); };#endif
net/ipv4/af_inet.c +6 -5
@@ -1345,16 +1345,22 @@ static __net_init int ipv4_mib_init_net(struct net *net)if (snmp_mib_init ((void **)net->mib.tcp_statistics,sizeof (struct tcp_mib )) <0 ) goto err_tcp_mib; +if (snmp_mib_init ((void **)net->mib.ip_statistics, +sizeof (struct ipstats_mib )) <0 ) + goto err_ip_mib;tcp_mib_init (net);return 0 ; +err_ip_mib: +snmp_mib_free ((void **)net->mib.tcp_statistics); err_tcp_mib:return -ENOMEM ; } static __net_exit void ipv4_mib_exit_net(struct net *net) { +snmp_mib_free ((void **)net->mib.ip_statistics);snmp_mib_free ((void **)net->mib.tcp_statistics); }
@@ -1368,9 +1374,6 @@ static int __init init_ipv4_mibs(void)if (snmp_mib_init ((void **)net_statistics,sizeof (struct linux_mib )) <0 ) goto err_net_mib; -if (snmp_mib_init ((void **)ip_statistics, -sizeof (struct ipstats_mib )) <0 ) - goto err_ip_mib;if (snmp_mib_init ((void **)icmp_statistics,sizeof (struct icmp_mib )) <0 ) goto err_icmp_mib;
@@ -1398,8 +1401,6 @@ err_udp_mib: err_icmpmsg_mib:snmp_mib_free ((void **)icmp_statistics); err_icmp_mib: -snmp_mib_free ((void **)ip_statistics); -err_ip_mib:snmp_mib_free ((void **)net_statistics); err_net_mib:return -ENOMEM ;
net/ipv4/ip_input.c +0 -8
@@ -145,12 +145,6 @@#include <linux/netlink.h> /* -* SNMP management statistics -*/ - -DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics) __read_mostly; - -/* * Process Router Attention IP option */ int ip_call_ra_chain (struct sk_buff *skb)
@@ -447,5 +441,3 @@ drop: out:return NET_RX_DROP ; } - -EXPORT_SYMBOL (ip_statistics);
net/ipv4/proc.c +2 -2
@@ -344,7 +344,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)for (i =0 ; snmp4_ipstats_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)ip_statistics, +snmp_fold_field ((void **)init_net.mib.ip_statistics, snmp4_ipstats_list[i].entry));icmp_put (seq);/* RFC 2011 compatibility */
@@ -431,7 +431,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v)seq_puts (seq,"\nIpExt:" );for (i =0 ; snmp4_ipextstats_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)ip_statistics, +snmp_fold_field ((void **)init_net.mib.ip_statistics, snmp4_ipextstats_list[i].entry));seq_putc (seq,'\n' );
Signature · 1 line
1.5.5.1
PATCH 5/16 mib: put net statistics on struct net
In reply to Pavel EmelyanovSimilar to ip and tcp ones :)
--- include/net/ip.h | 11 +++++------ include/net/netns/mib.h | 1 + net/ipv4/af_inet.c | 14 ++++++-------- net/ipv4/proc.c | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-)
include/net/ip.h +5 -6
@@ -159,12 +159,11 @@ extern struct ipv4_config ipv4_config;#define IP_INC_STATS (net, field) SNMP_INC_STATS((net)->mib.ip_statistics, field)#define IP_INC_STATS_BH (net, field) SNMP_INC_STATS_BH((net)->mib.ip_statistics, field)#define IP_ADD_STATS_BH (net, field, val) SNMP_ADD_STATS_BH((net)->mib.ip_statistics, field, val) -DECLARE_SNMP_STAT(struct linux_mib, net_statistics); -#define NET_INC_STATS (net, field) do { (void)net; SNMP_INC_STATS(net_statistics, field); } while (0) -#define NET_INC_STATS_BH (net, field) do { (void)net; SNMP_INC_STATS_BH(net_statistics, field); } while (0) -#define NET_INC_STATS_USER (net, field) do { (void)net; SNMP_INC_STATS_USER(net_statistics, field); } while (0) -#define NET_ADD_STATS_BH (net, field, adnd) do { (void)net; SNMP_ADD_STATS_BH(net_statistics, field, adnd); } while (0) -#define NET_ADD_STATS_USER (net, field, adnd) do { (void)net; SNMP_ADD_STATS_USER(net_statistics, field, adnd); } while (0) +#define NET_INC_STATS (net, field) SNMP_INC_STATS((net)->mib.net_statistics, field) +#define NET_INC_STATS_BH (net, field) SNMP_INC_STATS_BH((net)->mib.net_statistics, field) +#define NET_INC_STATS_USER (net, field) SNMP_INC_STATS_USER((net)->mib.net_statistics, field) +#define NET_ADD_STATS_BH (net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd) +#define NET_ADD_STATS_USER (net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd)extern unsigned long snmp_fold_field (void *mib[],int offt);extern int snmp_mib_init (void *ptr[2 ],size_t mibsize);
include/net/netns/mib.h +1 -0
@@ -6,6 +6,7 @@struct netns_mib { DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics); + DEFINE_SNMP_STAT(struct linux_mib, net_statistics); };#endif
net/ipv4/af_inet.c +6 -8
@@ -115,8 +115,6 @@#include <linux/mroute.h> #endif -DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly; -extern void ip_mc_drop_socket (struct sock *sk);/* The inetsw table contains everything that inet_create needs to
@@ -1348,10 +1346,15 @@ static __net_init int ipv4_mib_init_net(struct net *net)if (snmp_mib_init ((void **)net->mib.ip_statistics,sizeof (struct ipstats_mib )) <0 ) goto err_ip_mib; +if (snmp_mib_init ((void **)net->mib.net_statistics, +sizeof (struct linux_mib )) <0 ) + goto err_net_mib;tcp_mib_init (net);return 0 ; +err_net_mib: +snmp_mib_free ((void **)net->mib.ip_statistics); err_ip_mib:snmp_mib_free ((void **)net->mib.tcp_statistics); err_tcp_mib:
@@ -1360,6 +1363,7 @@ err_tcp_mib: static __net_exit void ipv4_mib_exit_net(struct net *net) { +snmp_mib_free ((void **)net->mib.net_statistics);snmp_mib_free ((void **)net->mib.ip_statistics);snmp_mib_free ((void **)net->mib.tcp_statistics); }
@@ -1371,9 +1375,6 @@ static __net_initdata struct pernet_operations ipv4_mib_ops = {static int __init init_ipv4_mibs (void ) { -if (snmp_mib_init ((void **)net_statistics, -sizeof (struct linux_mib )) <0 ) - goto err_net_mib;if (snmp_mib_init ((void **)icmp_statistics,sizeof (struct icmp_mib )) <0 ) goto err_icmp_mib;
@@ -1401,8 +1402,6 @@ err_udp_mib: err_icmpmsg_mib:snmp_mib_free ((void **)icmp_statistics); err_icmp_mib: -snmp_mib_free ((void **)net_statistics); -err_net_mib:return -ENOMEM ; }
@@ -1582,5 +1581,4 @@ EXPORT_SYMBOL(inet_sock_destruct);EXPORT_SYMBOL (inet_stream_connect);EXPORT_SYMBOL (inet_stream_ops);EXPORT_SYMBOL (inet_unregister_protosw); -EXPORT_SYMBOL (net_statistics);EXPORT_SYMBOL (sysctl_ip_nonlocal_bind);
net/ipv4/proc.c +1 -1
@@ -421,7 +421,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v)seq_puts (seq,"\nTcpExt:" );for (i =0 ; snmp4_net_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)net_statistics, +snmp_fold_field ((void **)init_net.mib.net_statistics, snmp4_net_list[i].entry));seq_puts (seq,"\nIpExt:" );
Signature · 1 line
1.5.5.1
PATCH 6/16 mib: put udp statistics on struct net
In reply to Pavel EmelyanovSimilar to... ouch, I repeat myself.
--- include/net/netns/mib.h | 1 + include/net/udp.h | 9 ++++----- net/ipv4/af_inet.c | 11 ++++++----- net/ipv4/proc.c | 2 +- net/ipv4/udp.c | 3 --- 5 files changed, 12 insertions(+), 14 deletions(-)
include/net/netns/mib.h +1 -0
@@ -7,6 +7,7 @@ struct netns_mib { DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics); DEFINE_SNMP_STAT(struct linux_mib, net_statistics); + DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); };#endif
include/net/udp.h +4 -5
@@ -148,7 +148,6 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname, char __user *optval, int optlen, int (*push_pending_frames)(struct sock *)); -DECLARE_SNMP_STAT(struct udp_mib, udp_statistics); DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
@@ -158,12 +157,12 @@ DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);/* * SNMP statistics for UDP and UDP-Lite */ -#define UDP_INC_STATS_USER (net, field, is_udplite) do { (void)net; \ +#define UDP_INC_STATS_USER (net, field, is_udplite) do { \ if (is_udplite) SNMP_INC_STATS_USER(udplite_statistics, field); \ - else SNMP_INC_STATS_USER(udp_statistics, field); } while(0) -#define UDP_INC_STATS_BH (net, field, is_udplite) do { (void)net; \ + else SNMP_INC_STATS_USER((net)->mib.udp_statistics, field); } while(0) +#define UDP_INC_STATS_BH (net, field, is_udplite) do { \ if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \ - else SNMP_INC_STATS_BH(udp_statistics, field); } while(0) + else SNMP_INC_STATS_BH((net)->mib.udp_statistics, field); } while(0)#define UDP6_INC_STATS_BH (net, field, is_udplite) do { (void)net; \ if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
net/ipv4/af_inet.c +6 -5
@@ -1349,10 +1349,15 @@ static __net_init int ipv4_mib_init_net(struct net *net)if (snmp_mib_init ((void **)net->mib.net_statistics,sizeof (struct linux_mib )) <0 ) goto err_net_mib; +if (snmp_mib_init ((void **)net->mib.udp_statistics, +sizeof (struct udp_mib )) <0 ) + goto err_udp_mib;tcp_mib_init (net);return 0 ; +err_udp_mib: +snmp_mib_free ((void **)net->mib.net_statistics); err_net_mib:snmp_mib_free ((void **)net->mib.ip_statistics); err_ip_mib:
@@ -1363,6 +1368,7 @@ err_tcp_mib: static __net_exit void ipv4_mib_exit_net(struct net *net) { +snmp_mib_free ((void **)net->mib.udp_statistics);snmp_mib_free ((void **)net->mib.net_statistics);snmp_mib_free ((void **)net->mib.ip_statistics);snmp_mib_free ((void **)net->mib.tcp_statistics);
@@ -1381,9 +1387,6 @@ static int __init init_ipv4_mibs(void)if (snmp_mib_init ((void **)icmpmsg_statistics,sizeof (struct icmpmsg_mib )) <0 ) goto err_icmpmsg_mib; -if (snmp_mib_init ((void **)udp_statistics, -sizeof (struct udp_mib )) <0 ) - goto err_udp_mib;if (snmp_mib_init ((void **)udplite_statistics,sizeof (struct udp_mib )) <0 ) goto err_udplite_mib;
@@ -1396,8 +1399,6 @@ static int __init init_ipv4_mibs(void) err_net:snmp_mib_free ((void **)udplite_statistics); err_udplite_mib: -snmp_mib_free ((void **)udp_statistics); -err_udp_mib:snmp_mib_free ((void **)icmpmsg_statistics); err_icmpmsg_mib:snmp_mib_free ((void **)icmp_statistics);
net/ipv4/proc.c +1 -1
@@ -374,7 +374,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)seq_puts (seq,"\nUdp:" );for (i =0 ; snmp4_udp_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)udp_statistics, +snmp_fold_field ((void **)init_net.mib.udp_statistics, snmp4_udp_list[i].entry));/* the UDP and UDP-Lite MIBs are the same */
net/ipv4/udp.c +0 -3
@@ -108,9 +108,6 @@* Snmp MIB for the UDP layer */ -DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly; -EXPORT_SYMBOL (udp_statistics); - DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6) __read_mostly;EXPORT_SYMBOL (udp_stats_in6);
Signature · 1 line
1.5.5.1
PATCH 7/16 mib: put udplite statistics on struct net
In reply to Pavel Emelyanov--- include/net/netns/mib.h | 1 + include/net/udp.h | 5 ++--- net/ipv4/af_inet.c | 11 ++++++----- net/ipv4/proc.c | 2 +- net/ipv4/udplite.c | 1 - 5 files changed, 10 insertions(+), 10 deletions(-)
include/net/netns/mib.h +1 -0
@@ -8,6 +8,7 @@ struct netns_mib { DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics); DEFINE_SNMP_STAT(struct linux_mib, net_statistics); DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); + DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); };#endif
include/net/udp.h +2 -3
@@ -151,17 +151,16 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname, DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */ -DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics); DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);/* * SNMP statistics for UDP and UDP-Lite */ #define UDP_INC_STATS_USER (net, field, is_udplite) do { \ - if (is_udplite) SNMP_INC_STATS_USER(udplite_statistics, field); \ + if (is_udplite) SNMP_INC_STATS_USER((net)->mib.udplite_statistics, field); \ else SNMP_INC_STATS_USER((net)->mib.udp_statistics, field); } while(0)#define UDP_INC_STATS_BH (net, field, is_udplite) do { \ - if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \ + if (is_udplite) SNMP_INC_STATS_BH((net)->mib.udplite_statistics, field); \ else SNMP_INC_STATS_BH((net)->mib.udp_statistics, field); } while(0)#define UDP6_INC_STATS_BH (net, field, is_udplite) do { (void)net; \
net/ipv4/af_inet.c +6 -5
@@ -1352,10 +1352,15 @@ static __net_init int ipv4_mib_init_net(struct net *net)if (snmp_mib_init ((void **)net->mib.udp_statistics,sizeof (struct udp_mib )) <0 ) goto err_udp_mib; +if (snmp_mib_init ((void **)net->mib.udplite_statistics, +sizeof (struct udp_mib )) <0 ) + goto err_udplite_mib;tcp_mib_init (net);return 0 ; +err_udplite_mib: +snmp_mib_free ((void **)net->mib.udp_statistics); err_udp_mib:snmp_mib_free ((void **)net->mib.net_statistics); err_net_mib:
@@ -1368,6 +1373,7 @@ err_tcp_mib: static __net_exit void ipv4_mib_exit_net(struct net *net) { +snmp_mib_free ((void **)net->mib.udplite_statistics);snmp_mib_free ((void **)net->mib.udp_statistics);snmp_mib_free ((void **)net->mib.net_statistics);snmp_mib_free ((void **)net->mib.ip_statistics);
@@ -1387,9 +1393,6 @@ static int __init init_ipv4_mibs(void)if (snmp_mib_init ((void **)icmpmsg_statistics,sizeof (struct icmpmsg_mib )) <0 ) goto err_icmpmsg_mib; -if (snmp_mib_init ((void **)udplite_statistics, -sizeof (struct udp_mib )) <0 ) - goto err_udplite_mib;if (register_pernet_subsys (&ipv4_mib_ops)) goto err_net;
@@ -1397,8 +1400,6 @@ static int __init init_ipv4_mibs(void)return 0 ; err_net: -snmp_mib_free ((void **)udplite_statistics); -err_udplite_mib:snmp_mib_free ((void **)icmpmsg_statistics); err_icmpmsg_mib:snmp_mib_free ((void **)icmp_statistics);
net/ipv4/proc.c +1 -1
@@ -385,7 +385,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)seq_puts (seq,"\nUdpLite:" );for (i =0 ; snmp4_udp_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)udplite_statistics, +snmp_fold_field ((void **)init_net.mib.udplite_statistics, snmp4_udp_list[i].entry));seq_putc (seq,'\n' );
net/ipv4/udplite.c +0 -1
@@ -11,7 +11,6 @@* 2 of the License, or (at your option) any later version. */ #include "udp_impl.h" -DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics) __read_mostly;struct hlist_head udplite_hash[UDP_HTABLE_SIZE ];
Signature · 1 line
1.5.5.1
PATCH 8/16 mib: put icmp statistics on struct net
In reply to Pavel Emelyanov--- include/net/icmp.h | 5 ++--- include/net/netns/mib.h | 1 + net/ipv4/af_inet.c | 11 ++++++----- net/ipv4/icmp.c | 2 -- net/ipv4/proc.c | 8 ++++---- 5 files changed, 13 insertions(+), 14 deletions(-)
include/net/icmp.h +2 -3
@@ -29,10 +29,9 @@ struct icmp_err { };extern struct icmp_err icmp_err_convert[]; -DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics); DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics); -#define ICMP_INC_STATS (net, field) SNMP_INC_STATS(icmp_statistics, field) -#define ICMP_INC_STATS_BH (net, field) SNMP_INC_STATS_BH(icmp_statistics, field) +#define ICMP_INC_STATS (net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field) +#define ICMP_INC_STATS_BH (net, field) SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field)#define ICMPMSGOUT_INC_STATS (net, field) SNMP_INC_STATS(icmpmsg_statistics, field+256)#define ICMPMSGIN_INC_STATS_BH (net, field) SNMP_INC_STATS_BH(icmpmsg_statistics, field)
include/net/netns/mib.h +1 -0
@@ -9,6 +9,7 @@ struct netns_mib { DEFINE_SNMP_STAT(struct linux_mib, net_statistics); DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); + DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); };#endif
net/ipv4/af_inet.c +6 -5
@@ -1355,10 +1355,15 @@ static __net_init int ipv4_mib_init_net(struct net *net)if (snmp_mib_init ((void **)net->mib.udplite_statistics,sizeof (struct udp_mib )) <0 ) goto err_udplite_mib; +if (snmp_mib_init ((void **)net->mib.icmp_statistics, +sizeof (struct icmp_mib )) <0 ) + goto err_icmp_mib;tcp_mib_init (net);return 0 ; +err_icmp_mib: +snmp_mib_free ((void **)net->mib.udplite_statistics); err_udplite_mib:snmp_mib_free ((void **)net->mib.udp_statistics); err_udp_mib:
@@ -1373,6 +1378,7 @@ err_tcp_mib: static __net_exit void ipv4_mib_exit_net(struct net *net) { +snmp_mib_free ((void **)net->mib.icmp_statistics);snmp_mib_free ((void **)net->mib.udplite_statistics);snmp_mib_free ((void **)net->mib.udp_statistics);snmp_mib_free ((void **)net->mib.net_statistics);
@@ -1387,9 +1393,6 @@ static __net_initdata struct pernet_operations ipv4_mib_ops = {static int __init init_ipv4_mibs (void ) { -if (snmp_mib_init ((void **)icmp_statistics, -sizeof (struct icmp_mib )) <0 ) - goto err_icmp_mib;if (snmp_mib_init ((void **)icmpmsg_statistics,sizeof (struct icmpmsg_mib )) <0 ) goto err_icmpmsg_mib;
@@ -1402,8 +1405,6 @@ static int __init init_ipv4_mibs(void) err_net:snmp_mib_free ((void **)icmpmsg_statistics); err_icmpmsg_mib: -snmp_mib_free ((void **)icmp_statistics); -err_icmp_mib:return -ENOMEM ; }
net/ipv4/icmp.c +0 -2
@@ -114,7 +114,6 @@ struct icmp_bxm {/* * Statistics */ -DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics) __read_mostly; DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics) __read_mostly;/* An array of errno for error messages from dest unreach. */
@@ -1213,5 +1212,4 @@ int __init icmp_init(void)EXPORT_SYMBOL (icmp_err_convert);EXPORT_SYMBOL (icmp_send); -EXPORT_SYMBOL (icmp_statistics);EXPORT_SYMBOL (xrlim_allow);
net/ipv4/proc.c +4 -4
@@ -311,15 +311,15 @@ static void icmp_put(struct seq_file *seq)for (i=0 ; icmpmibmap[i].name !=NULL ; i++)seq_printf (seq," Out%s" , icmpmibmap[i].name);seq_printf (seq,"\nIcmp: %lu %lu" , -snmp_fold_field ((void **) icmp_statistics,ICMP_MIB_INMSGS ), -snmp_fold_field ((void **) icmp_statistics,ICMP_MIB_INERRORS )); +snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_INMSGS ), +snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_INERRORS ));for (i=0 ; icmpmibmap[i].name !=NULL ; i++)seq_printf (seq," %lu" ,snmp_fold_field ((void **) icmpmsg_statistics, icmpmibmap[i].index));seq_printf (seq," %lu %lu" , -snmp_fold_field ((void **) icmp_statistics,ICMP_MIB_OUTMSGS ), -snmp_fold_field ((void **) icmp_statistics,ICMP_MIB_OUTERRORS )); +snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_OUTMSGS ), +snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_OUTERRORS ));for (i=0 ; icmpmibmap[i].name !=NULL ; i++) seq_printf(seq, " %lu", snmp_fold_field((void **) icmpmsg_statistics,
Signature · 1 line
1.5.5.1
PATCH 9/16 mib: put icmpmsg statistics on struct net
In reply to Pavel Emelyanov--- include/net/icmp.h | 5 ++--- include/net/netns/mib.h | 1 + net/ipv4/af_inet.c | 12 ++++++------ net/ipv4/icmp.c | 5 ----- net/ipv4/proc.c | 10 +++++----- 5 files changed, 14 insertions(+), 19 deletions(-)
include/net/icmp.h +2 -3
@@ -29,11 +29,10 @@ struct icmp_err { };extern struct icmp_err icmp_err_convert[]; -DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);#define ICMP_INC_STATS (net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field)#define ICMP_INC_STATS_BH (net, field) SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field) -#define ICMPMSGOUT_INC_STATS (net, field) SNMP_INC_STATS(icmpmsg_statistics, field+256) -#define ICMPMSGIN_INC_STATS_BH (net, field) SNMP_INC_STATS_BH(icmpmsg_statistics, field) +#define ICMPMSGOUT_INC_STATS (net, field) SNMP_INC_STATS((net)->mib.icmpmsg_statistics, field+256) +#define ICMPMSGIN_INC_STATS_BH (net, field) SNMP_INC_STATS_BH((net)->mib.icmpmsg_statistics, field)struct dst_entry ;struct net_proto_family ;
include/net/netns/mib.h +1 -0
@@ -10,6 +10,7 @@ struct netns_mib { DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); + DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics); };#endif
net/ipv4/af_inet.c +6 -6
@@ -1358,10 +1358,15 @@ static __net_init int ipv4_mib_init_net(struct net *net)if (snmp_mib_init ((void **)net->mib.icmp_statistics,sizeof (struct icmp_mib )) <0 ) goto err_icmp_mib; +if (snmp_mib_init ((void **)net->mib.icmpmsg_statistics, +sizeof (struct icmpmsg_mib )) <0 ) + goto err_icmpmsg_mib;tcp_mib_init (net);return 0 ; +err_icmpmsg_mib: +snmp_mib_free ((void **)net->mib.icmp_statistics); err_icmp_mib:snmp_mib_free ((void **)net->mib.udplite_statistics); err_udplite_mib:
@@ -1378,6 +1383,7 @@ err_tcp_mib: static __net_exit void ipv4_mib_exit_net(struct net *net) { +snmp_mib_free ((void **)net->mib.icmpmsg_statistics);snmp_mib_free ((void **)net->mib.icmp_statistics);snmp_mib_free ((void **)net->mib.udplite_statistics);snmp_mib_free ((void **)net->mib.udp_statistics);
@@ -1393,18 +1399,12 @@ static __net_initdata struct pernet_operations ipv4_mib_ops = {static int __init init_ipv4_mibs (void ) { -if (snmp_mib_init ((void **)icmpmsg_statistics, -sizeof (struct icmpmsg_mib )) <0 ) - goto err_icmpmsg_mib; -if (register_pernet_subsys (&ipv4_mib_ops)) goto err_net;return 0 ; err_net: -snmp_mib_free ((void **)icmpmsg_statistics); -err_icmpmsg_mib:return -ENOMEM ; }
net/ipv4/icmp.c +0 -5
@@ -111,11 +111,6 @@ struct icmp_bxm {unsigned char optbuf[40 ]; }; -/* -* Statistics -*/ -DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics) __read_mostly; -/* An array of errno for error messages from dest unreach. */ /* RFC 1122: 3.2.2.1 States that NET_UNREACH, HOST_UNREACH and SR_FAILED MUST be considered 'transient errs'. */
net/ipv4/proc.c +5 -5
@@ -270,7 +270,7 @@ static void icmpmsg_put(struct seq_file *seq) count =0 ;for (i =0 ; i <ICMPMSG_MIB_MAX ; i++) { -if (snmp_fold_field ((void **) icmpmsg_statistics, i)) +if (snmp_fold_field ((void **) init_net.mib.icmpmsg_statistics, i)) out[count++] = i;if (count <PERLINE )continue ;
@@ -282,7 +282,7 @@ static void icmpmsg_put(struct seq_file *seq)seq_printf (seq,"\nIcmpMsg: " );for (j =0 ; j <PERLINE ; ++j)seq_printf (seq," %lu" , -snmp_fold_field ((void **) icmpmsg_statistics, +snmp_fold_field ((void **) init_net.mib.icmpmsg_statistics, out[j]));seq_putc (seq,'\n' ); }
@@ -294,7 +294,7 @@ static void icmpmsg_put(struct seq_file *seq)seq_printf (seq,"\nIcmpMsg:" );for (j =0 ; j < count; ++j)seq_printf (seq," %lu" ,snmp_fold_field ((void **) - icmpmsg_statistics, out[j])); + init_net.mib.icmpmsg_statistics, out[j])); }#undef PERLINE
@@ -315,14 +315,14 @@ static void icmp_put(struct seq_file *seq) snmp_fold_field((void **) init_net.mib.icmp_statistics, ICMP_MIB_INERRORS));for (i=0 ; icmpmibmap[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **) icmpmsg_statistics, +snmp_fold_field ((void **) init_net.mib.icmpmsg_statistics, icmpmibmap[i].index));seq_printf (seq," %lu %lu" ,snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_OUTMSGS ),snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_OUTERRORS ));for (i=0 ; icmpmibmap[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **) icmpmsg_statistics, +snmp_fold_field ((void **) init_net.mib.icmpmsg_statistics, icmpmibmap[i].index |0x100 )); }
Signature · 1 line
1.5.5.1
PATCH 10/16 ipvs: clean the init_ipv4_mibs error paths
In reply to Pavel EmelyanovAfter moving all the stuff outside this function it looks a bit ugly - make it look better.
--- net/ipv4/af_inet.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
net/ipv4/af_inet.c +1 -7
@@ -1399,13 +1399,7 @@ static __net_initdata struct pernet_operations ipv4_mib_ops = {static int __init init_ipv4_mibs (void ) { -if (register_pernet_subsys (&ipv4_mib_ops)) - goto err_net; - -return 0 ; - -err_net: -return -ENOMEM ; +return register_pernet_subsys (&ipv4_mib_ops); }static int ipv4_proc_init (void );
Signature · 1 line
1.5.5.1
PATCH 11/16 proc: create /proc/net/netstat file in each net
In reply to Pavel EmelyanovNow all the shown in it statistics is netnsizated, time to show it in appropriate net.
The appropriate net init/exit ops already exist - they make the sockstat file per net - so just extend them.
--- net/ipv4/proc.c | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 38 insertions(+), 9 deletions(-)
net/ipv4/proc.c +38 -9
@@ -413,6 +413,7 @@ static const struct file_operations snmp_seq_fops = {static int netstat_seq_show (struct seq_file *seq,void *v) {int i; +struct net *net = seq->private;seq_puts (seq,"TcpExt:" );for (i =0 ; snmp4_net_list[i].name !=NULL ; i++)
@@ -421,7 +422,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v)seq_puts (seq,"\nTcpExt:" );for (i =0 ; snmp4_net_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)init_net.mib.net_statistics, +snmp_fold_field ((void **)net->mib.net_statistics, snmp4_net_list[i].entry));seq_puts (seq,"\nIpExt:" );
@@ -431,7 +432,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v)seq_puts (seq,"\nIpExt:" );for (i =0 ; snmp4_ipextstats_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)init_net.mib.ip_statistics, +snmp_fold_field ((void **)net->mib.ip_statistics, snmp4_ipextstats_list[i].entry));seq_putc (seq,'\n' );
@@ -440,7 +441,32 @@ static int netstat_seq_show(struct seq_file *seq, void *v)static int netstat_seq_open (struct inode *inode,struct file *file) { -return single_open (file, netstat_seq_show,NULL ); +int err; +struct net *net; + + err = -ENXIO ; + net =get_proc_net (inode); +if (net ==NULL ) + goto err_net; + + err =single_open (file, netstat_seq_show, net); +if (err <0 ) + goto err_open; + +return 0 ; + +err_open: +put_net (net); +err_net: +return err; +} + +static int netstat_seq_release (struct inode *inode,struct file *file) +{ +struct net *net = ((struct seq_file *)file->private_data)->private; + +put_net (net); +return single_release (inode, file); }static const struct file_operations netstat_seq_fops = {
@@ -448,18 +474,26 @@ static const struct file_operations netstat_seq_fops = { .open = netstat_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = single_release, + .release = netstat_seq_release, };static __net_init int ip_proc_init_net (struct net *net) {if (!proc_net_fops_create (net,"sockstat" ,S_IRUGO , &sockstat_seq_fops))return -ENOMEM ; +if (!proc_net_fops_create (net,"netstat" ,S_IRUGO , &netstat_seq_fops)) + goto out_netstat; +return 0 ; + +out_netstat: +proc_net_remove (net,"sockstat" ); +return -ENOMEM ; } static __net_exit void ip_proc_exit_net(struct net *net) { +proc_net_remove (net,"netstat" );proc_net_remove (net,"sockstat" ); }
@@ -475,16 +509,11 @@ int __init ip_misc_proc_init(void)if (register_pernet_subsys (&ip_proc_ops)) goto out_pernet; -if (!proc_net_fops_create (&init_net,"netstat" ,S_IRUGO , &netstat_seq_fops)) - goto out_netstat; -if (!proc_net_fops_create (&init_net,"snmp" ,S_IRUGO , &snmp_seq_fops)) goto out_snmp; out:return rc; out_snmp: -proc_net_remove (&init_net,"netstat" ); -out_netstat:unregister_pernet_subsys (&ip_proc_ops); out_pernet: rc = -ENOMEM ;
Signature · 1 line
1.5.5.1
PATCH 12/16 proc: create /proc/net/snmp file in each net
In reply to Pavel EmelyanovAll the statistics show in this file is also made per-net already.
--- net/ipv4/proc.c | 70 +++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 50 insertions(+), 20 deletions(-)
net/ipv4/proc.c +50 -20
@@ -266,11 +266,12 @@ static void icmpmsg_put(struct seq_file *seq)int j, i, count;static int out[PERLINE ]; +struct net *net = seq->private; count =0 ;for (i =0 ; i <ICMPMSG_MIB_MAX ; i++) { -if (snmp_fold_field ((void **) init_net.mib.icmpmsg_statistics, i)) +if (snmp_fold_field ((void **) net->mib.icmpmsg_statistics, i)) out[count++] = i;if (count <PERLINE )continue ;
@@ -282,7 +283,7 @@ static void icmpmsg_put(struct seq_file *seq)seq_printf (seq,"\nIcmpMsg: " );for (j =0 ; j <PERLINE ; ++j)seq_printf (seq," %lu" , -snmp_fold_field ((void **) init_net.mib.icmpmsg_statistics, +snmp_fold_field ((void **) net->mib.icmpmsg_statistics, out[j]));seq_putc (seq,'\n' ); }
@@ -294,7 +295,7 @@ static void icmpmsg_put(struct seq_file *seq)seq_printf (seq,"\nIcmpMsg:" );for (j =0 ; j < count; ++j)seq_printf (seq," %lu" ,snmp_fold_field ((void **) - init_net.mib.icmpmsg_statistics, out[j])); + net->mib.icmpmsg_statistics, out[j])); }#undef PERLINE
@@ -303,6 +304,7 @@ static void icmpmsg_put(struct seq_file *seq)static void icmp_put (struct seq_file *seq) {int i; +struct net *net = seq->private;seq_puts (seq,"\nIcmp: InMsgs InErrors" );for (i=0 ; icmpmibmap[i].name !=NULL ; i++)
@@ -311,18 +313,18 @@ static void icmp_put(struct seq_file *seq)for (i=0 ; icmpmibmap[i].name !=NULL ; i++)seq_printf (seq," Out%s" , icmpmibmap[i].name);seq_printf (seq,"\nIcmp: %lu %lu" , -snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_INMSGS ), -snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_INERRORS )); +snmp_fold_field ((void **) net->mib.icmp_statistics,ICMP_MIB_INMSGS ), +snmp_fold_field ((void **) net->mib.icmp_statistics,ICMP_MIB_INERRORS ));for (i=0 ; icmpmibmap[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **) init_net.mib.icmpmsg_statistics, +snmp_fold_field ((void **) net->mib.icmpmsg_statistics, icmpmibmap[i].index));seq_printf (seq," %lu %lu" , -snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_OUTMSGS ), -snmp_fold_field ((void **) init_net.mib.icmp_statistics,ICMP_MIB_OUTERRORS )); +snmp_fold_field ((void **) net->mib.icmp_statistics,ICMP_MIB_OUTMSGS ), +snmp_fold_field ((void **) net->mib.icmp_statistics,ICMP_MIB_OUTERRORS ));for (i=0 ; icmpmibmap[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **) init_net.mib.icmpmsg_statistics, +snmp_fold_field ((void **) net->mib.icmpmsg_statistics, icmpmibmap[i].index |0x100 )); }
@@ -332,6 +334,7 @@ static void icmp_put(struct seq_file *seq)static int snmp_seq_show (struct seq_file *seq,void *v) {int i; +struct net *net = seq->private;seq_puts (seq,"Ip: Forwarding DefaultTTL" );
@@ -344,7 +347,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)for (i =0 ; snmp4_ipstats_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)init_net.mib.ip_statistics, +snmp_fold_field ((void **)net->mib.ip_statistics, snmp4_ipstats_list[i].entry));icmp_put (seq);/* RFC 2011 compatibility */
@@ -359,11 +362,11 @@ static int snmp_seq_show(struct seq_file *seq, void *v)/* MaxConn field is signed, RFC 2012 */ if (snmp4_tcp_list[i].entry ==TCP_MIB_MAXCONN )seq_printf (seq," %ld" , -snmp_fold_field ((void **)init_net.mib.tcp_statistics, +snmp_fold_field ((void **)net->mib.tcp_statistics, snmp4_tcp_list[i].entry));else seq_printf (seq," %lu" , -snmp_fold_field ((void **)init_net.mib.tcp_statistics, +snmp_fold_field ((void **)net->mib.tcp_statistics, snmp4_tcp_list[i].entry)); }
@@ -374,7 +377,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)seq_puts (seq,"\nUdp:" );for (i =0 ; snmp4_udp_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)init_net.mib.udp_statistics, +snmp_fold_field ((void **)net->mib.udp_statistics, snmp4_udp_list[i].entry));/* the UDP and UDP-Lite MIBs are the same */
@@ -385,7 +388,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)seq_puts (seq,"\nUdpLite:" );for (i =0 ; snmp4_udp_list[i].name !=NULL ; i++)seq_printf (seq," %lu" , -snmp_fold_field ((void **)init_net.mib.udplite_statistics, +snmp_fold_field ((void **)net->mib.udplite_statistics, snmp4_udp_list[i].entry));seq_putc (seq,'\n' );
@@ -394,7 +397,32 @@ static int snmp_seq_show(struct seq_file *seq, void *v)static int snmp_seq_open (struct inode *inode,struct file *file) { -return single_open (file, snmp_seq_show,NULL ); +int err; +struct net *net; + + err = -ENXIO ; + net =get_proc_net (inode); +if (net ==NULL ) + goto err_net; + + err =single_open (file, snmp_seq_show, net); +if (err <0 ) + goto err_open; + +return 0 ; + +err_open: +put_net (net); +err_net: +return err; +} + +static int snmp_seq_release (struct inode *inode,struct file *file) +{ +struct net *net = ((struct seq_file *)file->private_data)->private; + +put_net (net); +return single_release (inode, file); }static const struct file_operations snmp_seq_fops = {
@@ -402,7 +430,7 @@ static const struct file_operations snmp_seq_fops = { .open = snmp_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = single_release, + .release = snmp_seq_release, };
@@ -483,9 +511,13 @@ static __net_init int ip_proc_init_net(struct net *net)return -ENOMEM ;if (!proc_net_fops_create (net,"netstat" ,S_IRUGO , &netstat_seq_fops)) goto out_netstat; +if (!proc_net_fops_create (net,"snmp" ,S_IRUGO , &snmp_seq_fops)) + goto out_snmp;return 0 ; +out_snmp: +proc_net_remove (net,"netstat" ); out_netstat:proc_net_remove (net,"sockstat" );return -ENOMEM ;
@@ -493,6 +525,7 @@ out_netstat: static __net_exit void ip_proc_exit_net(struct net *net) { +proc_net_remove (net,"snmp" );proc_net_remove (net,"netstat" );proc_net_remove (net,"sockstat" ); }
@@ -509,12 +542,9 @@ int __init ip_misc_proc_init(void)if (register_pernet_subsys (&ip_proc_ops)) goto out_pernet; -if (!proc_net_fops_create (&init_net,"snmp" ,S_IRUGO , &snmp_seq_fops)) - goto out_snmp; out:return rc; -out_snmp: -unregister_pernet_subsys (&ip_proc_ops); + out_pernet: rc = -ENOMEM ; goto out;
Signature · 1 line
1.5.5.1
PATCH 13/16 proc: show per-net ip_devconf.forwarding in /proc/net/snmp
In reply to Pavel EmelyanovThis one has become per-net long ago, but the appropriate file is per-net only now.
--- net/ipv4/proc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv4/proc.c +1 -1
@@ -342,7 +342,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)seq_printf (seq," %s" , snmp4_ipstats_list[i].name);seq_printf (seq,"\nIp: %d %d" , -IPV4_DEVCONF_ALL (&init_net,FORWARDING ) ?1 :2 , +IPV4_DEVCONF_ALL (net,FORWARDING ) ?1 :2 , sysctl_ip_default_ttl);for (i =0 ; snmp4_ipstats_list[i].name !=NULL ; i++)
Signature · 1 line
1.5.5.1
PATCH 14/16 proc: clean the ip_misc_proc_init and ip_proc_init_net error paths
In reply to Pavel EmelyanovAfter all this stuff is moved outside, this function can look better.
Besides, I tuned the error path in ip_proc_init_net to make it have only 2 exit points, not 3.
--- net/ipv4/proc.c | 15 +++------------ 1 files changed, 3 insertions(+), 12 deletions(-)
net/ipv4/proc.c +3 -12
@@ -508,7 +508,7 @@ static const struct file_operations netstat_seq_fops = {static __net_init int ip_proc_init_net (struct net *net) {if (!proc_net_fops_create (net,"sockstat" ,S_IRUGO , &sockstat_seq_fops)) -return -ENOMEM ; + goto out_sockstat;if (!proc_net_fops_create (net,"netstat" ,S_IRUGO , &netstat_seq_fops)) goto out_netstat;if (!proc_net_fops_create (net,"snmp" ,S_IRUGO , &snmp_seq_fops))
@@ -520,6 +520,7 @@ out_snmp:proc_net_remove (net,"netstat" ); out_netstat:proc_net_remove (net,"sockstat" ); +out_sockstat:return -ENOMEM ; }
@@ -537,16 +538,6 @@ static __net_initdata struct pernet_operations ip_proc_ops = {int __init ip_misc_proc_init (void ) { -int rc =0 ; - -if (register_pernet_subsys (&ip_proc_ops)) - goto out_pernet; - -out: -return rc; - -out_pernet: - rc = -ENOMEM ; - goto out; +return register_pernet_subsys (&ip_proc_ops); }
Signature · 1 line
1.5.5.1
PATCH 15/16 proc: consolidate per-net single_open callers
In reply to Pavel EmelyanovThere are already 7 of them - time to kill some duplicate code.
--- fs/proc/proc_net.c | 24 +++++++++++++++++ include/linux/seq_file_net.h | 2 + net/ipv4/fib_trie.c | 13 +--------- net/ipv4/proc.c | 57 ++--------------------------------------- net/ipv6/proc.c | 19 +------------- net/ipv6/route.c | 26 +----------------- 6 files changed, 33 insertions(+), 108 deletions(-)
fs/proc/proc_net.c +24 -0
@@ -51,6 +51,30 @@ int seq_open_net(struct inode *ino, struct file *f, }EXPORT_SYMBOL_GPL (seq_open_net); +int single_open_net (struct inode *inode,struct file *file, +int (*show)(struct seq_file *,void *)) +{ +int err; +struct net *net; + + err = -ENXIO ; + net =get_proc_net (inode); +if (net ==NULL ) + goto err_net; + + err =single_open (file, show, net); +if (err <0 ) + goto err_open; + +return 0 ; + +err_open: +put_net (net); +err_net: +return err; +} +EXPORT_SYMBOL_GPL (single_open_net); +int seq_release_net (struct inode *ino,struct file *f) {struct seq_file *seq;
include/linux/seq_file_net.h +2 -0
@@ -14,6 +14,8 @@ struct seq_net_private {int seq_open_net (struct inode *,struct file *,const struct seq_operations *,int ); +int single_open_net (struct inode *,struct file *file, +int (*show)(struct seq_file *,void *));int seq_release_net (struct inode *,struct file *);static inline struct net *seq_file_net (struct seq_file *seq) {
net/ipv4/fib_trie.c +1 -12
@@ -2251,18 +2251,7 @@ static int fib_triestat_seq_show(struct seq_file *seq, void *v)static int fib_triestat_seq_open (struct inode *inode,struct file *file) { -int err; -struct net *net; - - net =get_proc_net (inode); -if (net ==NULL ) -return -ENXIO ; - err =single_open (file, fib_triestat_seq_show, net); -if (err <0 ) { -put_net (net); -return err; - } -return 0 ; +return single_open_net (inode, file, fib_triestat_seq_show); }static int fib_triestat_seq_release (struct inode *ino,struct file *f)
net/ipv4/proc.c +3 -54
75 lines not on this page · raw message
net/ipv6/proc.c +1 -18
@@ -183,24 +183,7 @@ static int snmp6_seq_show(struct seq_file *seq, void *v)static int sockstat6_seq_open (struct inode *inode,struct file *file) { -int err; -struct net *net; - - err = -ENXIO ; - net =get_proc_net (inode); -if (net ==NULL ) - goto err_net; - - err =single_open (file, sockstat6_seq_show, net); -if (err <0 ) - goto err_open; - -return 0 ; - -err_open: -put_net (net); -err_net: -return err; +return single_open_net (inode, file, sockstat6_seq_show); }static int sockstat6_seq_release (struct inode *inode,struct file *file)
net/ipv6/route.c +2 -24
@@ -2416,18 +2416,7 @@ static int ipv6_route_show(struct seq_file *m, void *v)static int ipv6_route_open (struct inode *inode,struct file *file) { -int err; -struct net *net =get_proc_net (inode); -if (!net) -return -ENXIO ; - - err =single_open (file, ipv6_route_show, net); -if (err <0 ) { -put_net (net); -return err; - } - -return 0 ; +return single_open_net (inode, file, ipv6_route_show); }static int ipv6_route_release (struct inode *inode,struct file *file)
@@ -2463,18 +2452,7 @@ static int rt6_stats_seq_show(struct seq_file *seq, void *v)static int rt6_stats_seq_open (struct inode *inode,struct file *file) { -int err; -struct net *net =get_proc_net (inode); -if (!net) -return -ENXIO ; - - err =single_open (file, rt6_stats_seq_show, net); -if (err <0 ) { -put_net (net); -return err; - } - -return 0 ; +return single_open_net (inode, file, rt6_stats_seq_show); }static int rt6_stats_seq_release (struct inode *inode,struct file *file)
Signature · 1 line
1.5.5.1
PATCH 16/16 proc: consolidate per-net single-release callers
In reply to Pavel EmelyanovThey are symmetrical to single_open ones :)
--- fs/proc/proc_net.c | 8 ++++++++ include/linux/seq_file_net.h | 1 + net/ipv4/fib_trie.c | 9 +-------- net/ipv4/proc.c | 30 +++--------------------------- net/ipv6/proc.c | 10 +--------- net/ipv6/route.c | 20 ++------------------ 6 files changed, 16 insertions(+), 62 deletions(-)
fs/proc/proc_net.c +8 -0
@@ -87,6 +87,14 @@ int seq_release_net(struct inode *ino, struct file *f) }EXPORT_SYMBOL_GPL (seq_release_net); +int single_release_net (struct inode *ino,struct file *f) +{ +struct seq_file *seq = f->private_data; +put_net (seq->private); +return single_release (ino, f); +} +EXPORT_SYMBOL_GPL (single_release_net); +static struct net *get_proc_task_net (struct inode *dir) {struct task_struct *task;
include/linux/seq_file_net.h +1 -0
@@ -17,6 +17,7 @@ int seq_open_net(struct inode *, struct file *,int single_open_net (struct inode *,struct file *file,int (*show)(struct seq_file *,void *));int seq_release_net (struct inode *,struct file *); +int single_release_net (struct inode *,struct file *);static inline struct net *seq_file_net (struct seq_file *seq) {#ifdef CONFIG_NET_NS
net/ipv4/fib_trie.c +1 -8
@@ -2254,19 +2254,12 @@ static int fib_triestat_seq_open(struct inode *inode, struct file *file)return single_open_net (inode, file, fib_triestat_seq_show); } -static int fib_triestat_seq_release (struct inode *ino,struct file *f) -{ -struct seq_file *seq = f->private_data; -put_net (seq->private); -return single_release (ino, f); -} -static const struct file_operations fib_triestat_fops = { .owner =THIS_MODULE , .open = fib_triestat_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = fib_triestat_seq_release, + .release = single_release_net, };static struct node *fib_trie_get_idx (struct seq_file *seq,loff_t pos)
net/ipv4/proc.c +3 -27
@@ -74,20 +74,12 @@ static int sockstat_seq_open(struct inode *inode, struct file *file)return single_open_net (inode, file, sockstat_seq_show); } -static int sockstat_seq_release (struct inode *inode,struct file *file) -{ -struct net *net = ((struct seq_file *)file->private_data)->private; - -put_net (net); -return single_release (inode, file); -} -static const struct file_operations sockstat_seq_fops = { .owner =THIS_MODULE , .open = sockstat_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = sockstat_seq_release, + .release = single_release_net, };/* snmp items */
@@ -383,20 +375,12 @@ static int snmp_seq_open(struct inode *inode, struct file *file)return single_open_net (inode, file, snmp_seq_show); } -static int snmp_seq_release (struct inode *inode,struct file *file) -{ -struct net *net = ((struct seq_file *)file->private_data)->private; - -put_net (net); -return single_release (inode, file); -} -static const struct file_operations snmp_seq_fops = { .owner =THIS_MODULE , .open = snmp_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = snmp_seq_release, + .release = single_release_net, };
@@ -438,20 +422,12 @@ static int netstat_seq_open(struct inode *inode, struct file *file)return single_open_net (inode, file, netstat_seq_show); } -static int netstat_seq_release (struct inode *inode,struct file *file) -{ -struct net *net = ((struct seq_file *)file->private_data)->private; - -put_net (net); -return single_release (inode, file); -} -static const struct file_operations netstat_seq_fops = { .owner =THIS_MODULE , .open = netstat_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = netstat_seq_release, + .release = single_release_net, };static __net_init int ip_proc_init_net (struct net *net)
net/ipv6/proc.c +1 -9
@@ -186,20 +186,12 @@ static int sockstat6_seq_open(struct inode *inode, struct file *file)return single_open_net (inode, file, sockstat6_seq_show); } -static int sockstat6_seq_release (struct inode *inode,struct file *file) -{ -struct net *net = ((struct seq_file *)file->private_data)->private; - -put_net (net); -return single_release (inode, file); -} -static const struct file_operations sockstat6_seq_fops = { .owner =THIS_MODULE , .open = sockstat6_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = sockstat6_seq_release, + .release = single_release_net, };static int snmp6_seq_open (struct inode *inode,struct file *file)
net/ipv6/route.c +2 -18
@@ -2419,20 +2419,12 @@ static int ipv6_route_open(struct inode *inode, struct file *file)return single_open_net (inode, file, ipv6_route_show); } -static int ipv6_route_release (struct inode *inode,struct file *file) -{ -struct seq_file *seq = file->private_data; -struct net *net = seq->private; -put_net (net); -return single_release (inode, file); -} -static const struct file_operations ipv6_route_proc_fops = { .owner =THIS_MODULE , .open = ipv6_route_open, .read = seq_read, .llseek = seq_lseek, - .release = ipv6_route_release, + .release = single_release_net, };static int rt6_stats_seq_show (struct seq_file *seq,void *v)
@@ -2455,20 +2447,12 @@ static int rt6_stats_seq_open(struct inode *inode, struct file *file) return single_open_net(inode, file, rt6_stats_seq_show); } -static int rt6_stats_seq_release (struct inode *inode,struct file *file) -{ -struct seq_file *seq = file->private_data; -struct net *net = (struct net *)seq->private; -put_net (net); -return single_release (inode, file); -} -static const struct file_operations rt6_stats_seq_fops = { .owner =THIS_MODULE , .open = rt6_stats_seq_open, .read = seq_read, .llseek = seq_lseek, - .release = rt6_stats_seq_release, + .release = single_release_net, };#endif /* CONFIG_PROC_FS */
Signature · 1 line
1.5.5.1
David Miller
maintainerFrom: Pavel Emelyanov <[email protected]>
Date: Thu, 17 Jul 2008 17:19:09 +0400
Quoted 8 lines
This is the notorious "finalizing set" - after this all the ipv4 stats are isolated from each other. The ipv6, dccp and sctp I touched with previous sets deserve special handling and will be done in 2.6.28
No *new* stuff for 2.6.27 from me, thank you Dave for your patience :)
Signed-off-by Pavel Emelyanov <[email protected]>
All applied, thanks Pavel.
I keep hearing noises that some day sysfs+ns will work, is that something we'll see in 2.6.27 possibly? That would help my own build validation and testing of changes.
Quoted 8 lines · David Miller
From: Pavel Emelyanov <[email protected]>
Date: Thu, 17 Jul 2008 17:19:09 +0400Quoted 5 lines
This is the notorious "finalizing set" - after this all the ipv4 stats are isolated from each other. The ipv6, dccp and sctp I touched with previous sets deserve special handling and will be done in 2.6.28
Quoted 8 lines
Quoted 3 lines
No *new* stuff for 2.6.27 from me, thank you Dave for your patience :)
Signed-off-by Pavel Emelyanov <[email protected]>All applied, thanks Pavel.
I keep hearing noises that some day sysfs+ns will work, is that something we'll see in 2.6.27 possibly?
Unfortunately not in 2.6.27 :( Eric send sysfs-for-namespaces patchset 2 or 3 weeks ago, but Greg was going for vacation that time.
Quoted 7 lines
That would help my own build validation and testing of changes.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 7 lines · Pavel Emelyanov
Quoted 3 lines · David Miller
I keep hearing noises that some day sysfs+ns will work, is that something we'll see in 2.6.27 possibly?
Unfortunately not in 2.6.27 :( Eric send sysfs-for-namespaces patchset 2 or 3 weeks ago, but Greg was going for vacation that time.
Yes the timing has been bad all around. But finally Tejun and I agree on a patchset that will work, and Greg doesn't have a problem putting it in his tree for post 2.6.27.
Quoted 1 line
Quoted 1 line
That would help my own build validation and testing of changes.
It currently looks like these changes will show up in the first round of linux-next. My apologies for the delay. Untangling the knot that is sysfs is a challenge.
Eric