28 #include <openssl/hmac.h> 94 for (i = 0; i <= first_segment; i++)
109 if (!HMAC_Final (sm->
hmac_ctx, (
unsigned char *) addrp, &sig_len))
127 int bswap_needed = va_arg (*args,
int);
131 flags = clib_host_to_net_u16 (flags);
134 s =
format (s,
"cleanup ");
137 s =
format (s,
"reroute ");
140 for (i = 1; i <= 4; i++)
143 s =
format (s,
"[%d] ", i);
158 s =
format (s,
"OrgSrc ");
178 { {254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
181 int print_hmac = va_arg (*args,
int);
182 int i, pl_index, max_segs;
183 int flags_host_byte_order = clib_net_to_host_u16 (h->
flags);
185 s =
format (s,
"next proto %d, len %d, type %d",
187 s =
format (s,
"\n segs left %d, first_segment %d, hmac key %d",
190 flags_host_byte_order, 0 );
197 max_segs = (h->
length >> 1);
202 s =
format (s,
"\n Segments (in processing order):");
207 s =
format (s,
"\n (empty placeholder)");
211 s =
format (s,
"\n Policy List:");
214 for (i = (h->
first_segment + 1); i < max_segs; i++, pl_index++)
217 char *tags[] = {
" ",
"InPE: ",
"EgPE: ",
"OrgSrc: " };
220 if (pl_index >= 1 && pl_index <= 4)
223 (flags_host_byte_order, pl_index);
224 tag = tags[this_pl_flag];
245 u32 max_header_bytes = va_arg (*args,
u32);
249 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
250 return format (s,
"ip6_sr header truncated");
255 0 , max_header_bytes);
264 #define foreach_sr_rewrite_next \ 265 _(ERROR, "error-drop") \ 266 _(IP6_LOOKUP, "ip6-lookup") \ 267 _(SR_LOCAL, "sr-local") \ 268 _(SR_REPLICATE,"sr-replicate") 270 #define foreach_sr_rewrite_next \ 271 _(ERROR, "error-drop") \ 272 _(IP6_LOOKUP, "ip6-lookup") \ 273 _(SR_LOCAL, "sr-local") 281 #define _(s,n) SR_REWRITE_NEXT_##s, 303 #define sr_error(n,s) s, 313 #define sr_error(n,s) SR_REWRITE_ERROR_##n, 337 (s,
"SR-REWRITE: next %s ip6 src %U dst %U len %u\n" 338 " rx-fib-id %d tx-fib-id %d\n%U",
340 ?
"sr-local" :
"ip6-lookup",
362 u32 n_left_from, next_index, *from, *to_next;
373 while (n_left_from > 0)
380 while (0 && n_left_from >= 4 && n_left_to_next >= 2)
383 vlib_buffer_t *b0, *b1;
384 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;
441 next0 = SR_REWRITE_NEXT_SR_REPLICATE;
457 next0 = SR_REWRITE_NEXT_SR_LOCAL;
461 u32 len_bytes =
sizeof (ip6_header_t);
466 (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
468 ip6_hop_by_hop_ext_t *ext_hdr =
473 next_hdr = ext_hdr->next_hdr;
509 next0 = sr_local_cb ? sr_local_cb (vm, node, b0, ip0, sr0) :
519 b0->
error = node->
errors[SR_REWRITE_ERROR_APP_CALLBACK];
528 next1 = SR_REWRITE_NEXT_SR_REPLICATE;
538 next1 = SR_REWRITE_NEXT_SR_LOCAL;
542 u32 len_bytes =
sizeof (ip6_header_t);
547 (ip1->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
549 ip6_hop_by_hop_ext_t *ext_hdr =
554 next_hdr = ext_hdr->next_hdr;
587 next1 = sr_local_cb ? sr_local_cb (vm, node, b1, ip1, sr1) :
597 b1->
error = node->
errors[SR_REWRITE_ERROR_APP_CALLBACK];
633 to_next, n_left_to_next,
634 bi0, bi1, next0, next1);
637 while (n_left_from > 0 && n_left_to_next > 0)
641 ip6_header_t *ip0 = 0;
644 u32 next0 = SR_REWRITE_NEXT_IP6_LOOKUP;
669 next0 = SR_REWRITE_NEXT_SR_REPLICATE;
692 next0 = SR_REWRITE_NEXT_SR_LOCAL;
696 u32 len_bytes =
sizeof (ip6_header_t);
701 (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
703 ip6_hop_by_hop_ext_t *ext_hdr =
707 next_hdr = ext_hdr->next_hdr;
743 next0 = sr_local_cb ? sr_local_cb (vm, node, b0, ip0, sr0) :
753 b0->
error = node->
errors[SR_REWRITE_ERROR_APP_CALLBACK];
778 to_next, n_left_to_next,
789 .name =
"sr-rewrite",
791 .vector_size =
sizeof (
u32),
795 .n_errors = SR_REWRITE_N_ERROR,
796 .error_strings = sr_rewrite_error_strings,
798 .runtime_data_bytes = 0,
802 #define _(s,n) [SR_REWRITE_NEXT_##s] = n, 813 u32 dst_address_length,
u32 rx_table_id)
816 .
fp_len = dst_address_length,
819 .ip6 = *dst_address_arg,
857 if (indexp && *indexp)
907 u32 rx_fib_index, tx_fib_index;
908 u32 hmac_key_index_u32;
909 u8 hmac_key_index = 0;
999 clib_warning (
"Tunnel index %d not found in policy_index %d",
1019 key_copy = (
void *) (hp->
key);
1027 memset (t, 0,
sizeof (*t));
1047 header_length =
sizeof (*h) +
1053 hmac_key_index_u32 = 0;
1055 &hmac_key_index_u32);
1058 if (hmac_key_index_u32 >= 256)
1060 hmac_key_index = hmac_key_index_u32;
1061 header_length += SHA256_DIGEST_LENGTH;
1070 h->
length = (header_length / 8) - 1;
1081 h->
hmac_key = hmac_key_index & 0xFF;
1152 memset (pt, 0,
sizeof (*pt));
1197 return (
format (s,
"SR: tunnel:[%d]", index));
1231 int src_address_set = 0;
1234 int dst_address_set = 0;
1236 u8 *shared_secret = 0;
1238 u8 *policy_name = 0;
1239 u32 rx_table_id = 0;
1240 u32 tx_table_id = 0;
1254 else if (
unformat (input,
"rx-fib-id %d", &rx_table_id))
1256 else if (
unformat (input,
"tx-fib-id %d", &tx_table_id))
1259 src_address_set = 1;
1260 else if (
unformat (input,
"name %s", &name))
1262 else if (
unformat (input,
"policy %s", &policy_name))
1264 else if (
unformat (input,
"dst %U/%d",
1266 dst_address_set = 1;
1272 sizeof (*this_seg));
1279 else if (
unformat (input,
"clean"))
1281 else if (
unformat (input,
"protected"))
1283 else if (
unformat (input,
"key %s", &shared_secret))
1285 _vec_len (shared_secret) -= 1;
1286 else if (
unformat (input,
"InPE %d", &pl_index))
1288 if (pl_index <= 0 || pl_index > 4)
1290 pl_index_range_error:
1292 (0,
"Policy List Element Index %d out of range (1-4)",
1299 else if (
unformat (input,
"EgPE %d", &pl_index))
1301 if (pl_index <= 0 || pl_index > 4)
1302 goto pl_index_range_error;
1306 else if (
unformat (input,
"OrgSrc %d", &pl_index))
1308 if (pl_index <= 0 || pl_index > 4)
1309 goto pl_index_range_error;
1317 if (!src_address_set)
1320 if (!dst_address_set)
1326 memset (a, 0,
sizeof (*a));
1386 .path =
"sr tunnel",
1388 "sr tunnel [del] [name <name>] src <addr> dst <addr> [next <addr>] " 1389 "[clean] [reroute] [key <secret>] [policy <policy_name>]" 1390 "[rx-fib-id <fib_id>] [tx-fib-id <fib_id>]",
1456 if (
unformat (input,
"name %s", &name))
1474 vec_add1 (tunnels, t);
1484 for (i = 0; i <
vec_len (tunnels); i++)
1495 .path =
"show sr tunnel",
1496 .short_help =
"show sr tunnel [name <sr-tunnel-name>]",
1515 u32 *tunnel_indices = 0;
1596 u8 **tunnel_names = 0;
1597 u8 *tunnel_name = 0;
1606 else if (
unformat (input,
"name %s", &name))
1608 else if (
unformat (input,
"tunnel %s", &tunnel_name))
1612 vec_add1 (tunnel_names, tunnel_name);
1624 memset (a, 0,
sizeof (*a));
1641 "tunnel name to associate to SR policy is required");
1665 .path =
"sr policy",
1667 "sr policy [del] name <policy-name> tunnel <sr-tunnel-name> [tunnel <sr-tunnel-name>]*",
1695 if (
unformat (input,
"name %s", &name))
1700 "policy with name %s not found. Showing all.",
1714 vec_add1 (policies, policy);
1727 for (i = 0; i <
vec_len (policies); i++)
1729 policy = policies[
i];
1746 .path =
"show sr policy",
1747 .short_help =
"show sr policy [name <sr-policy-name>]",
1860 u8 *policy_name = 0;
1861 int multicast_address_set = 0;
1872 multicast_address_set = 1;
1873 else if (
unformat (input,
"sr-policy %s", &policy_name))
1879 if (!is_del && !policy_name)
1882 if (!multicast_address_set)
1885 memset (a, 0,
sizeof (*a));
1895 "cannot use multicast replicate spray case without DPDK installed");
1910 "tunnel name to associate to SR policy is required");
1928 .path =
"sr multicast-map",
1930 "sr multicast-map address <multicast-ip6-address> sr-policy <sr-policy-name> [del]",
1961 vlib_cli_output (vm,
"no multicast maps configured");
1964 multicast_address = *((ip6_address_t *)key);
1965 pt = pool_elt_at_index (sm->policies, value);
1968 vlib_cli_output (vm,
"address: %U policy: %s",
1969 format_ip6_address, &multicast_address,
1973 vlib_cli_output (vm,
"BUG: policy not found for address: %U with policy index %d",
1974 format_ip6_address, &multicast_address,
1987 .path =
"show sr multicast-map",
1988 .short_help =
"show sr multicast-map",
1994 #define foreach_sr_fix_dst_addr_next \ 1995 _(DROP, "error-drop") 2002 #define _(s,n) SR_FIX_DST_ADDR_NEXT_##s, 2012 #define sr_fix_dst_error(n,s) s, 2014 #undef sr_fix_dst_error 2022 #define sr_fix_dst_error(n,s) SR_FIX_DST_ERROR_##n, 2024 #undef sr_fix_dst_error 2060 s =
format (s,
"SR-FIX_ADDR: next %s ip6 src %U dst %U\n",
2062 ?
"drop" :
"output",
2064 if (t->
next_index != SR_FIX_DST_ADDR_NEXT_DROP)
2069 format (s,
" output via %s",
2070 hi ? (
char *) (hi->
name) :
"Invalid adj");
2089 u32 n_left_from, next_index, *from, *to_next;
2098 while (n_left_from > 0)
2105 while (0 && n_left_from >= 4 && n_left_to_next >= 2)
2109 u32 next0 = SR_FIX_DST_ADDR_NEXT_DROP;
2110 u32 next1 = SR_FIX_DST_ADDR_NEXT_DROP;
2129 n_left_to_next -= 2;
2137 to_next, n_left_to_next,
2138 bi0, bi1, next0, next1);
2142 while (n_left_from > 0 && n_left_to_next > 0)
2149 u32 next0 = SR_FIX_DST_ADDR_NEXT_DROP;
2158 n_left_to_next -= 1;
2174 b0->
error = node->
errors[SR_FIX_DST_ERROR_NO_SR_HEADER];
2188 b0->
error = node->
errors[SR_FIX_DST_ERROR_NO_MORE_SEGMENTS];
2212 if (next0 != SR_FIX_DST_ADDR_NEXT_DROP)
2224 to_next, n_left_to_next,
2237 .name =
"sr-fix-dst-addr",
2239 .vector_size =
sizeof (
u32),
2243 .runtime_data_bytes = 0,
2245 .n_errors = SR_FIX_DST_N_ERROR,
2246 .error_strings = sr_fix_dst_error_strings,
2250 #define _(s,n) [SR_FIX_DST_ADDR_NEXT_##s] = n, 2293 ASSERT (ip6_lookup_node);
2296 ASSERT (ip6_rewrite_node);
2309 OpenSSL_add_all_digests ();
2311 sm->
md = (
void *) EVP_get_digestbyname (
"sha1");
2324 #define foreach_sr_local_next \ 2325 _ (ERROR, "error-drop") \ 2326 _ (IP6_LOOKUP, "ip6-lookup") 2333 #define _(s,n) SR_LOCAL_NEXT_##s, 2355 #define sr_error(n,s) s, 2365 #define sr_error(n,s) SR_LOCAL_ERROR_##n, 2386 s =
format (s,
"SR-LOCAL: src %U dst %U len %u next_index %d",
2393 s =
format (s,
"\n popped SR header");
2419 static u8 *signature;
2461 for (i = 0; i <= first_segment; i++)
2469 clib_warning (
"verify key index %d keybuf: %U", key_index,
2475 memset (signature, 0,
vec_len (signature));
2483 if (!HMAC_Final (sm->
hmac_ctx, signature, &sig_len))
2488 clib_warning (
"computed signature len %d, value %U", sig_len,
2495 SHA256_DIGEST_LENGTH);
2497 return memcmp (signature, addrp, SHA256_DIGEST_LENGTH);
2514 u32 n_left_from, next_index, *from, *to_next;
2525 while (n_left_from > 0)
2531 while (n_left_from >= 4 && n_left_to_next >= 2)
2534 vlib_buffer_t *b0, *b1;
2535 ip6_header_t *ip0, *ip1;
2538 u32 next0 = SR_LOCAL_NEXT_IP6_LOOKUP;
2539 u32 next1 = SR_LOCAL_NEXT_IP6_LOOKUP;
2543 vlib_buffer_t *p2, *p3;
2561 n_left_to_next -= 2;
2569 (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
2571 ip6_hop_by_hop_ext_t *ext_hdr =
2580 next0 = SR_LOCAL_NEXT_ERROR;
2582 node->
errors[SR_LOCAL_ERROR_BAD_ROUTING_HEADER_TYPE];
2589 next0 = SR_LOCAL_NEXT_ERROR;
2590 b0->
error = node->
errors[SR_LOCAL_ERROR_NO_MORE_SEGMENTS];
2598 next0 = SR_LOCAL_NEXT_ERROR;
2599 b0->
error = node->
errors[SR_LOCAL_ERROR_HMAC_INVALID];
2604 next0 = sr_local_cb ? sr_local_cb (vm, node, b0, ip0, sr0) : next0;
2611 next0 ^= 0xFFFFFFFF;
2613 b0->
error = node->
errors[SR_LOCAL_ERROR_APP_CALLBACK];
2636 u64 *copy_dst0, *copy_src0;
2638 u32 copy_len_u64s0 = 0;
2646 (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
2648 ip6_hop_by_hop_ext_t *ext_hdr =
2651 (((ip6_ext_header_t *) ext_hdr)->n_data_u64s) + 1;
2664 copy_src0 = (
u64 *) ip0;
2665 copy_dst0 = copy_src0 + (sr0->
length + 1);
2667 copy_dst0[4 + copy_len_u64s0] = copy_src0[4 + copy_len_u64s0];
2668 copy_dst0[3 + copy_len_u64s0] = copy_src0[3 + copy_len_u64s0];
2669 copy_dst0[2 + copy_len_u64s0] = copy_src0[2 + copy_len_u64s0];
2670 copy_dst0[1 + copy_len_u64s0] = copy_src0[1 + copy_len_u64s0];
2671 copy_dst0[0 + copy_len_u64s0] = copy_src0[0 + copy_len_u64s0];
2673 for (i = copy_len_u64s0 - 1; i >= 0; i--)
2675 copy_dst0[
i] = copy_src0[
i];
2701 (ip1->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
2704 ip6_hop_by_hop_ext_t *ext_hdr =
2713 next1 = SR_LOCAL_NEXT_ERROR;
2715 node->
errors[SR_LOCAL_ERROR_BAD_ROUTING_HEADER_TYPE];
2722 next1 = SR_LOCAL_NEXT_ERROR;
2723 b1->
error = node->
errors[SR_LOCAL_ERROR_NO_MORE_SEGMENTS];
2731 next1 = SR_LOCAL_NEXT_ERROR;
2732 b1->
error = node->
errors[SR_LOCAL_ERROR_HMAC_INVALID];
2737 next1 = sr_local_cb ? sr_local_cb (vm, node, b1, ip1, sr1) : next1;
2744 next1 ^= 0xFFFFFFFF;
2746 b1->
error = node->
errors[SR_LOCAL_ERROR_APP_CALLBACK];
2769 u64 *copy_dst1, *copy_src1;
2771 u32 copy_len_u64s1 = 0;
2779 (ip1->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
2781 ip6_hop_by_hop_ext_t *ext_hdr =
2784 (((ip6_ext_header_t *) ext_hdr)->n_data_u64s) + 1;
2797 copy_src1 = (
u64 *) ip1;
2798 copy_dst1 = copy_src1 + (sr1->
length + 1);
2800 copy_dst1[4 + copy_len_u64s1] = copy_src1[4 + copy_len_u64s1];
2801 copy_dst1[3 + copy_len_u64s1] = copy_src1[3 + copy_len_u64s1];
2802 copy_dst1[2 + copy_len_u64s1] = copy_src1[2 + copy_len_u64s1];
2803 copy_dst1[1 + copy_len_u64s1] = copy_src1[1 + copy_len_u64s1];
2804 copy_dst1[0 + copy_len_u64s1] = copy_src1[0 + copy_len_u64s1];
2806 for (i = copy_len_u64s1 - 1; i >= 0; i--)
2808 copy_dst1[
i] = copy_src1[
i];
2831 to_next, n_left_to_next,
2832 bi0, bi1, next0, next1);
2835 while (n_left_from > 0 && n_left_to_next > 0)
2839 ip6_header_t *ip0 = 0;
2842 u32 next0 = SR_LOCAL_NEXT_IP6_LOOKUP;
2849 n_left_to_next -= 1;
2856 (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
2858 ip6_hop_by_hop_ext_t *ext_hdr =
2866 next0 = SR_LOCAL_NEXT_ERROR;
2868 node->
errors[SR_LOCAL_ERROR_BAD_ROUTING_HEADER_TYPE];
2875 next0 = SR_LOCAL_NEXT_ERROR;
2876 b0->
error = node->
errors[SR_LOCAL_ERROR_NO_MORE_SEGMENTS];
2884 next0 = SR_LOCAL_NEXT_ERROR;
2885 b0->
error = node->
errors[SR_LOCAL_ERROR_HMAC_INVALID];
2890 next0 = sr_local_cb ? sr_local_cb (vm, node, b0, ip0, sr0) : next0;
2897 next0 ^= 0xFFFFFFFF;
2899 b0->
error = node->
errors[SR_LOCAL_ERROR_APP_CALLBACK];
2922 u64 *copy_dst0, *copy_src0;
2924 u32 copy_len_u64s0 = 0;
2932 (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS))
2934 ip6_hop_by_hop_ext_t *ext_hdr =
2937 (((ip6_ext_header_t *) ext_hdr)->n_data_u64s) + 1;
2951 copy_src0 = (
u64 *) ip0;
2952 copy_dst0 = copy_src0 + (sr0->
length + 1);
2953 copy_dst0[4 + copy_len_u64s0] = copy_src0[4 + copy_len_u64s0];
2954 copy_dst0[3 + copy_len_u64s0] = copy_src0[3 + copy_len_u64s0];
2955 copy_dst0[2 + copy_len_u64s0] = copy_src0[2 + copy_len_u64s0];
2956 copy_dst0[1 + copy_len_u64s0] = copy_src0[1 + copy_len_u64s0];
2957 copy_dst0[0 + copy_len_u64s0] = copy_src0[0 + copy_len_u64s0];
2959 for (i = copy_len_u64s0 - 1; i >= 0; i--)
2961 copy_dst0[
i] = copy_src0[
i];
2984 to_next, n_left_to_next,
2991 SR_LOCAL_ERROR_PKTS_PROCESSED,
3001 .vector_size =
sizeof (
u32),
3004 .runtime_data_bytes = 0,
3006 .n_errors = SR_LOCAL_N_ERROR,
3007 .error_strings = sr_local_error_strings,
3011 #define _(s,n) [SR_LOCAL_NEXT_##s] = n, 3059 if (
unformat (input,
"rx-table-id %d", &fib_id))
3062 if (fib_index == ~0)
3086 sw_if_index = adj->rewrite_header.sw_if_index;
3100 .path =
"set ip6 sr rewrite",
3101 .short_help =
"set ip6 sr rewrite <ip6-address> [fib-id <id>]",
3128 if (
unformat (input,
"validate on"))
3130 else if (
unformat (input,
"chunk-offset off"))
3143 .path =
"test sr hmac",
3144 .short_help =
"test sr hmac validate [on|off]",
3176 ASSERT (index == key_id);
3210 u8 *shared_secret = 0;
3217 else if (
unformat (input,
"id %d", &key_id))
3219 else if (
unformat (input,
"key %s", &shared_secret))
3222 _vec_len (shared_secret) -= 1;
3228 if (is_del == 0 && shared_secret == 0)
3231 if (shared_secret == 0 && key_id_set == 0)
3253 .short_help =
"sr hmac [del] id <nn> key <str>",
3285 .path =
"show sr hmac",
3286 .short_help =
"show sr hmac",
3321 .path =
"test sr debug",
3322 .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) ...
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.
u32 fib_table_id_find_fib_index(fib_protocol_t proto, u32 table_id)
fib_protocol_t fp_proto
protocol type
HMAC_CTX * hmac_ctx
Openssl var.
dpo_lock_fn_t dv_lock
A reference counting lock function.
Segment Route tunnel key.
u8 * format_sr_dpo(u8 *s, va_list *args)
static vlib_cli_command_t test_sr_debug
(constructor) VLIB_CLI_COMMAND (test_sr_debug)
#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.
A virtual function table regisitered for a DPO type.
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.
fib_node_index_t fib_table_lookup_exact_match(u32 fib_index, const fib_prefix_t *prefix)
Perfom an exact match in the non-forwarding table.
void ip6_register_protocol(u32 protocol, u32 node_index)
u32 tx_fib_index
TX Fib index.
static ip6_fib_t * ip6_fib_get(fib_node_index_t 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
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.
u8 * name
Pptional tunnel name.
static const char *const sr_ip6_nodes[]
int ip6_sr_add_del_policy(ip6_sr_add_del_policy_args_t *a)
Add or Delete a Segment Routing policy.
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).
vlib_node_registration_t ip6_rewrite_node
(constructor) VLIB_REGISTER_NODE (ip6_rewrite_node)
struct _vlib_node_registration vlib_node_registration_t
static void * ip6_ext_next_header(ip6_ext_header_t *ext_hdr)
#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.
static dpo_type_t sr_dpo_type
Dynamically added SR DPO type.
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 ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
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.
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type() ...
#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)
static vlib_cli_command_t test_sr_hmac_validate
(constructor) VLIB_CLI_COMMAND (test_sr_hmac_validate)
u8 * name
optional name argument - for referencing SR tunnel/policy by name
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Aggregrate type for a prefix.
static vlib_cli_command_t show_sr_hmac
(constructor) VLIB_CLI_COMMAND (show_sr_hmac)
static vlib_cli_command_t show_sr_policy_command
(constructor) VLIB_CLI_COMMAND (show_sr_policy_command)
#define clib_warning(format, args...)
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
u16 fp_len
The mask length.
#define vlib_call_init_function(vm, x)
static const char *const *const sr_nodes[DPO_PROTO_NUM]
#define foreach_sr_rewrite_next
Defined valid next nodes.
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
#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
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Args required for add/del tunnel.
#define hash_create_mem(elts, key_bytes, value_bytes)
u8 is_del
Delete the tunnnel?
#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.
#define hash_unset_mem(h, key)
static char * sr_local_error_strings[]
Definition of SR local error-strings.
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.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
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)
#define ip6_ext_header_len(p)
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)
u16 mcast_group_index
Force re-lookup in a different FIB.
#define vec_free(V)
Free vector's memory (no header).
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
static void sr_dpo_unlock(dpo_id_t *dpo)
no-op unlock function.
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.
#define IP6_SR_HEADER_FLAG_PL_ELT_ORIG_SRC_ADDR
Flag bits.
u32 fib_node_index_t
A typedef of a node index.
#define IP6_SR_HEADER_FLAG_PL_ELT_NOT_PRESENT
Flag bits.
u32 * tunnel_indices
vector to SR tunnel index
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
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.
static void * ip6_next_header(ip6_header_t *i)
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)
#define VLIB_CLI_COMMAND(x,...)
u8 * format_ip6_sr_header(u8 *s, va_list *args)
Format function for decoding ip6_sr_header_t.
u8 validate_hmac
validate hmac keys
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
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)
static void sr_dpo_lock(dpo_id_t *dpo)
no-op lock function.
static vlib_cli_command_t sr_hmac
(constructor) VLIB_CLI_COMMAND (sr_hmac)
adj_index_t fib_entry_get_adj_for_source(fib_node_index_t fib_entry_index, fib_source_t source)
ip_lookup_main_t lookup_main
#define vec_delete(V, N, M)
Delete N elements starting at element M.
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
static vlib_cli_command_t set_ip6_sr_rewrite
(constructor) VLIB_CLI_COMMAND (set_ip6_sr_rewrite)
#define IP6_SR_HEADER_FLAG_PL_ELT_INGRESS_PE
Flag bits.
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)
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
static const dpo_vft_t sr_vft
#define FIB_NODE_INDEX_INVALID
uword * policy_index_by_multicast_address
multicast address to policy mapping
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip_lookup_next_t lookup_next_index
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.
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
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.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
u8 * format_sr_local_trace(u8 *s, va_list *args)
Format SR local trace.
#define foreach_sr_fix_dst_addr_next
#define clib_error_return(e, args...)
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