26 #include <openssl/hmac.h> 87 for (i = 0; i <= first_segment; i++)
102 if (!HMAC_Final (sm->
hmac_ctx, (
unsigned char *) addrp, &sig_len))
120 int bswap_needed = va_arg (*args,
int);
124 flags = clib_host_to_net_u16 (flags);
127 s =
format (s,
"cleanup ");
130 s =
format (s,
"reroute ");
133 for (i = 1; i <= 4; i++)
136 s =
format (s,
"[%d] ", i);
151 s =
format (s,
"OrgSrc ");
171 { {254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
174 int print_hmac = va_arg (*args,
int);
175 int i, pl_index, max_segs;
176 int flags_host_byte_order = clib_net_to_host_u16 (h->
flags);
178 s =
format (s,
"next proto %d, len %d, type %d",
180 s =
format (s,
"\n segs left %d, first_segment %d, hmac key %d",
183 flags_host_byte_order, 0 );
190 max_segs = (h->
length >> 1);
195 s =
format (s,
"\n Segments (in processing order):");
200 s =
format (s,
"\n (empty placeholder)");
204 s =
format (s,
"\n Policy List:");
207 for (i = (h->
first_segment + 1); i < max_segs; i++, pl_index++)
210 char *tags[] = {
" ",
"InPE: ",
"EgPE: ",
"OrgSrc: " };
213 if (pl_index >= 1 && pl_index <= 4)
216 (flags_host_byte_order, pl_index);
217 tag = tags[this_pl_flag];
238 u32 max_header_bytes = va_arg (*args,
u32);
242 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
243 return format (s,
"ip6_sr header truncated");
248 0 , max_header_bytes);
257 #define foreach_sr_rewrite_next \ 258 _(ERROR, "error-drop") \ 259 _(IP6_LOOKUP, "ip6-lookup") \ 260 _(SR_LOCAL, "sr-local") \ 261 _(SR_REPLICATE,"sr-replicate") 263 #define foreach_sr_rewrite_next \ 264 _(ERROR, "error-drop") \ 265 _(IP6_LOOKUP, "ip6-lookup") \ 266 _(SR_LOCAL, "sr-local") 274 #define _(s,n) SR_REWRITE_NEXT_##s, 296 #define sr_error(n,s) s, 306 #define sr_error(n,s) SR_REWRITE_ERROR_##n, 334 (s,
"SR-REWRITE: next %s ip6 src %U dst %U len %u\n" 335 " rx-fib-id %d tx-fib-id %d\n%U",
337 ?
"sr-local" :
"ip6-lookup",
359 u32 n_left_from, next_index, *from, *to_next;
372 while (n_left_from > 0)
379 while (0 && n_left_from >= 4 && n_left_to_next >= 2)
382 vlib_buffer_t *b0, *b1;
383 ip6_header_t *ip0, *ip1;
387 u32 next0 = SR_REWRITE_NEXT_IP6_LOOKUP;
388 u32 next1 = SR_REWRITE_NEXT_IP6_LOOKUP;
394 vlib_buffer_t *p2, *p3;
450 next0 = SR_REWRITE_NEXT_SR_LOCAL;
460 ip0, sizeof (ip6_header_t));
483 next0 = sr_local_cb ? sr_local_cb (vm, node, b0, ip0, sr0) :
493 b0->
error = node->
errors[SR_REWRITE_ERROR_APP_CALLBACK];
502 next1 = SR_REWRITE_NEXT_SR_LOCAL;
507 ip0, sizeof (ip6_header_t));
528 next1 = sr_local_cb ? sr_local_cb (vm, node, b1, ip1, sr1) :
538 b1->
error = node->
errors[SR_REWRITE_ERROR_APP_CALLBACK];
570 to_next, n_left_to_next,
571 bi0, bi1, next0, next1);
574 while (n_left_from > 0 && n_left_to_next > 0)
578 ip6_header_t *ip0 = 0;
582 u32 next0 = SR_REWRITE_NEXT_IP6_LOOKUP;
609 next0 = SR_REWRITE_NEXT_SR_REPLICATE;
631 next0 = SR_REWRITE_NEXT_SR_LOCAL;
641 ip0, sizeof (ip6_header_t));
664 next0 = sr_local_cb ? sr_local_cb (vm, node, b0, ip0, sr0) :
674 b0->
error = node->
errors[SR_REWRITE_ERROR_APP_CALLBACK];
699 to_next, n_left_to_next,
711 .name =
"sr-rewrite",
713 .vector_size =
sizeof (
u32),
717 .n_errors = SR_REWRITE_N_ERROR,
720 .runtime_data_bytes = 0,
724 #define _(s,n) [SR_REWRITE_NEXT_##s] = n, 733 u32 dst_address_length,
740 BVT (clib_bihash_kv) kv, value;
744 memset (&a, 0,
sizeof (a));
748 dst_address = *dst_address_arg;
752 kv.key[0] = dst_address.
as_u64[0];
753 kv.key[1] = dst_address.
as_u64[1];
754 kv.key[2] = ((
u64) ((fib - im6->
fibs)) << 32) | dst_address_length;
798 if (indexp && *indexp)
851 u32 rx_fib_index, tx_fib_index;
853 u32 hmac_key_index_u32;
854 u8 hmac_key_index = 0;
943 clib_warning (
"Tunnel index %d not found in policy_index %d",
963 key_copy = (
void *) (hp->
key);
971 memset (t, 0,
sizeof (*t));
991 header_length =
sizeof (*h) +
997 hmac_key_index_u32 = 0;
999 &hmac_key_index_u32);
1002 if (hmac_key_index_u32 >= 256)
1004 hmac_key_index = hmac_key_index_u32;
1005 header_length += SHA256_DIGEST_LENGTH;
1014 h->
length = (header_length / 8) - 1;
1025 h->
hmac_key = hmac_key_index & 0xFF;
1060 memset (&adj, 0,
sizeof (adj));
1080 ap->rewrite_header.sw_if_index = t - sm->
tunnels;
1107 memset (pt, 0,
sizeof (*pt));
1144 int src_address_set = 0;
1147 int dst_address_set = 0;
1149 u8 *shared_secret = 0;
1151 u8 *policy_name = 0;
1152 u32 rx_table_id = 0;
1153 u32 tx_table_id = 0;
1167 else if (
unformat (input,
"rx-fib-id %d", &rx_table_id))
1169 else if (
unformat (input,
"tx-fib-id %d", &tx_table_id))
1172 src_address_set = 1;
1173 else if (
unformat (input,
"name %s", &name))
1175 else if (
unformat (input,
"policy %s", &policy_name))
1177 else if (
unformat (input,
"dst %U/%d",
1179 dst_address_set = 1;
1185 sizeof (*this_seg));
1192 else if (
unformat (input,
"clean"))
1194 else if (
unformat (input,
"protected"))
1196 else if (
unformat (input,
"key %s", &shared_secret))
1198 _vec_len (shared_secret) -= 1;
1199 else if (
unformat (input,
"InPE %d", &pl_index))
1201 if (pl_index <= 0 || pl_index > 4)
1203 pl_index_range_error:
1205 (0,
"Policy List Element Index %d out of range (1-4)",
1212 else if (
unformat (input,
"EgPE %d", &pl_index))
1214 if (pl_index <= 0 || pl_index > 4)
1215 goto pl_index_range_error;
1219 else if (
unformat (input,
"OrgSrc %d", &pl_index))
1221 if (pl_index <= 0 || pl_index > 4)
1222 goto pl_index_range_error;
1230 if (!src_address_set)
1233 if (!dst_address_set)
1239 memset (a, 0,
sizeof (*a));
1299 .path =
"sr tunnel",
1301 "sr tunnel [del] [name <name>] src <addr> dst <addr> [next <addr>] " 1302 "[clean] [reroute] [key <secret>] [policy <policy_name>]" 1303 "[rx-fib-id <fib_id>] [tx-fib-id <fib_id>]",
1373 if (
unformat (input,
"name %s", &name))
1391 vec_add1 (tunnels, t);
1401 for (i = 0; i <
vec_len (tunnels); i++)
1412 .path =
"show sr tunnel",
1413 .short_help =
"show sr tunnel [name <sr-tunnel-name>]",
1432 u32 *tunnel_indices = 0;
1513 u8 **tunnel_names = 0;
1514 u8 *tunnel_name = 0;
1523 else if (
unformat (input,
"name %s", &name))
1525 else if (
unformat (input,
"tunnel %s", &tunnel_name))
1529 vec_add1 (tunnel_names, tunnel_name);
1541 memset (a, 0,
sizeof (*a));
1558 "tunnel name to associate to SR policy is required");
1582 .path =
"sr policy",
1584 "sr policy [del] name <policy-name> tunnel <sr-tunnel-name> [tunnel <sr-tunnel-name>]*",
1612 if (
unformat (input,
"name %s", &name))
1617 "policy with name %s not found. Showing all.",
1631 vec_add1 (policies, policy);
1644 for (i = 0; i <
vec_len (policies); i++)
1646 policy = policies[
i];
1663 .path =
"show sr policy",
1664 .short_help =
"show sr policy [name <sr-policy-name>]",
1718 memset (&adj, 0,
sizeof (adj));
1738 ap->rewrite_header.sw_if_index = t - sm->
tunnels;
1791 u8 *policy_name = 0;
1792 int multicast_address_set = 0;
1803 multicast_address_set = 1;
1804 else if (
unformat (input,
"sr-policy %s", &policy_name))
1810 if (!is_del && !policy_name)
1813 if (!multicast_address_set)
1816 memset (a, 0,
sizeof (*a));
1826 "cannot use multicast replicate spray case without DPDK installed");
1841 "tunnel name to associate to SR policy is required");
1859 .path =
"sr multicast-map",
1861 "sr multicast-map address <multicast-ip6-address> sr-policy <sr-policy-name> [del]",
1892 vlib_cli_output (vm,
"no multicast maps configured");
1895 multicast_address = *((ip6_address_t *)key);
1896 pt = pool_elt_at_index (sm->policies, value);
1899 vlib_cli_output (vm,
"address: %U policy: %s",
1900 format_ip6_address, &multicast_address,
1904 vlib_cli_output (vm,
"BUG: policy not found for address: %U with policy index %d",
1905 format_ip6_address, &multicast_address,
1918 .path =
"show sr multicast-map",
1919 .short_help =
"show sr multicast-map",
1925 #define foreach_sr_fix_dst_addr_next \ 1926 _(DROP, "error-drop") 1933 #define _(s,n) SR_FIX_DST_ADDR_NEXT_##s, 1943 #define sr_fix_dst_error(n,s) s, 1945 #undef sr_fix_dst_error 1953 #define sr_fix_dst_error(n,s) SR_FIX_DST_ERROR_##n, 1955 #undef sr_fix_dst_error 1991 s =
format (s,
"SR-FIX_ADDR: next %s ip6 src %U dst %U\n",
1993 ?
"drop" :
"output",
1995 if (t->
next_index != SR_FIX_DST_ADDR_NEXT_DROP)
2000 format (s,
" output via %s",
2001 hi ? (
char *) (hi->
name) :
"Invalid adj");
2020 u32 n_left_from, next_index, *from, *to_next;
2029 while (n_left_from > 0)
2036 while (0 && n_left_from >= 4 && n_left_to_next >= 2)
2040 u32 next0 = SR_FIX_DST_ADDR_NEXT_DROP;
2041 u32 next1 = SR_FIX_DST_ADDR_NEXT_DROP;
2060 n_left_to_next -= 2;
2068 to_next, n_left_to_next,
2069 bi0, bi1, next0, next1);
2073 while (n_left_from > 0 && n_left_to_next > 0)
2080 u32 next0 = SR_FIX_DST_ADDR_NEXT_DROP;
2089 n_left_to_next -= 1;
2105 b0->
error = node->
errors[SR_FIX_DST_ERROR_NO_SR_HEADER];
2119 b0->
error = node->
errors[SR_FIX_DST_ERROR_NO_MORE_SEGMENTS];
2143 if (next0 != SR_FIX_DST_ADDR_NEXT_DROP)
2155 to_next, n_left_to_next,
2168 .name =
"sr-fix-dst-addr",
2170 .vector_size =
sizeof (
u32),
2174 .runtime_data_bytes = 0,
2176 .n_errors = SR_FIX_DST_N_ERROR,
2181 #define _(s,n) [SR_FIX_DST_ADDR_NEXT_##s] = n, 2222 ASSERT (ip6_lookup_node);
2225 ASSERT (ip6_rewrite_node);
2242 OpenSSL_add_all_digests ();
2244 sm->
md = (
void *) EVP_get_digestbyname (
"sha1");
2255 #define foreach_sr_local_next \ 2256 _ (ERROR, "error-drop") \ 2257 _ (IP6_LOOKUP, "ip6-lookup") 2264 #define _(s,n) SR_LOCAL_NEXT_##s, 2286 #define sr_error(n,s) s, 2296 #define sr_error(n,s) SR_LOCAL_ERROR_##n, 2317 s =
format (s,
"SR-LOCAL: src %U dst %U len %u next_index %d",
2324 s =
format (s,
"\n popped SR header");
2350 static u8 *signature;
2392 for (i = 0; i <= first_segment; i++)
2400 clib_warning (
"verify key index %d keybuf: %U", key_index,
2406 memset (signature, 0,
vec_len (signature));
2414 if (!HMAC_Final (sm->
hmac_ctx, signature, &sig_len))
2419 clib_warning (
"computed signature len %d, value %U", sig_len,
2426 SHA256_DIGEST_LENGTH);
2428 return memcmp (signature, addrp, SHA256_DIGEST_LENGTH);
2445 u32 n_left_from, next_index, *from, *to_next;
2456 while (n_left_from > 0)
2462 while (n_left_from >= 4 && n_left_to_next >= 2)
2465 vlib_buffer_t *b0, *b1;
2466 ip6_header_t *ip0, *ip1;
2469 u32 next0 = SR_LOCAL_NEXT_IP6_LOOKUP;
2470 u32 next1 = SR_LOCAL_NEXT_IP6_LOOKUP;
2473 vlib_buffer_t *p2, *p3;
2491 n_left_to_next -= 2;
2501 next0 = SR_LOCAL_NEXT_ERROR;
2503 node->
errors[SR_LOCAL_ERROR_BAD_ROUTING_HEADER_TYPE];
2510 next0 = SR_LOCAL_NEXT_ERROR;
2511 b0->
error = node->
errors[SR_LOCAL_ERROR_NO_MORE_SEGMENTS];
2519 next0 = SR_LOCAL_NEXT_ERROR;
2520 b0->
error = node->
errors[SR_LOCAL_ERROR_HMAC_INVALID];
2525 next0 = sr_local_cb ? sr_local_cb (vm, node, b0, ip0, sr0) : next0;
2532 next0 ^= 0xFFFFFFFF;
2534 b0->
error = node->
errors[SR_LOCAL_ERROR_APP_CALLBACK];
2557 u64 *copy_dst0, *copy_src0;
2572 copy_src0 = (
u64 *) ip0;
2573 copy_dst0 = copy_src0 + (sr0->
length + 1);
2575 copy_dst0[4] = copy_src0[4];
2576 copy_dst0[3] = copy_src0[3];
2577 copy_dst0[2] = copy_src0[2];
2578 copy_dst0[1] = copy_src0[1];
2579 copy_dst0[0] = copy_src0[0];
2606 next1 = SR_LOCAL_NEXT_ERROR;
2608 node->
errors[SR_LOCAL_ERROR_BAD_ROUTING_HEADER_TYPE];
2615 next1 = SR_LOCAL_NEXT_ERROR;
2616 b1->
error = node->
errors[SR_LOCAL_ERROR_NO_MORE_SEGMENTS];
2624 next1 = SR_LOCAL_NEXT_ERROR;
2625 b1->
error = node->
errors[SR_LOCAL_ERROR_HMAC_INVALID];
2630 next1 = sr_local_cb ? sr_local_cb (vm, node, b1, ip1, sr1) : next1;
2637 next1 ^= 0xFFFFFFFF;
2639 b1->
error = node->
errors[SR_LOCAL_ERROR_APP_CALLBACK];
2662 u64 *copy_dst1, *copy_src1;
2677 copy_src1 = (
u64 *) ip1;
2678 copy_dst1 = copy_src1 + (sr1->
length + 1);
2680 copy_dst1[4] = copy_src1[4];
2681 copy_dst1[3] = copy_src1[3];
2682 copy_dst1[2] = copy_src1[2];
2683 copy_dst1[1] = copy_src1[1];
2684 copy_dst1[0] = copy_src1[0];
2706 to_next, n_left_to_next,
2707 bi0, bi1, next0, next1);
2710 while (n_left_from > 0 && n_left_to_next > 0)
2714 ip6_header_t *ip0 = 0;
2717 u32 next0 = SR_LOCAL_NEXT_IP6_LOOKUP;
2724 n_left_to_next -= 1;
2732 next0 = SR_LOCAL_NEXT_ERROR;
2734 node->
errors[SR_LOCAL_ERROR_BAD_ROUTING_HEADER_TYPE];
2741 next0 = SR_LOCAL_NEXT_ERROR;
2742 b0->
error = node->
errors[SR_LOCAL_ERROR_NO_MORE_SEGMENTS];
2750 next0 = SR_LOCAL_NEXT_ERROR;
2751 b0->
error = node->
errors[SR_LOCAL_ERROR_HMAC_INVALID];
2756 next0 = sr_local_cb ? sr_local_cb (vm, node, b0, ip0, sr0) : next0;
2763 next0 ^= 0xFFFFFFFF;
2765 b0->
error = node->
errors[SR_LOCAL_ERROR_APP_CALLBACK];
2788 u64 *copy_dst0, *copy_src0;
2803 copy_src0 = (
u64 *) ip0;
2804 copy_dst0 = copy_src0 + (sr0->
length + 1);
2806 copy_dst0[4] = copy_src0[4];
2807 copy_dst0[3] = copy_src0[3];
2808 copy_dst0[2] = copy_src0[2];
2809 copy_dst0[1] = copy_src0[1];
2810 copy_dst0[0] = copy_src0[0];
2832 to_next, n_left_to_next,
2839 SR_LOCAL_ERROR_PKTS_PROCESSED,
2849 .vector_size =
sizeof (
u32),
2852 .runtime_data_bytes = 0,
2854 .n_errors = SR_LOCAL_N_ERROR,
2859 #define _(s,n) [SR_LOCAL_NEXT_##s] = n, 2904 if (
unformat (input,
"rx-table-id %d", &fib_id))
2925 sw_if_index = adj->rewrite_header.sw_if_index;
2939 .path =
"set ip6 sr rewrite",
2940 .short_help =
"set ip6 sr rewrite <ip6-address> [fib-id <id>]",
2967 if (
unformat (input,
"validate on"))
2969 else if (
unformat (input,
"chunk-offset off"))
2982 .path =
"test sr hmac",
2983 .short_help =
"test sr hmac validate [on|off]",
3015 ASSERT (index == key_id);
3049 u8 *shared_secret = 0;
3056 else if (
unformat (input,
"id %d", &key_id))
3058 else if (
unformat (input,
"key %s", &shared_secret))
3061 _vec_len (shared_secret) -= 1;
3067 if (is_del == 0 && shared_secret == 0)
3070 if (shared_secret == 0 && key_id_set == 0)
3092 .short_help =
"sr hmac [del] id <nn> key <str>",
3124 .path =
"show sr hmac",
3125 .short_help =
"show sr hmac",
3160 .path =
"test sr debug",
3161 .short_help =
"test sr debug on|off",
static int ip6_delete_route_no_next_hop(ip6_address_t *dst_address_arg, u32 dst_address_length, u32 rx_table_id)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static void ip6_address_mask(ip6_address_t *a, ip6_address_t *mask)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
HMAC_CTX * hmac_ctx
Openssl var.
Segment Route tunnel key.
#define vec_foreach_index(var, v)
Iterate over vector indices.
sr_fix_dst_error_t
Struct for errors for SR Fix Destination rewrite.
sll srl srl sll sra u16x4 i
Args for creating a policy.
static vlib_cli_command_t show_sr_multicast_map_command
(constructor) VLIB_CLI_COMMAND (show_sr_multicast_map_command)
static char * sr_rewrite_error_strings[]
Error strings for SR rewrite.
uword * tunnel_index_by_key
find an sr "tunnel" by its outer-IP src/dst
#define IP6_SR_HEADER_FLAG_PL_ELT_EGRESS_PE
Flag bits.
void ip6_register_protocol(u32 protocol, u32 node_index)
u32 tx_fib_index
TX Fib index.
u32 policy_index
Indicates that this tunnel is part of a policy comprising of multiple tunnels.
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
#define IP6_SR_HEADER_FLAG_PROTECTED
Flag bits.
u32 dst_mask_width
Mask width for FIB entry.
ip6_address_t * multicast_address
multicast IP6 address
ip_lookup_next_t lookup_next_index
u8 * format_sr_rewrite_trace(u8 *s, va_list *args)
Format function for SR rewrite trace.
static clib_error_t * test_sr_hmac_validate_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Test routine for validation of HMAC.
void ip6_sr_tunnel_display(vlib_main_t *vm, ip6_sr_tunnel_t *t)
Display Segment Routing tunnel.
u32 miss_adj_index
Adjacency index for routing table misses, local punts, and drops.
u8 * name
Pptional tunnel name.
int ip6_sr_add_del_policy(ip6_sr_add_del_policy_args_t *a)
Add or Delete a Segment Routing policy.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
vlib_node_registration_t ip6_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip6_rewrite_node)
ip_adjacency_t * ip_add_adjacency(ip_lookup_main_t *lm, ip_adjacency_t *copy_adj, u32 n_adj, u32 *adj_index_return)
struct _vlib_node_registration vlib_node_registration_t
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static vlib_cli_command_t show_sr_tunnel_command
(constructor) VLIB_CLI_COMMAND (show_sr_tunnel_command)
ip6_address_t * tags
"Tag" list, aka segments inserted at the end of the list, past last_seg
#define hash_set_mem(h, key, value)
ip6_sr_tunnel_key_t key
src, dst address
i32 sr_hmac_add_del_key(ip6_sr_main_t *sm, u32 key_id, u8 *shared_secret, u8 is_del)
Add or Delete HMAC key.
#define ROUTING_HEADER_TYPE_SR
u32 rx_fib_index
RX Fib index.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
static clib_error_t * sr_add_del_policy_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI Parser for Add or Delete a Segment Routing policy.
ip6_sr_main_t * sr_get_main(vlib_main_t *vm)
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
sr_local_error_t
Struct for definition of SR local error-strings.
int ip6_sr_add_del_multicastmap(ip6_sr_add_del_multicastmap_args_t *a)
Add or Delete a mapping of IP6 multicast address to Segment Routing policy.
static char * sr_fix_dst_error_strings[]
Error strings for SR Fix Destination rewrite.
u8 * format_ip6_sr_header_flags(u8 *s, va_list *args)
Format function for decoding various SR flags.
ip6_address_t * segments
segment list, when inserting an ip6 SR header
vnet_main_t * vnet_get_main(void)
static uword sr_rewrite(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Main processing dual-loop for Segment Routing Rewrite.
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static uword sr_local(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
SR local node.
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
ip6_sr_hmac_key_t * hmac_keys
pool of hmac keys
sr_rewrite_error_t
Struct for SR rewrite error strings.
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
static uword ip6_address_is_equal(ip6_address_t *a, ip6_address_t *b)
u8 * name
optional name argument - for referencing SR tunnel/policy by name
ip6_fib_t * find_ip6_fib_by_table_index_or_id(ip6_main_t *im, u32 table_index_or_id, u32 flags)
Get or create an IPv6 fib.
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static vlib_cli_command_t show_sr_policy_command
(constructor) VLIB_CLI_COMMAND (show_sr_policy_command)
#define clib_warning(format, args...)
u32 table_index_or_table_id
Struct for data for SR rewrite packet trace.
static vlib_cli_command_t sr_multicast_map_command
(constructor) VLIB_CLI_COMMAND (sr_multicast_map_command)
#define hash_get_pair(h, key)
#define IPPROTO_IPV6_ROUTE
#define vlib_call_init_function(vm, x)
#define foreach_sr_rewrite_next
Defined valid next nodes.
void ip6_add_del_route(ip6_main_t *im, ip6_add_del_route_args_t *args)
#define IP6_SR_HEADER_FLAG_CLEANUP
Flag bits.
static clib_error_t * sr_add_del_tunnel_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI parser for Add or Delete a Segment Routing tunnel.
#define hash_create_string(elts, value_bytes)
sr_fix_dst_addr_next_t
Struct for valid next-nodes for SR fix destination address node.
Information for fix address trace.
static vlib_cli_command_t sr_policy_command
(constructor) VLIB_CLI_COMMAND (sr_policy_command)
static clib_error_t * test_sr_debug_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Test for SR debug flag.
#define VLIB_BUFFER_PRE_DATA_SIZE
ip6_address_t dst_address
Args required for add/del tunnel.
#define hash_create_mem(elts, key_bytes, value_bytes)
u8 is_del
Delete the tunnnel?
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define hash_unset_mem(h, key)
static char * sr_local_error_strings[]
Definition of SR local error-strings.
void ip6_maybe_remap_adjacencies(ip6_main_t *im, u32 table_index_or_table_id, u32 flags)
Args for mapping of multicast address to policy name.
u8 * format_sr_fix_addr_trace(u8 *s, va_list *args)
Formatter for fix address trace.
vlib_main_t * vlib_main
convenience
void * sr_local_cb
application API callback
u8 is_debug
enable debug spew
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
u8 * format_ip6_sr_header_with_length(u8 *s, va_list *args)
Format function for decoding ip6_sr_header_t with length.
u16 flags_net_byte_order
Flags, e.g.
void vnet_register_sr_app_callback(void *cb)
Register a callback routine to set next0 in sr_local.
static clib_error_t * sr_hmac_add_del_key_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 ip6_lookup_sr_replicate_index
ip6-replicate next index for multicast tunnel
#define vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1)
Finish enqueueing two buffers forward in the graph.
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
int ip6_sr_add_del_tunnel(ip6_sr_add_del_tunnel_args_t *a)
Add or Delete a Segment Routing tunnel.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define hash_foreach_mem(key_var, value_var, h, body)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
uword * fib_index_by_table_id
ip6_address_t * src_address
Key (header imposition case)
ip6_address_t fib_masks[129]
u8 * policy_name
optional policy name
vnet_main_t * vnet_main
convenience
u8 * rewrite
The actual ip6 SR header.
clib_error_t * ip_main_init(vlib_main_t *vm)
#define CLIB_PREFETCH(addr, size, type)
#define vec_free(V)
Free vector's memory (no header).
static clib_error_t * show_sr_multicast_map_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI Parser for Displaying a mapping of IP6 multicast address to Segment Routing policy.
#define clib_memcpy(a, b, c)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
u32 ip6_fib_lookup_with_table(ip6_main_t *im, u32 fib_index, ip6_address_t *dst)
#define IP6_ROUTE_FLAG_DEL
#define IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR
Flag bits.
#define IP6_SR_HEADER_FLAG_PL_ELT_NOT_PRESENT
Flag bits.
u32 * tunnel_indices
vector to SR tunnel index
static clib_error_t * show_sr_hmac_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI parser for show HMAC key shared secrets.
void sr_fix_hmac(ip6_sr_main_t *sm, ip6_header_t *ip, ip6_sr_header_t *sr)
Use passed HMAC key in ip6_sr_header_t in OpenSSL HMAC routines.
#define IP4_ROUTE_FLAG_DEL
sr_local_next_t
Struct for definition of next-nodes for SR local.
u8 * policy_name
name of policy to map to
static vlib_cli_command_t sr_tunnel_command
(constructor) VLIB_CLI_COMMAND (sr_tunnel_command)
u8 * format_ip6_sr_header(u8 *s, va_list *args)
Format function for decoding ip6_sr_header_t.
u8 validate_hmac
validate hmac keys
ip6_address_t first_hop
First hop, to save 1 elt in the segment list.
static ip6_sr_hmac_key_t * find_or_add_shared_secret(ip6_sr_main_t *sm, u8 *secret, u32 *indexp)
Find or add if not found - HMAC shared secret.
vlib_node_registration_t ip6_lookup_node
(constructor) VLIB_REGISTER_NODE (ip6_lookup_node)
ip_lookup_main_t lookup_main
#define vec_delete(V, N, M)
Delete N elements starting at element M.
int clib_bihash_search(clib_bihash *h, clib_bihash_kv *search_v, clib_bihash_kv *return_v)
Search a bi-hash table.
static clib_error_t * sr_init(vlib_main_t *vm)
static uword sr_fix_dst_addr(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Fix SR destination address - dual-loop.
ip6_sr_tunnel_t * tunnels
pool of tunnel instances, sr entry only
static int sr_validate_hmac(ip6_sr_main_t *sm, ip6_header_t *ip, ip6_sr_header_t *sr)
Validate the SR HMAC.
#define foreach_sr_local_next
Definition of next-nodes for SR local.
uword * policy_index_by_policy_name
find a policy by name
u8 is_del
Delete the policy?
uword * tunnel_index_by_name
find an sr "tunnel" by its name
vlib_node_registration_t sr_fix_dst_addr_node
(constructor) VLIB_REGISTER_NODE (sr_fix_dst_addr_node)
static clib_error_t * show_sr_policy_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI Parser for Displaying Segment Routing policy.
static void * clib_mem_alloc(uword size)
static clib_error_t * set_ip6_sr_rewrite_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI parser for SR fix destination rewrite node.
#define VLIB_BUFFER_IS_TRACED
#define IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE
Flag bits.
#define IP6_ROUTE_FLAG_FIB_INDEX
static clib_error_t * sr_add_del_multicast_map_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI Parser for Adding or Delete a mapping of IP6 multicast address to Segment Routing policy...
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
u32 ip6_lookup_sr_next_index
ip6-lookup next index for imposition FIB entries
Struct for packet trace of SR local.
u8 * shared_secret
Shared secret => generate SHA-256 HMAC security fields.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
uword * hmac_key_by_shared_secret
hmac key id by shared secret
VLIB_CLI_COMMAND(set_interface_ip_source_and_port_range_check_command, static)
uword * policy_index_by_multicast_address
multicast address to policy mapping
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_node_registration_t sr_replicate_node
(constructor) VLIB_REGISTER_NODE (sr_replicate_node)
ip6_sr_policy_t * policies
policy pool
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
ip6_address_t * dst_address
u8 ** tunnel_names
tunnel names
static int ip6_sr_policy_list_shift_from_index(int pl_index)
#define hash_get_mem(h, key)
Shared secret for keyed-hash message authentication code (HMAC).
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
static clib_error_t * show_sr_tunnel_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI Parser for Display Segment Routing tunnel.
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#define VLIB_REGISTER_NODE(x,...)
This packet is to be rewritten and forwarded to the next processing node.
#define IP6_ROUTE_FLAG_ADD
#define vec_foreach(var, vec)
Vector iterator.
u8 * format_sr_local_trace(u8 *s, va_list *args)
Format SR local trace.
i16 explicit_fib_index
Force re-lookup in a different FIB.
#define foreach_sr_fix_dst_addr_next
#define clib_error_return(e, args...)
#define IP6_ROUTE_FLAG_TABLE_ID
static clib_error_t * ip6_lookup_init(vlib_main_t *vm)
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
u8 is_del
Delete the mapping.
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
sr_rewrite_next_t
Struct for defined valid next nodes.
vlib_node_registration_t sr_rewrite_node
(constructor) VLIB_REGISTER_NODE (sr_rewrite_node)
static int ip6_sr_policy_list_flags(u16 flags_host_byte_order, int pl_index)
pl_index is one-origined
static ip_adjacency_t * ip_get_adjacency(ip_lookup_main_t *lm, u32 adj_index)
static vlib_node_registration_t sr_local_node
(constructor) VLIB_REGISTER_NODE (sr_local_node)
u32 ip6_rewrite_sr_next_index
ip6-rewrite next index for reinstalling the original dst address