diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-12-06 00:13:48 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:56:35 -0500 |
commit | 78c686e9faff05f1194e892d5b1273ce24021ff6 (patch) | |
tree | 4ac7916385f7f88657bafd1cf30abbdfc00457b7 /net | |
parent | f4d900a2cae94256f56be7769734100c7054bf00 (diff) |
[IPV4] ROUTE: Collect proc-related functions together
The net/ipv4/route.c file declares some entries for proc
to dump some routing info. The reading functions are
scattered over this file - collect them together.
Besides, remove a useless IP_RT_ACCT_CPU macro.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/route.c | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index fcae074b7ae4..9736f6895628 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -481,6 +481,45 @@ static const struct file_operations rt_cpu_seq_fops = { | |||
481 | .release = seq_release, | 481 | .release = seq_release, |
482 | }; | 482 | }; |
483 | 483 | ||
484 | #ifdef CONFIG_NET_CLS_ROUTE | ||
485 | static int ip_rt_acct_read(char *buffer, char **start, off_t offset, | ||
486 | int length, int *eof, void *data) | ||
487 | { | ||
488 | unsigned int i; | ||
489 | |||
490 | if ((offset & 3) || (length & 3)) | ||
491 | return -EIO; | ||
492 | |||
493 | if (offset >= sizeof(struct ip_rt_acct) * 256) { | ||
494 | *eof = 1; | ||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | if (offset + length >= sizeof(struct ip_rt_acct) * 256) { | ||
499 | length = sizeof(struct ip_rt_acct) * 256 - offset; | ||
500 | *eof = 1; | ||
501 | } | ||
502 | |||
503 | offset /= sizeof(u32); | ||
504 | |||
505 | if (length > 0) { | ||
506 | u32 *dst = (u32 *) buffer; | ||
507 | |||
508 | *start = buffer; | ||
509 | memset(dst, 0, length); | ||
510 | |||
511 | for_each_possible_cpu(i) { | ||
512 | unsigned int j; | ||
513 | u32 *src; | ||
514 | |||
515 | src = ((u32 *) per_cpu_ptr(ip_rt_acct, i)) + offset; | ||
516 | for (j = 0; j < length/4; j++) | ||
517 | dst[j] += src[j]; | ||
518 | } | ||
519 | } | ||
520 | return length; | ||
521 | } | ||
522 | #endif | ||
484 | #endif /* CONFIG_PROC_FS */ | 523 | #endif /* CONFIG_PROC_FS */ |
485 | 524 | ||
486 | static __inline__ void rt_free(struct rtable *rt) | 525 | static __inline__ void rt_free(struct rtable *rt) |
@@ -2898,48 +2937,6 @@ ctl_table ipv4_route_table[] = { | |||
2898 | 2937 | ||
2899 | #ifdef CONFIG_NET_CLS_ROUTE | 2938 | #ifdef CONFIG_NET_CLS_ROUTE |
2900 | struct ip_rt_acct *ip_rt_acct __read_mostly; | 2939 | struct ip_rt_acct *ip_rt_acct __read_mostly; |
2901 | |||
2902 | /* IP route accounting ptr for this logical cpu number. */ | ||
2903 | #define IP_RT_ACCT_CPU(cpu) (per_cpu_ptr(ip_rt_acct, cpu)) | ||
2904 | |||
2905 | #ifdef CONFIG_PROC_FS | ||
2906 | static int ip_rt_acct_read(char *buffer, char **start, off_t offset, | ||
2907 | int length, int *eof, void *data) | ||
2908 | { | ||
2909 | unsigned int i; | ||
2910 | |||
2911 | if ((offset & 3) || (length & 3)) | ||
2912 | return -EIO; | ||
2913 | |||
2914 | if (offset >= sizeof(struct ip_rt_acct) * 256) { | ||
2915 | *eof = 1; | ||
2916 | return 0; | ||
2917 | } | ||
2918 | |||
2919 | if (offset + length >= sizeof(struct ip_rt_acct) * 256) { | ||
2920 | length = sizeof(struct ip_rt_acct) * 256 - offset; | ||
2921 | *eof = 1; | ||
2922 | } | ||
2923 | |||
2924 | offset /= sizeof(u32); | ||
2925 | |||
2926 | if (length > 0) { | ||
2927 | u32 *dst = (u32 *) buffer; | ||
2928 | |||
2929 | *start = buffer; | ||
2930 | memset(dst, 0, length); | ||
2931 | |||
2932 | for_each_possible_cpu(i) { | ||
2933 | unsigned int j; | ||
2934 | u32 *src = ((u32 *) IP_RT_ACCT_CPU(i)) + offset; | ||
2935 | |||
2936 | for (j = 0; j < length/4; j++) | ||
2937 | dst[j] += src[j]; | ||
2938 | } | ||
2939 | } | ||
2940 | return length; | ||
2941 | } | ||
2942 | #endif /* CONFIG_PROC_FS */ | ||
2943 | #endif /* CONFIG_NET_CLS_ROUTE */ | 2940 | #endif /* CONFIG_NET_CLS_ROUTE */ |
2944 | 2941 | ||
2945 | static __initdata unsigned long rhash_entries; | 2942 | static __initdata unsigned long rhash_entries; |