• Home
  • Raw
  • Download

Lines Matching refs:net

128 struct dst_entry *__xfrm_dst_lookup(struct net *net, int tos, int oif,  in __xfrm_dst_lookup()  argument
140 dst = afinfo->dst_lookup(net, tos, oif, saddr, daddr, mark); in __xfrm_dst_lookup()
154 struct net *net = xs_net(x); in xfrm_dst_lookup() local
168 dst = __xfrm_dst_lookup(net, tos, oif, saddr, daddr, family, mark); in xfrm_dst_lookup()
262 struct xfrm_policy *xfrm_policy_alloc(struct net *net, gfp_t gfp) in xfrm_policy_alloc() argument
269 write_pnet(&policy->xp_net, net); in xfrm_policy_alloc()
330 static inline unsigned int idx_hash(struct net *net, u32 index) in idx_hash() argument
332 return __idx_hash(index, net->xfrm.policy_idx_hmask); in idx_hash()
336 static void __get_hash_thresh(struct net *net, in __get_hash_thresh() argument
342 *dbits = net->xfrm.policy_bydst[dir].dbits4; in __get_hash_thresh()
343 *sbits = net->xfrm.policy_bydst[dir].sbits4; in __get_hash_thresh()
347 *dbits = net->xfrm.policy_bydst[dir].dbits6; in __get_hash_thresh()
348 *sbits = net->xfrm.policy_bydst[dir].sbits6; in __get_hash_thresh()
357 static struct hlist_head *policy_hash_bysel(struct net *net, in policy_hash_bysel() argument
361 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in policy_hash_bysel()
366 __get_hash_thresh(net, family, dir, &dbits, &sbits); in policy_hash_bysel()
370 return &net->xfrm.policy_inexact[dir]; in policy_hash_bysel()
372 return rcu_dereference_check(net->xfrm.policy_bydst[dir].table, in policy_hash_bysel()
373 lockdep_is_held(&net->xfrm.xfrm_policy_lock)) + hash; in policy_hash_bysel()
376 static struct hlist_head *policy_hash_direct(struct net *net, in policy_hash_direct() argument
381 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in policy_hash_direct()
386 __get_hash_thresh(net, family, dir, &dbits, &sbits); in policy_hash_direct()
389 return rcu_dereference_check(net->xfrm.policy_bydst[dir].table, in policy_hash_direct()
390 lockdep_is_held(&net->xfrm.xfrm_policy_lock)) + hash; in policy_hash_direct()
393 static void xfrm_dst_hash_transfer(struct net *net, in xfrm_dst_hash_transfer() argument
409 __get_hash_thresh(net, pol->family, dir, &dbits, &sbits); in xfrm_dst_hash_transfer()
450 static void xfrm_bydst_resize(struct net *net, int dir) in xfrm_bydst_resize() argument
452 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_bydst_resize()
462 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_bydst_resize()
465 odst = rcu_dereference_protected(net->xfrm.policy_bydst[dir].table, in xfrm_bydst_resize()
466 lockdep_is_held(&net->xfrm.xfrm_policy_lock)); in xfrm_bydst_resize()
468 odst = rcu_dereference_protected(net->xfrm.policy_bydst[dir].table, in xfrm_bydst_resize()
469 lockdep_is_held(&net->xfrm.xfrm_policy_lock)); in xfrm_bydst_resize()
472 xfrm_dst_hash_transfer(net, odst + i, ndst, nhashmask, dir); in xfrm_bydst_resize()
474 rcu_assign_pointer(net->xfrm.policy_bydst[dir].table, ndst); in xfrm_bydst_resize()
475 net->xfrm.policy_bydst[dir].hmask = nhashmask; in xfrm_bydst_resize()
478 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_bydst_resize()
485 static void xfrm_byidx_resize(struct net *net, int total) in xfrm_byidx_resize() argument
487 unsigned int hmask = net->xfrm.policy_idx_hmask; in xfrm_byidx_resize()
490 struct hlist_head *oidx = net->xfrm.policy_byidx; in xfrm_byidx_resize()
497 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_byidx_resize()
502 net->xfrm.policy_byidx = nidx; in xfrm_byidx_resize()
503 net->xfrm.policy_idx_hmask = nhashmask; in xfrm_byidx_resize()
505 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_byidx_resize()
510 static inline int xfrm_bydst_should_resize(struct net *net, int dir, int *total) in xfrm_bydst_should_resize() argument
512 unsigned int cnt = net->xfrm.policy_count[dir]; in xfrm_bydst_should_resize()
513 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_bydst_should_resize()
525 static inline int xfrm_byidx_should_resize(struct net *net, int total) in xfrm_byidx_should_resize() argument
527 unsigned int hmask = net->xfrm.policy_idx_hmask; in xfrm_byidx_should_resize()
536 void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si) in xfrm_spd_getinfo() argument
538 si->incnt = net->xfrm.policy_count[XFRM_POLICY_IN]; in xfrm_spd_getinfo()
539 si->outcnt = net->xfrm.policy_count[XFRM_POLICY_OUT]; in xfrm_spd_getinfo()
540 si->fwdcnt = net->xfrm.policy_count[XFRM_POLICY_FWD]; in xfrm_spd_getinfo()
541 si->inscnt = net->xfrm.policy_count[XFRM_POLICY_IN+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
542 si->outscnt = net->xfrm.policy_count[XFRM_POLICY_OUT+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
543 si->fwdscnt = net->xfrm.policy_count[XFRM_POLICY_FWD+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
544 si->spdhcnt = net->xfrm.policy_idx_hmask; in xfrm_spd_getinfo()
552 struct net *net = container_of(work, struct net, xfrm.policy_hash_work); in xfrm_hash_resize() local
559 if (xfrm_bydst_should_resize(net, dir, &total)) in xfrm_hash_resize()
560 xfrm_bydst_resize(net, dir); in xfrm_hash_resize()
562 if (xfrm_byidx_should_resize(net, total)) in xfrm_hash_resize()
563 xfrm_byidx_resize(net, total); in xfrm_hash_resize()
570 struct net *net = container_of(work, struct net, in xfrm_hash_rebuild() local
587 seq = read_seqbegin(&net->xfrm.policy_hthresh.lock); in xfrm_hash_rebuild()
589 lbits4 = net->xfrm.policy_hthresh.lbits4; in xfrm_hash_rebuild()
590 rbits4 = net->xfrm.policy_hthresh.rbits4; in xfrm_hash_rebuild()
591 lbits6 = net->xfrm.policy_hthresh.lbits6; in xfrm_hash_rebuild()
592 rbits6 = net->xfrm.policy_hthresh.rbits6; in xfrm_hash_rebuild()
593 } while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq)); in xfrm_hash_rebuild()
595 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_hash_rebuild()
599 INIT_HLIST_HEAD(&net->xfrm.policy_inexact[dir]); in xfrm_hash_rebuild()
600 hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_hash_rebuild()
601 odst = net->xfrm.policy_bydst[dir].table; in xfrm_hash_rebuild()
606 net->xfrm.policy_bydst[dir].dbits4 = rbits4; in xfrm_hash_rebuild()
607 net->xfrm.policy_bydst[dir].sbits4 = lbits4; in xfrm_hash_rebuild()
608 net->xfrm.policy_bydst[dir].dbits6 = rbits6; in xfrm_hash_rebuild()
609 net->xfrm.policy_bydst[dir].sbits6 = lbits6; in xfrm_hash_rebuild()
612 net->xfrm.policy_bydst[dir].dbits4 = lbits4; in xfrm_hash_rebuild()
613 net->xfrm.policy_bydst[dir].sbits4 = rbits4; in xfrm_hash_rebuild()
614 net->xfrm.policy_bydst[dir].dbits6 = lbits6; in xfrm_hash_rebuild()
615 net->xfrm.policy_bydst[dir].sbits6 = rbits6; in xfrm_hash_rebuild()
620 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { in xfrm_hash_rebuild()
627 chain = policy_hash_bysel(net, &policy->selector, in xfrm_hash_rebuild()
642 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_hash_rebuild()
647 void xfrm_policy_hash_rebuild(struct net *net) in xfrm_policy_hash_rebuild() argument
649 schedule_work(&net->xfrm.policy_hthresh.work); in xfrm_policy_hash_rebuild()
655 static u32 xfrm_gen_index(struct net *net, int dir, u32 index) in xfrm_gen_index() argument
675 list = net->xfrm.policy_byidx + idx_hash(net, idx); in xfrm_gen_index()
747 struct net *net = xp_net(policy); in xfrm_policy_insert() local
753 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
754 chain = policy_hash_bysel(net, &policy->selector, policy->family, dir); in xfrm_policy_insert()
765 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
786 rt_genid_bump_ipv4(net); in xfrm_policy_insert()
788 rt_genid_bump_ipv6(net); in xfrm_policy_insert()
794 policy->index = delpol ? delpol->index : xfrm_gen_index(net, dir, policy->index); in xfrm_policy_insert()
795 hlist_add_head(&policy->byidx, net->xfrm.policy_byidx+idx_hash(net, policy->index)); in xfrm_policy_insert()
800 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
804 else if (xfrm_bydst_should_resize(net, dir, NULL)) in xfrm_policy_insert()
805 schedule_work(&net->xfrm.policy_hash_work); in xfrm_policy_insert()
811 struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, u32 mark, u32 if_id, in xfrm_policy_bysel_ctx() argument
821 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
822 chain = policy_hash_bysel(net, sel, sel->family, dir); in xfrm_policy_bysel_ctx()
835 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
844 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
852 struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u32 if_id, in xfrm_policy_byid() argument
864 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
865 chain = net->xfrm.policy_byidx + idx_hash(net, id); in xfrm_policy_byid()
876 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
885 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
895 xfrm_policy_flush_secctx_check(struct net *net, u8 type, bool task_valid) in xfrm_policy_flush_secctx_check() argument
904 &net->xfrm.policy_inexact[dir], bydst) { in xfrm_policy_flush_secctx_check()
913 for (i = net->xfrm.policy_bydst[dir].hmask; i >= 0; i--) { in xfrm_policy_flush_secctx_check()
915 net->xfrm.policy_bydst[dir].table + i, in xfrm_policy_flush_secctx_check()
933 xfrm_policy_flush_secctx_check(struct net *net, u8 type, bool task_valid) in xfrm_policy_flush_secctx_check() argument
939 int xfrm_policy_flush(struct net *net, u8 type, bool task_valid) in xfrm_policy_flush() argument
943 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
945 err = xfrm_policy_flush_secctx_check(net, type, task_valid); in xfrm_policy_flush()
955 &net->xfrm.policy_inexact[dir], bydst) { in xfrm_policy_flush()
959 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
966 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
970 for (i = net->xfrm.policy_bydst[dir].hmask; i >= 0; i--) { in xfrm_policy_flush()
973 net->xfrm.policy_bydst[dir].table + i, in xfrm_policy_flush()
978 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
984 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
993 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
998 int xfrm_policy_walk(struct net *net, struct xfrm_policy_walk *walk, in xfrm_policy_walk() argument
1013 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk()
1015 x = list_first_entry(&net->xfrm.policy_all, struct xfrm_policy_walk_entry, all); in xfrm_policy_walk()
1020 list_for_each_entry_from(x, &net->xfrm.policy_all, all) { in xfrm_policy_walk()
1041 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk()
1055 void xfrm_policy_walk_done(struct xfrm_policy_walk *walk, struct net *net) in xfrm_policy_walk_done() argument
1060 spin_lock_bh(&net->xfrm.xfrm_policy_lock); /*FIXME where is net? */ in xfrm_policy_walk_done()
1062 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk_done()
1093 static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type, in xfrm_policy_lookup_bytype() argument
1114 chain = policy_hash_direct(net, daddr, saddr, family, dir); in xfrm_policy_lookup_bytype()
1134 chain = &net->xfrm.policy_inexact[dir]; in xfrm_policy_lookup_bytype()
1164 static struct xfrm_policy *xfrm_policy_lookup(struct net *net, in xfrm_policy_lookup() argument
1171 pol = xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_SUB, fl, family, in xfrm_policy_lookup()
1176 return xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_MAIN, fl, family, in xfrm_policy_lookup()
1226 struct net *net = xp_net(pol); in __xfrm_policy_link() local
1228 list_add(&pol->walk.all, &net->xfrm.policy_all); in __xfrm_policy_link()
1229 net->xfrm.policy_count[dir]++; in __xfrm_policy_link()
1236 struct net *net = xp_net(pol); in __xfrm_policy_unlink() local
1248 net->xfrm.policy_count[dir]--; in __xfrm_policy_unlink()
1265 struct net *net = xp_net(pol); in xfrm_policy_delete() local
1267 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_delete()
1269 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_delete()
1280 struct net *net = sock_net(sk); in xfrm_sk_policy_insert() local
1288 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_insert()
1290 lockdep_is_held(&net->xfrm.xfrm_policy_lock)); in xfrm_sk_policy_insert()
1293 pol->index = xfrm_gen_index(net, XFRM_POLICY_MAX+dir, 0); in xfrm_sk_policy_insert()
1306 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_insert()
1317 struct net *net = xp_net(old); in clone_policy() local
1338 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in clone_policy()
1340 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in clone_policy()
1369 xfrm_get_saddr(struct net *net, int oif, xfrm_address_t *local, in xfrm_get_saddr() argument
1377 err = afinfo->get_saddr(net, oif, local, remote, mark); in xfrm_get_saddr()
1388 struct net *net = xp_net(policy); in xfrm_tmpl_resolve_one() local
1406 error = xfrm_get_saddr(net, fl->flowi_oif, in xfrm_tmpl_resolve_one()
1497 static inline struct xfrm_dst *xfrm_alloc_dst(struct net *net, int family) in xfrm_alloc_dst() argument
1508 dst_ops = &net->xfrm.xfrm4_dst_ops; in xfrm_alloc_dst()
1512 dst_ops = &net->xfrm.xfrm6_dst_ops; in xfrm_alloc_dst()
1576 struct net *net = xp_net(policy); in xfrm_bundle_create() local
1598 struct xfrm_dst *xdst = xfrm_alloc_dst(net, family); in xfrm_bundle_create()
1750 struct net *net = xp_net(pols[0]); in xfrm_resolve_and_create_bundle() local
1763 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR); in xfrm_resolve_and_create_bundle()
1769 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTBUNDLEGENERROR); in xfrm_resolve_and_create_bundle()
1788 struct net *net = xp_net(pol); in xfrm_policy_queue_process() local
1805 dst = xfrm_lookup(net, dst->path, &fl, sk, 0); in xfrm_policy_queue_process()
1835 dst = xfrm_lookup(net, skb_dst(skb)->path, &fl, skb->sk, 0); in xfrm_policy_queue_process()
1845 dst_output(net, skb->sk, skb); in xfrm_policy_queue_process()
1858 static int xdst_queue_output(struct net *net, struct sock *sk, struct sk_buff *skb) in xdst_queue_output() argument
1900 static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net, in xfrm_create_dummy_bundle() argument
1912 xdst = xfrm_alloc_dst(net, family); in xfrm_create_dummy_bundle()
1917 net->xfrm.sysctl_larval_drop || in xfrm_create_dummy_bundle()
1959 static struct xfrm_dst *xfrm_bundle_lookup(struct net *net, in xfrm_bundle_lookup() argument
1971 pols[0] = xfrm_policy_lookup(net, fl, family, dir, if_id); in xfrm_bundle_lookup()
2004 xdst = xfrm_create_dummy_bundle(net, xflo, fl, num_xfrms, family); in xfrm_bundle_lookup()
2016 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR); in xfrm_bundle_lookup()
2022 static struct dst_entry *make_blackhole(struct net *net, u16 family, in make_blackhole() argument
2032 ret = afinfo->blackhole_route(net, dst_orig); in make_blackhole()
2047 struct dst_entry *xfrm_lookup_with_ifid(struct net *net, in xfrm_lookup_with_ifid() argument
2109 !net->xfrm.policy_count[XFRM_POLICY_OUT]) in xfrm_lookup_with_ifid()
2112 xdst = xfrm_bundle_lookup(net, fl, family, dir, &xflo, if_id); in xfrm_lookup_with_ifid()
2134 if (net->xfrm.sysctl_larval_drop) { in xfrm_lookup_with_ifid()
2135 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTNOSTATES); in xfrm_lookup_with_ifid()
2142 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTNOSTATES); in xfrm_lookup_with_ifid()
2161 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLBLOCK); in xfrm_lookup_with_ifid()
2200 struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, in xfrm_lookup() argument
2204 return xfrm_lookup_with_ifid(net, dst_orig, fl, sk, flags, 0); in xfrm_lookup()
2211 struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig, in xfrm_lookup_route() argument
2215 struct dst_entry *dst = xfrm_lookup(net, dst_orig, fl, sk, in xfrm_lookup_route()
2220 return make_blackhole(net, dst_orig->ops->family, dst_orig); in xfrm_lookup_route()
2326 struct net *net = dev_net(skb->dev); in __xfrm_policy_check() local
2353 XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR); in __xfrm_policy_check()
2366 XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMISMATCH); in __xfrm_policy_check()
2377 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR); in __xfrm_policy_check()
2383 pol = xfrm_policy_lookup(net, &fl, family, dir, if_id); in __xfrm_policy_check()
2386 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR); in __xfrm_policy_check()
2393 XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOPOLS); in __xfrm_policy_check()
2405 pols[1] = xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_MAIN, in __xfrm_policy_check()
2410 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR); in __xfrm_policy_check()
2434 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLBLOCK); in __xfrm_policy_check()
2438 XFRM_INC_STATS(net, LINUX_MIB_XFRMINBUFFERERROR); in __xfrm_policy_check()
2446 xfrm_tmpl_sort(stp, tpp, xfrm_nr, family, net); in __xfrm_policy_check()
2462 XFRM_INC_STATS(net, LINUX_MIB_XFRMINTMPLMISMATCH); in __xfrm_policy_check()
2468 XFRM_INC_STATS(net, LINUX_MIB_XFRMINTMPLMISMATCH); in __xfrm_policy_check()
2475 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLBLOCK); in __xfrm_policy_check()
2487 struct net *net = dev_net(skb->dev); in __xfrm_route_forward() local
2493 XFRM_INC_STATS(net, LINUX_MIB_XFRMFWDHDRERROR); in __xfrm_route_forward()
2499 XFRM_INC_STATS(net, LINUX_MIB_XFRMFWDHDRERROR); in __xfrm_route_forward()
2503 dst = xfrm_lookup(net, skb_dst(skb), &fl, NULL, XFRM_LOOKUP_QUEUE); in __xfrm_route_forward()
2787 static int __net_init xfrm_statistics_init(struct net *net) in xfrm_statistics_init() argument
2790 net->mib.xfrm_statistics = alloc_percpu(struct linux_xfrm_mib); in xfrm_statistics_init()
2791 if (!net->mib.xfrm_statistics) in xfrm_statistics_init()
2793 rv = xfrm_proc_init(net); in xfrm_statistics_init()
2795 free_percpu(net->mib.xfrm_statistics); in xfrm_statistics_init()
2799 static void xfrm_statistics_fini(struct net *net) in xfrm_statistics_fini() argument
2801 xfrm_proc_fini(net); in xfrm_statistics_fini()
2802 free_percpu(net->mib.xfrm_statistics); in xfrm_statistics_fini()
2805 static int __net_init xfrm_statistics_init(struct net *net) in xfrm_statistics_init() argument
2810 static void xfrm_statistics_fini(struct net *net) in xfrm_statistics_fini() argument
2815 static int __net_init xfrm_policy_init(struct net *net) in xfrm_policy_init() argument
2820 if (net_eq(net, &init_net)) in xfrm_policy_init()
2829 net->xfrm.policy_byidx = xfrm_hash_alloc(sz); in xfrm_policy_init()
2830 if (!net->xfrm.policy_byidx) in xfrm_policy_init()
2832 net->xfrm.policy_idx_hmask = hmask; in xfrm_policy_init()
2837 net->xfrm.policy_count[dir] = 0; in xfrm_policy_init()
2838 net->xfrm.policy_count[XFRM_POLICY_MAX + dir] = 0; in xfrm_policy_init()
2839 INIT_HLIST_HEAD(&net->xfrm.policy_inexact[dir]); in xfrm_policy_init()
2841 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_init()
2851 net->xfrm.policy_hthresh.lbits4 = 32; in xfrm_policy_init()
2852 net->xfrm.policy_hthresh.rbits4 = 32; in xfrm_policy_init()
2853 net->xfrm.policy_hthresh.lbits6 = 128; in xfrm_policy_init()
2854 net->xfrm.policy_hthresh.rbits6 = 128; in xfrm_policy_init()
2856 seqlock_init(&net->xfrm.policy_hthresh.lock); in xfrm_policy_init()
2858 INIT_LIST_HEAD(&net->xfrm.policy_all); in xfrm_policy_init()
2859 INIT_WORK(&net->xfrm.policy_hash_work, xfrm_hash_resize); in xfrm_policy_init()
2860 INIT_WORK(&net->xfrm.policy_hthresh.work, xfrm_hash_rebuild); in xfrm_policy_init()
2861 if (net_eq(net, &init_net)) in xfrm_policy_init()
2869 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_init()
2872 xfrm_hash_free(net->xfrm.policy_byidx, sz); in xfrm_policy_init()
2877 static void xfrm_policy_fini(struct net *net) in xfrm_policy_fini() argument
2882 flush_work(&net->xfrm.policy_hash_work); in xfrm_policy_fini()
2884 xfrm_policy_flush(net, XFRM_POLICY_TYPE_SUB, false); in xfrm_policy_fini()
2886 xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, false); in xfrm_policy_fini()
2888 WARN_ON(!list_empty(&net->xfrm.policy_all)); in xfrm_policy_fini()
2893 WARN_ON(!hlist_empty(&net->xfrm.policy_inexact[dir])); in xfrm_policy_fini()
2895 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_fini()
2901 sz = (net->xfrm.policy_idx_hmask + 1) * sizeof(struct hlist_head); in xfrm_policy_fini()
2902 WARN_ON(!hlist_empty(net->xfrm.policy_byidx)); in xfrm_policy_fini()
2903 xfrm_hash_free(net->xfrm.policy_byidx, sz); in xfrm_policy_fini()
2906 static int __net_init xfrm_net_init(struct net *net) in xfrm_net_init() argument
2911 spin_lock_init(&net->xfrm.xfrm_state_lock); in xfrm_net_init()
2912 spin_lock_init(&net->xfrm.xfrm_policy_lock); in xfrm_net_init()
2913 mutex_init(&net->xfrm.xfrm_cfg_mutex); in xfrm_net_init()
2915 rv = xfrm_statistics_init(net); in xfrm_net_init()
2918 rv = xfrm_state_init(net); in xfrm_net_init()
2921 rv = xfrm_policy_init(net); in xfrm_net_init()
2924 rv = xfrm_sysctl_init(net); in xfrm_net_init()
2931 xfrm_policy_fini(net); in xfrm_net_init()
2933 xfrm_state_fini(net); in xfrm_net_init()
2935 xfrm_statistics_fini(net); in xfrm_net_init()
2940 static void __net_exit xfrm_net_exit(struct net *net) in xfrm_net_exit() argument
2942 xfrm_sysctl_fini(net); in xfrm_net_exit()
2943 xfrm_policy_fini(net); in xfrm_net_exit()
2944 xfrm_state_fini(net); in xfrm_net_exit()
2945 xfrm_statistics_fini(net); in xfrm_net_exit()
3051 u8 dir, u8 type, struct net *net) in xfrm_migrate_policy_find() argument
3057 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_migrate_policy_find()
3058 chain = policy_hash_direct(net, &sel->daddr, &sel->saddr, sel->family, dir); in xfrm_migrate_policy_find()
3067 chain = &net->xfrm.policy_inexact[dir]; in xfrm_migrate_policy_find()
3081 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_migrate_policy_find()
3187 struct xfrm_kmaddress *k, struct net *net, in xfrm_migrate() argument
3207 if ((pol = xfrm_migrate_policy_find(sel, dir, type, net)) == NULL) { in xfrm_migrate()
3214 if ((x = xfrm_migrate_state_find(mp, net))) { in xfrm_migrate()