static unsigned int xfrm_policy_hashmax __read_mostly = 1 * 1024 * 1024;
 
-static inline unsigned int idx_hash(u32 index)
+static inline unsigned int idx_hash(struct net *net, u32 index)
 {
-       return __idx_hash(index, init_net.xfrm.policy_idx_hmask);
+       return __idx_hash(index, net->xfrm.policy_idx_hmask);
 }
 
 static struct hlist_head *policy_hash_bysel(struct xfrm_selector *sel, unsigned short family, int dir)
                idx_generator += 8;
                if (idx == 0)
                        idx = 8;
-               list = init_net.xfrm.policy_byidx + idx_hash(idx);
+               list = init_net.xfrm.policy_byidx + idx_hash(&init_net, idx);
                found = 0;
                hlist_for_each_entry(p, entry, list, byidx) {
                        if (p->index == idx) {
                init_net.xfrm.policy_count[dir]--;
        }
        policy->index = delpol ? delpol->index : xfrm_gen_index(dir);
-       hlist_add_head(&policy->byidx, init_net.xfrm.policy_byidx+idx_hash(policy->index));
+       hlist_add_head(&policy->byidx, init_net.xfrm.policy_byidx+idx_hash(&init_net, policy->index));
        policy->curlft.add_time = get_seconds();
        policy->curlft.use_time = 0;
        if (!mod_timer(&policy->timer, jiffies + HZ))
 
        *err = 0;
        write_lock_bh(&xfrm_policy_lock);
-       chain = init_net.xfrm.policy_byidx + idx_hash(id);
+       chain = init_net.xfrm.policy_byidx + idx_hash(&init_net, id);
        ret = NULL;
        hlist_for_each_entry(pol, entry, chain, byidx) {
                if (pol->type == type && pol->index == id) {
 
        list_add(&pol->walk.all, &net->xfrm.policy_all);
        hlist_add_head(&pol->bydst, chain);
-       hlist_add_head(&pol->byidx, net->xfrm.policy_byidx+idx_hash(pol->index));
+       hlist_add_head(&pol->byidx, net->xfrm.policy_byidx+idx_hash(net, pol->index));
        net->xfrm.policy_count[dir]++;
        xfrm_pol_hold(pol);