xfrm: Use a static gc threshold value for ipv6
[sfrench/cifs-2.6.git] / net / ipv6 / xfrm6_policy.c
index ef39812107b17c2c90c38e24df363e76008dd745..6ce4a4fd3b30b8b56599573c0f605151cb1c5bb3 100644 (file)
@@ -20,7 +20,7 @@
 #include <net/ip.h>
 #include <net/ipv6.h>
 #include <net/ip6_route.h>
-#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
+#if IS_ENABLED(CONFIG_IPV6_MIP6)
 #include <net/mip6.h>
 #endif
 
@@ -73,6 +73,13 @@ static int xfrm6_get_tos(const struct flowi *fl)
        return 0;
 }
 
+static void xfrm6_init_dst(struct net *net, struct xfrm_dst *xdst)
+{
+       struct rt6_info *rt = (struct rt6_info *)xdst;
+
+       rt6_init_peer(rt, net->ipv6.peers);
+}
+
 static int xfrm6_init_path(struct xfrm_dst *path, struct dst_entry *dst,
                           int nfheader_len)
 {
@@ -175,7 +182,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
                        fl6->flowi6_proto = nexthdr;
                        return;
 
-#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
+#if IS_ENABLED(CONFIG_IPV6_MIP6)
                case IPPROTO_MH:
                        if (!onlyproto && pskb_may_pull(skb, nh + offset + 3 - skb->data)) {
                                struct ip6_mh *mh;
@@ -286,6 +293,7 @@ static struct xfrm_policy_afinfo xfrm6_policy_afinfo = {
        .get_saddr =            xfrm6_get_saddr,
        .decode_session =       _decode_session6,
        .get_tos =              xfrm6_get_tos,
+       .init_dst =             xfrm6_init_dst,
        .init_path =            xfrm6_init_path,
        .fill_dst =             xfrm6_fill_dst,
        .blackhole_route =      ip6_blackhole_route,
@@ -319,21 +327,7 @@ static struct ctl_table_header *sysctl_hdr;
 int __init xfrm6_init(void)
 {
        int ret;
-       unsigned int gc_thresh;
-
-       /*
-        * We need a good default value for the xfrm6 gc threshold.
-        * In ipv4 we set it to the route hash table size * 8, which
-        * is half the size of the maximaum route cache for ipv4.  It
-        * would be good to do the same thing for v6, except the table is
-        * constructed differently here.  Here each table for a net namespace
-        * can have FIB_TABLE_HASHSZ entries, so lets go with the same
-        * computation that we used for ipv4 here.  Also, lets keep the initial
-        * gc_thresh to a minimum of 1024, since, the ipv6 route cache defaults
-        * to that as a minimum as well
-        */
-       gc_thresh = FIB6_TABLE_HASHSZ * 8;
-       xfrm6_dst_ops.gc_thresh = (gc_thresh < 1024) ? 1024 : gc_thresh;
+
        dst_entries_init(&xfrm6_dst_ops);
 
        ret = xfrm6_policy_init();