diff options
Diffstat (limited to 'include/net/ip_vs.h')
-rw-r--r-- | include/net/ip_vs.h | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 4265b5e00c94..605d5db81a39 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 | */ | ||
97 | static 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 */ |
95 | extern int ip_vs_conn_tab_size; | 107 | extern 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 | */ | ||
338 | struct 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 | */ | ||
348 | struct 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 | ||
343 | struct ip_vs_stats { | 372 | struct 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 | |||
350 | struct dst_entry; | 395 | struct dst_entry; |
351 | struct iphdr; | 396 | struct iphdr; |
352 | struct ip_vs_conn; | 397 | struct ip_vs_conn; |