|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
32 #define IPSEC_TUN_DEFAULT_HASH_NUM_BUCKETS (64 * 1024)
33 #define IPSEC_TUN_DEFAULT_HASH_MEMORY_SIZE 512 << 20
81 #define ITP_DBG(_itp, _fmt, _args...) \
83 vlib_log_debug(ipsec_tun_protect_logger, \
85 format_ipsec_tun_protect, \
89 #define ITP_DBG2(_fmt, _args...) \
91 vlib_log_debug(ipsec_tun_protect_logger, \
146 if (!(itp->
itp_flags & IPSEC_PROTECT_ITF))
158 if ((sa->
crypto_alg == IPSEC_CRYPTO_ALG_NONE &&
159 sa->
integ_alg == IPSEC_INTEG_ALG_NONE) &&
162 im->esp6_no_crypto_tun_node_index);
163 else if (itp->
itp_flags & IPSEC_PROTECT_L2)
165 im->esp6_encrypt_l2_tun_node_index);
171 next =
im->esp4_encrypt_tun_node_index;
174 next =
im->esp6_encrypt_tun_node_index;
177 next =
im->esp_mpls_encrypt_tun_node_index;
264 clib_host_to_net_u32 (sa->
spi));
266 if (!clib_bihash_is_initialised_8_16 (&
im->tun4_protect_by_key))
267 clib_bihash_init_8_16 (&
im->tun4_protect_by_key,
268 "IPSec IPv4 tunnels",
272 clib_bihash_add_del_8_16 (&
im->tun4_protect_by_key, bkey, 1);
280 .spi = clib_host_to_net_u32 (sa->
spi),
286 if (!clib_bihash_is_initialised_24_16 (&
im->tun6_protect_by_key))
287 clib_bihash_init_24_16 (&
im->tun6_protect_by_key,
288 "IPSec IPv6 tunnels",
291 clib_bihash_add_del_24_16 (&
im->tun6_protect_by_key, bkey, 1);
380 ipsec4_tunnel_kv_t key;
381 clib_bihash_kv_8_16_t res, *bkey = (clib_bihash_kv_8_16_t*)&key;
383 ipsec4_tunnel_mk_key(&key, &itp->itp_crypto.dst.ip4,
384 clib_host_to_net_u32 (sa->spi));
386 if (!clib_bihash_search_8_16 (&im->tun4_protect_by_key, bkey, &res))
388 clib_bihash_add_del_8_16 (&im->tun4_protect_by_key, bkey, 0);
389 ipsec_tun_unregister_nodes(AF_IP4);
397 .spi = clib_host_to_net_u32 (sa->
spi),
402 if (!clib_bihash_search_24_16 (&
im->tun6_protect_by_key, bkey, &res))
404 clib_bihash_add_del_24_16 (&
im->tun6_protect_by_key, bkey, 0);
471 if (ipsec_sa_is_set_IS_TUNNEL (sa))
475 if (!(itp->
itp_flags & IPSEC_PROTECT_ITF))
477 ipsec_sa_set_IS_PROTECT (sa);
485 itp->
itp_flags &= ~IPSEC_PROTECT_ENCAPED;
531 ipsec_sa_unset_IS_PROTECT (sa);
578 rv = VNET_API_ERROR_LIMIT_EXCEEDED;
591 if (~0 == sas_in[ii])
593 rv = VNET_API_ERROR_INVALID_VALUE;
602 rv = VNET_API_ERROR_INVALID_VALUE;
617 if (NULL == dev_class->ip_tun_desc)
619 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
653 if (!ipsec_sa_is_set_IS_TUNNEL (sa))
655 rv = VNET_API_ERROR_INVALID_DST_ADDRESS;
731 return (VNET_API_ERROR_NO_SUCH_ENTRY);
936 clib_bihash_init_8_16 (&
im->tun4_protect_by_key,
937 "IPSec IPv4 tunnels", n_buckets, table_size);
939 clib_bihash_init_24_16 (&
im->tun6_protect_by_key,
940 "IPSec IPv6 tunnels", n_buckets, table_size);
949 clib_bihash_init_24_16 (&
im->tun6_protect_by_key,
950 "IPSec IPv6 tunnels",
953 clib_bihash_init_8_16 (&
im->tun4_protect_by_key,
954 "IPSec IPv4 tunnels",
959 im->esp4_no_crypto_tun_node_index =
961 im->esp6_no_crypto_tun_node_index =
963 im->esp6_encrypt_l2_tun_node_index =
965 im->esp4_encrypt_l2_tun_node_index =
void ipsec_itf_adj_stack(adj_index_t ai, u32 sai)
void ip4_unregister_protocol(u32 protocolx)
static adj_walk_rc_t ipsec_tun_protect_adj_remove(adj_index_t ai, void *arg)
const static adj_delegate_vft_t ipsec_tun_adj_delegate_vft
VFT registered with the adjacency delegate.
void adj_delegate_remove(adj_index_t ai, adj_delegate_type_t type)
Remove a delegate from an adjacency.
void ipsec_tun_register_nodes(ip_address_family_t af)
vnet_interface_main_t * im
index_t id_itp
If the interface is P2P then there is only one protect object associated with the auto-adj for each N...
index_t ad_index
The index passed by the provider to identify its delegate instance.
fib_protocol_t ia_nh_proto
The protocol of the neighbor/peer.
ipsec_tun_protect_t * ipsec_tun_protect_pool
Pool of tunnel protection objects.
static void ipsec4_tunnel_mk_key(ipsec4_tunnel_kv_t *k, const ip4_address_t *ip, u32 spi)
void vnet_feature_register(vnet_feature_update_cb_t cb, void *data)
struct _vnet_device_class vnet_device_class_t
An ADJ delegate virtual function table.
ipsec_tun_protect_itf_db_t * id_itf
Per-interface vector.
ipsec_protect_flags_t itp_flags
vlib_node_registration_t ipsec6_tun_input_node
(constructor) VLIB_REGISTER_NODE (ipsec6_tun_input_node)
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
static const ipsec_tun_protect_t * ipsec_tun_protect_from_const_base(const adj_delegate_t *ad)
static ipsec_tun_protect_db_t itp_db
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void ip46_address_reset(ip46_address_t *ip46)
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
static void clib_mem_free(void *p)
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
struct ipsec_tun_protect_db_t_ ipsec_tun_protect_db_t
static void ipsec_tun_protect_set_crypto_addr(ipsec_tun_protect_t *itp)
#define hash_foreach(key_var, value_var, h, body)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
uword * id_hash
A hash table key'd on IP (4 or 6) address.
static uword hash_elts(void *v)
#define hash_set_mem(h, key, value)
#define pool_put(P, E)
Free an object E in pool P.
index_t ipsec_sa_find_and_lock(u32 id)
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
const static teib_vft_t ipsec_tun_teib_vft
static void ipsec_tun_protect_adj_delegate_adj_deleted(adj_delegate_t *ad)
#define IPSEC_TUN_DEFAULT_HASH_MEMORY_SIZE
static void ipsec_tun_protect_adj_delegate_adj_modified(adj_delegate_t *ad)
void ip4_register_protocol(u32 protocol, u32 node_index)
static vnet_device_class_t * vnet_get_device_class(vnet_main_t *vnm, u32 dev_class_index)
static u32 ipsec_tun_protect_get_adj_next(vnet_link_t linkt, const ipsec_tun_protect_t *itp)
u32 esp4_decrypt_tun_node_index
static void ipsec_tun_protect_rx_db_remove(ipsec_main_t *im, const ipsec_tun_protect_t *itp)
void adj_nbr_midchain_update_next_node(adj_index_t adj_index, u32 next_node)
Update the VLIB node to which packets are sent post processing.
const fib_prefix_t * teib_entry_get_nh(const teib_entry_t *te)
const static ipsec_tun_protect_itf_db_t IPSEC_TUN_PROTECT_DEFAULT_DB_ENTRY
void ip_address_from_46(const ip46_address_t *nh, fib_protocol_t fproto, ip_address_t *ip)
void ipsec_unregister_udp_port(u16 port)
static void ipsec_tun_teib_entry_deleted(const teib_entry_t *ne)
#define FOR_EACH_IPSEC_PROTECT_INPUT_SAI(_itp, _sai, body)
#define ITP_DBG(_itp, _fmt, _args...)
static void ipsec_tun_protect_adj_delegate_adj_created(adj_index_t ai)
static adj_walk_rc_t ipsec_tun_protect_adj_add(adj_index_t ai, void *arg)
#define hash_create_mem(elts, key_bytes, value_bytes)
int adj_delegate_add(ip_adjacency_t *adj, adj_delegate_type_t adt, index_t adi)
Add a delegate to an adjacency.
void ipsec_itf_adj_unstack(adj_index_t ai)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define IP_ADDRESS_V4_ALL_0S
int vnet_sw_interface_is_p2p(vnet_main_t *vnm, u32 sw_if_index)
#define hash_unset_mem(h, key)
static ipsec_sa_t * ipsec_sa_get(u32 sa_index)
enum adj_delegate_type_t_ adj_delegate_type_t
A Delagate is a means to implement the Delagation design pattern; the extension of an object's functi...
vnet_main_t * vnet_get_main(void)
static index_t ipsec_tun_protect_find(u32 sw_if_index, const ip_address_t *nh)
adj_index_t ad_adj_index
The ADJ entry object to which the delagate is attached.
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
The DB of all added per-nh tunnel protectiond.
#define vec_foreach_index(var, v)
Iterate over vector indices.
int ipsec_tun_protect_update(u32 sw_if_index, const ip_address_t *nh, u32 sa_out, u32 *sas_in)
u8 * format_ip_address(u8 *s, va_list *args)
index_t * ipsec_tun_protect_sa_by_adj_index
Adj index to TX SA mapping.
walk_rc_t(* ipsec_tun_protect_walk_cb_t)(index_t itpi, void *arg)
static void ipsec_tun_protect_update_from_teib(ipsec_tun_protect_t *itp, const teib_entry_t *ne)
void ipsec_sa_unlock(index_t sai)
result of a lookup in the protection bihash
adj_delegate_type_t adj_delegate_register_new_type(const adj_delegate_vft_t *vft)
adj_delegate_register_new_type
struct ipsec_tun_protect_itf_db_t_ ipsec_tun_protect_itf_db_t
The DB of all added per-nh tunnel protectiond.
void ipsec_register_udp_port(u16 port)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
fib_protocol_t ip_address_to_46(const ip_address_t *addr, ip46_address_t *a)
vnet_feature_main_t feature_main
void ipsec_sa_lock(index_t sai)
static void ipsec_tun_protect_add_adj(adj_index_t ai, const ipsec_tun_protect_t *itp)
static_always_inline void ip46_address_copy(ip46_address_t *dst, const ip46_address_t *src)
ipsec_crypto_alg_t crypto_alg
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
static clib_error_t * ipsec_tunnel_protect_init(vlib_main_t *vm)
static u32 ipsec_tun_node_regs[N_AF]
static void ipsec_tun_protect_tx_db_add(ipsec_tun_protect_t *itp)
static void ipsec_tun_protect_unconfig(ipsec_main_t *im, ipsec_tun_protect_t *itp)
static u8 ip46_address_is_zero(const ip46_address_t *ip46)
#define hash_get_mem(h, key)
#define vec_free(V)
Free vector's memory (no header).
union ip_adjacency_t_::@144 sub_type
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
u32 vnet_feature_modify_end_node(u8 arc_index, u32 sw_if_index, u32 end_node_index)
void teib_register(const teib_vft_t *vft)
8 octet key, 8 octet key value pair
vlib_node_registration_t ipsec4_tun_input_node
(constructor) VLIB_REGISTER_NODE (ipsec4_tun_input_node)
#define pool_foreach_index(i, v)
#define IPSEC_TUN_DEFAULT_HASH_NUM_BUCKETS
format_function_t format_vnet_sw_if_index_name
description fragment has unexpected format
static void ipsec_tun_protect_rx_db_add(ipsec_main_t *im, const ipsec_tun_protect_t *itp)
void ip6_unregister_protocol(u32 protocol)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
static u8 * ipsec_tun_protect_adj_delegate_format(const adj_delegate_t *aed, u8 *s)
u32 teib_entry_get_sw_if_index(const teib_entry_t *te)
accessors for the opaque struct
vnet_link_t adj_get_link_type(adj_index_t ai)
Return the link type of the adjacency.
#define VLIB_INIT_FUNCTION(x)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vl_api_address_family_t af
void ipsec_tun_unregister_nodes(ip_address_family_t af)
adj_delegate_adj_deleted_t adv_adj_deleted
index_t itp_in_sas[ITP_MAX_N_SA_IN]
int ipsec_tun_protect_del(u32 sw_if_index, const ip_address_t *nh)
teib_entry_added_t nv_added
const ip_address_t * teib_entry_get_peer(const teib_entry_t *te)
#define vec_foreach(var, vec)
Vector iterator.
const ip_address_t IP_ADDR_ALL_0
u32 adj_index_t
An index for adjacencies.
void ipsec_tun_table_init(ip_address_family_t af, uword table_size, u32 n_buckets)
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static vlib_main_t * vlib_get_main(void)
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
void adj_nbr_walk_nh(u32 sw_if_index, fib_protocol_t adj_nh_proto, const ip46_address_t *nh, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given next-hop.
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
teib_entry_t * teib_entry_find(u32 sw_if_index, const ip_address_t *peer)
vlib_log_class_t ipsec_tun_protect_logger
The logger.
ipsec_integ_alg_t integ_alg
void adj_nbr_walk(u32 sw_if_index, fib_protocol_t adj_nh_proto, adj_walk_cb_t cb, void *ctx)
Walk all adjacencies on a link for a given next-hop protocol.
u8 adj_is_midchain(adj_index_t ai)
void ip6_register_protocol(u32 protocol, u32 node_index)
static void ipsec_tun_protect_tx_db_remove(ipsec_tun_protect_t *itp)
#define FOR_EACH_IPSEC_PROTECT_INPUT_SA(_itp, _sa, body)
u32 esp6_decrypt_tun_node_index
static ipsec_tun_protect_t * ipsec_tun_protect_get(u32 index)
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
void ip_address_copy(ip_address_t *dst, const ip_address_t *src)
void ipsec_tun_protect_walk_itf(u32 sw_if_index, ipsec_tun_protect_walk_cb_t fn, void *ctx)
static void ipsec_tun_teib_entry_added(const teib_entry_t *ne)
vl_api_interface_index_t sw_if_index
void adj_nbr_midchain_reset_next_node(adj_index_t adj_index)
Return the adjacency's next node to its default value.
#define ITP_DBG2(_fmt, _args...)
u8 device_input_feature_arc_index
Feature arc index for device-input.
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
static void * clib_mem_alloc(uword size)
Aggregate type for a prefix.
void ipsec_tun_protect_walk(ipsec_tun_protect_walk_cb_t fn, void *ctx)
static void ipsec_tun_protect_config(ipsec_main_t *im, ipsec_tun_protect_t *itp, u32 sa_out, u32 *sas_in)
enum ip_address_family_t_ ip_address_family_t
static adj_delegate_type_t ipsec_tun_adj_delegate_type
Adj delegate registered type.
struct ip_adjacency_t_::@144::@146 midchain
IP_LOOKUP_NEXT_MIDCHAIN.
static void ipsec_tun_feature_update(u32 sw_if_index, u8 arc_index, u8 is_enable, void *data)