Input: speed up suspend/shutdown for PS/2 mice and keyboards
[safe/jmp/linux-2.6] / net / ipv4 / route.c
index a849bb1..e446496 100644 (file)
@@ -131,8 +131,8 @@ static int ip_rt_min_advmss __read_mostly   = 256;
 static int ip_rt_secret_interval __read_mostly = 10 * 60 * HZ;
 static int rt_chain_length_max __read_mostly   = 20;
 
-static void rt_worker_func(struct work_struct *work);
-static DECLARE_DELAYED_WORK(expires_work, rt_worker_func);
+static struct delayed_work expires_work;
+static unsigned long expires_ljiffies;
 
 /*
  *     Interface to generic destination cache.
@@ -513,43 +513,42 @@ static const struct file_operations rt_cpu_seq_fops = {
 };
 
 #ifdef CONFIG_NET_CLS_ROUTE
-static int ip_rt_acct_read(char *buffer, char **start, off_t offset,
-                          int length, int *eof, void *data)
-{
-       unsigned int i;
-
-       if ((offset & 3) || (length & 3))
-               return -EIO;
-
-       if (offset >= sizeof(struct ip_rt_acct) * 256) {
-               *eof = 1;
-               return 0;
-       }
-
-       if (offset + length >= sizeof(struct ip_rt_acct) * 256) {
-               length = sizeof(struct ip_rt_acct) * 256 - offset;
-               *eof = 1;
+static int rt_acct_proc_show(struct seq_file *m, void *v)
+{
+       struct ip_rt_acct *dst, *src;
+       unsigned int i, j;
+
+       dst = kcalloc(256, sizeof(struct ip_rt_acct), GFP_KERNEL);
+       if (!dst)
+               return -ENOMEM;
+
+       for_each_possible_cpu(i) {
+               src = (struct ip_rt_acct *)per_cpu_ptr(ip_rt_acct, i);
+               for (j = 0; j < 256; j++) {
+                       dst[j].o_bytes   += src[j].o_bytes;
+                       dst[j].o_packets += src[j].o_packets;
+                       dst[j].i_bytes   += src[j].i_bytes;
+                       dst[j].i_packets += src[j].i_packets;
+               }
        }
 
-       offset /= sizeof(u32);
-
-       if (length > 0) {
-               u32 *dst = (u32 *) buffer;
-
-               *start = buffer;
-               memset(dst, 0, length);
-
-               for_each_possible_cpu(i) {
-                       unsigned int j;
-                       u32 *src;
+       seq_write(m, dst, 256 * sizeof(struct ip_rt_acct));
+       kfree(dst);
+       return 0;
+}
 
-                       src = ((u32 *) per_cpu_ptr(ip_rt_acct, i)) + offset;
-                       for (j = 0; j < length/4; j++)
-                               dst[j] += src[j];
-               }
-       }
-       return length;
+static int rt_acct_proc_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, rt_acct_proc_show, NULL);
 }
+
+static const struct file_operations rt_acct_proc_fops = {
+       .owner          = THIS_MODULE,
+       .open           = rt_acct_proc_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
 #endif
 
 static int __net_init ip_rt_do_proc_init(struct net *net)
@@ -567,8 +566,7 @@ static int __net_init ip_rt_do_proc_init(struct net *net)
                goto err2;
 
 #ifdef CONFIG_NET_CLS_ROUTE
-       pde = create_proc_read_entry("rt_acct", 0, net->proc_net,
-                       ip_rt_acct_read, NULL);
+       pde = proc_create("rt_acct", 0, net->proc_net, &rt_acct_proc_fops);
        if (!pde)
                goto err3;
 #endif
@@ -703,7 +701,7 @@ static inline int compare_keys(struct flowi *fl1, struct flowi *fl2)
 
 static inline int compare_netns(struct rtable *rt1, struct rtable *rt2)
 {
-       return dev_net(rt1->u.dst.dev) == dev_net(rt2->u.dst.dev);
+       return net_eq(dev_net(rt1->u.dst.dev), dev_net(rt2->u.dst.dev));
 }
 
 static inline int rt_is_expired(struct rtable *rth)
@@ -787,9 +785,12 @@ static void rt_check_expire(void)
        struct rtable *rth, *aux, **rthp;
        unsigned long samples = 0;
        unsigned long sum = 0, sum2 = 0;
+       unsigned long delta;
        u64 mult;
 
-       mult = ((u64)ip_rt_gc_interval) << rt_hash_log;
+       delta = jiffies - expires_ljiffies;
+       expires_ljiffies = jiffies;
+       mult = ((u64)delta) << rt_hash_log;
        if (ip_rt_gc_timeout > 1)
                do_div(mult, ip_rt_gc_timeout);
        goal = (unsigned int)mult;
@@ -899,6 +900,12 @@ void rt_cache_flush(struct net *net, int delay)
                rt_do_flush(!in_softirq());
 }
 
+/* Flush previous cache invalidated entries from the cache */
+void rt_cache_flush_batch(void)
+{
+       rt_do_flush(!in_softirq());
+}
+
 /*
  * We change rt_genid and let gc do the cleanup
  */
