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> ...]";
45 u8 *rewrite_str = NULL;
55 rewrite_len += sr_hdr_len;
63 clib_host_to_net_u32 (0 | ((6 & 0xF) << 28));
72 iph->
protocol = IP_PROTOCOL_IPV6_ROUTE;
77 srh->
length = sr_hdr_len / 8 - 1;
85 ip6_address_t *this_address;
89 *addrp = *this_address;
142 ls_mem->
nh_adj = nh_adj_index;
215 IP_PROTOCOL_IP_IN_IP);
366 s =
format (s,
"\tSegment list:\t< ");
372 s =
format (s,
"\b\b >\n");
379 format (s,
"\tGood rewrite traffic: \t[%Ld packets : %Ld bytes]\n",
382 format (s,
"\tBad rewrite traffic: \t[%Ld packets : %Ld bytes]\n",
398 void **plugin_mem_p = va_arg (*args,
void **);
408 ip6_address_t next_sid;
409 ip6_address_t *sid_list = NULL;
412 #define PARAM_AS_NH (1 << 0) 413 #define PARAM_AS_OIF (1 << 1) 414 #define PARAM_AS_IIF (1 << 2) 415 #define PARAM_AS_SRC (1 << 3) 429 if (!(params & PARAM_AS_NH) &&
unformat (input,
"nh %U",
438 vnm, &sw_if_index_out))
444 vnm, &sw_if_index_in))
466 if ((params & params_chk) != params_chk || sid_list == NULL)
475 *plugin_mem_p = ls_mem;
480 ls_mem->
nh_addr.ip4 = nh_addr.ip4;
482 ls_mem->
nh_addr.ip6 = nh_addr.ip6;
499 return (
format (s,
"SR: static_proxy_index:[%u]", index));
563 .arc_name =
"device-input",
564 .node_name =
"srv6-as2-rewrite",
570 .arc_name =
"ip4-unicast",
571 .node_name =
"srv6-as4-rewrite",
577 .arc_name =
"ip6-unicast",
578 .node_name =
"srv6-as6-rewrite",
585 .version = VPP_BUILD_VER,
586 .description =
"Static Segment Routing for IPv6 (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)
#define IP_PROTOCOL_IP6_ETHERNET
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
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)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
u8 sr_get_hop_limit(void)
u32 srv6_localsid_behavior_id
SRv6 LocalSID behavior number.
vnet_interface_main_t interface_main
vl_api_ip_proto_t protocol
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void srv6_as_dpo_lock(dpo_id_t *dpo)
u32 * sw_iface_localsid2
Retrieve local SID from iface.
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).
Combined counter to hold both packets and byte differences.
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)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
format_function_t format_vnet_sw_if_index_name
int sr_localsid_register_function(vlib_main_t *vm, u8 *fn_name, u8 *keyword_str, u8 *def_str, u8 *params_str, u8 prefix_length, 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.
#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)
description fragment has unexpected format
#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...
srv6_as_localsid_t ** sids
Pool of AS SID pointers.
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 ...
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
counter_t packets
packet counter
static const char *const *const srv6_as_nodes[DPO_PROTO_NUM]
vnet_main_t * vnet_main
[convenience] vnet main
#define pool_put(P, E)
Free an object E in pool P.
vl_api_mac_address_t src_addr
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 void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
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 ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#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.
vlib_combined_counter_main_t invalid_counters
Invalid rewrite counters.
u32 sw_if_index_in
Incoming iface from proxied dev.
static void clib_mem_free(void *p)
#define SID_CREATE_INVALID_IFACE_TYPE
#define VNET_FEATURES(...)
ip46_address_t nh_addr
Proxied device address.
counter_t bytes
byte counter
#define SID_CREATE_INVALID_IFACE_INDEX
VNET_FEATURE_INIT(srv6_as2_rewrite, static)
#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.
vlib_combined_counter_main_t valid_counters
Valid rewrite counters.
Segment Routing main datastructure.
vnet_sw_interface_type_t type
srv6_as_main_t srv6_as_main
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.
#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)
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)