46 u32 dev_instance = va_arg (*args,
u32);
47 return format (s,
"ipsec%d", dev_instance);
71 .fp_len = (ipsec_sa_is_set_IS_TUNNEL_V6(sa) ? 128 : 32),
72 .fp_proto = (ipsec_sa_is_set_IS_TUNNEL_V6(sa)?
145 ip46_address_t *
src, ip46_address_t *
dst,
u8 * is_l2)
188 .name =
"IPSEC Tunnel",
205 #define IPSEC_ITF_MAX_INSTANCE (16 * 1024) 277 *sw_if_indexp = (
u32) ~ 0;
279 if (mode != TUNNEL_MODE_P2P)
280 return VNET_API_ERROR_UNSUPPORTED;
288 return VNET_API_ERROR_INVALID_REGISTRATION;
290 pool_get (ipsec_itf_pool, ipsec_itf);
301 ipsec_itf_device_class.index,
303 ipsec_hw_interface_class.index,
323 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
327 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
331 if (NULL == ipsec_itf)
332 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
335 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
338 pool_put (ipsec_itf_pool, ipsec_itf);
354 instance = sw_if_index = ~0;
361 if (
unformat (line_input,
"instance %d", &instance))
398 .path =
"ipsec itf create",
399 .short_help =
"ipsec itf create [instance <instance>]",
424 if (~0 != sw_if_index)
449 .path =
"ipsec itf delete",
450 .short_help =
"ipsec itf delete <interface>",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static u8 * format_ipsec_itf_name(u8 *s, va_list *args)
vl_api_wireguard_peer_flags_t flags
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
vnet_interface_main_t interface_main
static clib_error_t * ipsec_itf_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
void adj_midchain_delegate_stack(adj_index_t ai, u32 fib_index, const fib_prefix_t *pfx)
create/attach a midchain delegate and stack it on the prefix passed
static int ipsec_itf_instance_free(u32 instance)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
void ipsec_tun_protect_walk_itf(u32 sw_if_index, ipsec_tun_protect_walk_cb_t fn, void *ctx)
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
unformat_function_t unformat_vnet_sw_interface
static adj_walk_rc_t ipsec_itf_adj_stack_cb(adj_index_t ai, void *arg)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static clib_error_t * ipsec_itf_delete_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_vnet_sw_if_index_name
static void ipsec_itf_restack(index_t itpi, const ipsec_itf_t *itf)
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static_always_inline void mac_address_set_zero(mac_address_t *mac)
enum walk_rc_t_ walk_rc_t
Walk return code.
VNET_DEVICE_CLASS(ipsec_itf_device_class)
static void ip46_address_reset(ip46_address_t *ip46)
void ipsec_itf_adj_unstack(adj_index_t ai)
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
vnet_hw_interface_flags_t flags
Aggregate type for a prefix.
#define clib_error_return(e, args...)
static ipsec_itf_t * ipsec_itf_pool
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u32 adj_get_sw_if_index(adj_index_t ai)
Return the sw interface index of the adjacency.
static ipsec_itf_t * ipsec_itf_find_by_sw_if_index(u32 sw_if_index)
#define pool_put(P, E)
Free an object E in pool P.
static ipsec_sa_t * ipsec_sa_get(u32 sa_index)
vl_api_tunnel_mode_t mode
ip46_address_t tunnel_dst_addr
A dedicated IPSec interface type.
VNET_HW_INTERFACE_CLASS(ipsec_hw_interface_class)
void ipsec_itf_adj_stack(adj_index_t ai, u32 sai)
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
static u32 * ipsec_itf_index_by_sw_if_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
u32 adj_index_t
An index for adjacencies.
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
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.
#define IPSEC_ITF_MAX_INSTANCE
void adj_midchain_delegate_unstack(adj_index_t ai)
unstack a midchain delegate (this stacks it on a drop)
#define VLIB_CLI_COMMAND(x,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static int ipsec_itf_tunnel_desc(u32 sw_if_index, ip46_address_t *src, ip46_address_t *dst, u8 *is_l2)
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static ipsec_tun_protect_t * ipsec_tun_protect_get(u32 index)
int ipsec_itf_delete(u32 sw_if_index)
void ipsec_itf_update_adj(vnet_main_t *vnm, u32 sw_if_index, adj_index_t ai)
static uword * ipsec_itf_instances
void vnet_delete_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
static walk_rc_t ipsec_tun_protect_walk_state_change(index_t itpi, void *arg)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
vnet_sw_interface_t * sw_interfaces
a point 2 point interface
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
static clib_error_t * ipsec_itf_create_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int ipsec_itf_create(u32 user_instance, tunnel_mode_t mode, u32 *sw_if_indexp)
static u8 * ipsec_itf_build_rewrite_i(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t link_type, const void *dst_address)
static uword clib_bitmap_first_clear(uword *ai)
Return the lowest numbered clear bit in a bitmap.
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
static u8 * ipsec_itf_build_rewrite(void)
enum tunnel_mode_t_ tunnel_mode_t
vl_api_interface_index_t sw_if_index
static u32 ipsec_itf_instance_alloc(u32 want)