aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/net/ip_vs.h51
-rw-r--r--include/net/netns/ip_vs.h4
2 files changed, 52 insertions, 3 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 4265b5e00c9..605d5db81a3 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -90,6 +90,18 @@ static inline struct net *skb_sknet(struct sk_buff *skb)
90 return &init_net; 90 return &init_net;
91#endif 91#endif
92} 92}
93/*
94 * This one needed for single_open_net since net is stored directly in
95 * private not as a struct i.e. seq_file_net cant be used.
96 */
97static inline struct net *seq_file_single_net(struct seq_file *seq)
98{
99#ifdef CONFIG_NET_NS
100 return (struct net *)seq->private;
101#else
102 return &init_net;
103#endif
104}
93 105
94/* Connections' size value needed by ip_vs_ctl.c */ 106/* Connections' size value needed by ip_vs_ctl.c */
95extern int ip_vs_conn_tab_size; 107extern int ip_vs_conn_tab_size;
@@ -320,6 +332,23 @@ struct ip_vs_seq {
320 before last resized pkt */ 332 before last resized pkt */
321}; 333};
322 334
335/*
336 * counters per cpu
337 */
338struct ip_vs_counters {
339 __u32 conns; /* connections scheduled */
340 __u32 inpkts; /* incoming packets */
341 __u32 outpkts; /* outgoing packets */
342 __u64 inbytes; /* incoming bytes */
343 __u64 outbytes; /* outgoing bytes */
344};
345/*
346 * Stats per cpu
347 */
348struct ip_vs_cpu_stats {
349 struct ip_vs_counters ustats;
350 struct u64_stats_sync syncp;
351};
323 352
324/* 353/*
325 * IPVS statistics objects 354 * IPVS statistics objects
@@ -341,12 +370,28 @@ struct ip_vs_estimator {
341}; 370};
342 371
343struct ip_vs_stats { 372struct ip_vs_stats {
344 struct ip_vs_stats_user ustats; /* statistics */ 373 struct ip_vs_stats_user ustats; /* statistics */
345 struct ip_vs_estimator est; /* estimator */ 374 struct ip_vs_estimator est; /* estimator */
346 375 struct ip_vs_cpu_stats *cpustats; /* per cpu counters */
347 spinlock_t lock; /* spin lock */ 376 spinlock_t lock; /* spin lock */
348}; 377};
349 378
379/*
380 * Helper Macros for per cpu
381 * ipvs->tot_stats->ustats.count
382 */
383#define IPVS_STAT_INC(ipvs, count) \
384 __this_cpu_inc((ipvs)->ustats->count)
385
386#define IPVS_STAT_ADD(ipvs, count, value) \
387 do {\
388 write_seqcount_begin(per_cpu_ptr((ipvs)->ustats_seq, \
389 raw_smp_processor_id())); \
390 __this_cpu_add((ipvs)->ustats->count, value); \
391 write_seqcount_end(per_cpu_ptr((ipvs)->ustats_seq, \
392 raw_smp_processor_id())); \
393 } while (0)
394
350struct dst_entry; 395struct dst_entry;
351struct iphdr; 396struct iphdr;
352struct ip_vs_conn; 397struct ip_vs_conn;
diff --git a/include/net/netns/ip_vs.h b/include/net/netns/ip_vs.h
index aba78f3c834..bd1dad87217 100644
--- a/include/net/netns/ip_vs.h
+++ b/include/net/netns/ip_vs.h
@@ -61,6 +61,10 @@ struct netns_ipvs {
61 struct list_head sctp_apps[SCTP_APP_TAB_SIZE]; 61 struct list_head sctp_apps[SCTP_APP_TAB_SIZE];
62 spinlock_t sctp_app_lock; 62 spinlock_t sctp_app_lock;
63#endif 63#endif
64 /* ip_vs_ctl */
65 struct ip_vs_stats *tot_stats; /* Statistics & est. */
66 struct ip_vs_cpu_stats __percpu *cpustats; /* Stats per cpu */
67 seqcount_t *ustats_seq; /* u64 read retry */
64 68
65 /* ip_vs_lblc */ 69 /* ip_vs_lblc */
66 int sysctl_lblc_expiration; 70 int sysctl_lblc_expiration;