24 #include <vpp/app/version.h> 27 #define SID_CREATE_IFACE_FEATURE_ERROR -1 28 #define SID_CREATE_INVALID_IFACE_TYPE -3 29 #define SID_CREATE_INVALID_IFACE_INDEX -4 30 #define SID_CREATE_INVALID_ADJ_INDEX -5 35 "Endpoint with static proxy to SR-unaware appliance";
37 "nh <next-hop> oif <iface-out> iif <iface-in> src <src-addr> next <sid> [next <sid> ...]";
54 rewrite_len += sr_hdr_len;
62 clib_host_to_net_u32 (0 | ((6 & 0xF) << 28));
71 iph->
protocol = IP_PROTOCOL_IPV6_ROUTE;
76 srh->
length = sr_hdr_len / 8 - 1;
88 *addrp = *this_address;
138 ls_mem->
nh_adj = nh_adj_index;
177 IP_PROTOCOL_IP_IN_IP);
292 s =
format (s,
"\tSegment list:\t< ");
298 s =
format (s,
"\b\b > ");
313 void **plugin_mem_p = va_arg (*args,
void **);
319 ip46_address_t nh_addr;
327 #define PARAM_AS_NH (1 << 0) 328 #define PARAM_AS_OIF (1 << 1) 329 #define PARAM_AS_IIF (1 << 2) 330 #define PARAM_AS_SRC (1 << 3) 344 if (!(params & PARAM_AS_NH) &&
unformat (input,
"nh %U",
353 vnm, &sw_if_index_out))
359 vnm, &sw_if_index_in))
381 if ((params & params_chk) != params_chk || sid_list ==
NULL)
389 memset (ls_mem, 0,
sizeof *ls_mem);
390 *plugin_mem_p = ls_mem;
395 ls_mem->
nh_addr.ip4 = nh_addr.ip4;
397 ls_mem->
nh_addr.ip6 = nh_addr.ip6;
414 return (
format (s,
"SR: static_proxy_index:[%u]", index));
477 .arc_name =
"ip4-unicast",
478 .node_name =
"srv6-as4-rewrite",
484 .arc_name =
"ip6-unicast",
485 .node_name =
"srv6-as6-rewrite",
492 .version = VPP_BUILD_VER,
493 .description =
"Static SRv6 proxy",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
dpo_lock_fn_t dv_lock
A reference counting lock function.
unsigned char function_name[]
A virtual function table regisitered for a DPO type.
static u8 * prepare_rewrite(ip6_address_t src_addr, ip6_address_t *sid_list, u8 protocol)
static void * clib_mem_alloc_aligned_at_offset(uword size, uword align, uword align_offset, int os_out_of_memory_on_failure)
u32 * sw_iface_localsid4
Retrieve local SID from iface.
vnet_main_t * vnet_get_main(void)
u32 srv6_localsid_behavior_id
SRv6 LocalSID behavior number.
vnet_interface_main_t interface_main
srv6_as_main_t srv6_as_main
void srv6_as_dpo_lock(dpo_id_t *dpo)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
dpo_type_t srv6_as_dpo_type
DPO type.
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define IPv6_DEFAULT_HEADER_LENGTH
unformat_function_t unformat_vnet_sw_interface
#define ROUTING_HEADER_TYPE_SR
static clib_error_t * srv6_as_init(vlib_main_t *vm)
format_function_t format_vnet_sw_if_index_name
#define pool_len(p)
Number of elements in pool vector.
u8 * format_srv6_as_localsid(u8 *s, va_list *args)
static int srv6_as_localsid_removal_fn(ip6_sr_localsid_t *localsid)
void srv6_as_dpo_unlock(dpo_id_t *dpo)
#define VLIB_INIT_FUNCTION(x)
#define clib_error_return(e, args...)
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
uword unformat_srv6_as_localsid(unformat_input_t *input, va_list *args)
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
static u8 * format_srv6_as_dpo(u8 *s, va_list *args)
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
u32 nh_adj
Adjacency index for out.
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
static const char *const *const srv6_as_nodes[DPO_PROTO_NUM]
vnet_main_t * vnet_main
[convenience] vnet main
ip6_address_t * sid_list
SID list to be restored.
unsigned char params_str[]
ip6_sr_localsid_t * localsids
static void free_ls_mem(srv6_as_localsid_t *ls_mem)
u8 * rewrite
Headers to be rewritten.
static const char *const srv6_as_ip6_nodes[]
#define vec_free(V)
Free vector's memory (no header).
unsigned char keyword_str[]
ip6_address_t src_addr
Source address to be restored.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
#define SID_CREATE_IFACE_FEATURE_ERROR
u32 adj_index_t
An index for adjacencies.
u32 sw_if_index_out
Outgoing iface to proxied dev.
void * plugin_mem
Memory to be used by the plugin callback functions.
u32 sw_if_index_in
Incoming iface from proxied dev.
static void clib_mem_free(void *p)
#define SID_CREATE_INVALID_IFACE_TYPE
ip46_address_t nh_addr
Proxied device address.
#define SID_CREATE_INVALID_IFACE_INDEX
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vnet_sw_interface_t * sw_interfaces
vlib_main_t * vlib_main
[convenience] vlib main
u32 * sw_iface_localsid6
Retrieve local SID from iface.
Segment Routing main datastructure.
vnet_sw_interface_type_t type
int sr_localsid_register_function(vlib_main_t *vm, u8 *fn_name, u8 *keyword_str, u8 *def_str, u8 *params_str, dpo_type_t *dpo, format_function_t *ls_format, unformat_function_t *ls_unformat, sr_plugin_callback_t *creation_fn, sr_plugin_callback_t *removal_fn)
SR LocalSID plugin registry.
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
#define vec_foreach(var, vec)
Vector iterator.
VNET_FEATURE_INIT(srv6_as4_rewrite, static)
#define IPv6_DEFAULT_HOP_LIMIT
#define SID_CREATE_INVALID_ADJ_INDEX
static int srv6_as_localsid_creation_fn(ip6_sr_localsid_t *localsid)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)