@@ -1082,8 +1089,35 @@ restart:
        now = jiffies;
 
        if (!rt_caching(dev_net(rt->u.dst.dev))) {
-               rt_drop(rt);
-               return 0;
+               /*
+                * If we're not caching, just tell the caller we
+                * were successful and don't touch the route.  The
+                * caller hold the sole reference to the cache entry, and
+                * it will be released when the caller is done with it.
+                * If we drop it here, the callers have no way to resolve routes
+                * when we're not caching.  Instead, just point *rp at rt, so
+                * the caller gets a single use out of the route
+                * Note that we do rt_free on this new route entry, so that
+                * once its refcount hits zero, we are still able to reap it
+                * (Thanks Alexey)
+                * Note also the rt_free uses call_rcu.  We don't actually
+                * need rcu protection here, this is just our path to get
+                * on the route gc list.
+                */
+
+               if (rt->rt_type == RTN_UNICAST || rt->fl.iif == 0) {
+                       int err = arp_bind_neighbour(&rt->u.dst);
+                       if (err) {
+                               if (net_ratelimit())
+                                       printk(KERN_WARNING
+                                           "Neighbour table failure & not caching routes.\n");
+                               rt_drop(rt);
+                               return err;
+                       }
+               }
+
+               rt_free(rt);
+               goto skip_hashing;
        }
 
        rthp = &rt_hash_table[hash].chain;
