16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2607ca46eSDavid Howells #ifndef _LINUX_XFRM_H 3607ca46eSDavid Howells #define _LINUX_XFRM_H 4607ca46eSDavid Howells 515e318bdSJiri Benc #include <linux/in6.h> 6607ca46eSDavid Howells #include <linux/types.h> 71d495f1cSKees Cook #include <linux/stddef.h> 8607ca46eSDavid Howells 9607ca46eSDavid Howells /* All of the structures in this file may not change size as they are 10607ca46eSDavid Howells * passed into the kernel from userspace via netlink sockets. 11607ca46eSDavid Howells */ 12607ca46eSDavid Howells 13607ca46eSDavid Howells /* Structure to encapsulate addresses. I do not want to use 14607ca46eSDavid Howells * "standard" structure. My apologies. 15607ca46eSDavid Howells */ 16607ca46eSDavid Howells typedef union { 17607ca46eSDavid Howells __be32 a4; 18607ca46eSDavid Howells __be32 a6[4]; 1915e318bdSJiri Benc struct in6_addr in6; 20607ca46eSDavid Howells } xfrm_address_t; 21607ca46eSDavid Howells 22607ca46eSDavid Howells /* Ident of a specific xfrm_state. It is used on input to lookup 23607ca46eSDavid Howells * the state by (spi,daddr,ah/esp) or to store information about 24607ca46eSDavid Howells * spi, protocol and tunnel address on output. 25607ca46eSDavid Howells */ 26607ca46eSDavid Howells struct xfrm_id { 27607ca46eSDavid Howells xfrm_address_t daddr; 28607ca46eSDavid Howells __be32 spi; 29607ca46eSDavid Howells __u8 proto; 30607ca46eSDavid Howells }; 31607ca46eSDavid Howells 32607ca46eSDavid Howells struct xfrm_sec_ctx { 33607ca46eSDavid Howells __u8 ctx_doi; 34607ca46eSDavid Howells __u8 ctx_alg; 35607ca46eSDavid Howells __u16 ctx_len; 36607ca46eSDavid Howells __u32 ctx_sid; 371d495f1cSKees Cook char ctx_str[] __counted_by(ctx_len); 38607ca46eSDavid Howells }; 39607ca46eSDavid Howells 40607ca46eSDavid Howells /* Security Context Domains of Interpretation */ 41607ca46eSDavid Howells #define XFRM_SC_DOI_RESERVED 0 42607ca46eSDavid Howells #define XFRM_SC_DOI_LSM 1 43607ca46eSDavid Howells 44607ca46eSDavid Howells /* Security Context Algorithms */ 45607ca46eSDavid Howells #define XFRM_SC_ALG_RESERVED 0 46607ca46eSDavid Howells #define XFRM_SC_ALG_SELINUX 1 47607ca46eSDavid Howells 48607ca46eSDavid Howells /* Selector, used as selector both on policy rules (SPD) and SAs. */ 49607ca46eSDavid Howells 50607ca46eSDavid Howells struct xfrm_selector { 51607ca46eSDavid Howells xfrm_address_t daddr; 52607ca46eSDavid Howells xfrm_address_t saddr; 53607ca46eSDavid Howells __be16 dport; 54607ca46eSDavid Howells __be16 dport_mask; 55607ca46eSDavid Howells __be16 sport; 56607ca46eSDavid Howells __be16 sport_mask; 57607ca46eSDavid Howells __u16 family; 58607ca46eSDavid Howells __u8 prefixlen_d; 59607ca46eSDavid Howells __u8 prefixlen_s; 60607ca46eSDavid Howells __u8 proto; 61607ca46eSDavid Howells int ifindex; 62607ca46eSDavid Howells __kernel_uid32_t user; 63607ca46eSDavid Howells }; 64607ca46eSDavid Howells 65607ca46eSDavid Howells #define XFRM_INF (~(__u64)0) 66607ca46eSDavid Howells 67607ca46eSDavid Howells struct xfrm_lifetime_cfg { 68607ca46eSDavid Howells __u64 soft_byte_limit; 69607ca46eSDavid Howells __u64 hard_byte_limit; 70607ca46eSDavid Howells __u64 soft_packet_limit; 71607ca46eSDavid Howells __u64 hard_packet_limit; 72607ca46eSDavid Howells __u64 soft_add_expires_seconds; 73607ca46eSDavid Howells __u64 hard_add_expires_seconds; 74607ca46eSDavid Howells __u64 soft_use_expires_seconds; 75607ca46eSDavid Howells __u64 hard_use_expires_seconds; 76607ca46eSDavid Howells }; 77607ca46eSDavid Howells 78607ca46eSDavid Howells struct xfrm_lifetime_cur { 79607ca46eSDavid Howells __u64 bytes; 80607ca46eSDavid Howells __u64 packets; 81607ca46eSDavid Howells __u64 add_time; 82607ca46eSDavid Howells __u64 use_time; 83607ca46eSDavid Howells }; 84607ca46eSDavid Howells 85607ca46eSDavid Howells struct xfrm_replay_state { 86607ca46eSDavid Howells __u32 oseq; 87607ca46eSDavid Howells __u32 seq; 88607ca46eSDavid Howells __u32 bitmap; 89607ca46eSDavid Howells }; 90607ca46eSDavid Howells 91607ca46eSDavid Howells #define XFRMA_REPLAY_ESN_MAX 4096 92607ca46eSDavid Howells 93607ca46eSDavid Howells struct xfrm_replay_state_esn { 94607ca46eSDavid Howells unsigned int bmp_len; 95607ca46eSDavid Howells __u32 oseq; 96607ca46eSDavid Howells __u32 seq; 97607ca46eSDavid Howells __u32 oseq_hi; 98607ca46eSDavid Howells __u32 seq_hi; 99607ca46eSDavid Howells __u32 replay_window; 10094dfc73eSGustavo A. R. Silva __u32 bmp[]; 101607ca46eSDavid Howells }; 102607ca46eSDavid Howells 103607ca46eSDavid Howells struct xfrm_algo { 104607ca46eSDavid Howells char alg_name[64]; 105607ca46eSDavid Howells unsigned int alg_key_len; /* in bits */ 10694dfc73eSGustavo A. R. Silva char alg_key[]; 107607ca46eSDavid Howells }; 108607ca46eSDavid Howells 109607ca46eSDavid Howells struct xfrm_algo_auth { 110607ca46eSDavid Howells char alg_name[64]; 111607ca46eSDavid Howells unsigned int alg_key_len; /* in bits */ 112607ca46eSDavid Howells unsigned int alg_trunc_len; /* in bits */ 11394dfc73eSGustavo A. R. Silva char alg_key[]; 114607ca46eSDavid Howells }; 115607ca46eSDavid Howells 116607ca46eSDavid Howells struct xfrm_algo_aead { 117607ca46eSDavid Howells char alg_name[64]; 118607ca46eSDavid Howells unsigned int alg_key_len; /* in bits */ 119607ca46eSDavid Howells unsigned int alg_icv_len; /* in bits */ 12094dfc73eSGustavo A. R. Silva char alg_key[]; 121607ca46eSDavid Howells }; 122607ca46eSDavid Howells 123607ca46eSDavid Howells struct xfrm_stats { 124607ca46eSDavid Howells __u32 replay_window; 125607ca46eSDavid Howells __u32 replay; 126607ca46eSDavid Howells __u32 integrity_failed; 127607ca46eSDavid Howells }; 128607ca46eSDavid Howells 129607ca46eSDavid Howells enum { 130607ca46eSDavid Howells XFRM_POLICY_TYPE_MAIN = 0, 131607ca46eSDavid Howells XFRM_POLICY_TYPE_SUB = 1, 132607ca46eSDavid Howells XFRM_POLICY_TYPE_MAX = 2, 133607ca46eSDavid Howells XFRM_POLICY_TYPE_ANY = 255 134607ca46eSDavid Howells }; 135607ca46eSDavid Howells 136607ca46eSDavid Howells enum { 137607ca46eSDavid Howells XFRM_POLICY_IN = 0, 138607ca46eSDavid Howells XFRM_POLICY_OUT = 1, 139607ca46eSDavid Howells XFRM_POLICY_FWD = 2, 140607ca46eSDavid Howells XFRM_POLICY_MASK = 3, 141607ca46eSDavid Howells XFRM_POLICY_MAX = 3 142607ca46eSDavid Howells }; 143607ca46eSDavid Howells 144a4a87fa4SAntony Antony enum xfrm_sa_dir { 145a4a87fa4SAntony Antony XFRM_SA_DIR_IN = 1, 146a4a87fa4SAntony Antony XFRM_SA_DIR_OUT = 2 147a4a87fa4SAntony Antony }; 148a4a87fa4SAntony Antony 149607ca46eSDavid Howells enum { 150607ca46eSDavid Howells XFRM_SHARE_ANY, /* No limitations */ 151607ca46eSDavid Howells XFRM_SHARE_SESSION, /* For this session only */ 152607ca46eSDavid Howells XFRM_SHARE_USER, /* For this user only */ 153607ca46eSDavid Howells XFRM_SHARE_UNIQUE /* Use once */ 154607ca46eSDavid Howells }; 155607ca46eSDavid Howells 156607ca46eSDavid Howells #define XFRM_MODE_TRANSPORT 0 157607ca46eSDavid Howells #define XFRM_MODE_TUNNEL 1 158607ca46eSDavid Howells #define XFRM_MODE_ROUTEOPTIMIZATION 2 159607ca46eSDavid Howells #define XFRM_MODE_IN_TRIGGER 3 160607ca46eSDavid Howells #define XFRM_MODE_BEET 4 161*f69eb4f6SChristian Hopps #define XFRM_MODE_IPTFS 5 162*f69eb4f6SChristian Hopps #define XFRM_MODE_MAX 6 163607ca46eSDavid Howells 164607ca46eSDavid Howells /* Netlink configuration messages. */ 165607ca46eSDavid Howells enum { 166607ca46eSDavid Howells XFRM_MSG_BASE = 0x10, 167607ca46eSDavid Howells 168607ca46eSDavid Howells XFRM_MSG_NEWSA = 0x10, 169607ca46eSDavid Howells #define XFRM_MSG_NEWSA XFRM_MSG_NEWSA 170607ca46eSDavid Howells XFRM_MSG_DELSA, 171607ca46eSDavid Howells #define XFRM_MSG_DELSA XFRM_MSG_DELSA 172607ca46eSDavid Howells XFRM_MSG_GETSA, 173607ca46eSDavid Howells #define XFRM_MSG_GETSA XFRM_MSG_GETSA 174607ca46eSDavid Howells 175607ca46eSDavid Howells XFRM_MSG_NEWPOLICY, 176607ca46eSDavid Howells #define XFRM_MSG_NEWPOLICY XFRM_MSG_NEWPOLICY 177607ca46eSDavid Howells XFRM_MSG_DELPOLICY, 178607ca46eSDavid Howells #define XFRM_MSG_DELPOLICY XFRM_MSG_DELPOLICY 179607ca46eSDavid Howells XFRM_MSG_GETPOLICY, 180607ca46eSDavid Howells #define XFRM_MSG_GETPOLICY XFRM_MSG_GETPOLICY 181607ca46eSDavid Howells 182607ca46eSDavid Howells XFRM_MSG_ALLOCSPI, 183607ca46eSDavid Howells #define XFRM_MSG_ALLOCSPI XFRM_MSG_ALLOCSPI 184607ca46eSDavid Howells XFRM_MSG_ACQUIRE, 185607ca46eSDavid Howells #define XFRM_MSG_ACQUIRE XFRM_MSG_ACQUIRE 186607ca46eSDavid Howells XFRM_MSG_EXPIRE, 187607ca46eSDavid Howells #define XFRM_MSG_EXPIRE XFRM_MSG_EXPIRE 188607ca46eSDavid Howells 189607ca46eSDavid Howells XFRM_MSG_UPDPOLICY, 190607ca46eSDavid Howells #define XFRM_MSG_UPDPOLICY XFRM_MSG_UPDPOLICY 191607ca46eSDavid Howells XFRM_MSG_UPDSA, 192607ca46eSDavid Howells #define XFRM_MSG_UPDSA XFRM_MSG_UPDSA 193607ca46eSDavid Howells 194607ca46eSDavid Howells XFRM_MSG_POLEXPIRE, 195607ca46eSDavid Howells #define XFRM_MSG_POLEXPIRE XFRM_MSG_POLEXPIRE 196607ca46eSDavid Howells 197607ca46eSDavid Howells XFRM_MSG_FLUSHSA, 198607ca46eSDavid Howells #define XFRM_MSG_FLUSHSA XFRM_MSG_FLUSHSA 199607ca46eSDavid Howells XFRM_MSG_FLUSHPOLICY, 200607ca46eSDavid Howells #define XFRM_MSG_FLUSHPOLICY XFRM_MSG_FLUSHPOLICY 201607ca46eSDavid Howells 202607ca46eSDavid Howells XFRM_MSG_NEWAE, 203607ca46eSDavid Howells #define XFRM_MSG_NEWAE XFRM_MSG_NEWAE 204607ca46eSDavid Howells XFRM_MSG_GETAE, 205607ca46eSDavid Howells #define XFRM_MSG_GETAE XFRM_MSG_GETAE 206607ca46eSDavid Howells 207607ca46eSDavid Howells XFRM_MSG_REPORT, 208607ca46eSDavid Howells #define XFRM_MSG_REPORT XFRM_MSG_REPORT 209607ca46eSDavid Howells 210607ca46eSDavid Howells XFRM_MSG_MIGRATE, 211607ca46eSDavid Howells #define XFRM_MSG_MIGRATE XFRM_MSG_MIGRATE 212607ca46eSDavid Howells 213607ca46eSDavid Howells XFRM_MSG_NEWSADINFO, 214607ca46eSDavid Howells #define XFRM_MSG_NEWSADINFO XFRM_MSG_NEWSADINFO 215607ca46eSDavid Howells XFRM_MSG_GETSADINFO, 216607ca46eSDavid Howells #define XFRM_MSG_GETSADINFO XFRM_MSG_GETSADINFO 217607ca46eSDavid Howells 218607ca46eSDavid Howells XFRM_MSG_NEWSPDINFO, 219607ca46eSDavid Howells #define XFRM_MSG_NEWSPDINFO XFRM_MSG_NEWSPDINFO 220607ca46eSDavid Howells XFRM_MSG_GETSPDINFO, 221607ca46eSDavid Howells #define XFRM_MSG_GETSPDINFO XFRM_MSG_GETSPDINFO 222607ca46eSDavid Howells 223844f7eaaSEugene Syromiatnikov XFRM_MSG_MAPPING, 224844f7eaaSEugene Syromiatnikov #define XFRM_MSG_MAPPING XFRM_MSG_MAPPING 225844f7eaaSEugene Syromiatnikov 2262d151d39SSteffen Klassert XFRM_MSG_SETDEFAULT, 2272d151d39SSteffen Klassert #define XFRM_MSG_SETDEFAULT XFRM_MSG_SETDEFAULT 2282d151d39SSteffen Klassert XFRM_MSG_GETDEFAULT, 2292d151d39SSteffen Klassert #define XFRM_MSG_GETDEFAULT XFRM_MSG_GETDEFAULT 230607ca46eSDavid Howells __XFRM_MSG_MAX 231607ca46eSDavid Howells }; 232607ca46eSDavid Howells #define XFRM_MSG_MAX (__XFRM_MSG_MAX - 1) 233607ca46eSDavid Howells 234607ca46eSDavid Howells #define XFRM_NR_MSGTYPES (XFRM_MSG_MAX + 1 - XFRM_MSG_BASE) 235607ca46eSDavid Howells 236607ca46eSDavid Howells /* 237b6d2e438SAntony Antony * Generic LSM security context for communicating to user space 238607ca46eSDavid Howells * NOTE: Same format as sadb_x_sec_ctx 239607ca46eSDavid Howells */ 240607ca46eSDavid Howells struct xfrm_user_sec_ctx { 241607ca46eSDavid Howells __u16 len; 242607ca46eSDavid Howells __u16 exttype; 243607ca46eSDavid Howells __u8 ctx_alg; /* LSMs: e.g., selinux == 1 */ 244607ca46eSDavid Howells __u8 ctx_doi; 245607ca46eSDavid Howells __u16 ctx_len; 246607ca46eSDavid Howells }; 247607ca46eSDavid Howells 248607ca46eSDavid Howells struct xfrm_user_tmpl { 249607ca46eSDavid Howells struct xfrm_id id; 250607ca46eSDavid Howells __u16 family; 251607ca46eSDavid Howells xfrm_address_t saddr; 252607ca46eSDavid Howells __u32 reqid; 253607ca46eSDavid Howells __u8 mode; 254607ca46eSDavid Howells __u8 share; 255607ca46eSDavid Howells __u8 optional; 256607ca46eSDavid Howells __u32 aalgos; 257607ca46eSDavid Howells __u32 ealgos; 258607ca46eSDavid Howells __u32 calgos; 259607ca46eSDavid Howells }; 260607ca46eSDavid Howells 261607ca46eSDavid Howells struct xfrm_encap_tmpl { 262607ca46eSDavid Howells __u16 encap_type; 263607ca46eSDavid Howells __be16 encap_sport; 264607ca46eSDavid Howells __be16 encap_dport; 265607ca46eSDavid Howells xfrm_address_t encap_oa; 266607ca46eSDavid Howells }; 267607ca46eSDavid Howells 268607ca46eSDavid Howells /* AEVENT flags */ 269607ca46eSDavid Howells enum xfrm_ae_ftype_t { 270607ca46eSDavid Howells XFRM_AE_UNSPEC, 271607ca46eSDavid Howells XFRM_AE_RTHR=1, /* replay threshold*/ 272607ca46eSDavid Howells XFRM_AE_RVAL=2, /* replay value */ 273607ca46eSDavid Howells XFRM_AE_LVAL=4, /* lifetime value */ 274607ca46eSDavid Howells XFRM_AE_ETHR=8, /* expiry timer threshold */ 275607ca46eSDavid Howells XFRM_AE_CR=16, /* Event cause is replay update */ 276607ca46eSDavid Howells XFRM_AE_CE=32, /* Event cause is timer expiry */ 277607ca46eSDavid Howells XFRM_AE_CU=64, /* Event cause is policy update */ 278607ca46eSDavid Howells __XFRM_AE_MAX 279607ca46eSDavid Howells 280607ca46eSDavid Howells #define XFRM_AE_MAX (__XFRM_AE_MAX - 1) 281607ca46eSDavid Howells }; 282607ca46eSDavid Howells 283607ca46eSDavid Howells struct xfrm_userpolicy_type { 284607ca46eSDavid Howells __u8 type; 285607ca46eSDavid Howells __u16 reserved1; 286607ca46eSDavid Howells __u8 reserved2; 287607ca46eSDavid Howells }; 288607ca46eSDavid Howells 289607ca46eSDavid Howells /* Netlink message attributes. */ 290607ca46eSDavid Howells enum xfrm_attr_type_t { 291607ca46eSDavid Howells XFRMA_UNSPEC, 292607ca46eSDavid Howells XFRMA_ALG_AUTH, /* struct xfrm_algo */ 293607ca46eSDavid Howells XFRMA_ALG_CRYPT, /* struct xfrm_algo */ 294607ca46eSDavid Howells XFRMA_ALG_COMP, /* struct xfrm_algo */ 295607ca46eSDavid Howells XFRMA_ENCAP, /* struct xfrm_algo + struct xfrm_encap_tmpl */ 296607ca46eSDavid Howells XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */ 297607ca46eSDavid Howells XFRMA_SA, /* struct xfrm_usersa_info */ 298607ca46eSDavid Howells XFRMA_POLICY, /*struct xfrm_userpolicy_info */ 299607ca46eSDavid Howells XFRMA_SEC_CTX, /* struct xfrm_sec_ctx */ 300607ca46eSDavid Howells XFRMA_LTIME_VAL, 301607ca46eSDavid Howells XFRMA_REPLAY_VAL, 302607ca46eSDavid Howells XFRMA_REPLAY_THRESH, 303607ca46eSDavid Howells XFRMA_ETIMER_THRESH, 304607ca46eSDavid Howells XFRMA_SRCADDR, /* xfrm_address_t */ 305607ca46eSDavid Howells XFRMA_COADDR, /* xfrm_address_t */ 30636d76350SAntony Antony XFRMA_LASTUSED, /* __u64 */ 307607ca46eSDavid Howells XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */ 308607ca46eSDavid Howells XFRMA_MIGRATE, 309607ca46eSDavid Howells XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */ 310607ca46eSDavid Howells XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */ 311607ca46eSDavid Howells XFRMA_ALG_AUTH_TRUNC, /* struct xfrm_algo_auth */ 312607ca46eSDavid Howells XFRMA_MARK, /* struct xfrm_mark */ 313607ca46eSDavid Howells XFRMA_TFCPAD, /* __u32 */ 31434a3d4b2SRichard Guy Briggs XFRMA_REPLAY_ESN_VAL, /* struct xfrm_replay_state_esn */ 315a947b0a9SNicolas Dichtel XFRMA_SA_EXTRA_FLAGS, /* __u32 */ 316d3623099SNicolas Dichtel XFRMA_PROTO, /* __u8 */ 317870a2df4SNicolas Dichtel XFRMA_ADDRESS_FILTER, /* struct xfrm_address_filter */ 318de95c4a4SNicolas Dichtel XFRMA_PAD, 31929e42766SAntony Antony XFRMA_OFFLOAD_DEV, /* struct xfrm_user_offload */ 3209b42c1f1SSteffen Klassert XFRMA_SET_MARK, /* __u32 */ 3219b42c1f1SSteffen Klassert XFRMA_SET_MARK_MASK, /* __u32 */ 3227e652640SSteffen Klassert XFRMA_IF_ID, /* __u32 */ 3234e484b3eSAntony Antony XFRMA_MTIMER_THRESH, /* __u32 in seconds for input SA */ 324a4a87fa4SAntony Antony XFRMA_SA_DIR, /* __u8 */ 325f531d13bSEyal Birger XFRMA_NAT_KEEPALIVE_INTERVAL, /* __u32 in seconds for NAT keepalive */ 3261ddf9916SSteffen Klassert XFRMA_SA_PCPU, /* __u32 */ 327*f69eb4f6SChristian Hopps XFRMA_IPTFS_DROP_TIME, /* __u32 in: usec to wait for next seq */ 328*f69eb4f6SChristian Hopps XFRMA_IPTFS_REORDER_WINDOW, /* __u16 in: reorder window size (pkts) */ 329*f69eb4f6SChristian Hopps XFRMA_IPTFS_DONT_FRAG, /* out: don't use fragmentation */ 330*f69eb4f6SChristian Hopps XFRMA_IPTFS_INIT_DELAY, /* __u32 out: initial packet wait delay (usec) */ 331*f69eb4f6SChristian Hopps XFRMA_IPTFS_MAX_QSIZE, /* __u32 out: max ingress queue size (octets) */ 332*f69eb4f6SChristian Hopps XFRMA_IPTFS_PKT_SIZE, /* __u32 out: size of outer packet, 0 for PMTU */ 333607ca46eSDavid Howells __XFRMA_MAX 334607ca46eSDavid Howells 3359b42c1f1SSteffen Klassert #define XFRMA_OUTPUT_MARK XFRMA_SET_MARK /* Compatibility */ 336607ca46eSDavid Howells #define XFRMA_MAX (__XFRMA_MAX - 1) 337607ca46eSDavid Howells }; 338607ca46eSDavid Howells 339607ca46eSDavid Howells struct xfrm_mark { 340607ca46eSDavid Howells __u32 v; /* value */ 341607ca46eSDavid Howells __u32 m; /* mask */ 342607ca46eSDavid Howells }; 343607ca46eSDavid Howells 344607ca46eSDavid Howells enum xfrm_sadattr_type_t { 345607ca46eSDavid Howells XFRMA_SAD_UNSPEC, 346607ca46eSDavid Howells XFRMA_SAD_CNT, 347607ca46eSDavid Howells XFRMA_SAD_HINFO, 348607ca46eSDavid Howells __XFRMA_SAD_MAX 349607ca46eSDavid Howells 350607ca46eSDavid Howells #define XFRMA_SAD_MAX (__XFRMA_SAD_MAX - 1) 351607ca46eSDavid Howells }; 352607ca46eSDavid Howells 353607ca46eSDavid Howells struct xfrmu_sadhinfo { 354607ca46eSDavid Howells __u32 sadhcnt; /* current hash bkts */ 355607ca46eSDavid Howells __u32 sadhmcnt; /* max allowed hash bkts */ 356607ca46eSDavid Howells }; 357607ca46eSDavid Howells 358607ca46eSDavid Howells enum xfrm_spdattr_type_t { 359607ca46eSDavid Howells XFRMA_SPD_UNSPEC, 360607ca46eSDavid Howells XFRMA_SPD_INFO, 361607ca46eSDavid Howells XFRMA_SPD_HINFO, 362880a6fabSChristophe Gouault XFRMA_SPD_IPV4_HTHRESH, 363880a6fabSChristophe Gouault XFRMA_SPD_IPV6_HTHRESH, 364607ca46eSDavid Howells __XFRMA_SPD_MAX 365607ca46eSDavid Howells 366607ca46eSDavid Howells #define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1) 367607ca46eSDavid Howells }; 368607ca46eSDavid Howells 369607ca46eSDavid Howells struct xfrmu_spdinfo { 370607ca46eSDavid Howells __u32 incnt; 371607ca46eSDavid Howells __u32 outcnt; 372607ca46eSDavid Howells __u32 fwdcnt; 373607ca46eSDavid Howells __u32 inscnt; 374607ca46eSDavid Howells __u32 outscnt; 375607ca46eSDavid Howells __u32 fwdscnt; 376607ca46eSDavid Howells }; 377607ca46eSDavid Howells 378607ca46eSDavid Howells struct xfrmu_spdhinfo { 379607ca46eSDavid Howells __u32 spdhcnt; 380607ca46eSDavid Howells __u32 spdhmcnt; 381607ca46eSDavid Howells }; 382607ca46eSDavid Howells 383880a6fabSChristophe Gouault struct xfrmu_spdhthresh { 384880a6fabSChristophe Gouault __u8 lbits; 385880a6fabSChristophe Gouault __u8 rbits; 386880a6fabSChristophe Gouault }; 387880a6fabSChristophe Gouault 388607ca46eSDavid Howells struct xfrm_usersa_info { 389607ca46eSDavid Howells struct xfrm_selector sel; 390607ca46eSDavid Howells struct xfrm_id id; 391607ca46eSDavid Howells xfrm_address_t saddr; 392607ca46eSDavid Howells struct xfrm_lifetime_cfg lft; 393607ca46eSDavid Howells struct xfrm_lifetime_cur curlft; 394607ca46eSDavid Howells struct xfrm_stats stats; 395607ca46eSDavid Howells __u32 seq; 396607ca46eSDavid Howells __u32 reqid; 397607ca46eSDavid Howells __u16 family; 398607ca46eSDavid Howells __u8 mode; /* XFRM_MODE_xxx */ 399607ca46eSDavid Howells __u8 replay_window; 400607ca46eSDavid Howells __u8 flags; 401607ca46eSDavid Howells #define XFRM_STATE_NOECN 1 402607ca46eSDavid Howells #define XFRM_STATE_DECAP_DSCP 2 403607ca46eSDavid Howells #define XFRM_STATE_NOPMTUDISC 4 404607ca46eSDavid Howells #define XFRM_STATE_WILDRECV 8 405607ca46eSDavid Howells #define XFRM_STATE_ICMP 16 406607ca46eSDavid Howells #define XFRM_STATE_AF_UNSPEC 32 407607ca46eSDavid Howells #define XFRM_STATE_ALIGN4 64 408607ca46eSDavid Howells #define XFRM_STATE_ESN 128 409607ca46eSDavid Howells }; 410607ca46eSDavid Howells 411a947b0a9SNicolas Dichtel #define XFRM_SA_XFLAG_DONT_ENCAP_DSCP 1 412428d2459SPetr Vaněk #define XFRM_SA_XFLAG_OSEQ_MAY_WRAP 2 413a947b0a9SNicolas Dichtel 414607ca46eSDavid Howells struct xfrm_usersa_id { 415607ca46eSDavid Howells xfrm_address_t daddr; 416607ca46eSDavid Howells __be32 spi; 417607ca46eSDavid Howells __u16 family; 418607ca46eSDavid Howells __u8 proto; 419607ca46eSDavid Howells }; 420607ca46eSDavid Howells 421607ca46eSDavid Howells struct xfrm_aevent_id { 422607ca46eSDavid Howells struct xfrm_usersa_id sa_id; 423607ca46eSDavid Howells xfrm_address_t saddr; 424607ca46eSDavid Howells __u32 flags; 425607ca46eSDavid Howells __u32 reqid; 426607ca46eSDavid Howells }; 427607ca46eSDavid Howells 428607ca46eSDavid Howells struct xfrm_userspi_info { 429607ca46eSDavid Howells struct xfrm_usersa_info info; 430607ca46eSDavid Howells __u32 min; 431607ca46eSDavid Howells __u32 max; 432607ca46eSDavid Howells }; 433607ca46eSDavid Howells 434607ca46eSDavid Howells struct xfrm_userpolicy_info { 435607ca46eSDavid Howells struct xfrm_selector sel; 436607ca46eSDavid Howells struct xfrm_lifetime_cfg lft; 437607ca46eSDavid Howells struct xfrm_lifetime_cur curlft; 438607ca46eSDavid Howells __u32 priority; 439607ca46eSDavid Howells __u32 index; 440607ca46eSDavid Howells __u8 dir; 441607ca46eSDavid Howells __u8 action; 442607ca46eSDavid Howells #define XFRM_POLICY_ALLOW 0 443607ca46eSDavid Howells #define XFRM_POLICY_BLOCK 1 444607ca46eSDavid Howells __u8 flags; 445607ca46eSDavid Howells #define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */ 446607ca46eSDavid Howells /* Automatically expand selector to include matching ICMP payloads. */ 447607ca46eSDavid Howells #define XFRM_POLICY_ICMP 2 4481ddf9916SSteffen Klassert #define XFRM_POLICY_CPU_ACQUIRE 4 449607ca46eSDavid Howells __u8 share; 450607ca46eSDavid Howells }; 451607ca46eSDavid Howells 452607ca46eSDavid Howells struct xfrm_userpolicy_id { 453607ca46eSDavid Howells struct xfrm_selector sel; 454607ca46eSDavid Howells __u32 index; 455607ca46eSDavid Howells __u8 dir; 456607ca46eSDavid Howells }; 457607ca46eSDavid Howells 458607ca46eSDavid Howells struct xfrm_user_acquire { 459607ca46eSDavid Howells struct xfrm_id id; 460607ca46eSDavid Howells xfrm_address_t saddr; 461607ca46eSDavid Howells struct xfrm_selector sel; 462607ca46eSDavid Howells struct xfrm_userpolicy_info policy; 463607ca46eSDavid Howells __u32 aalgos; 464607ca46eSDavid Howells __u32 ealgos; 465607ca46eSDavid Howells __u32 calgos; 466607ca46eSDavid Howells __u32 seq; 467607ca46eSDavid Howells }; 468607ca46eSDavid Howells 469607ca46eSDavid Howells struct xfrm_user_expire { 470607ca46eSDavid Howells struct xfrm_usersa_info state; 471607ca46eSDavid Howells __u8 hard; 472607ca46eSDavid Howells }; 473607ca46eSDavid Howells 474607ca46eSDavid Howells struct xfrm_user_polexpire { 475607ca46eSDavid Howells struct xfrm_userpolicy_info pol; 476607ca46eSDavid Howells __u8 hard; 477607ca46eSDavid Howells }; 478607ca46eSDavid Howells 479607ca46eSDavid Howells struct xfrm_usersa_flush { 480607ca46eSDavid Howells __u8 proto; 481607ca46eSDavid Howells }; 482607ca46eSDavid Howells 483607ca46eSDavid Howells struct xfrm_user_report { 484607ca46eSDavid Howells __u8 proto; 485607ca46eSDavid Howells struct xfrm_selector sel; 486607ca46eSDavid Howells }; 487607ca46eSDavid Howells 488607ca46eSDavid Howells /* Used by MIGRATE to pass addresses IKE should use to perform 489607ca46eSDavid Howells * SA negotiation with the peer */ 490607ca46eSDavid Howells struct xfrm_user_kmaddress { 491607ca46eSDavid Howells xfrm_address_t local; 492607ca46eSDavid Howells xfrm_address_t remote; 493607ca46eSDavid Howells __u32 reserved; 494607ca46eSDavid Howells __u16 family; 495607ca46eSDavid Howells }; 496607ca46eSDavid Howells 497607ca46eSDavid Howells struct xfrm_user_migrate { 498607ca46eSDavid Howells xfrm_address_t old_daddr; 499607ca46eSDavid Howells xfrm_address_t old_saddr; 500607ca46eSDavid Howells xfrm_address_t new_daddr; 501607ca46eSDavid Howells xfrm_address_t new_saddr; 502607ca46eSDavid Howells __u8 proto; 503607ca46eSDavid Howells __u8 mode; 504607ca46eSDavid Howells __u16 reserved; 505607ca46eSDavid Howells __u32 reqid; 506607ca46eSDavid Howells __u16 old_family; 507607ca46eSDavid Howells __u16 new_family; 508607ca46eSDavid Howells }; 509607ca46eSDavid Howells 510607ca46eSDavid Howells struct xfrm_user_mapping { 511607ca46eSDavid Howells struct xfrm_usersa_id id; 512607ca46eSDavid Howells __u32 reqid; 513607ca46eSDavid Howells xfrm_address_t old_saddr; 514607ca46eSDavid Howells xfrm_address_t new_saddr; 515607ca46eSDavid Howells __be16 old_sport; 516607ca46eSDavid Howells __be16 new_sport; 517607ca46eSDavid Howells }; 518607ca46eSDavid Howells 519870a2df4SNicolas Dichtel struct xfrm_address_filter { 520d3623099SNicolas Dichtel xfrm_address_t saddr; 521d3623099SNicolas Dichtel xfrm_address_t daddr; 522d3623099SNicolas Dichtel __u16 family; 523d3623099SNicolas Dichtel __u8 splen; 524d3623099SNicolas Dichtel __u8 dplen; 525d3623099SNicolas Dichtel }; 526d3623099SNicolas Dichtel 527d77e38e6SSteffen Klassert struct xfrm_user_offload { 528d77e38e6SSteffen Klassert int ifindex; 529d77e38e6SSteffen Klassert __u8 flags; 530d77e38e6SSteffen Klassert }; 5315e25c25aSPetr Vaněk /* This flag was exposed without any kernel code that supports it. 5325e25c25aSPetr Vaněk * Unfortunately, strongswan has the code that sets this flag, 5335e25c25aSPetr Vaněk * which makes it impossible to reuse this bit. 5347c76ecd9SLeon Romanovsky * 5357c76ecd9SLeon Romanovsky * So leave it here to make sure that it won't be reused by mistake. 5367c76ecd9SLeon Romanovsky */ 537d77e38e6SSteffen Klassert #define XFRM_OFFLOAD_IPV6 1 538d77e38e6SSteffen Klassert #define XFRM_OFFLOAD_INBOUND 2 539d14f28b8SLeon Romanovsky /* Two bits above are relevant for state path only, while 540d14f28b8SLeon Romanovsky * offload is used for both policy and state flows. 541d14f28b8SLeon Romanovsky * 542d14f28b8SLeon Romanovsky * In policy offload mode, they are free and can be safely reused. 543d14f28b8SLeon Romanovsky */ 544d14f28b8SLeon Romanovsky #define XFRM_OFFLOAD_PACKET 4 545d77e38e6SSteffen Klassert 5462d151d39SSteffen Klassert struct xfrm_userpolicy_default { 547f8d858e6SNicolas Dichtel #define XFRM_USERPOLICY_UNSPEC 0 548f8d858e6SNicolas Dichtel #define XFRM_USERPOLICY_BLOCK 1 549f8d858e6SNicolas Dichtel #define XFRM_USERPOLICY_ACCEPT 2 550f8d858e6SNicolas Dichtel __u8 in; 551f8d858e6SNicolas Dichtel __u8 fwd; 552f8d858e6SNicolas Dichtel __u8 out; 5532d151d39SSteffen Klassert }; 5542d151d39SSteffen Klassert 555607ca46eSDavid Howells #ifndef __KERNEL__ 556607ca46eSDavid Howells /* backwards compatibility for userspace */ 557607ca46eSDavid Howells #define XFRMGRP_ACQUIRE 1 558607ca46eSDavid Howells #define XFRMGRP_EXPIRE 2 559607ca46eSDavid Howells #define XFRMGRP_SA 4 560607ca46eSDavid Howells #define XFRMGRP_POLICY 8 561607ca46eSDavid Howells #define XFRMGRP_REPORT 0x20 562607ca46eSDavid Howells #endif 563607ca46eSDavid Howells 564607ca46eSDavid Howells enum xfrm_nlgroups { 565607ca46eSDavid Howells XFRMNLGRP_NONE, 566607ca46eSDavid Howells #define XFRMNLGRP_NONE XFRMNLGRP_NONE 567607ca46eSDavid Howells XFRMNLGRP_ACQUIRE, 568607ca46eSDavid Howells #define XFRMNLGRP_ACQUIRE XFRMNLGRP_ACQUIRE 569607ca46eSDavid Howells XFRMNLGRP_EXPIRE, 570607ca46eSDavid Howells #define XFRMNLGRP_EXPIRE XFRMNLGRP_EXPIRE 571607ca46eSDavid Howells XFRMNLGRP_SA, 572607ca46eSDavid Howells #define XFRMNLGRP_SA XFRMNLGRP_SA 573607ca46eSDavid Howells XFRMNLGRP_POLICY, 574607ca46eSDavid Howells #define XFRMNLGRP_POLICY XFRMNLGRP_POLICY 575607ca46eSDavid Howells XFRMNLGRP_AEVENTS, 576607ca46eSDavid Howells #define XFRMNLGRP_AEVENTS XFRMNLGRP_AEVENTS 577607ca46eSDavid Howells XFRMNLGRP_REPORT, 578607ca46eSDavid Howells #define XFRMNLGRP_REPORT XFRMNLGRP_REPORT 579607ca46eSDavid Howells XFRMNLGRP_MIGRATE, 580607ca46eSDavid Howells #define XFRMNLGRP_MIGRATE XFRMNLGRP_MIGRATE 581607ca46eSDavid Howells XFRMNLGRP_MAPPING, 582607ca46eSDavid Howells #define XFRMNLGRP_MAPPING XFRMNLGRP_MAPPING 583607ca46eSDavid Howells __XFRMNLGRP_MAX 584607ca46eSDavid Howells }; 585607ca46eSDavid Howells #define XFRMNLGRP_MAX (__XFRMNLGRP_MAX - 1) 586607ca46eSDavid Howells 587607ca46eSDavid Howells #endif /* _LINUX_XFRM_H */ 588