63 #define foreach_sr_policy_rewrite_next \ 64 _(IP6_LOOKUP, "ip6-lookup") \ 65 _(ERROR, "error-drop") 69 #define _(s,n) SR_POLICY_REWRITE_NEXT_##s, 76 #define foreach_sr_policy_rewrite_error \ 77 _(INTERNAL_ERROR, "Segment Routing undefined error") \ 78 _(BSID_ZERO, "BSID with SL = 0") \ 79 _(COUNTER_TOTAL, "SR steered IPv6 packets") \ 80 _(COUNTER_ENCAP, "SR: Encaps packets") \ 81 _(COUNTER_INSERT, "SR: SRH inserted packets") \ 82 _(COUNTER_BSID, "SR: BindingSID steered packets") 86 #define _(sym,str) SR_POLICY_REWRITE_ERROR_##sym, 93 #define _(sym,string) string, 132 .path =
"set sr encaps source",
133 .short_help =
"set sr encaps source addr <ip6_addr>",
152 u32 header_length = 0;
167 clib_host_to_net_u32 (0 | ((6 & 0xF) << 28));
175 iph->
protocol = IP_PROTOCOL_IPV6_ROUTE;
207 u32 header_length = 0;
245 u32 header_length = 0;
294 memset (segment_list, 0,
sizeof (*segment_list));
364 .ip6 = sr_policy->
bsid,
470 .ip6 = sr_policy->
bsid,
544 u32 weight,
u8 behavior,
u32 fib_table,
u8 is_encap)
573 (
u32) ~ 0 ? fib_table : 0));
584 memset (sr_policy, 0,
sizeof (*sr_policy));
586 sr_policy->
type = behavior;
587 sr_policy->
fib_table = (fib_table != (
u32) ~ 0 ? fib_table : 0);
595 create_sl (sr_policy, segments, weight, is_encap);
601 "SRv6 steering of IP6 prefixes through BSIDs");
603 "SRv6 steering of IP4 prefixes through BSIDs");
651 .ip6 = sr_policy->
bsid,
724 u32 *sl_index_iterate;
754 else if (operation == 2)
762 if (*sl_index_iterate == sl_index)
765 if (*sl_index_iterate != sl_index)
783 else if (operation == 3)
787 if (*sl_index_iterate == sl_index)
790 if (*sl_index_iterate != sl_index)
795 segment_list->
weight = weight;
815 char is_del = 0, is_add = 0, is_mod = 0;
818 u32 sr_policy_index = (
u32) ~ 0, sl_index = (
u32) ~ 0;
819 u32 weight = (
u32) ~ 0, fib_table = (
u32) ~ 0;
827 if (!is_add && !is_mod && !is_del &&
unformat (input,
"add"))
829 else if (!is_add && !is_mod && !is_del &&
unformat (input,
"del"))
831 else if (!is_add && !is_mod && !is_del &&
unformat (input,
"mod"))
836 else if (!is_add && !policy_set
837 &&
unformat (input,
"index %d", &sr_policy_index))
839 else if (
unformat (input,
"weight %d", &weight));
847 else if (
unformat (input,
"add sl"))
849 else if (
unformat (input,
"del sl index %d", &sl_index))
851 else if (
unformat (input,
"mod sl index %d", &sl_index))
853 else if (fib_table == (
u32) ~ 0
854 &&
unformat (input,
"fib-table %d", &fib_table));
857 else if (
unformat (input,
"insert"))
865 if (!is_add && !is_mod && !is_del)
886 if (operation != 1 && sl_index == (
u32) ~ 0)
888 if (operation == 1 &&
vec_len (segments) == 0)
890 if (operation == 3 && weight == (
u32) ~ 0)
893 sr_policy_index, fib_table, operation, segments,
905 "There is already a FIB entry for the BindingSID address.\n" 906 "The SR policy could not be created.");
911 "The selected SR policy only contains ONE segment list. " 912 "Please remove the SR policy instead");
915 "Could not delete the segment list. " 916 "It is not associated with that SR policy.");
919 "Could not modify the segment list. " 920 "The given SL is not associated with such SR policy.");
930 .short_help =
"sr policy [add||del||mod] [bsid 2001::1||index 5] " 931 "next A:: next B:: next C:: (weight 1) (fib-table 2) (encap|insert)",
933 "Manipulation of SR policies.\n" 934 "A Segment Routing policy may contain several SID lists. Each SID list has\n" 935 "an associated weight (default 1), which will result in wECMP (uECMP).\n" 936 "Segment Routing policies might be of type encapsulation or srh insertion\n" 937 "Each SR policy will be associated with a unique BindingSID.\n" 938 "A BindingSID is a locally allocated SegmentID. For every packet that arrives\n" 939 "with IPv6_DA:BSID such traffic will be steered into the SR policy.\n" 940 "The add command will create a SR policy with its first segment list (sl)\n" 941 "The mod command allows you to add, remove, or modify the existing segment lists\n" 942 "within an SR policy.\n" 943 "The del command allows you to delete a SR policy along with all its associated\n" 969 {vec_add1 (vec_policies, sr_policy); } );
974 sr_policy = vec_policies[
i];
979 (sr_policy->
is_encap ?
"Encapsulation" :
991 s =
format (s,
"\t[%u].- ", *sl_index);
998 s =
format (s,
"\b\b > ");
1009 .path =
"show sr policies",
1010 .short_help =
"show sr policies",
1028 (s,
"SR-policy-rewrite: src %U dst %U",
1061 u32 n_left_from, next_index, *from, *to_next;
1068 int encap_pkts = 0, bsid_pkts = 0;
1070 while (n_left_from > 0)
1077 while (n_left_from >= 8 && n_left_to_next >= 4)
1079 u32 bi0, bi1, bi2, bi3;
1081 u32 next0, next1, next2, next3;
1082 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1084 ip6_header_t *ip0_encap, *ip1_encap, *ip2_encap, *ip3_encap;
1108 to_next[0] = bi0 = from[0];
1109 to_next[1] = bi1 = from[1];
1110 to_next[2] = bi2 = from[2];
1111 to_next[3] = bi3 = from[3];
1115 n_left_to_next -= 4;
1218 n_left_to_next, bi0, bi1, bi2, bi3,
1219 next0, next1, next2, next3);
1223 while (n_left_from > 0 && n_left_to_next > 0)
1229 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1236 n_left_to_next -= 1;
1268 n_left_to_next, bi0, next0);
1276 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
1279 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
1288 .name =
"sr-pl-rewrite-encaps",
1289 .vector_size =
sizeof (
u32),
1296 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n, 1317 ip0_encap->
ttl -= 1;
1318 checksum0 = ip0_encap->
checksum + clib_host_to_net_u16 (0x0100);
1319 checksum0 += checksum0 >= 0xffff;
1326 clib_host_to_net_u32 (0 | ((6 & 0xF) << 28) |
1327 ((ip0_encap->
tos & 0xFF) << 20));
1328 sr0 = (
void *) (ip0 + 1);
1329 sr0->
protocol = IP_PROTOCOL_IP_IN_IP;
1340 u32 n_left_from, next_index, *from, *to_next;
1347 int encap_pkts = 0, bsid_pkts = 0;
1349 while (n_left_from > 0)
1356 while (n_left_from >= 8 && n_left_to_next >= 4)
1358 u32 bi0, bi1, bi2, bi3;
1360 u32 next0, next1, next2, next3;
1361 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1363 ip4_header_t *ip0_encap, *ip1_encap, *ip2_encap, *ip3_encap;
1387 to_next[0] = bi0 = from[0];
1388 to_next[1] = bi1 = from[1];
1389 to_next[2] = bi2 = from[2];
1390 to_next[3] = bi3 = from[3];
1394 n_left_to_next -= 4;
1496 n_left_to_next, bi0, bi1, bi2, bi3,
1497 next0, next1, next2, next3);
1501 while (n_left_from > 0 && n_left_to_next > 0)
1508 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1515 n_left_to_next -= 1;
1547 n_left_to_next, bi0, next0);
1555 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
1558 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
1567 .name =
"sr-pl-rewrite-encaps-v4",
1568 .vector_size =
sizeof (
u32),
1575 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n, 1596 return (*((
u64 *) m) & 0xffffffffffff);
1604 uword is_ip, eh_size;
1608 eh_type = clib_net_to_host_u16 (eh->
type);
1611 is_ip = (eh_type == ETHERNET_TYPE_IP4 || eh_type == ETHERNET_TYPE_IP6);
1634 u32 n_left_from, next_index, *from, *to_next;
1641 int encap_pkts = 0, bsid_pkts = 0;
1643 while (n_left_from > 0)
1650 while (n_left_from >= 8 && n_left_to_next >= 4)
1652 u32 bi0, bi1, bi2, bi3;
1654 u32 next0, next1, next2, next3;
1655 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1683 to_next[0] = bi0 = from[0];
1684 to_next[1] = bi1 = from[1];
1685 to_next[2] = bi2 = from[2];
1686 to_next[3] = bi3 = from[3];
1690 n_left_to_next -= 4;
1812 sr0 = (
void *) (ip0 + 1);
1813 sr1 = (
void *) (ip1 + 1);
1814 sr2 = (
void *) (ip2 + 1);
1815 sr3 = (
void *) (ip3 + 1);
1818 IP_PROTOCOL_IP6_NONXT;
1868 n_left_to_next, bi0, bi1, bi2, bi3,
1869 next0, next1, next2, next3);
1873 while (n_left_from > 0 && n_left_to_next > 0)
1882 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1889 n_left_to_next -= 1;
1926 sr0 = (
void *) (ip0 + 1);
1927 sr0->
protocol = IP_PROTOCOL_IP6_NONXT;
1942 n_left_to_next, bi0, next0);
1950 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
1953 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
1962 .name =
"sr-pl-rewrite-encaps-l2",
1963 .vector_size =
sizeof (
u32),
1970 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n, 1985 u32 n_left_from, next_index, *from, *to_next;
1992 int insert_pkts = 0, bsid_pkts = 0;
1994 while (n_left_from > 0)
2001 while (n_left_from >= 8 && n_left_to_next >= 4)
2003 u32 bi0, bi1, bi2, bi3;
2005 u32 next0, next1, next2, next3;
2006 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2010 u16 new_l0, new_l1, new_l2, new_l3;
2033 to_next[0] = bi0 = from[0];
2034 to_next[1] = bi1 = from[1];
2035 to_next[2] = bi2 = from[2];
2036 to_next[3] = bi3 = from[3];
2040 n_left_to_next -= 4;
2073 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2080 if (ip1->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2087 if (ip2->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2094 if (ip3->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2102 (
void *) sr0 - (
void *) ip0);
2104 (
void *) sr1 - (
void *) ip1);
2106 (
void *) sr2 - (
void *) ip2);
2108 (
void *) sr3 - (
void *) ip3);
2183 ip6_ext_header_t *ip_ext;
2184 if (ip0 + 1 == (
void *) sr0)
2187 ip0->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2191 ip_ext = (
void *) (ip0 + 1);
2193 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2196 if (ip1 + 1 == (
void *) sr1)
2199 ip1->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2203 ip_ext = (
void *) (ip2 + 1);
2205 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2208 if (ip2 + 1 == (
void *) sr2)
2211 ip2->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2215 ip_ext = (
void *) (ip2 + 1);
2217 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2220 if (ip3 + 1 == (
void *) sr3)
2223 ip3->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2227 ip_ext = (
void *) (ip3 + 1);
2229 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2278 n_left_to_next, bi0, bi1, bi2, bi3,
2279 next0, next1, next2, next3);
2283 while (n_left_from > 0 && n_left_to_next > 0)
2290 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2298 n_left_to_next -= 1;
2309 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2317 (
void *) sr0 - (
void *) ip0);
2339 if (ip0 + 1 == (
void *) sr0)
2342 ip0->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2346 ip6_ext_header_t *ip_ext = (
void *) (ip0 + 1);
2348 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2365 n_left_to_next, bi0, next0);
2373 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
2376 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
2384 .name =
"sr-pl-rewrite-insert",
2385 .vector_size =
sizeof (
u32),
2392 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n, 2407 u32 n_left_from, next_index, *from, *to_next;
2414 int insert_pkts = 0, bsid_pkts = 0;
2416 while (n_left_from > 0)
2423 while (n_left_from >= 8 && n_left_to_next >= 4)
2425 u32 bi0, bi1, bi2, bi3;
2427 u32 next0, next1, next2, next3;
2428 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2432 u16 new_l0, new_l1, new_l2, new_l3;
2455 to_next[0] = bi0 = from[0];
2456 to_next[1] = bi1 = from[1];
2457 to_next[2] = bi2 = from[2];
2458 to_next[3] = bi3 = from[3];
2462 n_left_to_next -= 4;
2495 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2502 if (ip1->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2509 if (ip2->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2516 if (ip3->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2524 (
void *) sr0 - (
void *) ip0);
2526 (
void *) sr1 - (
void *) ip1);
2528 (
void *) sr2 - (
void *) ip2);
2530 (
void *) sr3 - (
void *) ip3);
2596 ip6_ext_header_t *ip_ext;
2597 if (ip0 + 1 == (
void *) sr0)
2600 ip0->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2604 ip_ext = (
void *) (ip0 + 1);
2606 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2609 if (ip1 + 1 == (
void *) sr1)
2612 ip1->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2616 ip_ext = (
void *) (ip2 + 1);
2618 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2621 if (ip2 + 1 == (
void *) sr2)
2624 ip2->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2628 ip_ext = (
void *) (ip2 + 1);
2630 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2633 if (ip3 + 1 == (
void *) sr3)
2636 ip3->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2640 ip_ext = (
void *) (ip3 + 1);
2642 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2691 n_left_to_next, bi0, bi1, bi2, bi3,
2692 next0, next1, next2, next3);
2696 while (n_left_from > 0 && n_left_to_next > 0)
2703 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2711 n_left_to_next -= 1;
2722 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2730 (
void *) sr0 - (
void *) ip0);
2750 if (ip0 + 1 == (
void *) sr0)
2753 ip0->
protocol = IP_PROTOCOL_IPV6_ROUTE;
2757 ip6_ext_header_t *ip_ext = (
void *) (ip0 + 1);
2759 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2776 n_left_to_next, bi0, next0);
2784 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
2787 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
2795 .name =
"sr-pl-rewrite-b-insert",
2796 .vector_size =
sizeof (
u32),
2803 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n, 2822 goto error_bsid_encaps;
2838 *next0 = SR_POLICY_REWRITE_NEXT_ERROR;
2839 b0->
error = node->
errors[SR_POLICY_REWRITE_ERROR_BSID_ZERO];
2850 u32 n_left_from, next_index, *from, *to_next;
2857 int encap_pkts = 0, bsid_pkts = 0;
2859 while (n_left_from > 0)
2866 while (n_left_from >= 8 && n_left_to_next >= 4)
2868 u32 bi0, bi1, bi2, bi3;
2870 u32 next0, next1, next2, next3;
2871 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2873 ip6_header_t *ip0_encap, *ip1_encap, *ip2_encap, *ip3_encap;
2875 ip6_ext_header_t *prev0, *prev1, *prev2, *prev3;
2899 to_next[0] = bi0 = from[0];
2900 to_next[1] = bi1 = from[1];
2901 to_next[2] = bi2 = from[2];
2902 to_next[3] = bi3 = from[3];
2906 n_left_to_next -= 4;
2940 IP_PROTOCOL_IPV6_ROUTE);
2942 IP_PROTOCOL_IPV6_ROUTE);
2944 IP_PROTOCOL_IPV6_ROUTE);
2946 IP_PROTOCOL_IPV6_ROUTE);
3022 n_left_to_next, bi0, bi1, bi2, bi3,
3023 next0, next1, next2, next3);
3027 while (n_left_from > 0 && n_left_to_next > 0)
3032 ip6_ext_header_t *prev0;
3035 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
3042 n_left_to_next -= 1;
3053 IP_PROTOCOL_IPV6_ROUTE);
3077 n_left_to_next, bi0, next0);
3085 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
3088 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
3097 .name =
"sr-pl-rewrite-b-encaps",
3098 .vector_size =
sizeof (
u32),
3105 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n, 3122 s =
format (s,
"SR: Segment List index:[%d]", index);
3123 s =
format (s,
"\n\tSegments:");
3132 s =
format (s,
"\b\b > - ");
3145 "sr-pl-rewrite-encaps",
3150 "sr-pl-rewrite-encaps-v4",
3160 "sr-pl-rewrite-insert",
3169 "sr-pl-rewrite-b-insert",
3178 "sr-pl-rewrite-b-encaps",
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static clib_error_t * sr_policy_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI for 'sr policies' command family.
u32 fib_table_create_and_lock(fib_protocol_t proto, const char *const fmt,...)
Create a new table with no table ID.
static u8 * compute_rewrite_insert(ip6_address_t *sl)
SR rewrite string computation for SRH insertion (inline)
u32 fib_table_id_find_fib_index(fib_protocol_t proto, u32 table_id)
fib_protocol_t fp_proto
protocol type
dpo_lock_fn_t dv_lock
A reference counting lock function.
u8 type
Type (default is 0)
#define vec_foreach_index(var, v)
Iterate over vector indices.
sll srl srl sll sra u16x4 i
#define SR_POLICY_TYPE_SPRAY
fib_node_index_t path_index
The index of the FIB path.
#define foreach_sr_policy_rewrite_error
A virtual function table regisitered for a DPO type.
static uword sr_policy_rewrite_b_insert(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Graph node for applying a SR policy into a packet.
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.
dpo_id_t path_dpo
ID of the Data-path object.
static uword sr_policy_rewrite_b_encaps(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Graph node for applying a SR policy BSID - Encapsulation.
void sr_dpo_unlock(dpo_id_t *dpo)
no-op unlock function.
static const char *const sr_pr_encaps_ip4_nodes[]
static int dpo_id_is_valid(const dpo_id_t *dpoi)
Return true if the DPO object is valid, i.e.
vlib_node_registration_t sr_policy_rewrite_b_encaps_node
(constructor) VLIB_REGISTER_NODE (sr_policy_rewrite_b_encaps_node)
static u32 ip4_compute_flow_hash(const ip4_header_t *ip, flow_hash_config_t flow_hash_config)
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
#define ethernet_buffer_header_size(b)
Determine the size of the Ethernet headers of the current frame in the buffer.
int sr_policy_mod(ip6_address_t *bsid, u32 index, u32 fib_table, u8 operation, ip6_address_t *segments, u32 sl_index, u32 weight)
Modify an existing SR policy.
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.
dpo_id_t ip4_dpo
DPO for Encaps IPv6.
#define VLIB_BUFFER_PRE_DATA_SIZE
static uword sr_policy_rewrite_insert(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Graph node for applying a SR policy into a packet.
ip6_address_t * segments
SIDs (key)
static u8 * compute_rewrite_bsid(ip6_address_t *sl)
SR rewrite string computation for SRH insertion with BSID (inline)
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).
#define vlib_validate_buffer_enqueue_x4(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, bi2, bi3, next0, next1, next2, next3)
Finish enqueueing four buffers forward in the graph.
static clib_error_t * set_sr_src_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static ip6_sr_sl_t * create_sl(ip6_sr_policy_t *sr_policy, ip6_address_t *sl, u32 weight, u8 is_encap)
Creates a Segment List and adds it to an SR policy.
static const char *const *const sr_pr_bsid_encaps_nodes[DPO_PROTO_NUM]
#define IPv6_DEFAULT_HEADER_LENGTH
u32 l2_sr_policy_rewrite_index
#define ROUTING_HEADER_TYPE_SR
static u8 * format_sr_segment_list_dpo(u8 *s, va_list *args)
vlib_error_t * errors
Vector of errors for this node.
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
ip6_sr_steering_policy_t * steer_policies
static_always_inline void encaps_processing_v6(vlib_node_runtime_t *node, vlib_buffer_t *b0, ip6_header_t *ip0, ip6_header_t *ip0_encap)
IPv6 encapsulation processing as per RFC2473.
vlib_node_registration_t sr_policy_rewrite_encaps_v4_node
(constructor) VLIB_REGISTER_NODE (sr_policy_rewrite_encaps_v4_node)
u8 * rewrite_bsid
Precomputed rewrite header for bindingSID.
vlib_node_registration_t sr_policy_rewrite_encaps_l2_node
(constructor) VLIB_REGISTER_NODE (sr_policy_rewrite_encaps_l2_node)
static uword sr_policy_rewrite_encaps_l2(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Graph node for applying a SR policy into a L2 frame.
flow_hash_config_t fib_table_get_flow_hash_config(u32 fib_index, fib_protocol_t proto)
Get the flow hash configured used by the table.
index_t load_balance_create(u32 n_buckets, dpo_proto_t lb_proto, flow_hash_config_t fhc)
dpo_id_t ip6_dpo
DPO for Encaps/Insert IPv6.
u32 * sw_iface_sr_policies
vlib_node_registration_t sr_policy_rewrite_encaps_node
(constructor) VLIB_REGISTER_NODE (sr_policy_rewrite_encaps_node)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define static_always_inline
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.
static const char *const sr_pr_insert_ip6_nodes[]
static u32 l2_flow_hash(vlib_buffer_t *b0)
#define VLIB_INIT_FUNCTION(x)
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a 'special' entry from the FIB.
SR Segment List (SID list)
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
void load_balance_multipath_update(const dpo_id_t *dpo, const load_balance_path_t *raw_nhs, load_balance_flags_t flags)
static uword sr_policy_rewrite_encaps(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Graph node for applying a SR policy into an IPv6 packet.
static const char *const *const sr_pr_encaps_nodes[DPO_PROTO_NUM]
static u64 mac_to_u64(u8 *m)
fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto)
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
int sr_policy_del(ip6_address_t *bsid, u32 index)
Delete a SR policy.
static void update_replicate(ip6_sr_policy_t *sr_policy)
Updates the Replicate DPO after an SR Policy change.
void fib_table_unlock(u32 fib_index, fib_protocol_t proto)
Take a reference counting lock on the table.
vlib_node_registration_t sr_policy_rewrite_b_insert_node
(constructor) VLIB_REGISTER_NODE (sr_policy_rewrite_b_insert_node)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
vlib_node_registration_t sr_policy_rewrite_insert_node
(constructor) VLIB_REGISTER_NODE (sr_policy_rewrite_insert_node)
u16 current_length
Nbytes between current data and the end of this buffer.
static const char *const sr_pr_bsid_insert_ip6_nodes[]
static dpo_type_t sr_pr_bsid_insert_dpo_type
#define SR_SEGMENT_LIST_WEIGHT_DEFAULT
static u8 * compute_rewrite_encaps(ip6_address_t *sl)
SR rewrite string computation for IPv6 encapsulation (inline)
load-balancing over a choice of [un]equal cost paths
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u32 ip6_compute_flow_hash(const ip6_header_t *ip, flow_hash_config_t flow_hash_config)
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
void sr_dpo_lock(dpo_id_t *dpo)
no-op lock function.
#define vec_del1(v, i)
Delete the element at index I.
#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.
static uword mhash_set(mhash_t *h, void *key, uword new_value, uword *old_value)
#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).
u8 is_encap
Mode (0 is SRH insert, 1 Encaps)
static uword sr_policy_rewrite_encaps_v4(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Graph node for applying a SR policy into an IPv4 packet.
vlib_error_t error
Error code for buffers to be enqueued to error handler.
u32 weight
SID list weight (wECMP / UCMP)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
sr_policy_rewrite_error_t
#define ip6_ext_header_len(p)
void replicate_multipath_update(const dpo_id_t *dpo, load_balance_path_t *next_hops)
fib_node_index_t fib_table_entry_special_dpo_update(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Update a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the...
void mhash_init(mhash_t *h, uword n_value_bytes, uword n_key_bytes)
#define hash_mix64(a0, b0, c0)
#define CLIB_PREFETCH(addr, size, type)
static const char *const sr_pr_bsid_encaps_ip6_nodes[]
#define vec_free(V)
Free vector's memory (no header).
static_always_inline void end_bsid_encaps_srh_processing(vlib_node_runtime_t *node, vlib_buffer_t *b0, ip6_header_t *ip0, ip6_sr_header_t *sr0, u32 *next0)
Function BSID encapsulation.
static u8 * format_sr_policy_rewrite_trace(u8 *s, va_list *args)
Trace for the SR Policy Rewrite graph node.
u32 * segments_lists
SID lists indexes (vector)
#define VLIB_BUFFER_IS_TRACED
#define clib_memcpy(a, b, c)
u32 fib_node_index_t
A typedef of a node index.
dpo_id_t bsid_dpo
DPO for Encaps/Insert for BSID.
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.
index_t replicate_create(u32 n_buckets, dpo_proto_t rep_proto)
#define foreach_sr_policy_rewrite_next
clib_error_t * sr_policy_rewrite_init(vlib_main_t *vm)
SR Policy Rewrite initialization.
#define VLIB_CLI_COMMAND(x,...)
static const char *const *const sr_pr_bsid_insert_nodes[DPO_PROTO_NUM]
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
#define pool_put_index(p, i)
Free pool element with given index.
static uword * mhash_get(mhash_t *h, const void *key)
static const char *const *const sr_pr_insert_nodes[DPO_PROTO_NUM]
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
#define VLIB_NODE_FLAG_TRACE
#define IP_FLOW_HASH_DEFAULT
Default: 5-tuple without the "reverse" bit.
static dpo_type_t sr_pr_encaps_dpo_type
Dynamically added SR SL DPO type.
static_always_inline void encaps_processing_v4(vlib_node_runtime_t *node, vlib_buffer_t *b0, ip6_header_t *ip0, ip4_header_t *ip0_encap)
IPv4 encapsulation processing as per RFC2473.
u32 flow_hash_config_t
A flow hash configuration is a mask of the flow hash options.
mhash_t sr_policies_index_hash
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
int sr_policy_add(ip6_address_t *bsid, ip6_address_t *segments, u32 weight, u8 behavior, u32 fib_table, u8 is_encap)
Create a new SR policy.
#define FIB_NODE_INDEX_INVALID
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip6_sr_policy_t * sr_policies
u32 path_weight
weight for the path.
u8 * rewrite
Precomputed rewrite header.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define SR_POLICY_TYPE_DEFAULT
dpo_id_t bsid_dpo
SR Policy specific DPO - BSID.
static dpo_type_t sr_pr_insert_dpo_type
One path from an [EU]CMP set that the client wants to add to a load-balance object.
static char * sr_policy_rewrite_error_strings[]
Segment Routing data structures definitions.
Segment Routing main datastructure.
#define VLIB_REGISTER_NODE(x,...)
dpo_id_t ip6_dpo
SR Policy specific DPO - IPv4.
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
#define vec_foreach(var, vec)
Vector iterator.
static const char *const sr_pr_encaps_ip6_nodes[]
#define ip6_ext_header_find_t(i, p, m, t)
u16 flags
Copy of main node flags.
static dpo_type_t sr_pr_bsid_encaps_dpo_type
#define CLIB_CACHE_LINE_BYTES
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
#define IPv6_DEFAULT_HOP_LIMIT
dpo_id_t ip4_dpo
SR Policy specific DPO - IPv6.
static ip6_address_t sr_pr_encaps_src
IPv6 SA for encapsulated packets.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static void update_lb(ip6_sr_policy_t *sr_policy)
Updates the Load Balancer after an SR Policy change.
ip6_address_t bsid
BindingSID (key)
static u32 ip_flow_hash(void *data)
static clib_error_t * show_sr_policies_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
CLI to display onscreen all the SR policies.
static uword pool_elts(void *v)
Number of active elements in a pool.