diff options
-rw-r--r-- | net/ipv4/ip_input.c | 2 | ||||
-rw-r--r-- | net/ipv4/route.c | 15 |
2 files changed, 4 insertions, 13 deletions
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c index 5b8a7603e606..4068e178d747 100644 --- a/net/ipv4/ip_input.c +++ b/net/ipv4/ip_input.c | |||
@@ -347,7 +347,7 @@ static int ip_rcv_finish(struct sk_buff *skb) | |||
347 | 347 | ||
348 | #ifdef CONFIG_NET_CLS_ROUTE | 348 | #ifdef CONFIG_NET_CLS_ROUTE |
349 | if (unlikely(skb->dst->tclassid)) { | 349 | if (unlikely(skb->dst->tclassid)) { |
350 | struct ip_rt_acct *st = ip_rt_acct + 256*smp_processor_id(); | 350 | struct ip_rt_acct *st = per_cpu_ptr(ip_rt_acct, smp_processor_id()); |
351 | u32 idx = skb->dst->tclassid; | 351 | u32 idx = skb->dst->tclassid; |
352 | st[idx&0xFF].o_packets++; | 352 | st[idx&0xFF].o_packets++; |
353 | st[idx&0xFF].o_bytes+=skb->len; | 353 | st[idx&0xFF].o_bytes+=skb->len; |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 94ef788a2ac6..a21021bf1409 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2858,12 +2858,10 @@ ctl_table ipv4_route_table[] = { | |||
2858 | #endif | 2858 | #endif |
2859 | 2859 | ||
2860 | #ifdef CONFIG_NET_CLS_ROUTE | 2860 | #ifdef CONFIG_NET_CLS_ROUTE |
2861 | struct ip_rt_acct *ip_rt_acct; | 2861 | struct ip_rt_acct *ip_rt_acct __read_mostly; |
2862 | |||
2863 | /* This code sucks. But you should have seen it before! --RR */ | ||
2864 | 2862 | ||
2865 | /* IP route accounting ptr for this logical cpu number. */ | 2863 | /* IP route accounting ptr for this logical cpu number. */ |
2866 | #define IP_RT_ACCT_CPU(i) (ip_rt_acct + i * 256) | 2864 | #define IP_RT_ACCT_CPU(cpu) (per_cpu_ptr(ip_rt_acct, cpu)) |
2867 | 2865 | ||
2868 | #ifdef CONFIG_PROC_FS | 2866 | #ifdef CONFIG_PROC_FS |
2869 | static int ip_rt_acct_read(char *buffer, char **start, off_t offset, | 2867 | static int ip_rt_acct_read(char *buffer, char **start, off_t offset, |
@@ -2923,16 +2921,9 @@ int __init ip_rt_init(void) | |||
2923 | (jiffies ^ (jiffies >> 7))); | 2921 | (jiffies ^ (jiffies >> 7))); |
2924 | 2922 | ||
2925 | #ifdef CONFIG_NET_CLS_ROUTE | 2923 | #ifdef CONFIG_NET_CLS_ROUTE |
2926 | { | 2924 | ip_rt_acct = __alloc_percpu(256 * sizeof(struct ip_rt_acct)); |
2927 | int order; | ||
2928 | for (order = 0; | ||
2929 | (PAGE_SIZE << order) < 256 * sizeof(struct ip_rt_acct) * NR_CPUS; order++) | ||
2930 | /* NOTHING */; | ||
2931 | ip_rt_acct = (struct ip_rt_acct *)__get_free_pages(GFP_KERNEL, order); | ||
2932 | if (!ip_rt_acct) | 2925 | if (!ip_rt_acct) |
2933 | panic("IP: failed to allocate ip_rt_acct\n"); | 2926 | panic("IP: failed to allocate ip_rt_acct\n"); |
2934 | memset(ip_rt_acct, 0, PAGE_SIZE << order); | ||
2935 | } | ||
2936 | #endif | 2927 | #endif |
2937 | 2928 | ||
2938 | ipv4_dst_ops.kmem_cachep = | 2929 | ipv4_dst_ops.kmem_cachep = |