Lines Matching refs:xfrm

456 	return __idx_hash(index, net->xfrm.policy_idx_hmask);  in idx_hash()
466 *dbits = net->xfrm.policy_bydst[dir].dbits4; in __get_hash_thresh()
467 *sbits = net->xfrm.policy_bydst[dir].sbits4; in __get_hash_thresh()
471 *dbits = net->xfrm.policy_bydst[dir].dbits6; in __get_hash_thresh()
472 *sbits = net->xfrm.policy_bydst[dir].sbits6; in __get_hash_thresh()
485 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in policy_hash_bysel()
496 return rcu_dereference_check(net->xfrm.policy_bydst[dir].table, in policy_hash_bysel()
497 lockdep_is_held(&net->xfrm.xfrm_policy_lock)) + hash; in policy_hash_bysel()
505 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in policy_hash_direct()
513 return rcu_dereference_check(net->xfrm.policy_bydst[dir].table, in policy_hash_direct()
514 lockdep_is_held(&net->xfrm.xfrm_policy_lock)) + hash; in policy_hash_direct()
576 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_bydst_resize()
586 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_bydst_resize()
587 write_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation); in xfrm_bydst_resize()
589 odst = rcu_dereference_protected(net->xfrm.policy_bydst[dir].table, in xfrm_bydst_resize()
590 lockdep_is_held(&net->xfrm.xfrm_policy_lock)); in xfrm_bydst_resize()
595 rcu_assign_pointer(net->xfrm.policy_bydst[dir].table, ndst); in xfrm_bydst_resize()
596 net->xfrm.policy_bydst[dir].hmask = nhashmask; in xfrm_bydst_resize()
598 write_seqcount_end(&net->xfrm.xfrm_policy_hash_generation); in xfrm_bydst_resize()
599 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_bydst_resize()
608 unsigned int hmask = net->xfrm.policy_idx_hmask; in xfrm_byidx_resize()
611 struct hlist_head *oidx = net->xfrm.policy_byidx; in xfrm_byidx_resize()
618 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_byidx_resize()
623 net->xfrm.policy_byidx = nidx; in xfrm_byidx_resize()
624 net->xfrm.policy_idx_hmask = nhashmask; in xfrm_byidx_resize()
626 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_byidx_resize()
633 unsigned int cnt = net->xfrm.policy_count[dir]; in xfrm_bydst_should_resize()
634 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_bydst_should_resize()
648 unsigned int hmask = net->xfrm.policy_idx_hmask; in xfrm_byidx_should_resize()
659 si->incnt = net->xfrm.policy_count[XFRM_POLICY_IN]; in xfrm_spd_getinfo()
660 si->outcnt = net->xfrm.policy_count[XFRM_POLICY_OUT]; in xfrm_spd_getinfo()
661 si->fwdcnt = net->xfrm.policy_count[XFRM_POLICY_FWD]; in xfrm_spd_getinfo()
662 si->inscnt = net->xfrm.policy_count[XFRM_POLICY_IN+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
663 si->outscnt = net->xfrm.policy_count[XFRM_POLICY_OUT+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
664 si->fwdscnt = net->xfrm.policy_count[XFRM_POLICY_FWD+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
665 si->spdhcnt = net->xfrm.policy_idx_hmask; in xfrm_spd_getinfo()
673 struct net *net = container_of(work, struct net, xfrm.policy_hash_work); in xfrm_hash_resize()
705 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_alloc_bin()
721 seqcount_spinlock_init(&bin->count, &net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_alloc_bin()
727 list_add(&bin->inexact_bins, &net->xfrm.inexact_bins); in xfrm_policy_inexact_alloc_bin()
847 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { in xfrm_policy_inexact_list_reinsert()
1108 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_prune_bin()
1110 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_prune_bin()
1117 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in __xfrm_policy_inexact_flush()
1119 list_for_each_entry_safe(bin, t, &net->xfrm.inexact_bins, inexact_bins) in __xfrm_policy_inexact_flush()
1131 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_alloc_chain()
1196 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_insert()
1210 chain = &net->xfrm.policy_inexact[dir]; in xfrm_policy_inexact_insert()
1222 xfrm.policy_hthresh.work); in xfrm_hash_rebuild()
1238 seq = read_seqbegin(&net->xfrm.policy_hthresh.lock); in xfrm_hash_rebuild()
1240 lbits4 = net->xfrm.policy_hthresh.lbits4; in xfrm_hash_rebuild()
1241 rbits4 = net->xfrm.policy_hthresh.rbits4; in xfrm_hash_rebuild()
1242 lbits6 = net->xfrm.policy_hthresh.lbits6; in xfrm_hash_rebuild()
1243 rbits6 = net->xfrm.policy_hthresh.rbits6; in xfrm_hash_rebuild()
1244 } while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq)); in xfrm_hash_rebuild()
1246 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_hash_rebuild()
1247 write_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation); in xfrm_hash_rebuild()
1252 list_for_each_entry(policy, &net->xfrm.policy_all, walk.all) { in xfrm_hash_rebuild()
1295 &net->xfrm.policy_inexact[dir], in xfrm_hash_rebuild()
1301 hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_hash_rebuild()
1302 odst = net->xfrm.policy_bydst[dir].table; in xfrm_hash_rebuild()
1309 net->xfrm.policy_bydst[dir].dbits4 = rbits4; in xfrm_hash_rebuild()
1310 net->xfrm.policy_bydst[dir].sbits4 = lbits4; in xfrm_hash_rebuild()
1311 net->xfrm.policy_bydst[dir].dbits6 = rbits6; in xfrm_hash_rebuild()
1312 net->xfrm.policy_bydst[dir].sbits6 = lbits6; in xfrm_hash_rebuild()
1315 net->xfrm.policy_bydst[dir].dbits4 = lbits4; in xfrm_hash_rebuild()
1316 net->xfrm.policy_bydst[dir].sbits4 = rbits4; in xfrm_hash_rebuild()
1317 net->xfrm.policy_bydst[dir].dbits6 = lbits6; in xfrm_hash_rebuild()
1318 net->xfrm.policy_bydst[dir].sbits6 = rbits6; in xfrm_hash_rebuild()
1323 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { in xfrm_hash_rebuild()
1356 write_seqcount_end(&net->xfrm.xfrm_policy_hash_generation); in xfrm_hash_rebuild()
1357 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_hash_rebuild()
1364 schedule_work(&net->xfrm.policy_hthresh.work); in xfrm_policy_hash_rebuild()
1390 list = net->xfrm.policy_byidx + idx_hash(net, idx); in xfrm_gen_index()
1576 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
1584 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
1601 hlist_add_head(&policy->byidx, net->xfrm.policy_byidx+idx_hash(net, policy->index)); in xfrm_policy_insert()
1606 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
1611 schedule_work(&net->xfrm.policy_hash_work); in xfrm_policy_insert()
1649 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
1658 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
1665 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
1692 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
1699 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
1721 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
1722 chain = net->xfrm.policy_byidx + idx_hash(net, id); in xfrm_policy_byid()
1732 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
1741 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
1756 list_for_each_entry(pol, &net->xfrm.policy_all, walk.all) { in xfrm_policy_flush_secctx_check()
1783 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
1790 list_for_each_entry(pol, &net->xfrm.policy_all, walk.all) { in xfrm_policy_flush()
1798 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
1802 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
1810 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
1830 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk()
1832 x = list_first_entry(&net->xfrm.policy_all, struct xfrm_policy_walk_entry, all); in xfrm_policy_walk()
1837 list_for_each_entry_from(x, &net->xfrm.policy_all, all) { in xfrm_policy_walk()
1858 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk()
1877 spin_lock_bh(&net->xfrm.xfrm_policy_lock); /*FIXME where is net? */ in xfrm_policy_walk_done()
1879 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk_done()
2002 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_lookup()
2096 sequence = read_seqcount_begin(&net->xfrm.xfrm_policy_hash_generation); in xfrm_policy_lookup_bytype()
2098 } while (read_seqcount_retry(&net->xfrm.xfrm_policy_hash_generation, sequence)); in xfrm_policy_lookup_bytype()
2129 if (read_seqcount_retry(&net->xfrm.xfrm_policy_hash_generation, sequence)) in xfrm_policy_lookup_bytype()
2203 list_add(&pol->walk.all, &net->xfrm.policy_all); in __xfrm_policy_link()
2204 net->xfrm.policy_count[dir]++; in __xfrm_policy_link()
2224 net->xfrm.policy_count[dir]--; in __xfrm_policy_unlink()
2243 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_delete()
2245 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_delete()
2264 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_insert()
2266 lockdep_is_held(&net->xfrm.xfrm_policy_lock)); in xfrm_sk_policy_insert()
2282 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_insert()
2314 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in clone_policy()
2316 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in clone_policy()
2362 struct xfrm_state **xfrm, unsigned short family) in xfrm_tmpl_resolve_one() argument
2395 xfrm[nx++] = x; in xfrm_tmpl_resolve_one()
2415 xfrm_state_put(xfrm[nx]); in xfrm_tmpl_resolve_one()
2421 struct xfrm_state **xfrm, unsigned short family) in xfrm_tmpl_resolve() argument
2424 struct xfrm_state **tpp = (npols > 1) ? tp : xfrm; in xfrm_tmpl_resolve()
2446 xfrm_state_sort(xfrm, tpp, cnx, family); in xfrm_tmpl_resolve()
2476 dst_ops = &net->xfrm.xfrm4_dst_ops; in xfrm_alloc_dst()
2480 dst_ops = &net->xfrm.xfrm6_dst_ops; in xfrm_alloc_dst()
2531 struct xfrm_state **xfrm, in xfrm_bundle_create() argument
2578 if (xfrm[i]->sel.family == AF_UNSPEC) { in xfrm_bundle_create()
2579 inner_mode = xfrm_ip2inner_mode(xfrm[i], in xfrm_bundle_create()
2587 inner_mode = &xfrm[i]->inner_mode; in xfrm_bundle_create()
2592 if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) { in xfrm_bundle_create()
2595 if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m) in xfrm_bundle_create()
2596 mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]); in xfrm_bundle_create()
2598 family = xfrm[i]->props.family; in xfrm_bundle_create()
2599 dst = xfrm_dst_lookup(xfrm[i], tos, fl->flowi_oif, in xfrm_bundle_create()
2607 dst1->xfrm = xfrm[i]; in xfrm_bundle_create()
2608 xdst->xfrm_genid = xfrm[i]->genid; in xfrm_bundle_create()
2625 header_len += xfrm[i]->props.header_len; in xfrm_bundle_create()
2626 if (xfrm[i]->type->flags & XFRM_TYPE_NON_FRAGMENT) in xfrm_bundle_create()
2627 nfheader_len += xfrm[i]->props.header_len; in xfrm_bundle_create()
2628 trailer_len += xfrm[i]->props.trailer_len; in xfrm_bundle_create()
2650 header_len -= xdst_prev->u.dst.xfrm->props.header_len; in xfrm_bundle_create()
2651 trailer_len -= xdst_prev->u.dst.xfrm->props.trailer_len; in xfrm_bundle_create()
2658 xfrm_state_put(xfrm[i]); in xfrm_bundle_create()
2717 struct xfrm_state *xfrm[XFRM_MAX_DEPTH]; in xfrm_resolve_and_create_bundle() local
2724 err = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family); in xfrm_resolve_and_create_bundle()
2734 dst = xfrm_bundle_create(pols[0], xfrm, bundle, err, fl, dst_orig); in xfrm_resolve_and_create_bundle()
2895 net->xfrm.sysctl_larval_drop || in xfrm_create_dummy_bundle()
3087 !net->xfrm.policy_count[XFRM_POLICY_OUT])) in xfrm_lookup_with_ifid()
3112 if (net->xfrm.sysctl_larval_drop) { in xfrm_lookup_with_ifid()
3152 if (dst && dst->xfrm && in xfrm_lookup_with_ifid()
3153 dst->xfrm->props.mode == XFRM_MODE_TUNNEL) in xfrm_lookup_with_ifid()
3722 while ((dst = xfrm_dst_child(dst)) && dst->xfrm && dst->dev == dev) { in xfrm_dst_ifdown()
3757 pmtu = xfrm_state_mtu(dst->xfrm, pmtu); in xfrm_init_pmtu()
3792 if (dst->xfrm->km.state != XFRM_STATE_VALID) in xfrm_bundle_ok()
3794 if (xdst->xfrm_genid != dst->xfrm->genid) in xfrm_bundle_ok()
3817 } while (dst->xfrm); in xfrm_bundle_ok()
3827 mtu = xfrm_state_mtu(dst->xfrm, mtu); in xfrm_bundle_ok()
3856 while (dst->xfrm) { in xfrm_get_dst_nexthop()
3857 const struct xfrm_state *xfrm = dst->xfrm; in xfrm_get_dst_nexthop() local
3861 if (xfrm->props.mode == XFRM_MODE_TRANSPORT) in xfrm_get_dst_nexthop()
3863 if (xfrm->type->flags & XFRM_TYPE_REMOTE_COADDR) in xfrm_get_dst_nexthop()
3864 daddr = xfrm->coaddr; in xfrm_get_dst_nexthop()
3865 else if (!(xfrm->type->flags & XFRM_TYPE_LOCAL_COADDR)) in xfrm_get_dst_nexthop()
3866 daddr = &xfrm->id.daddr; in xfrm_get_dst_nexthop()
4009 net->xfrm.policy_byidx = xfrm_hash_alloc(sz); in xfrm_policy_init()
4010 if (!net->xfrm.policy_byidx) in xfrm_policy_init()
4012 net->xfrm.policy_idx_hmask = hmask; in xfrm_policy_init()
4017 net->xfrm.policy_count[dir] = 0; in xfrm_policy_init()
4018 net->xfrm.policy_count[XFRM_POLICY_MAX + dir] = 0; in xfrm_policy_init()
4019 INIT_HLIST_HEAD(&net->xfrm.policy_inexact[dir]); in xfrm_policy_init()
4021 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_init()
4031 net->xfrm.policy_hthresh.lbits4 = 32; in xfrm_policy_init()
4032 net->xfrm.policy_hthresh.rbits4 = 32; in xfrm_policy_init()
4033 net->xfrm.policy_hthresh.lbits6 = 128; in xfrm_policy_init()
4034 net->xfrm.policy_hthresh.rbits6 = 128; in xfrm_policy_init()
4036 seqlock_init(&net->xfrm.policy_hthresh.lock); in xfrm_policy_init()
4038 INIT_LIST_HEAD(&net->xfrm.policy_all); in xfrm_policy_init()
4039 INIT_LIST_HEAD(&net->xfrm.inexact_bins); in xfrm_policy_init()
4040 INIT_WORK(&net->xfrm.policy_hash_work, xfrm_hash_resize); in xfrm_policy_init()
4041 INIT_WORK(&net->xfrm.policy_hthresh.work, xfrm_hash_rebuild); in xfrm_policy_init()
4048 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_init()
4051 xfrm_hash_free(net->xfrm.policy_byidx, sz); in xfrm_policy_init()
4062 flush_work(&net->xfrm.policy_hash_work); in xfrm_policy_fini()
4068 WARN_ON(!list_empty(&net->xfrm.policy_all)); in xfrm_policy_fini()
4073 WARN_ON(!hlist_empty(&net->xfrm.policy_inexact[dir])); in xfrm_policy_fini()
4075 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_fini()
4081 sz = (net->xfrm.policy_idx_hmask + 1) * sizeof(struct hlist_head); in xfrm_policy_fini()
4082 WARN_ON(!hlist_empty(net->xfrm.policy_byidx)); in xfrm_policy_fini()
4083 xfrm_hash_free(net->xfrm.policy_byidx, sz); in xfrm_policy_fini()
4085 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_fini()
4086 list_for_each_entry_safe(b, t, &net->xfrm.inexact_bins, inexact_bins) in xfrm_policy_fini()
4088 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_fini()
4096 spin_lock_init(&net->xfrm.xfrm_state_lock); in xfrm_net_init()
4097 spin_lock_init(&net->xfrm.xfrm_policy_lock); in xfrm_net_init()
4098 seqcount_spinlock_init(&net->xfrm.xfrm_policy_hash_generation, &net->xfrm.xfrm_policy_lock); in xfrm_net_init()
4099 mutex_init(&net->xfrm.xfrm_cfg_mutex); in xfrm_net_init()
4244 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_migrate_policy_find()
4254 chain = &net->xfrm.policy_inexact[dir]; in xfrm_migrate_policy_find()
4268 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_migrate_policy_find()