Lines Matching refs:xfrm

35 	rcu_dereference_protected((table), lockdep_is_held(&(net)->xfrm.xfrm_state_lock))
63 return __xfrm_dst_hash(daddr, saddr, reqid, family, net->xfrm.state_hmask); in xfrm_dst_hash()
71 return __xfrm_src_hash(daddr, saddr, family, net->xfrm.state_hmask); in xfrm_src_hash()
78 return __xfrm_spi_hash(daddr, spi, proto, family, net->xfrm.state_hmask); in xfrm_spi_hash()
83 return __xfrm_seq_hash(seq, net->xfrm.state_hmask); in xfrm_seq_hash()
130 struct net *net = container_of(work, struct net, xfrm.state_hash_work); in xfrm_hash_resize()
136 nsize = xfrm_hash_new_size(net->xfrm.state_hmask); in xfrm_hash_resize()
159 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_hash_resize()
160 write_seqcount_begin(&net->xfrm.xfrm_state_hash_generation); in xfrm_hash_resize()
163 odst = xfrm_state_deref_prot(net->xfrm.state_bydst, net); in xfrm_hash_resize()
164 for (i = net->xfrm.state_hmask; i >= 0; i--) in xfrm_hash_resize()
167 osrc = xfrm_state_deref_prot(net->xfrm.state_bysrc, net); in xfrm_hash_resize()
168 ospi = xfrm_state_deref_prot(net->xfrm.state_byspi, net); in xfrm_hash_resize()
169 oseq = xfrm_state_deref_prot(net->xfrm.state_byseq, net); in xfrm_hash_resize()
170 ohashmask = net->xfrm.state_hmask; in xfrm_hash_resize()
172 rcu_assign_pointer(net->xfrm.state_bydst, ndst); in xfrm_hash_resize()
173 rcu_assign_pointer(net->xfrm.state_bysrc, nsrc); in xfrm_hash_resize()
174 rcu_assign_pointer(net->xfrm.state_byspi, nspi); in xfrm_hash_resize()
175 rcu_assign_pointer(net->xfrm.state_byseq, nseq); in xfrm_hash_resize()
176 net->xfrm.state_hmask = nhashmask; in xfrm_hash_resize()
178 write_seqcount_end(&net->xfrm.xfrm_state_hash_generation); in xfrm_hash_resize()
179 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_hash_resize()
685 spin_lock(&net->xfrm.xfrm_state_lock); in __xfrm_state_delete()
693 net->xfrm.state_num--; in __xfrm_state_delete()
694 spin_unlock(&net->xfrm.xfrm_state_lock); in __xfrm_state_delete()
731 for (i = 0; i <= net->xfrm.state_hmask; i++) { in xfrm_state_flush_secctx_check()
734 hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) { in xfrm_state_flush_secctx_check()
751 for (i = 0; i <= net->xfrm.state_hmask; i++) { in xfrm_dev_state_flush_secctx_check()
755 hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) { in xfrm_dev_state_flush_secctx_check()
786 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_flush()
792 for (i = 0; i <= net->xfrm.state_hmask; i++) { in xfrm_state_flush()
795 hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) { in xfrm_state_flush()
799 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_flush()
811 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_flush()
817 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_flush()
829 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_dev_state_flush()
835 for (i = 0; i <= net->xfrm.state_hmask; i++) { in xfrm_dev_state_flush()
839 hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) { in xfrm_dev_state_flush()
844 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_dev_state_flush()
853 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_dev_state_flush()
862 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_dev_state_flush()
869 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_sad_getinfo()
870 si->sadcnt = net->xfrm.state_num; in xfrm_sad_getinfo()
871 si->sadhcnt = net->xfrm.state_hmask + 1; in xfrm_sad_getinfo()
873 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_sad_getinfo()
961 hlist_for_each_entry_rcu(x, net->xfrm.state_byspi + h, byspi) { in __xfrm_state_lookup()
986 hlist_for_each_entry_rcu(x, net->xfrm.state_bysrc + h, bysrc) { in __xfrm_state_lookup_byaddr()
1022 (net->xfrm.state_hmask + 1) < xfrm_state_hashmax && in xfrm_hash_grow_check()
1023 net->xfrm.state_num > net->xfrm.state_hmask) in xfrm_hash_grow_check()
1024 schedule_work(&net->xfrm.state_hash_work); in xfrm_hash_grow_check()
1089 sequence = read_seqcount_begin(&net->xfrm.xfrm_state_hash_generation); in xfrm_state_find()
1093 hlist_for_each_entry_rcu(x, net->xfrm.state_bydst + h, bydst) { in xfrm_state_find()
1110 hlist_for_each_entry_rcu(x, net->xfrm.state_bydst + h_wildcard, bydst) { in xfrm_state_find()
1165 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_find()
1167 list_add(&x->km.all, &net->xfrm.state_all); in xfrm_state_find()
1168 hlist_add_head_rcu(&x->bydst, net->xfrm.state_bydst + h); in xfrm_state_find()
1170 hlist_add_head_rcu(&x->bysrc, net->xfrm.state_bysrc + h); in xfrm_state_find()
1173 hlist_add_head_rcu(&x->byspi, net->xfrm.state_byspi + h); in xfrm_state_find()
1177 hlist_add_head_rcu(&x->byseq, net->xfrm.state_byseq + h); in xfrm_state_find()
1179 x->lft.hard_add_expires_seconds = net->xfrm.sysctl_acq_expires; in xfrm_state_find()
1181 ktime_set(net->xfrm.sysctl_acq_expires, 0), in xfrm_state_find()
1183 net->xfrm.state_num++; in xfrm_state_find()
1185 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_find()
1206 if (read_seqcount_retry(&net->xfrm.xfrm_state_hash_generation, sequence)) { in xfrm_state_find()
1225 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_stateonly_find()
1227 hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) { in xfrm_stateonly_find()
1244 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_stateonly_find()
1257 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_lookup_byspi()
1258 list_for_each_entry(w, &net->xfrm.state_all, all) { in xfrm_state_lookup_byspi()
1265 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_lookup_byspi()
1268 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_lookup_byspi()
1278 list_add(&x->km.all, &net->xfrm.state_all); in __xfrm_state_insert()
1282 hlist_add_head_rcu(&x->bydst, net->xfrm.state_bydst + h); in __xfrm_state_insert()
1285 hlist_add_head_rcu(&x->bysrc, net->xfrm.state_bysrc + h); in __xfrm_state_insert()
1291 hlist_add_head_rcu(&x->byspi, net->xfrm.state_byspi + h); in __xfrm_state_insert()
1297 hlist_add_head_rcu(&x->byseq, net->xfrm.state_byseq + h); in __xfrm_state_insert()
1304 net->xfrm.state_num++; in __xfrm_state_insert()
1321 hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) { in __xfrm_state_bump_genids()
1336 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_insert()
1339 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_insert()
1356 hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) { in __find_acq_core()
1405 x->lft.hard_add_expires_seconds = net->xfrm.sysctl_acq_expires; in __find_acq_core()
1408 ktime_set(net->xfrm.sysctl_acq_expires, 0), in __find_acq_core()
1410 list_add(&x->km.all, &net->xfrm.state_all); in __find_acq_core()
1411 hlist_add_head_rcu(&x->bydst, net->xfrm.state_bydst + h); in __find_acq_core()
1413 hlist_add_head_rcu(&x->bysrc, net->xfrm.state_bysrc + h); in __find_acq_core()
1415 net->xfrm.state_num++; in __find_acq_core()
1438 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_add()
1467 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_add()
1610 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_migrate_state_find()
1615 hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) { in xfrm_migrate_state_find()
1632 hlist_for_each_entry(x, net->xfrm.state_bysrc+h, bysrc) { in xfrm_migrate_state_find()
1646 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_migrate_state_find()
1692 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_update()
1712 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_update()
1749 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_update()
1758 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_update()
1817 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_lookup_byaddr()
1819 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_lookup_byaddr()
1831 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_find_acq()
1833 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_find_acq()
1972 hlist_for_each_entry_rcu(x, net->xfrm.state_byseq + h, byseq) { in __xfrm_find_acq_byseq()
1988 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_find_acq_byseq()
1990 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_find_acq_byseq()
2073 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_alloc_spi()
2076 hlist_add_head_rcu(&x->byspi, net->xfrm.state_byspi + h); in xfrm_alloc_spi()
2077 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_alloc_spi()
2117 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_walk()
2119 x = list_first_entry(&net->xfrm.state_all, struct xfrm_state_walk, all); in xfrm_state_walk()
2122 list_for_each_entry_from(x, &net->xfrm.state_all, all) { in xfrm_state_walk()
2143 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_walk()
2166 spin_lock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_walk_done()
2168 spin_unlock_bh(&net->xfrm.xfrm_state_lock); in xfrm_state_walk_done()
2692 INIT_LIST_HEAD(&net->xfrm.state_all); in xfrm_state_init()
2696 net->xfrm.state_bydst = xfrm_hash_alloc(sz); in xfrm_state_init()
2697 if (!net->xfrm.state_bydst) in xfrm_state_init()
2699 net->xfrm.state_bysrc = xfrm_hash_alloc(sz); in xfrm_state_init()
2700 if (!net->xfrm.state_bysrc) in xfrm_state_init()
2702 net->xfrm.state_byspi = xfrm_hash_alloc(sz); in xfrm_state_init()
2703 if (!net->xfrm.state_byspi) in xfrm_state_init()
2705 net->xfrm.state_byseq = xfrm_hash_alloc(sz); in xfrm_state_init()
2706 if (!net->xfrm.state_byseq) in xfrm_state_init()
2708 net->xfrm.state_hmask = ((sz / sizeof(struct hlist_head)) - 1); in xfrm_state_init()
2710 net->xfrm.state_num = 0; in xfrm_state_init()
2711 INIT_WORK(&net->xfrm.state_hash_work, xfrm_hash_resize); in xfrm_state_init()
2712 spin_lock_init(&net->xfrm.xfrm_state_lock); in xfrm_state_init()
2713 seqcount_spinlock_init(&net->xfrm.xfrm_state_hash_generation, in xfrm_state_init()
2714 &net->xfrm.xfrm_state_lock); in xfrm_state_init()
2718 xfrm_hash_free(net->xfrm.state_byspi, sz); in xfrm_state_init()
2720 xfrm_hash_free(net->xfrm.state_bysrc, sz); in xfrm_state_init()
2722 xfrm_hash_free(net->xfrm.state_bydst, sz); in xfrm_state_init()
2731 flush_work(&net->xfrm.state_hash_work); in xfrm_state_fini()
2735 WARN_ON(!list_empty(&net->xfrm.state_all)); in xfrm_state_fini()
2737 sz = (net->xfrm.state_hmask + 1) * sizeof(struct hlist_head); in xfrm_state_fini()
2738 WARN_ON(!hlist_empty(net->xfrm.state_byseq)); in xfrm_state_fini()
2739 xfrm_hash_free(net->xfrm.state_byseq, sz); in xfrm_state_fini()
2740 WARN_ON(!hlist_empty(net->xfrm.state_byspi)); in xfrm_state_fini()
2741 xfrm_hash_free(net->xfrm.state_byspi, sz); in xfrm_state_fini()
2742 WARN_ON(!hlist_empty(net->xfrm.state_bysrc)); in xfrm_state_fini()
2743 xfrm_hash_free(net->xfrm.state_bysrc, sz); in xfrm_state_fini()
2744 WARN_ON(!hlist_empty(net->xfrm.state_bydst)); in xfrm_state_fini()
2745 xfrm_hash_free(net->xfrm.state_bydst, sz); in xfrm_state_fini()