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,
145 .path =
"set sr encaps source",
146 .short_help =
"set sr encaps source addr <ip6_addr>",
175 if (hop_limit <= 0 || hop_limit > 255)
183 .path =
"set sr encaps hop-limit",
184 .short_help =
"set sr encaps hop-limit <value>",
202 ip6_address_t *addrp, *this_address;
203 u32 header_length = 0;
211 header_length +=
vec_len (sl) *
sizeof (ip6_address_t);
218 clib_host_to_net_u32 (0 | ((6 & 0xF) << 28));
228 iph->
protocol = IP_PROTOCOL_IPV6_ROUTE;
234 (
vec_len (sl) *
sizeof (ip6_address_t))) / 8) - 1;
241 sizeof (ip6_address_t));
261 ip6_address_t *addrp, *this_address;
262 u32 header_length = 0;
267 header_length += (
vec_len (sl) + 1) *
sizeof (ip6_address_t);
276 ((
vec_len (sl) + 1) *
sizeof (ip6_address_t))) / 8) - 1;
283 sizeof (ip6_address_t));
300 ip6_address_t *addrp, *this_address;
301 u32 header_length = 0;
306 header_length +=
vec_len (sl) *
sizeof (ip6_address_t);
315 (
vec_len (sl) *
sizeof (ip6_address_t))) / 8) - 1;
322 sizeof (ip6_address_t));
352 clib_memset (segment_list, 0,
sizeof (*segment_list));
461 .ip6 = sr_policy->
bsid,
564 .ip6 = sr_policy->
bsid,
594 path.path_weight = 1;
666 (fib_table != (
u32) ~ 0 ? fib_table : 0));
680 sr_policy->
fib_table = (fib_table != (
u32) ~ 0 ? fib_table : 0);
685 sr_policy->
plugin = plugin;
701 "SRv6 steering of IP6 prefixes through BSIDs");
704 "SRv6 steering of IP4 prefixes through BSIDs");
752 .ip6 = sr_policy->
bsid,
839 u32 *sl_index_iterate;
869 else if (operation == 2)
899 else if (operation == 3)
932 char is_del = 0, is_add = 0, is_mod = 0;
934 ip6_address_t bsid, next_address;
937 ip6_address_t *segments = 0, *this_seg;
942 void *ls_plugin_mem = 0;
946 if (!is_add && !is_mod && !is_del &&
unformat (input,
"add"))
948 else if (!is_add && !is_mod && !is_del &&
unformat (input,
"del"))
950 else if (!is_add && !is_mod && !is_del &&
unformat (input,
"mod"))
955 else if (!is_add && !policy_set
956 &&
unformat (input,
"index %d", &sr_policy_index))
966 else if (
unformat (input,
"add sl"))
972 else if (fib_table == (
u32) ~ 0
973 &&
unformat (input,
"fib-table %d", &fib_table));
976 else if (
unformat (input,
"insert"))
980 else if (!behavior &&
unformat (input,
"behavior"))
995 (input,
"%U", (*plugin_it)->ls_unformat, &ls_plugin_mem))
997 behavior = (*plugin_it)->sr_policy_function_number;
1011 if (!is_add && !is_mod && !is_del)
1019 if (behavior &&
vec_len (segments) == 0)
1029 behavior, ls_plugin_mem);
1042 if (operation == 1 &&
vec_len (segments) == 0)
1044 if (operation == 3 &&
weight == (
u32) ~ 0)
1048 sr_policy_index, fib_table, operation, segments,
1063 "There is already a FIB entry for the BindingSID address.\n"
1064 "The SR policy could not be created.");
1069 "The selected SR policy only contains ONE segment list. "
1070 "Please remove the SR policy instead");
1073 "Could not delete the segment list. "
1074 "It is not associated with that SR policy.");
1077 "Could not modify the segment list. "
1078 "The given SL is not associated with such SR policy.");
1087 .path =
"sr policy",
1088 .short_help =
"sr policy [add||del||mod] [bsid 2001::1||index 5] "
1089 "next A:: next B:: next C:: (weight 1) (fib-table 2) (encap|insert)",
1091 "Manipulation of SR policies.\n"
1092 "A Segment Routing policy may contain several SID lists. Each SID list has\n"
1093 "an associated weight (default 1), which will result in wECMP (uECMP).\n"
1094 "Segment Routing policies might be of type encapsulation or srh insertion\n"
1095 "Each SR policy will be associated with a unique BindingSID.\n"
1096 "A BindingSID is a locally allocated SegmentID. For every packet that arrives\n"
1097 "with IPv6_DA:BSID such traffic will be steered into the SR policy.\n"
1098 "The add command will create a SR policy with its first segment list (sl)\n"
1099 "The mod command allows you to add, remove, or modify the existing segment lists\n"
1100 "within an SR policy.\n"
1101 "The del command allows you to delete a SR policy along with all its associated\n"
1119 ip6_address_t *
addr;
1127 {
vec_add1 (vec_policies, sr_policy); }
1132 sr_policy = vec_policies[
i];
1137 (sr_policy->
is_encap ?
"Encapsulation" :
1139 switch (sr_policy->
type)
1162 s =
format (s,
"\b\b > ");
1173 .path =
"show sr policies",
1174 .short_help =
"show sr policies",
1194 .path =
"show sr encaps source addr",
1195 .short_help =
"show sr encaps source addr",
1215 .path =
"show sr encaps hop-limit",
1216 .short_help =
"show sr encaps hop-limit",
1234 (s,
"SR-policy-rewrite: src %U dst %U",
1260 (clib_net_to_host_u32 (
1263 (flow_label & 0x0000ffff));
1281 int encap_pkts = 0, bsid_pkts = 0;
1292 u32 bi0, bi1, bi2, bi3;
1294 u32 next0, next1, next2, next3;
1295 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1297 ip6_header_t *ip0_encap, *ip1_encap, *ip2_encap, *ip3_encap;
1321 to_next[0] = bi0 =
from[0];
1322 to_next[1] = bi1 =
from[1];
1323 to_next[2] = bi2 =
from[2];
1324 to_next[3] = bi3 =
from[3];
1328 n_left_to_next -= 4;
1398 sizeof (tr->
src.as_u8));
1400 sizeof (tr->
dst.as_u8));
1408 sizeof (tr->
src.as_u8));
1410 sizeof (tr->
dst.as_u8));
1418 sizeof (tr->
src.as_u8));
1420 sizeof (tr->
dst.as_u8));
1428 sizeof (tr->
src.as_u8));
1430 sizeof (tr->
dst.as_u8));
1436 n_left_to_next, bi0, bi1, bi2, bi3,
1437 next0, next1, next2, next3);
1447 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1454 n_left_to_next -= 1;
1481 sizeof (tr->
src.as_u8));
1483 sizeof (tr->
dst.as_u8));
1488 n_left_to_next, bi0, next0);
1496 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
1499 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
1508 .name =
"sr-pl-rewrite-encaps",
1509 .vector_size =
sizeof (
u32),
1516 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
1538 ip0_encap->
ttl -= 1;
1539 checksum0 = ip0_encap->
checksum + clib_host_to_net_u16 (0x0100);
1540 checksum0 += checksum0 >= 0xffff;
1548 0 | ((6 & 0xF) << 28) | ((ip0_encap->
tos & 0xFF) << 20) |
1549 (flow_label & 0x0000ffff));
1550 if (ip0->
protocol == IP_PROTOCOL_IPV6_ROUTE)
1552 sr0 = (
void *) (ip0 + 1);
1553 sr0->
protocol = IP_PROTOCOL_IP_IN_IP;
1556 ip0->
protocol = IP_PROTOCOL_IP_IN_IP;
1574 int encap_pkts = 0, bsid_pkts = 0;
1585 u32 bi0, bi1, bi2, bi3;
1587 u32 next0, next1, next2, next3;
1588 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1590 ip4_header_t *ip0_encap, *ip1_encap, *ip2_encap, *ip3_encap;
1614 to_next[0] = bi0 =
from[0];
1615 to_next[1] = bi1 =
from[1];
1616 to_next[2] = bi2 =
from[2];
1617 to_next[3] = bi3 =
from[3];
1621 n_left_to_next -= 4;
1690 sizeof (tr->
src.as_u8));
1692 sizeof (tr->
dst.as_u8));
1700 sizeof (tr->
src.as_u8));
1702 sizeof (tr->
dst.as_u8));
1710 sizeof (tr->
src.as_u8));
1712 sizeof (tr->
dst.as_u8));
1720 sizeof (tr->
src.as_u8));
1722 sizeof (tr->
dst.as_u8));
1728 n_left_to_next, bi0, bi1, bi2, bi3,
1729 next0, next1, next2, next3);
1740 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1747 n_left_to_next -= 1;
1774 sizeof (tr->
src.as_u8));
1776 sizeof (tr->
dst.as_u8));
1781 n_left_to_next, bi0, next0);
1789 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
1792 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
1801 .name =
"sr-pl-rewrite-encaps-v4",
1802 .vector_size =
sizeof (
u32),
1809 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
1830 return (*((
u64 *) m) & 0xffffffffffff);
1838 uword is_ip, eh_size;
1842 eh_type = clib_net_to_host_u16 (eh->
type);
1845 is_ip = (eh_type == ETHERNET_TYPE_IP4 || eh_type == ETHERNET_TYPE_IP6);
1875 int encap_pkts = 0, bsid_pkts = 0;
1886 u32 bi0, bi1, bi2, bi3;
1888 u32 next0, next1, next2, next3;
1889 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1895 u32 flow_label0, flow_label1, flow_label2, flow_label3;
1918 to_next[0] = bi0 =
from[0];
1919 to_next[1] = bi1 =
from[1];
1920 to_next[2] = bi2 =
from[2];
1921 to_next[3] = bi3 =
from[3];
1925 n_left_to_next -= 4;
2051 if (ip0->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2053 sr0 = (
void *) (ip0 + 1);
2059 if (ip1->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2061 sr1 = (
void *) (ip1 + 1);
2067 if (ip2->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2069 sr2 = (
void *) (ip2 + 1);
2075 if (ip3->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2077 sr3 = (
void *) (ip3 + 1);
2086 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label0 & 0xffff));
2088 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label1 & 0xffff));
2090 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label2 & 0xffff));
2092 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label3 & 0xffff));
2101 sizeof (tr->
src.as_u8));
2103 sizeof (tr->
dst.as_u8));
2111 sizeof (tr->
src.as_u8));
2113 sizeof (tr->
dst.as_u8));
2121 sizeof (tr->
src.as_u8));
2123 sizeof (tr->
dst.as_u8));
2131 sizeof (tr->
src.as_u8));
2133 sizeof (tr->
dst.as_u8));
2139 n_left_to_next, bi0, bi1, bi2, bi3,
2140 next0, next1, next2, next3);
2153 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2161 n_left_to_next -= 1;
2199 if (ip0->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2201 sr0 = (
void *) (ip0 + 1);
2208 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label0 & 0xffff));
2216 sizeof (tr->
src.as_u8));
2218 sizeof (tr->
dst.as_u8));
2223 n_left_to_next, bi0, next0);
2231 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
2234 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
2243 .name =
"sr-pl-rewrite-encaps-l2",
2244 .vector_size =
sizeof (
u32),
2251 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
2273 int insert_pkts = 0, bsid_pkts = 0;
2284 u32 bi0, bi1, bi2, bi3;
2286 u32 next0, next1, next2, next3;
2287 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2291 u16 new_l0, new_l1, new_l2, new_l3;
2314 to_next[0] = bi0 =
from[0];
2315 to_next[1] = bi1 =
from[1];
2316 to_next[2] = bi2 =
from[2];
2317 to_next[3] = bi3 =
from[3];
2321 n_left_to_next -= 4;
2354 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2361 if (ip1->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2368 if (ip2->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2375 if (ip3->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2383 (
void *) sr0 - (
void *) ip0);
2385 (
void *) sr1 - (
void *) ip1);
2387 (
void *) sr2 - (
void *) ip2);
2389 (
void *) sr3 - (
void *) ip3);
2410 ip0->hop_limit -= 1;
2411 ip1->hop_limit -= 1;
2412 ip2->hop_limit -= 1;
2413 ip3->hop_limit -= 1;
2416 clib_net_to_host_u16 (ip0->payload_length) +
2419 clib_net_to_host_u16 (ip1->payload_length) +
2422 clib_net_to_host_u16 (ip2->payload_length) +
2425 clib_net_to_host_u16 (ip3->payload_length) +
2428 ip0->payload_length = clib_host_to_net_u16 (new_l0);
2429 ip1->payload_length = clib_host_to_net_u16 (new_l1);
2430 ip2->payload_length = clib_host_to_net_u16 (new_l2);
2431 ip3->payload_length = clib_host_to_net_u16 (new_l3);
2438 sr0->
segments->as_u64[0] = ip0->dst_address.as_u64[0];
2439 sr0->
segments->as_u64[1] = ip0->dst_address.as_u64[1];
2440 sr1->
segments->as_u64[0] = ip1->dst_address.as_u64[0];
2441 sr1->
segments->as_u64[1] = ip1->dst_address.as_u64[1];
2442 sr2->
segments->as_u64[0] = ip2->dst_address.as_u64[0];
2443 sr2->
segments->as_u64[1] = ip2->dst_address.as_u64[1];
2444 sr3->
segments->as_u64[0] = ip3->dst_address.as_u64[0];
2445 sr3->
segments->as_u64[1] = ip3->dst_address.as_u64[1];
2447 ip0->dst_address.as_u64[0] =
2449 ip0->dst_address.as_u64[1] =
2451 ip1->dst_address.as_u64[0] =
2453 ip1->dst_address.as_u64[1] =
2455 ip2->dst_address.as_u64[0] =
2457 ip2->dst_address.as_u64[1] =
2459 ip3->dst_address.as_u64[0] =
2461 ip3->dst_address.as_u64[1] =
2464 ip6_ext_header_t *ip_ext;
2465 if (ip0 + 1 == (
void *) sr0)
2468 ip0->protocol = IP_PROTOCOL_IPV6_ROUTE;
2472 ip_ext = (
void *) (ip0 + 1);
2474 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2477 if (ip1 + 1 == (
void *) sr1)
2480 ip1->protocol = IP_PROTOCOL_IPV6_ROUTE;
2484 ip_ext = (
void *) (ip2 + 1);
2486 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2489 if (ip2 + 1 == (
void *) sr2)
2492 ip2->protocol = IP_PROTOCOL_IPV6_ROUTE;
2496 ip_ext = (
void *) (ip2 + 1);
2498 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2501 if (ip3 + 1 == (
void *) sr3)
2504 ip3->protocol = IP_PROTOCOL_IPV6_ROUTE;
2508 ip_ext = (
void *) (ip3 + 1);
2510 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2522 sizeof (tr->
src.as_u8));
2524 sizeof (tr->
dst.as_u8));
2532 sizeof (tr->
src.as_u8));
2534 sizeof (tr->
dst.as_u8));
2542 sizeof (tr->
src.as_u8));
2544 sizeof (tr->
dst.as_u8));
2552 sizeof (tr->
src.as_u8));
2554 sizeof (tr->
dst.as_u8));
2559 n_left_to_next, bi0, bi1, bi2, bi3,
2560 next0, next1, next2, next3);
2571 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2579 n_left_to_next -= 1;
2590 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2598 (
void *) sr0 - (
void *) ip0);
2605 ip0->hop_limit -= 1;
2607 clib_net_to_host_u16 (ip0->payload_length) +
2609 ip0->payload_length = clib_host_to_net_u16 (new_l0);
2612 sr0->
segments->as_u64[0] = ip0->dst_address.as_u64[0];
2613 sr0->
segments->as_u64[1] = ip0->dst_address.as_u64[1];
2615 ip0->dst_address.as_u64[0] =
2617 ip0->dst_address.as_u64[1] =
2620 if (ip0 + 1 == (
void *) sr0)
2623 ip0->protocol = IP_PROTOCOL_IPV6_ROUTE;
2627 ip6_ext_header_t *ip_ext = (
void *) (ip0 + 1);
2629 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2638 sizeof (tr->
src.as_u8));
2640 sizeof (tr->
dst.as_u8));
2646 n_left_to_next, bi0, next0);
2654 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
2657 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
2665 .name =
"sr-pl-rewrite-insert",
2666 .vector_size =
sizeof (
u32),
2673 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
2695 int insert_pkts = 0, bsid_pkts = 0;
2706 u32 bi0, bi1, bi2, bi3;
2708 u32 next0, next1, next2, next3;
2709 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2713 u16 new_l0, new_l1, new_l2, new_l3;
2736 to_next[0] = bi0 =
from[0];
2737 to_next[1] = bi1 =
from[1];
2738 to_next[2] = bi2 =
from[2];
2739 to_next[3] = bi3 =
from[3];
2743 n_left_to_next -= 4;
2776 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2783 if (ip1->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2790 if (ip2->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2797 if (ip3->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2805 (
u8 *) ip0, (
void *) sr0 - (
void *) ip0);
2807 (
u8 *) ip1, (
void *) sr1 - (
void *) ip1);
2809 (
u8 *) ip2, (
void *) sr2 - (
void *) ip2);
2811 (
u8 *) ip3, (
void *) sr3 - (
void *) ip3);
2832 ip0->hop_limit -= 1;
2833 ip1->hop_limit -= 1;
2834 ip2->hop_limit -= 1;
2835 ip3->hop_limit -= 1;
2838 clib_net_to_host_u16 (ip0->payload_length) +
2841 clib_net_to_host_u16 (ip1->payload_length) +
2844 clib_net_to_host_u16 (ip2->payload_length) +
2847 clib_net_to_host_u16 (ip3->payload_length) +
2850 ip0->payload_length = clib_host_to_net_u16 (new_l0);
2851 ip1->payload_length = clib_host_to_net_u16 (new_l1);
2852 ip2->payload_length = clib_host_to_net_u16 (new_l2);
2853 ip3->payload_length = clib_host_to_net_u16 (new_l3);
2860 ip0->dst_address.as_u64[0] =
2862 ip0->dst_address.as_u64[1] =
2864 ip1->dst_address.as_u64[0] =
2866 ip1->dst_address.as_u64[1] =
2868 ip2->dst_address.as_u64[0] =
2870 ip2->dst_address.as_u64[1] =
2872 ip3->dst_address.as_u64[0] =
2874 ip3->dst_address.as_u64[1] =
2877 ip6_ext_header_t *ip_ext;
2878 if (ip0 + 1 == (
void *) sr0)
2881 ip0->protocol = IP_PROTOCOL_IPV6_ROUTE;
2885 ip_ext = (
void *) (ip0 + 1);
2887 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2890 if (ip1 + 1 == (
void *) sr1)
2893 ip1->protocol = IP_PROTOCOL_IPV6_ROUTE;
2897 ip_ext = (
void *) (ip2 + 1);
2899 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2902 if (ip2 + 1 == (
void *) sr2)
2905 ip2->protocol = IP_PROTOCOL_IPV6_ROUTE;
2909 ip_ext = (
void *) (ip2 + 1);
2911 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2914 if (ip3 + 1 == (
void *) sr3)
2917 ip3->protocol = IP_PROTOCOL_IPV6_ROUTE;
2921 ip_ext = (
void *) (ip3 + 1);
2923 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2935 sizeof (tr->
src.as_u8));
2937 sizeof (tr->
dst.as_u8));
2945 sizeof (tr->
src.as_u8));
2947 sizeof (tr->
dst.as_u8));
2955 sizeof (tr->
src.as_u8));
2957 sizeof (tr->
dst.as_u8));
2965 sizeof (tr->
src.as_u8));
2967 sizeof (tr->
dst.as_u8));
2972 n_left_to_next, bi0, bi1, bi2, bi3,
2973 next0, next1, next2, next3);
2984 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2992 n_left_to_next -= 1;
3003 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
3011 (
u8 *) ip0, (
void *) sr0 - (
void *) ip0);
3018 ip0->hop_limit -= 1;
3020 clib_net_to_host_u16 (ip0->payload_length) +
3022 ip0->payload_length = clib_host_to_net_u16 (new_l0);
3026 ip0->dst_address.as_u64[0] =
3028 ip0->dst_address.as_u64[1] =
3031 if (ip0 + 1 == (
void *) sr0)
3034 ip0->protocol = IP_PROTOCOL_IPV6_ROUTE;
3038 ip6_ext_header_t *ip_ext = (
void *) (ip0 + 1);
3040 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
3049 sizeof (tr->
src.as_u8));
3051 sizeof (tr->
dst.as_u8));
3057 n_left_to_next, bi0, next0);
3065 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
3068 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
3076 .name =
"sr-pl-rewrite-b-insert",
3077 .vector_size =
sizeof (
u32),
3084 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
3097 u32 *next0,
u8 policy_type)
3099 ip6_address_t *new_dst0;
3102 goto error_bsid_encaps;
3109 new_dst0 = (ip6_address_t *) (sr0->
segments);
3118 *next0 = SR_POLICY_REWRITE_NEXT_ERROR;
3119 b0->
error =
node->errors[SR_POLICY_REWRITE_ERROR_BSID_ZERO];
3137 int encap_pkts = 0, bsid_pkts = 0;
3148 u32 bi0, bi1, bi2, bi3;
3150 u32 next0, next1, next2, next3;
3151 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
3153 ip6_header_t *ip0_encap, *ip1_encap, *ip2_encap, *ip3_encap;
3178 to_next[0] = bi0 =
from[0];
3179 to_next[1] = bi1 =
from[1];
3180 to_next[2] = bi2 =
from[2];
3181 to_next[3] = bi3 =
from[3];
3185 n_left_to_next -= 4;
3271 sizeof (tr->
src.as_u8));
3273 sizeof (tr->
dst.as_u8));
3281 sizeof (tr->
src.as_u8));
3283 sizeof (tr->
dst.as_u8));
3291 sizeof (tr->
src.as_u8));
3293 sizeof (tr->
dst.as_u8));
3301 sizeof (tr->
src.as_u8));
3303 sizeof (tr->
dst.as_u8));
3309 n_left_to_next, bi0, bi1, bi2, bi3,
3310 next0, next1, next2, next3);
3321 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
3328 n_left_to_next -= 1;
3358 sizeof (tr->
src.as_u8));
3360 sizeof (tr->
dst.as_u8));
3365 n_left_to_next, bi0, next0);
3373 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
3376 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
3385 .name =
"sr-pl-rewrite-b-encaps",
3386 .vector_size =
sizeof (
u32),
3393 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
3468 {
vec_add1 (plugins_vec, plugin); }
3474 plugin = plugins_vec[
i];
3484 .path =
"show sr policy behaviors",
3485 .short_help =
"show sr policy behaviors",
3495 ip6_address_t *
addr;
3500 s =
format (s,
"SR: Segment List index:[%d]",
index);
3501 s =
format (s,
"\n\tSegments:");
3510 s =
format (s,
"\b\b > - ");
3523 "sr-pl-rewrite-encaps",
3528 "sr-pl-rewrite-encaps-v4",
3538 "sr-pl-rewrite-insert",
3547 "sr-pl-rewrite-b-insert",
3556 "sr-pl-rewrite-b-encaps",
3575 sizeof (ip6_address_t));