Lines Matching refs:net
118 static inline struct dst_entry *__xfrm_dst_lookup(struct net *net, in __xfrm_dst_lookup() argument
131 dst = afinfo->dst_lookup(net, tos, oif, saddr, daddr); in __xfrm_dst_lookup()
144 struct net *net = xs_net(x); in xfrm_dst_lookup() local
158 dst = __xfrm_dst_lookup(net, tos, oif, saddr, daddr, family); in xfrm_dst_lookup()
282 struct xfrm_policy *xfrm_policy_alloc(struct net *net, gfp_t gfp) in xfrm_policy_alloc() argument
289 write_pnet(&policy->xp_net, net); in xfrm_policy_alloc()
349 static inline unsigned int idx_hash(struct net *net, u32 index) in idx_hash() argument
351 return __idx_hash(index, net->xfrm.policy_idx_hmask); in idx_hash()
355 static void __get_hash_thresh(struct net *net, in __get_hash_thresh() argument
361 *dbits = net->xfrm.policy_bydst[dir].dbits4; in __get_hash_thresh()
362 *sbits = net->xfrm.policy_bydst[dir].sbits4; in __get_hash_thresh()
366 *dbits = net->xfrm.policy_bydst[dir].dbits6; in __get_hash_thresh()
367 *sbits = net->xfrm.policy_bydst[dir].sbits6; in __get_hash_thresh()
376 static struct hlist_head *policy_hash_bysel(struct net *net, in policy_hash_bysel() argument
380 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in policy_hash_bysel()
385 __get_hash_thresh(net, family, dir, &dbits, &sbits); in policy_hash_bysel()
389 &net->xfrm.policy_inexact[dir] : in policy_hash_bysel()
390 net->xfrm.policy_bydst[dir].table + hash); in policy_hash_bysel()
393 static struct hlist_head *policy_hash_direct(struct net *net, in policy_hash_direct() argument
398 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in policy_hash_direct()
403 __get_hash_thresh(net, family, dir, &dbits, &sbits); in policy_hash_direct()
406 return net->xfrm.policy_bydst[dir].table + hash; in policy_hash_direct()
409 static void xfrm_dst_hash_transfer(struct net *net, in xfrm_dst_hash_transfer() argument
425 __get_hash_thresh(net, pol->family, dir, &dbits, &sbits); in xfrm_dst_hash_transfer()
466 static void xfrm_bydst_resize(struct net *net, int dir) in xfrm_bydst_resize() argument
468 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_bydst_resize()
471 struct hlist_head *odst = net->xfrm.policy_bydst[dir].table; in xfrm_bydst_resize()
478 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_bydst_resize()
481 xfrm_dst_hash_transfer(net, odst + i, ndst, nhashmask, dir); in xfrm_bydst_resize()
483 net->xfrm.policy_bydst[dir].table = ndst; in xfrm_bydst_resize()
484 net->xfrm.policy_bydst[dir].hmask = nhashmask; in xfrm_bydst_resize()
486 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_bydst_resize()
491 static void xfrm_byidx_resize(struct net *net, int total) in xfrm_byidx_resize() argument
493 unsigned int hmask = net->xfrm.policy_idx_hmask; in xfrm_byidx_resize()
496 struct hlist_head *oidx = net->xfrm.policy_byidx; in xfrm_byidx_resize()
503 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_byidx_resize()
508 net->xfrm.policy_byidx = nidx; in xfrm_byidx_resize()
509 net->xfrm.policy_idx_hmask = nhashmask; in xfrm_byidx_resize()
511 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_byidx_resize()
516 static inline int xfrm_bydst_should_resize(struct net *net, int dir, int *total) in xfrm_bydst_should_resize() argument
518 unsigned int cnt = net->xfrm.policy_count[dir]; in xfrm_bydst_should_resize()
519 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_bydst_should_resize()
531 static inline int xfrm_byidx_should_resize(struct net *net, int total) in xfrm_byidx_should_resize() argument
533 unsigned int hmask = net->xfrm.policy_idx_hmask; in xfrm_byidx_should_resize()
542 void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si) in xfrm_spd_getinfo() argument
544 read_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_spd_getinfo()
545 si->incnt = net->xfrm.policy_count[XFRM_POLICY_IN]; in xfrm_spd_getinfo()
546 si->outcnt = net->xfrm.policy_count[XFRM_POLICY_OUT]; in xfrm_spd_getinfo()
547 si->fwdcnt = net->xfrm.policy_count[XFRM_POLICY_FWD]; in xfrm_spd_getinfo()
548 si->inscnt = net->xfrm.policy_count[XFRM_POLICY_IN+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
549 si->outscnt = net->xfrm.policy_count[XFRM_POLICY_OUT+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
550 si->fwdscnt = net->xfrm.policy_count[XFRM_POLICY_FWD+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
551 si->spdhcnt = net->xfrm.policy_idx_hmask; in xfrm_spd_getinfo()
553 read_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_spd_getinfo()
560 struct net *net = container_of(work, struct net, xfrm.policy_hash_work); in xfrm_hash_resize() local
567 if (xfrm_bydst_should_resize(net, dir, &total)) in xfrm_hash_resize()
568 xfrm_bydst_resize(net, dir); in xfrm_hash_resize()
570 if (xfrm_byidx_should_resize(net, total)) in xfrm_hash_resize()
571 xfrm_byidx_resize(net, total); in xfrm_hash_resize()
578 struct net *net = container_of(work, struct net, in xfrm_hash_rebuild() local
595 seq = read_seqbegin(&net->xfrm.policy_hthresh.lock); in xfrm_hash_rebuild()
597 lbits4 = net->xfrm.policy_hthresh.lbits4; in xfrm_hash_rebuild()
598 rbits4 = net->xfrm.policy_hthresh.rbits4; in xfrm_hash_rebuild()
599 lbits6 = net->xfrm.policy_hthresh.lbits6; in xfrm_hash_rebuild()
600 rbits6 = net->xfrm.policy_hthresh.rbits6; in xfrm_hash_rebuild()
601 } while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq)); in xfrm_hash_rebuild()
603 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_hash_rebuild()
607 INIT_HLIST_HEAD(&net->xfrm.policy_inexact[dir]); in xfrm_hash_rebuild()
608 hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_hash_rebuild()
609 odst = net->xfrm.policy_bydst[dir].table; in xfrm_hash_rebuild()
614 net->xfrm.policy_bydst[dir].dbits4 = rbits4; in xfrm_hash_rebuild()
615 net->xfrm.policy_bydst[dir].sbits4 = lbits4; in xfrm_hash_rebuild()
616 net->xfrm.policy_bydst[dir].dbits6 = rbits6; in xfrm_hash_rebuild()
617 net->xfrm.policy_bydst[dir].sbits6 = lbits6; in xfrm_hash_rebuild()
620 net->xfrm.policy_bydst[dir].dbits4 = lbits4; in xfrm_hash_rebuild()
621 net->xfrm.policy_bydst[dir].sbits4 = rbits4; in xfrm_hash_rebuild()
622 net->xfrm.policy_bydst[dir].dbits6 = lbits6; in xfrm_hash_rebuild()
623 net->xfrm.policy_bydst[dir].sbits6 = rbits6; in xfrm_hash_rebuild()
628 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { in xfrm_hash_rebuild()
630 chain = policy_hash_bysel(net, &policy->selector, in xfrm_hash_rebuild()
645 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_hash_rebuild()
650 void xfrm_policy_hash_rebuild(struct net *net) in xfrm_policy_hash_rebuild() argument
652 schedule_work(&net->xfrm.policy_hthresh.work); in xfrm_policy_hash_rebuild()
658 static u32 xfrm_gen_index(struct net *net, int dir, u32 index) in xfrm_gen_index() argument
678 list = net->xfrm.policy_byidx + idx_hash(net, idx); in xfrm_gen_index()
750 struct net *net = xp_net(policy); in xfrm_policy_insert() local
756 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
757 chain = policy_hash_bysel(net, &policy->selector, policy->family, dir); in xfrm_policy_insert()
767 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
785 atomic_inc(&net->xfrm.flow_cache_genid); in xfrm_policy_insert()
789 rt_genid_bump_ipv4(net); in xfrm_policy_insert()
791 rt_genid_bump_ipv6(net); in xfrm_policy_insert()
797 policy->index = delpol ? delpol->index : xfrm_gen_index(net, dir, policy->index); in xfrm_policy_insert()
798 hlist_add_head(&policy->byidx, net->xfrm.policy_byidx+idx_hash(net, policy->index)); in xfrm_policy_insert()
803 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
807 else if (xfrm_bydst_should_resize(net, dir, NULL)) in xfrm_policy_insert()
808 schedule_work(&net->xfrm.policy_hash_work); in xfrm_policy_insert()
814 struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, u32 mark, u8 type, in xfrm_policy_bysel_ctx() argument
823 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
824 chain = policy_hash_bysel(net, sel, sel->family, dir); in xfrm_policy_bysel_ctx()
836 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
845 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
853 struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u8 type, in xfrm_policy_byid() argument
864 write_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()
875 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
884 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
894 xfrm_policy_flush_secctx_check(struct net *net, u8 type, bool task_valid) in xfrm_policy_flush_secctx_check() argument
903 &net->xfrm.policy_inexact[dir], bydst) { in xfrm_policy_flush_secctx_check()
912 for (i = net->xfrm.policy_bydst[dir].hmask; i >= 0; i--) { in xfrm_policy_flush_secctx_check()
914 net->xfrm.policy_bydst[dir].table + i, in xfrm_policy_flush_secctx_check()
932 xfrm_policy_flush_secctx_check(struct net *net, u8 type, bool task_valid) in xfrm_policy_flush_secctx_check() argument
938 int xfrm_policy_flush(struct net *net, u8 type, bool task_valid) in xfrm_policy_flush() argument
942 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
944 err = xfrm_policy_flush_secctx_check(net, type, task_valid); in xfrm_policy_flush()
954 &net->xfrm.policy_inexact[dir], bydst) { in xfrm_policy_flush()
958 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
965 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
969 for (i = net->xfrm.policy_bydst[dir].hmask; i >= 0; i--) { in xfrm_policy_flush()
972 net->xfrm.policy_bydst[dir].table + i, in xfrm_policy_flush()
977 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
983 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
992 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
997 int xfrm_policy_walk(struct net *net, struct xfrm_policy_walk *walk, in xfrm_policy_walk() argument
1012 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk()
1014 x = list_first_entry(&net->xfrm.policy_all, struct xfrm_policy_walk_entry, all); in xfrm_policy_walk()
1019 list_for_each_entry_from(x, &net->xfrm.policy_all, all) { in xfrm_policy_walk()
1040 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk()
1054 void xfrm_policy_walk_done(struct xfrm_policy_walk *walk, struct net *net) in xfrm_policy_walk_done() argument
1059 write_lock_bh(&net->xfrm.xfrm_policy_lock); /*FIXME where is net? */ in xfrm_policy_walk_done()
1061 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk_done()
1091 static struct xfrm_policy *xfrm_policy_lookup_bytype(struct net *net, u8 type, in xfrm_policy_lookup_bytype() argument
1106 read_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_lookup_bytype()
1107 chain = policy_hash_direct(net, daddr, saddr, family, dir); in xfrm_policy_lookup_bytype()
1124 chain = &net->xfrm.policy_inexact[dir]; in xfrm_policy_lookup_bytype()
1145 read_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_lookup_bytype()
1151 __xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir) in __xfrm_policy_lookup() argument
1156 pol = xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_SUB, fl, family, dir); in __xfrm_policy_lookup()
1160 return xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_MAIN, fl, family, dir); in __xfrm_policy_lookup()
1182 xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, in xfrm_policy_lookup() argument
1190 pol = __xfrm_policy_lookup(net, fl, family, flow_to_policy_dir(dir)); in xfrm_policy_lookup()
1222 struct net *net = sock_net(sk); in xfrm_sk_policy_lookup() local
1225 read_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_lookup()
1250 read_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_lookup()
1257 struct net *net = xp_net(pol); in __xfrm_policy_link() local
1259 list_add(&pol->walk.all, &net->xfrm.policy_all); in __xfrm_policy_link()
1260 net->xfrm.policy_count[dir]++; in __xfrm_policy_link()
1267 struct net *net = xp_net(pol); in __xfrm_policy_unlink() local
1279 net->xfrm.policy_count[dir]--; in __xfrm_policy_unlink()
1296 struct net *net = xp_net(pol); in xfrm_policy_delete() local
1298 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_delete()
1300 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_delete()
1311 struct net *net = xp_net(pol); in xfrm_sk_policy_insert() local
1319 write_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_insert()
1321 lockdep_is_held(&net->xfrm.xfrm_policy_lock)); in xfrm_sk_policy_insert()
1324 pol->index = xfrm_gen_index(net, XFRM_POLICY_MAX+dir, 0); in xfrm_sk_policy_insert()
1337 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_insert()
1348 struct net *net = xp_net(old); in clone_policy() local
1367 write_lock_bh(&net->xfrm.xfrm_policy_lock); in clone_policy()
1369 write_unlock_bh(&net->xfrm.xfrm_policy_lock); in clone_policy()
1398 xfrm_get_saddr(struct net *net, int oif, xfrm_address_t *local, in xfrm_get_saddr() argument
1406 err = afinfo->get_saddr(net, oif, local, remote); in xfrm_get_saddr()
1417 struct net *net = xp_net(policy); in xfrm_tmpl_resolve_one() local
1435 error = xfrm_get_saddr(net, fl->flowi_oif, in xfrm_tmpl_resolve_one()
1578 static inline struct xfrm_dst *xfrm_alloc_dst(struct net *net, int family) in xfrm_alloc_dst() argument
1589 dst_ops = &net->xfrm.xfrm4_dst_ops; in xfrm_alloc_dst()
1593 dst_ops = &net->xfrm.xfrm6_dst_ops; in xfrm_alloc_dst()
1658 struct net *net = xp_net(policy); in xfrm_bundle_create() local
1683 struct xfrm_dst *xdst = xfrm_alloc_dst(net, family); in xfrm_bundle_create()
1865 struct net *net = xp_net(pols[0]); in xfrm_resolve_and_create_bundle() local
1875 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR); in xfrm_resolve_and_create_bundle()
1881 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTBUNDLEGENERROR); in xfrm_resolve_and_create_bundle()
1893 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTBUNDLECHECKERROR); in xfrm_resolve_and_create_bundle()
1910 struct net *net = xp_net(pol); in xfrm_policy_queue_process() local
1927 dst = xfrm_lookup(net, dst->path, &fl, sk, 0); in xfrm_policy_queue_process()
1957 dst = xfrm_lookup(net, skb_dst(skb)->path, &fl, skb->sk, 0); in xfrm_policy_queue_process()
1967 dst_output(net, skb->sk, skb); in xfrm_policy_queue_process()
1980 static int xdst_queue_output(struct net *net, struct sock *sk, struct sk_buff *skb) in xdst_queue_output() argument
2022 static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net, in xfrm_create_dummy_bundle() argument
2034 xdst = xfrm_alloc_dst(net, family); in xfrm_create_dummy_bundle()
2039 net->xfrm.sysctl_larval_drop || in xfrm_create_dummy_bundle()
2082 xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir, in xfrm_bundle_lookup() argument
2114 pols[0] = __xfrm_policy_lookup(net, fl, family, in xfrm_bundle_lookup()
2161 xdst = xfrm_create_dummy_bundle(net, xflo, fl, num_xfrms, family); in xfrm_bundle_lookup()
2174 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR); in xfrm_bundle_lookup()
2183 static struct dst_entry *make_blackhole(struct net *net, u16 family, in make_blackhole() argument
2193 ret = afinfo->blackhole_route(net, dst_orig); in make_blackhole()
2205 struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, in xfrm_lookup() argument
2263 !net->xfrm.policy_count[XFRM_POLICY_OUT]) in xfrm_lookup()
2266 flo = flow_cache_lookup(net, fl, family, dir, in xfrm_lookup()
2290 if (net->xfrm.sysctl_larval_drop) { in xfrm_lookup()
2291 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTNOSTATES); in xfrm_lookup()
2298 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTNOSTATES); in xfrm_lookup()
2317 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLBLOCK); in xfrm_lookup()
2354 struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig, in xfrm_lookup_route() argument
2358 struct dst_entry *dst = xfrm_lookup(net, dst_orig, fl, sk, in xfrm_lookup_route()
2363 return make_blackhole(net, dst_orig->ops->family, dst_orig); in xfrm_lookup_route()
2465 struct net *net = dev_net(skb->dev); in __xfrm_policy_check() local
2481 XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR); in __xfrm_policy_check()
2494 XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMISMATCH); in __xfrm_policy_check()
2505 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR); in __xfrm_policy_check()
2513 flo = flow_cache_lookup(net, &fl, family, fl_dir, in __xfrm_policy_check()
2522 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR); in __xfrm_policy_check()
2529 XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOPOLS); in __xfrm_policy_check()
2541 pols[1] = xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_MAIN, in __xfrm_policy_check()
2546 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLERROR); in __xfrm_policy_check()
2570 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLBLOCK); in __xfrm_policy_check()
2574 XFRM_INC_STATS(net, LINUX_MIB_XFRMINBUFFERERROR); in __xfrm_policy_check()
2582 xfrm_tmpl_sort(stp, tpp, xfrm_nr, family, net); in __xfrm_policy_check()
2598 XFRM_INC_STATS(net, LINUX_MIB_XFRMINTMPLMISMATCH); in __xfrm_policy_check()
2604 XFRM_INC_STATS(net, LINUX_MIB_XFRMINTMPLMISMATCH); in __xfrm_policy_check()
2611 XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLBLOCK); in __xfrm_policy_check()
2623 struct net *net = dev_net(skb->dev); in __xfrm_route_forward() local
2629 XFRM_INC_STATS(net, LINUX_MIB_XFRMFWDHDRERROR); in __xfrm_route_forward()
2635 dst = xfrm_lookup(net, skb_dst(skb), &fl, NULL, XFRM_LOOKUP_QUEUE); in __xfrm_route_forward()
2707 void xfrm_garbage_collect(struct net *net) in xfrm_garbage_collect() argument
2709 flow_cache_flush(net); in xfrm_garbage_collect()
2713 static void xfrm_garbage_collect_deferred(struct net *net) in xfrm_garbage_collect_deferred() argument
2715 flow_cache_flush_deferred(net); in xfrm_garbage_collect_deferred()
2910 static int __net_init xfrm_statistics_init(struct net *net) in xfrm_statistics_init() argument
2913 net->mib.xfrm_statistics = alloc_percpu(struct linux_xfrm_mib); in xfrm_statistics_init()
2914 if (!net->mib.xfrm_statistics) in xfrm_statistics_init()
2916 rv = xfrm_proc_init(net); in xfrm_statistics_init()
2918 free_percpu(net->mib.xfrm_statistics); in xfrm_statistics_init()
2922 static void xfrm_statistics_fini(struct net *net) in xfrm_statistics_fini() argument
2924 xfrm_proc_fini(net); in xfrm_statistics_fini()
2925 free_percpu(net->mib.xfrm_statistics); in xfrm_statistics_fini()
2928 static int __net_init xfrm_statistics_init(struct net *net) in xfrm_statistics_init() argument
2933 static void xfrm_statistics_fini(struct net *net) in xfrm_statistics_fini() argument
2938 static int __net_init xfrm_policy_init(struct net *net) in xfrm_policy_init() argument
2943 if (net_eq(net, &init_net)) in xfrm_policy_init()
2952 net->xfrm.policy_byidx = xfrm_hash_alloc(sz); in xfrm_policy_init()
2953 if (!net->xfrm.policy_byidx) in xfrm_policy_init()
2955 net->xfrm.policy_idx_hmask = hmask; in xfrm_policy_init()
2960 net->xfrm.policy_count[dir] = 0; in xfrm_policy_init()
2961 net->xfrm.policy_count[XFRM_POLICY_MAX + dir] = 0; in xfrm_policy_init()
2962 INIT_HLIST_HEAD(&net->xfrm.policy_inexact[dir]); in xfrm_policy_init()
2964 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_init()
2974 net->xfrm.policy_hthresh.lbits4 = 32; in xfrm_policy_init()
2975 net->xfrm.policy_hthresh.rbits4 = 32; in xfrm_policy_init()
2976 net->xfrm.policy_hthresh.lbits6 = 128; in xfrm_policy_init()
2977 net->xfrm.policy_hthresh.rbits6 = 128; in xfrm_policy_init()
2979 seqlock_init(&net->xfrm.policy_hthresh.lock); in xfrm_policy_init()
2981 INIT_LIST_HEAD(&net->xfrm.policy_all); in xfrm_policy_init()
2982 INIT_WORK(&net->xfrm.policy_hash_work, xfrm_hash_resize); in xfrm_policy_init()
2983 INIT_WORK(&net->xfrm.policy_hthresh.work, xfrm_hash_rebuild); in xfrm_policy_init()
2984 if (net_eq(net, &init_net)) in xfrm_policy_init()
2992 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_init()
2995 xfrm_hash_free(net->xfrm.policy_byidx, sz); in xfrm_policy_init()
3000 static void xfrm_policy_fini(struct net *net) in xfrm_policy_fini() argument
3005 flush_work(&net->xfrm.policy_hash_work); in xfrm_policy_fini()
3007 xfrm_policy_flush(net, XFRM_POLICY_TYPE_SUB, false); in xfrm_policy_fini()
3009 xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, false); in xfrm_policy_fini()
3011 WARN_ON(!list_empty(&net->xfrm.policy_all)); in xfrm_policy_fini()
3016 WARN_ON(!hlist_empty(&net->xfrm.policy_inexact[dir])); in xfrm_policy_fini()
3018 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_fini()
3024 sz = (net->xfrm.policy_idx_hmask + 1) * sizeof(struct hlist_head); in xfrm_policy_fini()
3025 WARN_ON(!hlist_empty(net->xfrm.policy_byidx)); in xfrm_policy_fini()
3026 xfrm_hash_free(net->xfrm.policy_byidx, sz); in xfrm_policy_fini()
3029 static int __net_init xfrm_net_init(struct net *net) in xfrm_net_init() argument
3033 rv = xfrm_statistics_init(net); in xfrm_net_init()
3036 rv = xfrm_state_init(net); in xfrm_net_init()
3039 rv = xfrm_policy_init(net); in xfrm_net_init()
3042 rv = xfrm_sysctl_init(net); in xfrm_net_init()
3045 rv = flow_cache_init(net); in xfrm_net_init()
3050 spin_lock_init(&net->xfrm.xfrm_state_lock); in xfrm_net_init()
3051 rwlock_init(&net->xfrm.xfrm_policy_lock); in xfrm_net_init()
3052 mutex_init(&net->xfrm.xfrm_cfg_mutex); in xfrm_net_init()
3057 xfrm_sysctl_fini(net); in xfrm_net_init()
3059 xfrm_policy_fini(net); in xfrm_net_init()
3061 xfrm_state_fini(net); in xfrm_net_init()
3063 xfrm_statistics_fini(net); in xfrm_net_init()
3068 static void __net_exit xfrm_net_exit(struct net *net) in xfrm_net_exit() argument
3070 flow_cache_fini(net); in xfrm_net_exit()
3071 xfrm_sysctl_fini(net); in xfrm_net_exit()
3072 xfrm_policy_fini(net); in xfrm_net_exit()
3073 xfrm_state_fini(net); in xfrm_net_exit()
3074 xfrm_statistics_fini(net); in xfrm_net_exit()
3176 u8 dir, u8 type, struct net *net) in xfrm_migrate_policy_find() argument
3182 read_lock_bh(&net->xfrm.xfrm_policy_lock); /*FIXME*/ in xfrm_migrate_policy_find()
3183 chain = policy_hash_direct(net, &sel->daddr, &sel->saddr, sel->family, dir); in xfrm_migrate_policy_find()
3192 chain = &net->xfrm.policy_inexact[dir]; in xfrm_migrate_policy_find()
3206 read_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_migrate_policy_find()
3317 struct xfrm_kmaddress *k, struct net *net) in xfrm_migrate() argument
3330 if ((pol = xfrm_migrate_policy_find(sel, dir, type, net)) == NULL) { in xfrm_migrate()
3337 if ((x = xfrm_migrate_state_find(mp, net))) { in xfrm_migrate()