Lines Matching refs:xfrm

463 	return __idx_hash(index, net->xfrm.policy_idx_hmask);  in idx_hash()
473 *dbits = net->xfrm.policy_bydst[dir].dbits4; in __get_hash_thresh()
474 *sbits = net->xfrm.policy_bydst[dir].sbits4; in __get_hash_thresh()
478 *dbits = net->xfrm.policy_bydst[dir].dbits6; in __get_hash_thresh()
479 *sbits = net->xfrm.policy_bydst[dir].sbits6; in __get_hash_thresh()
492 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in policy_hash_bysel()
503 return rcu_dereference_check(net->xfrm.policy_bydst[dir].table, in policy_hash_bysel()
504 lockdep_is_held(&net->xfrm.xfrm_policy_lock)) + hash; in policy_hash_bysel()
512 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in policy_hash_direct()
520 return rcu_dereference_check(net->xfrm.policy_bydst[dir].table, in policy_hash_direct()
521 lockdep_is_held(&net->xfrm.xfrm_policy_lock)) + hash; in policy_hash_direct()
583 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_bydst_resize()
593 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_bydst_resize()
596 odst = rcu_dereference_protected(net->xfrm.policy_bydst[dir].table, in xfrm_bydst_resize()
597 lockdep_is_held(&net->xfrm.xfrm_policy_lock)); in xfrm_bydst_resize()
602 rcu_assign_pointer(net->xfrm.policy_bydst[dir].table, ndst); in xfrm_bydst_resize()
603 net->xfrm.policy_bydst[dir].hmask = nhashmask; in xfrm_bydst_resize()
606 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_bydst_resize()
615 unsigned int hmask = net->xfrm.policy_idx_hmask; in xfrm_byidx_resize()
618 struct hlist_head *oidx = net->xfrm.policy_byidx; in xfrm_byidx_resize()
625 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_byidx_resize()
630 net->xfrm.policy_byidx = nidx; in xfrm_byidx_resize()
631 net->xfrm.policy_idx_hmask = nhashmask; in xfrm_byidx_resize()
633 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_byidx_resize()
640 unsigned int cnt = net->xfrm.policy_count[dir]; in xfrm_bydst_should_resize()
641 unsigned int hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_bydst_should_resize()
655 unsigned int hmask = net->xfrm.policy_idx_hmask; in xfrm_byidx_should_resize()
666 si->incnt = net->xfrm.policy_count[XFRM_POLICY_IN]; in xfrm_spd_getinfo()
667 si->outcnt = net->xfrm.policy_count[XFRM_POLICY_OUT]; in xfrm_spd_getinfo()
668 si->fwdcnt = net->xfrm.policy_count[XFRM_POLICY_FWD]; in xfrm_spd_getinfo()
669 si->inscnt = net->xfrm.policy_count[XFRM_POLICY_IN+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
670 si->outscnt = net->xfrm.policy_count[XFRM_POLICY_OUT+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
671 si->fwdscnt = net->xfrm.policy_count[XFRM_POLICY_FWD+XFRM_POLICY_MAX]; in xfrm_spd_getinfo()
672 si->spdhcnt = net->xfrm.policy_idx_hmask; in xfrm_spd_getinfo()
680 struct net *net = container_of(work, struct net, xfrm.policy_hash_work); in xfrm_hash_resize()
712 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_alloc_bin()
728 seqcount_spinlock_init(&bin->count, &net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_alloc_bin()
734 list_add(&bin->inexact_bins, &net->xfrm.inexact_bins); in xfrm_policy_inexact_alloc_bin()
854 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { in xfrm_policy_inexact_list_reinsert()
1115 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_prune_bin()
1117 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_prune_bin()
1124 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in __xfrm_policy_inexact_flush()
1126 list_for_each_entry_safe(bin, t, &net->xfrm.inexact_bins, inexact_bins) in __xfrm_policy_inexact_flush()
1138 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_alloc_chain()
1203 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_insert()
1217 chain = &net->xfrm.policy_inexact[dir]; in xfrm_policy_inexact_insert()
1229 xfrm.policy_hthresh.work); in xfrm_hash_rebuild()
1245 seq = read_seqbegin(&net->xfrm.policy_hthresh.lock); in xfrm_hash_rebuild()
1247 lbits4 = net->xfrm.policy_hthresh.lbits4; in xfrm_hash_rebuild()
1248 rbits4 = net->xfrm.policy_hthresh.rbits4; in xfrm_hash_rebuild()
1249 lbits6 = net->xfrm.policy_hthresh.lbits6; in xfrm_hash_rebuild()
1250 rbits6 = net->xfrm.policy_hthresh.rbits6; in xfrm_hash_rebuild()
1251 } while (read_seqretry(&net->xfrm.policy_hthresh.lock, seq)); in xfrm_hash_rebuild()
1253 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_hash_rebuild()
1259 list_for_each_entry(policy, &net->xfrm.policy_all, walk.all) { in xfrm_hash_rebuild()
1302 &net->xfrm.policy_inexact[dir], in xfrm_hash_rebuild()
1308 hmask = net->xfrm.policy_bydst[dir].hmask; in xfrm_hash_rebuild()
1309 odst = net->xfrm.policy_bydst[dir].table; in xfrm_hash_rebuild()
1316 net->xfrm.policy_bydst[dir].dbits4 = rbits4; in xfrm_hash_rebuild()
1317 net->xfrm.policy_bydst[dir].sbits4 = lbits4; in xfrm_hash_rebuild()
1318 net->xfrm.policy_bydst[dir].dbits6 = rbits6; in xfrm_hash_rebuild()
1319 net->xfrm.policy_bydst[dir].sbits6 = lbits6; in xfrm_hash_rebuild()
1322 net->xfrm.policy_bydst[dir].dbits4 = lbits4; in xfrm_hash_rebuild()
1323 net->xfrm.policy_bydst[dir].sbits4 = rbits4; in xfrm_hash_rebuild()
1324 net->xfrm.policy_bydst[dir].dbits6 = lbits6; in xfrm_hash_rebuild()
1325 net->xfrm.policy_bydst[dir].sbits6 = rbits6; in xfrm_hash_rebuild()
1330 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { in xfrm_hash_rebuild()
1364 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_hash_rebuild()
1371 schedule_work(&net->xfrm.policy_hthresh.work); in xfrm_policy_hash_rebuild()
1397 list = net->xfrm.policy_byidx + idx_hash(net, idx); in xfrm_gen_index()
1583 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
1591 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
1608 hlist_add_head(&policy->byidx, net->xfrm.policy_byidx+idx_hash(net, policy->index)); in xfrm_policy_insert()
1613 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_insert()
1618 schedule_work(&net->xfrm.policy_hash_work); in xfrm_policy_insert()
1656 spin_lock_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()
1672 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()
1706 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_bysel_ctx()
1728 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
1729 chain = net->xfrm.policy_byidx + idx_hash(net, id); in xfrm_policy_byid()
1739 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
1748 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_byid()
1763 list_for_each_entry(pol, &net->xfrm.policy_all, walk.all) { in xfrm_policy_flush_secctx_check()
1790 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
1797 list_for_each_entry(pol, &net->xfrm.policy_all, walk.all) { in xfrm_policy_flush()
1805 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
1809 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
1817 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_flush()
1837 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk()
1839 x = list_first_entry(&net->xfrm.policy_all, struct xfrm_policy_walk_entry, all); in xfrm_policy_walk()
1844 list_for_each_entry_from(x, &net->xfrm.policy_all, all) { in xfrm_policy_walk()
1865 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk()
1884 spin_lock_bh(&net->xfrm.xfrm_policy_lock); /*FIXME where is net? */ in xfrm_policy_walk_done()
1886 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_walk_done()
2010 lockdep_assert_held(&net->xfrm.xfrm_policy_lock); in xfrm_policy_inexact_lookup()
2212 list_add(&pol->walk.all, &net->xfrm.policy_all); in __xfrm_policy_link()
2213 net->xfrm.policy_count[dir]++; in __xfrm_policy_link()
2233 net->xfrm.policy_count[dir]--; in __xfrm_policy_unlink()
2252 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_delete()
2254 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_delete()
2273 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_insert()
2275 lockdep_is_held(&net->xfrm.xfrm_policy_lock)); in xfrm_sk_policy_insert()
2291 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_sk_policy_insert()
2323 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in clone_policy()
2325 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in clone_policy()
2371 struct xfrm_state **xfrm, unsigned short family) in xfrm_tmpl_resolve_one() argument
2404 xfrm[nx++] = x; in xfrm_tmpl_resolve_one()
2424 xfrm_state_put(xfrm[nx]); in xfrm_tmpl_resolve_one()
2430 struct xfrm_state **xfrm, unsigned short family) in xfrm_tmpl_resolve() argument
2433 struct xfrm_state **tpp = (npols > 1) ? tp : xfrm; in xfrm_tmpl_resolve()
2455 xfrm_state_sort(xfrm, tpp, cnx, family); in xfrm_tmpl_resolve()
2485 dst_ops = &net->xfrm.xfrm4_dst_ops; in xfrm_alloc_dst()
2489 dst_ops = &net->xfrm.xfrm6_dst_ops; in xfrm_alloc_dst()
2542 struct xfrm_state **xfrm, in xfrm_bundle_create() argument
2589 if (xfrm[i]->sel.family == AF_UNSPEC) { in xfrm_bundle_create()
2590 inner_mode = xfrm_ip2inner_mode(xfrm[i], in xfrm_bundle_create()
2598 inner_mode = &xfrm[i]->inner_mode; in xfrm_bundle_create()
2603 if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) { in xfrm_bundle_create()
2606 if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m) in xfrm_bundle_create()
2607 mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]); in xfrm_bundle_create()
2609 family = xfrm[i]->props.family; in xfrm_bundle_create()
2610 dst = xfrm_dst_lookup(xfrm[i], tos, fl->flowi_oif, in xfrm_bundle_create()
2618 dst1->xfrm = xfrm[i]; in xfrm_bundle_create()
2619 xdst->xfrm_genid = xfrm[i]->genid; in xfrm_bundle_create()
2636 header_len += xfrm[i]->props.header_len; in xfrm_bundle_create()
2637 if (xfrm[i]->type->flags & XFRM_TYPE_NON_FRAGMENT) in xfrm_bundle_create()
2638 nfheader_len += xfrm[i]->props.header_len; in xfrm_bundle_create()
2639 trailer_len += xfrm[i]->props.trailer_len; in xfrm_bundle_create()
2661 header_len -= xdst_prev->u.dst.xfrm->props.header_len; in xfrm_bundle_create()
2662 trailer_len -= xdst_prev->u.dst.xfrm->props.trailer_len; in xfrm_bundle_create()
2669 xfrm_state_put(xfrm[i]); in xfrm_bundle_create()
2731 struct xfrm_state *xfrm[XFRM_MAX_DEPTH]; in xfrm_resolve_and_create_bundle() local
2738 err = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family); in xfrm_resolve_and_create_bundle()
2748 dst = xfrm_bundle_create(pols[0], xfrm, bundle, err, fl, dst_orig); in xfrm_resolve_and_create_bundle()
2909 net->xfrm.sysctl_larval_drop || in xfrm_create_dummy_bundle()
3101 !net->xfrm.policy_count[XFRM_POLICY_OUT])) in xfrm_lookup_with_ifid()
3126 if (net->xfrm.sysctl_larval_drop) { in xfrm_lookup_with_ifid()
3166 if (dst && dst->xfrm && in xfrm_lookup_with_ifid()
3167 dst->xfrm->props.mode == XFRM_MODE_TUNNEL) in xfrm_lookup_with_ifid()
3780 while ((dst = xfrm_dst_child(dst)) && dst->xfrm && dst->dev == dev) { in xfrm_dst_ifdown()
3815 pmtu = xfrm_state_mtu(dst->xfrm, pmtu); in xfrm_init_pmtu()
3850 if (dst->xfrm->km.state != XFRM_STATE_VALID) in xfrm_bundle_ok()
3852 if (xdst->xfrm_genid != dst->xfrm->genid) in xfrm_bundle_ok()
3875 } while (dst->xfrm); in xfrm_bundle_ok()
3885 mtu = xfrm_state_mtu(dst->xfrm, mtu); in xfrm_bundle_ok()
3914 while (dst->xfrm) { in xfrm_get_dst_nexthop()
3915 const struct xfrm_state *xfrm = dst->xfrm; in xfrm_get_dst_nexthop() local
3919 if (xfrm->props.mode == XFRM_MODE_TRANSPORT) in xfrm_get_dst_nexthop()
3921 if (xfrm->type->flags & XFRM_TYPE_REMOTE_COADDR) in xfrm_get_dst_nexthop()
3922 daddr = xfrm->coaddr; in xfrm_get_dst_nexthop()
3923 else if (!(xfrm->type->flags & XFRM_TYPE_LOCAL_COADDR)) in xfrm_get_dst_nexthop()
3924 daddr = &xfrm->id.daddr; in xfrm_get_dst_nexthop()
4067 net->xfrm.policy_byidx = xfrm_hash_alloc(sz); in xfrm_policy_init()
4068 if (!net->xfrm.policy_byidx) in xfrm_policy_init()
4070 net->xfrm.policy_idx_hmask = hmask; in xfrm_policy_init()
4075 net->xfrm.policy_count[dir] = 0; in xfrm_policy_init()
4076 net->xfrm.policy_count[XFRM_POLICY_MAX + dir] = 0; in xfrm_policy_init()
4077 INIT_HLIST_HEAD(&net->xfrm.policy_inexact[dir]); in xfrm_policy_init()
4079 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_init()
4089 net->xfrm.policy_hthresh.lbits4 = 32; in xfrm_policy_init()
4090 net->xfrm.policy_hthresh.rbits4 = 32; in xfrm_policy_init()
4091 net->xfrm.policy_hthresh.lbits6 = 128; in xfrm_policy_init()
4092 net->xfrm.policy_hthresh.rbits6 = 128; in xfrm_policy_init()
4094 seqlock_init(&net->xfrm.policy_hthresh.lock); in xfrm_policy_init()
4096 INIT_LIST_HEAD(&net->xfrm.policy_all); in xfrm_policy_init()
4097 INIT_LIST_HEAD(&net->xfrm.inexact_bins); in xfrm_policy_init()
4098 INIT_WORK(&net->xfrm.policy_hash_work, xfrm_hash_resize); in xfrm_policy_init()
4099 INIT_WORK(&net->xfrm.policy_hthresh.work, xfrm_hash_rebuild); in xfrm_policy_init()
4106 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_init()
4109 xfrm_hash_free(net->xfrm.policy_byidx, sz); in xfrm_policy_init()
4120 flush_work(&net->xfrm.policy_hash_work); in xfrm_policy_fini()
4126 WARN_ON(!list_empty(&net->xfrm.policy_all)); in xfrm_policy_fini()
4131 WARN_ON(!hlist_empty(&net->xfrm.policy_inexact[dir])); in xfrm_policy_fini()
4133 htab = &net->xfrm.policy_bydst[dir]; in xfrm_policy_fini()
4139 sz = (net->xfrm.policy_idx_hmask + 1) * sizeof(struct hlist_head); in xfrm_policy_fini()
4140 WARN_ON(!hlist_empty(net->xfrm.policy_byidx)); in xfrm_policy_fini()
4141 xfrm_hash_free(net->xfrm.policy_byidx, sz); in xfrm_policy_fini()
4143 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_fini()
4144 list_for_each_entry_safe(b, t, &net->xfrm.inexact_bins, inexact_bins) in xfrm_policy_fini()
4146 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_policy_fini()
4154 spin_lock_init(&net->xfrm.xfrm_state_lock); in xfrm_net_init()
4155 spin_lock_init(&net->xfrm.xfrm_policy_lock); in xfrm_net_init()
4156 mutex_init(&net->xfrm.xfrm_cfg_mutex); in xfrm_net_init()
4305 spin_lock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_migrate_policy_find()
4316 chain = &net->xfrm.policy_inexact[dir]; in xfrm_migrate_policy_find()
4331 spin_unlock_bh(&net->xfrm.xfrm_policy_lock); in xfrm_migrate_policy_find()