162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __NETNS_XFRM_H 362306a36Sopenharmony_ci#define __NETNS_XFRM_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <linux/list.h> 662306a36Sopenharmony_ci#include <linux/wait.h> 762306a36Sopenharmony_ci#include <linux/workqueue.h> 862306a36Sopenharmony_ci#include <linux/rhashtable-types.h> 962306a36Sopenharmony_ci#include <linux/xfrm.h> 1062306a36Sopenharmony_ci#include <net/dst_ops.h> 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_cistruct ctl_table_header; 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_cistruct xfrm_policy_hash { 1562306a36Sopenharmony_ci struct hlist_head __rcu *table; 1662306a36Sopenharmony_ci unsigned int hmask; 1762306a36Sopenharmony_ci u8 dbits4; 1862306a36Sopenharmony_ci u8 sbits4; 1962306a36Sopenharmony_ci u8 dbits6; 2062306a36Sopenharmony_ci u8 sbits6; 2162306a36Sopenharmony_ci}; 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_cistruct xfrm_policy_hthresh { 2462306a36Sopenharmony_ci struct work_struct work; 2562306a36Sopenharmony_ci seqlock_t lock; 2662306a36Sopenharmony_ci u8 lbits4; 2762306a36Sopenharmony_ci u8 rbits4; 2862306a36Sopenharmony_ci u8 lbits6; 2962306a36Sopenharmony_ci u8 rbits6; 3062306a36Sopenharmony_ci}; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cistruct netns_xfrm { 3362306a36Sopenharmony_ci struct list_head state_all; 3462306a36Sopenharmony_ci /* 3562306a36Sopenharmony_ci * Hash table to find appropriate SA towards given target (endpoint of 3662306a36Sopenharmony_ci * tunnel or destination of transport mode) allowed by selector. 3762306a36Sopenharmony_ci * 3862306a36Sopenharmony_ci * Main use is finding SA after policy selected tunnel or transport 3962306a36Sopenharmony_ci * mode. Also, it can be used by ah/esp icmp error handler to find 4062306a36Sopenharmony_ci * offending SA. 4162306a36Sopenharmony_ci */ 4262306a36Sopenharmony_ci struct hlist_head __rcu *state_bydst; 4362306a36Sopenharmony_ci struct hlist_head __rcu *state_bysrc; 4462306a36Sopenharmony_ci struct hlist_head __rcu *state_byspi; 4562306a36Sopenharmony_ci struct hlist_head __rcu *state_byseq; 4662306a36Sopenharmony_ci unsigned int state_hmask; 4762306a36Sopenharmony_ci unsigned int state_num; 4862306a36Sopenharmony_ci struct work_struct state_hash_work; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci struct list_head policy_all; 5162306a36Sopenharmony_ci struct hlist_head *policy_byidx; 5262306a36Sopenharmony_ci unsigned int policy_idx_hmask; 5362306a36Sopenharmony_ci unsigned int idx_generator; 5462306a36Sopenharmony_ci struct hlist_head policy_inexact[XFRM_POLICY_MAX]; 5562306a36Sopenharmony_ci struct xfrm_policy_hash policy_bydst[XFRM_POLICY_MAX]; 5662306a36Sopenharmony_ci unsigned int policy_count[XFRM_POLICY_MAX * 2]; 5762306a36Sopenharmony_ci struct work_struct policy_hash_work; 5862306a36Sopenharmony_ci struct xfrm_policy_hthresh policy_hthresh; 5962306a36Sopenharmony_ci struct list_head inexact_bins; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci struct sock *nlsk; 6362306a36Sopenharmony_ci struct sock *nlsk_stash; 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci u32 sysctl_aevent_etime; 6662306a36Sopenharmony_ci u32 sysctl_aevent_rseqth; 6762306a36Sopenharmony_ci int sysctl_larval_drop; 6862306a36Sopenharmony_ci u32 sysctl_acq_expires; 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci u8 policy_default[XFRM_POLICY_MAX]; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#ifdef CONFIG_SYSCTL 7362306a36Sopenharmony_ci struct ctl_table_header *sysctl_hdr; 7462306a36Sopenharmony_ci#endif 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci struct dst_ops xfrm4_dst_ops; 7762306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_IPV6) 7862306a36Sopenharmony_ci struct dst_ops xfrm6_dst_ops; 7962306a36Sopenharmony_ci#endif 8062306a36Sopenharmony_ci spinlock_t xfrm_state_lock; 8162306a36Sopenharmony_ci seqcount_spinlock_t xfrm_state_hash_generation; 8262306a36Sopenharmony_ci seqcount_spinlock_t xfrm_policy_hash_generation; 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci spinlock_t xfrm_policy_lock; 8562306a36Sopenharmony_ci struct mutex xfrm_cfg_mutex; 8662306a36Sopenharmony_ci}; 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci#endif 89