diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-08-06 04:47:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-15 02:30:36 -0400 |
commit | b01a24078fa3fc4f0f447d1306ce5adc495ead86 (patch) | |
tree | 6949f590c81e2c1ce193b1bdaec68a60e9842879 /net/sctp/protocol.c | |
parent | bb2db45b5495455ec7580315029184550709f4a2 (diff) |
sctp: Make the mib per network namespace
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Vlad Yasevich <vyasevich@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/protocol.c')
-rw-r--r-- | net/sctp/protocol.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 059c914c09f2..d58db315db85 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -69,7 +69,6 @@ | |||
69 | 69 | ||
70 | /* Global data structures. */ | 70 | /* Global data structures. */ |
71 | struct sctp_globals sctp_globals __read_mostly; | 71 | struct sctp_globals sctp_globals __read_mostly; |
72 | DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics) __read_mostly; | ||
73 | 72 | ||
74 | struct idr sctp_assocs_id; | 73 | struct idr sctp_assocs_id; |
75 | DEFINE_SPINLOCK(sctp_assocs_id_lock); | 74 | DEFINE_SPINLOCK(sctp_assocs_id_lock); |
@@ -961,7 +960,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb, | |||
961 | inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? | 960 | inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? |
962 | IP_PMTUDISC_DO : IP_PMTUDISC_DONT; | 961 | IP_PMTUDISC_DO : IP_PMTUDISC_DONT; |
963 | 962 | ||
964 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); | 963 | SCTP_INC_STATS(sock_net(&inet->sk), SCTP_MIB_OUTSCTPPACKS); |
965 | return ip_queue_xmit(skb, &transport->fl); | 964 | return ip_queue_xmit(skb, &transport->fl); |
966 | } | 965 | } |
967 | 966 | ||
@@ -1102,16 +1101,16 @@ int sctp_register_pf(struct sctp_pf *pf, sa_family_t family) | |||
1102 | return 1; | 1101 | return 1; |
1103 | } | 1102 | } |
1104 | 1103 | ||
1105 | static inline int init_sctp_mibs(void) | 1104 | static inline int init_sctp_mibs(struct net *net) |
1106 | { | 1105 | { |
1107 | return snmp_mib_init((void __percpu **)sctp_statistics, | 1106 | return snmp_mib_init((void __percpu **)net->sctp.sctp_statistics, |
1108 | sizeof(struct sctp_mib), | 1107 | sizeof(struct sctp_mib), |
1109 | __alignof__(struct sctp_mib)); | 1108 | __alignof__(struct sctp_mib)); |
1110 | } | 1109 | } |
1111 | 1110 | ||
1112 | static inline void cleanup_sctp_mibs(void) | 1111 | static inline void cleanup_sctp_mibs(struct net *net) |
1113 | { | 1112 | { |
1114 | snmp_mib_free((void __percpu **)sctp_statistics); | 1113 | snmp_mib_free((void __percpu **)net->sctp.sctp_statistics); |
1115 | } | 1114 | } |
1116 | 1115 | ||
1117 | static void sctp_v4_pf_init(void) | 1116 | static void sctp_v4_pf_init(void) |
@@ -1170,6 +1169,11 @@ static int sctp_net_init(struct net *net) | |||
1170 | { | 1169 | { |
1171 | int status; | 1170 | int status; |
1172 | 1171 | ||
1172 | /* Allocate and initialise sctp mibs. */ | ||
1173 | status = init_sctp_mibs(net); | ||
1174 | if (status) | ||
1175 | goto err_init_mibs; | ||
1176 | |||
1173 | /* Initialize proc fs directory. */ | 1177 | /* Initialize proc fs directory. */ |
1174 | status = sctp_proc_init(net); | 1178 | status = sctp_proc_init(net); |
1175 | if (status) | 1179 | if (status) |
@@ -1202,6 +1206,8 @@ err_ctl_sock_init: | |||
1202 | sctp_dbg_objcnt_exit(net); | 1206 | sctp_dbg_objcnt_exit(net); |
1203 | sctp_proc_exit(net); | 1207 | sctp_proc_exit(net); |
1204 | err_init_proc: | 1208 | err_init_proc: |
1209 | cleanup_sctp_mibs(net); | ||
1210 | err_init_mibs: | ||
1205 | return status; | 1211 | return status; |
1206 | } | 1212 | } |
1207 | 1213 | ||
@@ -1217,6 +1223,7 @@ static void sctp_net_exit(struct net *net) | |||
1217 | sctp_dbg_objcnt_exit(net); | 1223 | sctp_dbg_objcnt_exit(net); |
1218 | 1224 | ||
1219 | sctp_proc_exit(net); | 1225 | sctp_proc_exit(net); |
1226 | cleanup_sctp_mibs(net); | ||
1220 | } | 1227 | } |
1221 | 1228 | ||
1222 | static struct pernet_operations sctp_net_ops = { | 1229 | static struct pernet_operations sctp_net_ops = { |
@@ -1254,11 +1261,6 @@ SCTP_STATIC __init int sctp_init(void) | |||
1254 | if (!sctp_chunk_cachep) | 1261 | if (!sctp_chunk_cachep) |
1255 | goto err_chunk_cachep; | 1262 | goto err_chunk_cachep; |
1256 | 1263 | ||
1257 | /* Allocate and initialise sctp mibs. */ | ||
1258 | status = init_sctp_mibs(); | ||
1259 | if (status) | ||
1260 | goto err_init_mibs; | ||
1261 | |||
1262 | status = percpu_counter_init(&sctp_sockets_allocated, 0); | 1264 | status = percpu_counter_init(&sctp_sockets_allocated, 0); |
1263 | if (status) | 1265 | if (status) |
1264 | goto err_percpu_counter_init; | 1266 | goto err_percpu_counter_init; |
@@ -1474,8 +1476,6 @@ err_ehash_alloc: | |||
1474 | err_ahash_alloc: | 1476 | err_ahash_alloc: |
1475 | percpu_counter_destroy(&sctp_sockets_allocated); | 1477 | percpu_counter_destroy(&sctp_sockets_allocated); |
1476 | err_percpu_counter_init: | 1478 | err_percpu_counter_init: |
1477 | cleanup_sctp_mibs(); | ||
1478 | err_init_mibs: | ||
1479 | kmem_cache_destroy(sctp_chunk_cachep); | 1479 | kmem_cache_destroy(sctp_chunk_cachep); |
1480 | err_chunk_cachep: | 1480 | err_chunk_cachep: |
1481 | kmem_cache_destroy(sctp_bucket_cachep); | 1481 | kmem_cache_destroy(sctp_bucket_cachep); |
@@ -1514,7 +1514,6 @@ SCTP_STATIC __exit void sctp_exit(void) | |||
1514 | sizeof(struct sctp_bind_hashbucket))); | 1514 | sizeof(struct sctp_bind_hashbucket))); |
1515 | 1515 | ||
1516 | percpu_counter_destroy(&sctp_sockets_allocated); | 1516 | percpu_counter_destroy(&sctp_sockets_allocated); |
1517 | cleanup_sctp_mibs(); | ||
1518 | 1517 | ||
1519 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ | 1518 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ |
1520 | 1519 | ||