18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __NETNS_XFRM_H 38c2ecf20Sopenharmony_ci#define __NETNS_XFRM_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/list.h> 68c2ecf20Sopenharmony_ci#include <linux/wait.h> 78c2ecf20Sopenharmony_ci#include <linux/workqueue.h> 88c2ecf20Sopenharmony_ci#include <linux/rhashtable-types.h> 98c2ecf20Sopenharmony_ci#include <linux/xfrm.h> 108c2ecf20Sopenharmony_ci#include <net/dst_ops.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_cistruct ctl_table_header; 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cistruct xfrm_policy_hash { 158c2ecf20Sopenharmony_ci struct hlist_head __rcu *table; 168c2ecf20Sopenharmony_ci unsigned int hmask; 178c2ecf20Sopenharmony_ci u8 dbits4; 188c2ecf20Sopenharmony_ci u8 sbits4; 198c2ecf20Sopenharmony_ci u8 dbits6; 208c2ecf20Sopenharmony_ci u8 sbits6; 218c2ecf20Sopenharmony_ci}; 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_cistruct xfrm_policy_hthresh { 248c2ecf20Sopenharmony_ci struct work_struct work; 258c2ecf20Sopenharmony_ci seqlock_t lock; 268c2ecf20Sopenharmony_ci u8 lbits4; 278c2ecf20Sopenharmony_ci u8 rbits4; 288c2ecf20Sopenharmony_ci u8 lbits6; 298c2ecf20Sopenharmony_ci u8 rbits6; 308c2ecf20Sopenharmony_ci}; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistruct netns_xfrm { 338c2ecf20Sopenharmony_ci struct list_head state_all; 348c2ecf20Sopenharmony_ci /* 358c2ecf20Sopenharmony_ci * Hash table to find appropriate SA towards given target (endpoint of 368c2ecf20Sopenharmony_ci * tunnel or destination of transport mode) allowed by selector. 378c2ecf20Sopenharmony_ci * 388c2ecf20Sopenharmony_ci * Main use is finding SA after policy selected tunnel or transport 398c2ecf20Sopenharmony_ci * mode. Also, it can be used by ah/esp icmp error handler to find 408c2ecf20Sopenharmony_ci * offending SA. 418c2ecf20Sopenharmony_ci */ 428c2ecf20Sopenharmony_ci struct hlist_head __rcu *state_bydst; 438c2ecf20Sopenharmony_ci struct hlist_head __rcu *state_bysrc; 448c2ecf20Sopenharmony_ci struct hlist_head __rcu *state_byspi; 458c2ecf20Sopenharmony_ci unsigned int state_hmask; 468c2ecf20Sopenharmony_ci unsigned int state_num; 478c2ecf20Sopenharmony_ci struct work_struct state_hash_work; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci struct list_head policy_all; 508c2ecf20Sopenharmony_ci struct hlist_head *policy_byidx; 518c2ecf20Sopenharmony_ci unsigned int policy_idx_hmask; 528c2ecf20Sopenharmony_ci unsigned int idx_generator; 538c2ecf20Sopenharmony_ci struct hlist_head policy_inexact[XFRM_POLICY_MAX]; 548c2ecf20Sopenharmony_ci struct xfrm_policy_hash policy_bydst[XFRM_POLICY_MAX]; 558c2ecf20Sopenharmony_ci unsigned int policy_count[XFRM_POLICY_MAX * 2]; 568c2ecf20Sopenharmony_ci struct work_struct policy_hash_work; 578c2ecf20Sopenharmony_ci struct xfrm_policy_hthresh policy_hthresh; 588c2ecf20Sopenharmony_ci struct list_head inexact_bins; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci struct sock *nlsk; 628c2ecf20Sopenharmony_ci struct sock *nlsk_stash; 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci u32 sysctl_aevent_etime; 658c2ecf20Sopenharmony_ci u32 sysctl_aevent_rseqth; 668c2ecf20Sopenharmony_ci int sysctl_larval_drop; 678c2ecf20Sopenharmony_ci u32 sysctl_acq_expires; 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci u8 policy_default[XFRM_POLICY_MAX]; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci#ifdef CONFIG_SYSCTL 728c2ecf20Sopenharmony_ci struct ctl_table_header *sysctl_hdr; 738c2ecf20Sopenharmony_ci#endif 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci struct dst_ops xfrm4_dst_ops; 768c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_IPV6) 778c2ecf20Sopenharmony_ci struct dst_ops xfrm6_dst_ops; 788c2ecf20Sopenharmony_ci#endif 798c2ecf20Sopenharmony_ci spinlock_t xfrm_state_lock; 808c2ecf20Sopenharmony_ci seqcount_t xfrm_state_hash_generation; 818c2ecf20Sopenharmony_ci seqcount_spinlock_t xfrm_policy_hash_generation; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci spinlock_t xfrm_policy_lock; 848c2ecf20Sopenharmony_ci struct mutex xfrm_cfg_mutex; 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#endif 88