@@ -1200,7 +1234,8 @@ restart:
 #if RT_CACHE_DEBUG >= 2
        if (rt->u.dst.rt_next) {
                struct rtable *trt;
-               printk(KERN_DEBUG "rt_cache @%02x: %pI4", hash, &rt->rt_dst);
+               printk(KERN_DEBUG "rt_cache @%02x: %pI4",
+                      hash, &rt->rt_dst);
                for (trt = rt->u.dst.rt_next; trt; trt = trt->u.dst.rt_next)
                        printk(" . %pI4", &trt->rt_dst);
                printk("\n");
@@ -1214,6 +1249,8 @@ restart:
        rcu_assign_pointer(rt_hash_table[hash].chain, rt);
 
        spin_unlock_bh(rt_hash_lock_addr(hash));
+
+skip_hashing:
        if (rp)
                *rp = rt;
        else
@@ -1313,9 +1350,9 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
                return;
 
        net = dev_net(dev);
-       if (new_gw == old_gw || !IN_DEV_RX_REDIRECTS(in_dev)
-           || ipv4_is_multicast(new_gw) || ipv4_is_lbcast(new_gw)
-           || ipv4_is_zeronet(new_gw))
+       if (new_gw == old_gw || !IN_DEV_RX_REDIRECTS(in_dev) ||
+           ipv4_is_multicast(new_gw) || ipv4_is_lbcast(new_gw) ||
+           ipv4_is_zeronet(new_gw))
                goto reject_redirect;
 
        if (!rt_caching(net))
@@ -1481,13 +1518,17 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
 void ip_rt_send_redirect(struct sk_buff *skb)
 {
        struct rtable *rt = skb_rtable(skb);
-       struct in_device *in_dev = in_dev_get(rt->u.dst.dev);
+       struct in_device *in_dev;
+       int log_martians;
 
-       if (!in_dev)
+       rcu_read_lock();
+       in_dev = __in_dev_get_rcu(rt->u.dst.dev);
+       if (!in_dev || !IN_DEV_TX_REDIRECTS(in_dev)) {
+               rcu_read_unlock();
                return;
-
-       if (!IN_DEV_TX_REDIRECTS(in_dev))
-               goto out;
+       }
+       log_martians = IN_DEV_LOG_MARTIANS(in_dev);
+       rcu_read_unlock();
 
        /* No redirected packets during ip_rt_redirect_silence;
         * reset the algorithm.
@@ -1500,7 +1541,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)
         */
        if (rt->u.dst.rate_tokens >= ip_rt_redirect_number) {
                rt->u.dst.rate_last = jiffies;
-               goto out;
+               return;
        }
 
        /* Check for load limit; set rate_last to the latest sent
@@ -1514,7 +1555,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)
                rt->u.dst.rate_last = jiffies;
                ++rt->u.dst.rate_tokens;
 #ifdef CONFIG_IP_ROUTE_VERBOSE
-               if (IN_DEV_LOG_MARTIANS(in_dev) &&
+               if (log_martians &&
                    rt->u.dst.rate_tokens == ip_rt_redirect_number &&
                    net_ratelimit())
                        printk(KERN_WARNING "host %pI4/if%d ignores redirects for %pI4 to %pI4.\n",
@@ -1522,8 +1563,6 @@ void ip_rt_send_redirect(struct sk_buff *skb)
                                &rt->rt_dst, &rt->rt_gateway);
 #endif
        }
-out:
-       in_dev_put(in_dev);
 }
 
 static int ip_error(struct sk_buff *skb)
@@ -1593,9 +1632,6 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
        __be32  daddr = iph->daddr;
        unsigned short est_mtu = 0;
 
-       if (ipv4_config.no_pmtu_disc)
-               return 0;
-
        for (k = 0; k < 2; k++) {
                for (i = 0; i < 2; i++) {
                        unsigned hash = rt_hash(daddr, skeys[i], ikeys[k],
@@ -1819,7 +1855,7 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
                        goto e_inval;
                spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK);
        } else if (fib_validate_source(saddr, 0, tos, 0,
-                                       dev, &spec_dst, &itag) < 0)
+                                       dev, &spec_dst, &itag, 0) < 0)
                goto e_inval;
 
        rth = dst_alloc(&ipv4_dst_ops);
@@ -1932,7 +1968,7 @@ static int __mkroute_input(struct sk_buff *skb,
 
 
        err = fib_validate_source(saddr, daddr, tos, FIB_RES_OIF(*res),
-                                 in_dev->dev, &spec_dst, &itag);
+                                 in_dev->dev, &spec_dst, &itag, skb->mark);
        if (err < 0) {
                ip_handle_martian_source(in_dev->dev, in_dev, skb, daddr,
                                         saddr);
@@ -2106,7 +2142,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
                int result;
                result = fib_validate_source(saddr, daddr, tos,
                                             net->loopback_dev->ifindex,
-                                            dev, &spec_dst, &itag);
+                                            dev, &spec_dst, &itag, skb->mark);
                if (result < 0)
                        goto martian_source;
                if (result)
@@ -2135,7 +2171,7 @@ brd_input:
                spec_dst = inet_select_addr(dev, 0, RT_SCOPE_LINK);
        else {
                err = fib_validate_source(saddr, 0, tos, 0, dev, &spec_dst,
-                                         &itag);
+                                         &itag, skb->mark);
                if (err < 0)
                        goto martian_source;
                if (err)
@@ -2279,10 +2315,11 @@ skip_cache:
                                ip_hdr(skb)->protocol);
                        if (our
 #ifdef CONFIG_IP_MROUTE
-                           || (!ipv4_is_local_multicast(daddr) &&
-                               IN_DEV_MFORWARD(in_dev))
+                               ||
+                           (!ipv4_is_local_multicast(daddr) &&
+                            IN_DEV_MFORWARD(in_dev))
 #endif
-                           ) {
+                          ) {
                                rcu_read_unlock();
                                return ip_route_input_mc(skb, daddr, saddr,
                                                         tos, dev, our);
@@ -2479,9 +2516,9 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp,
                      of another iface. --ANK
                 */
 
-               if (oldflp->oif == 0
-                   && (ipv4_is_multicast(oldflp->fl4_dst) ||
-                       oldflp->fl4_dst == htonl(0xFFFFFFFF))) {
+               if (oldflp->oif == 0 &&
+                   (ipv4_is_multicast(oldflp->fl4_dst) ||
+                    oldflp->fl4_dst == htonl(0xFFFFFFFF))) {
                        /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */
                        dev_out = ip_dev_find(net, oldflp->fl4_src);
                        if (dev_out == NULL)
@@ -2820,7 +2857,7 @@ static int rt_fill_info(struct net *net,
        error = rt->u.dst.error;
        expires = rt->u.dst.expires ? rt->u.dst.expires - jiffies : 0;
        if (rt->peer) {
-               id = rt->peer->ip_id_count;
+               id = atomic_read(&rt->peer->ip_id_count) & 0xffff;
                if (rt->peer->tcp_ts_stamp) {
                        ts = rt->peer->tcp_ts;
                        tsage = get_seconds() - rt->peer->tcp_ts_stamp;
@@ -3001,7 +3038,7 @@ void ip_rt_multicast_event(struct in_device *in_dev)
 
 #ifdef CONFIG_SYSCTL
 static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,
-                                       struct file *filp, void __user *buffer,
+                                       void __user *buffer,
                                        size_t *lenp, loff_t *ppos)
 {
        if (write) {
@@ -3011,7 +3048,7 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,
 
                memcpy(&ctl, __ctl, sizeof(ctl));
                ctl.data = &flush_delay;
-               proc_dointvec(&ctl, write, filp, buffer, lenp, ppos);
+               proc_dointvec(&ctl, write, buffer, lenp, ppos);
 
                net = (struct net *)__ctl->extra1;
                rt_cache_flush(net, flush_delay);
@@ -3021,23 +3058,6 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,
        return -EINVAL;
 }
 
-static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table,
-                                               void __user *oldval,
-                                               size_t __user *oldlenp,
-                                               void __user *newval,
-                                               size_t newlen)
-{
-       int delay;
-       struct net *net;
-       if (newlen != sizeof(int))
-               return -EINVAL;
-       if (get_user(delay, (int __user *)newval))
-               return -EFAULT;
-       net = (struct net *)table->extra1;
-       rt_cache_flush(net, delay);
-       return 0;
-}
-
 static void rt_secret_reschedule(int old)
 {
        struct net *net;
@@ -3071,26 +3091,11 @@ static void rt_secret_reschedule(int old)
 }
 
 static int ipv4_sysctl_rt_secret_interval(ctl_table *ctl, int write,
-                                         struct file *filp,
                                          void __user *buffer, size_t *lenp,
                                          loff_t *ppos)
 {
        int old = ip_rt_secret_interval;
-       int ret = proc_dointvec_jiffies(ctl, write, filp, buffer, lenp, ppos);
-
-       rt_secret_reschedule(old);
-
-       return ret;
-}
-
-static int ipv4_sysctl_rt_secret_interval_strategy(ctl_table *table,
-                                                  void __user *oldval,
-                                                  size_t __user *oldlenp,
-                                                  void __user *newval,
-                                                  size_t newlen)
-{
-       int old = ip_rt_secret_interval;
-       int ret = sysctl_jiffies(table, oldval, oldlenp, newval, newlen);
+       int ret = proc_dointvec_jiffies(ctl, write, buffer, lenp, ppos);
 
        rt_secret_reschedule(old);
 
@@ -3099,7 +3104,6 @@ static int ipv4_sysctl_rt_secret_interval_strategy(ctl_table *table,
 
 static ctl_table ipv4_route_table[] = {
        {
-               .ctl_name       = NET_IPV4_ROUTE_GC_THRESH,
                .procname       = "gc_thresh",
                .data           = &ipv4_dst_ops.gc_thresh,
                .maxlen         = sizeof(int),
@@ -3107,7 +3111,6 @@ static ctl_table ipv4_route_table[] = {
                .proc_handler   = proc_dointvec,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_MAX_SIZE,
                .procname       = "max_size",
                .data           = &ip_rt_max_size,
                .maxlen         = sizeof(int),
@@ -3117,43 +3120,34 @@ static ctl_table ipv4_route_table[] = {
        {
                /*  Deprecated. Use gc_min_interval_ms */
 
-               .ctl_name       = NET_IPV4_ROUTE_GC_MIN_INTERVAL,
                .procname       = "gc_min_interval",
                .data           = &ip_rt_gc_min_interval,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec_jiffies,
-               .strategy       = sysctl_jiffies,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_GC_MIN_INTERVAL_MS,
                .procname       = "gc_min_interval_ms",
                .data           = &ip_rt_gc_min_interval,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec_ms_jiffies,
-               .strategy       = sysctl_ms_jiffies,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_GC_TIMEOUT,
                .procname       = "gc_timeout",
                .data           = &ip_rt_gc_timeout,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec_jiffies,
-               .strategy       = sysctl_jiffies,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_GC_INTERVAL,
                .procname       = "gc_interval",
                .data           = &ip_rt_gc_interval,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec_jiffies,
-               .strategy       = sysctl_jiffies,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_REDIRECT_LOAD,
                .procname       = "redirect_load",
                .data           = &ip_rt_redirect_load,
                .maxlen         = sizeof(int),
@@ -3161,7 +3155,6 @@ static ctl_table ipv4_route_table[] = {
                .proc_handler   = proc_dointvec,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_REDIRECT_NUMBER,
                .procname       = "redirect_number",
                .data           = &ip_rt_redirect_number,
                .maxlen         = sizeof(int),
@@ -3169,7 +3162,6 @@ static ctl_table ipv4_route_table[] = {
                .proc_handler   = proc_dointvec,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_REDIRECT_SILENCE,
                .procname       = "redirect_silence",
                .data           = &ip_rt_redirect_silence,
                .maxlen         = sizeof(int),
@@ -3177,7 +3169,6 @@ static ctl_table ipv4_route_table[] = {
                .proc_handler   = proc_dointvec,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_ERROR_COST,
                .procname       = "error_cost",
                .data           = &ip_rt_error_cost,
                .maxlen         = sizeof(int),
@@ -3185,7 +3176,6 @@ static ctl_table ipv4_route_table[] = {
                .proc_handler   = proc_dointvec,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_ERROR_BURST,
                .procname       = "error_burst",
                .data           = &ip_rt_error_burst,
                .maxlen         = sizeof(int),
@@ -3193,7 +3183,6 @@ static ctl_table ipv4_route_table[] = {
                .proc_handler   = proc_dointvec,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_GC_ELASTICITY,
                .procname       = "gc_elasticity",
                .data           = &ip_rt_gc_elasticity,
                .maxlen         = sizeof(int),
@@ -3201,16 +3190,13 @@ static ctl_table ipv4_route_table[] = {
                .proc_handler   = proc_dointvec,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_MTU_EXPIRES,
                .procname       = "mtu_expires",
                .data           = &ip_rt_mtu_expires,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = proc_dointvec_jiffies,
-               .strategy       = sysctl_jiffies,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_MIN_PMTU,
                .procname       = "min_pmtu",
                .data           = &ip_rt_min_pmtu,
                .maxlen         = sizeof(int),
@@ -3218,7 +3204,6 @@ static ctl_table ipv4_route_table[] = {
                .proc_handler   = proc_dointvec,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_MIN_ADVMSS,
                .procname       = "min_adv_mss",
                .data           = &ip_rt_min_advmss,
                .maxlen         = sizeof(int),
@@ -3226,50 +3211,46 @@ static ctl_table ipv4_route_table[] = {
                .proc_handler   = proc_dointvec,
        },
        {
-               .ctl_name       = NET_IPV4_ROUTE_SECRET_INTERVAL,
                .procname       = "secret_interval",
                .data           = &ip_rt_secret_interval,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = ipv4_sysctl_rt_secret_interval,
-               .strategy       = ipv4_sysctl_rt_secret_interval_strategy,
        },
-       { .ctl_name = 0 }
+       { }
 };
 
 static struct ctl_table empty[1];
 
 static struct ctl_table ipv4_skeleton[] =
 {
-       { .procname = "route", .ctl_name = NET_IPV4_ROUTE,
+       { .procname = "route", 
          .mode = 0555, .child = ipv4_route_table},
-       { .procname = "neigh", .ctl_name = NET_IPV4_NEIGH,
+       { .procname = "neigh", 
          .mode = 0555, .child = empty},
        { }
 };
 
 static __net_initdata struct ctl_path ipv4_path[] = {
-       { .procname = "net", .ctl_name = CTL_NET, },
-       { .procname = "ipv4", .ctl_name = NET_IPV4, },
+       { .procname = "net", },
+       { .procname = "ipv4", },
        { },
 };
 
 static struct ctl_table ipv4_route_flush_table[] = {
        {
-               .ctl_name       = NET_IPV4_ROUTE_FLUSH,
                .procname       = "flush",
                .maxlen         = sizeof(int),
                .mode           = 0200,
                .proc_handler   = ipv4_sysctl_rtcache_flush,
-               .strategy       = ipv4_sysctl_rtcache_flush_strategy,
        },
-       { .ctl_name = 0 },
+       { },
 };
 
 static __net_initdata struct ctl_path ipv4_route_path[] = {
-       { .procname = "net", .ctl_name = CTL_NET, },
-       { .procname = "ipv4", .ctl_name = NET_IPV4, },
-       { .procname = "route", .ctl_name = NET_IPV4_ROUTE, },
+       { .procname = "net", },
+       { .procname = "ipv4", },
+       { .procname = "route", },
        { },
 };
 
@@ -3278,7 +3259,7 @@ static __net_init int sysctl_route_net_init(struct net *net)
        struct ctl_table *tbl;
 
        tbl = ipv4_route_flush_table;
-       if (net != &init_net) {
+       if (!net_eq(net, &init_net)) {
                tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
                if (tbl == NULL)
                        goto err_dup;
@@ -3379,7 +3360,7 @@ int __init ip_rt_init(void)
                alloc_large_system_hash("IP route cache",
                                        sizeof(struct rt_hash_bucket),
                                        rhash_entries,
-                                       (num_physpages >= 128 * 1024) ?
+                                       (totalram_pages >= 128 * 1024) ?
                                        15 : 17,
                                        0,
                                        &rt_hash_log,
@@ -3397,6 +3378,8 @@ int __init ip_rt_init(void)
        /* All the timers, started at system startup tend
           to synchronize. Perturb it a bit.
         */
+       INIT_DELAYED_WORK_DEFERRABLE(&expires_work, rt_worker_func);
+       expires_ljiffies = jiffies;
        schedule_delayed_work(&expires_work,
                net_random() % ip_rt_gc_interval + ip_rt_gc_interval);
 
@@ -3407,7 +3390,7 @@ int __init ip_rt_init(void)
                printk(KERN_ERR "Unable to create route proc files\n");
 #ifdef CONFIG_XFRM
        xfrm_init();
-       xfrm4_init();
+       xfrm4_init(ip_rt_max_size);
 #endif
        rtnl_register(PF_INET, RTM_GETROUTE, inet_rtm_getroute, NULL);