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));
460 .ip6 = sr_policy->
bsid,
563 .ip6 = sr_policy->
bsid,
593 path.path_weight = 1;
637 u16 plugin,
void *ls_plugin_mem)
665 (fib_table != (
u32) ~ 0 ? fib_table : 0));
678 sr_policy->
type = behavior;
679 sr_policy->
fib_table = (fib_table != (
u32) ~ 0 ? fib_table : 0);
684 sr_policy->
plugin = plugin;
700 "SRv6 steering of IP6 prefixes through BSIDs");
703 "SRv6 steering of IP4 prefixes through BSIDs");
751 .ip6 = sr_policy->
bsid,
838 u32 *sl_index_iterate;
868 else if (operation == 2)
898 else if (operation == 3)
931 char is_del = 0, is_add = 0, is_mod = 0;
933 ip6_address_t bsid, next_address;
936 ip6_address_t *segments = 0, *this_seg;
941 void *ls_plugin_mem = 0;
945 if (!is_add && !is_mod && !is_del &&
unformat (input,
"add"))
947 else if (!is_add && !is_mod && !is_del &&
unformat (input,
"del"))
949 else if (!is_add && !is_mod && !is_del &&
unformat (input,
"mod"))
954 else if (!is_add && !policy_set
955 &&
unformat (input,
"index %d", &sr_policy_index))
965 else if (
unformat (input,
"add sl"))
971 else if (fib_table == (
u32) ~ 0
972 &&
unformat (input,
"fib-table %d", &fib_table));
975 else if (
unformat (input,
"insert"))
979 else if (!behavior &&
unformat (input,
"behavior"))
994 (input,
"%U", (*plugin_it)->ls_unformat, &ls_plugin_mem))
996 behavior = (*plugin_it)->sr_policy_function_number;
1010 if (!is_add && !is_mod && !is_del)
1018 if (behavior &&
vec_len (segments) == 0)
1030 behavior, ls_plugin_mem);
1043 if (operation == 1 &&
vec_len (segments) == 0)
1045 if (operation == 3 &&
weight == (
u32) ~ 0)
1049 sr_policy_index, fib_table, operation, segments,
1064 "There is already a FIB entry for the BindingSID address.\n"
1065 "The SR policy could not be created.");
1070 "The selected SR policy only contains ONE segment list. "
1071 "Please remove the SR policy instead");
1074 "Could not delete the segment list. "
1075 "It is not associated with that SR policy.");
1078 "Could not modify the segment list. "
1079 "The given SL is not associated with such SR policy.");
1088 .path =
"sr policy",
1089 .short_help =
"sr policy [add||del||mod] [bsid 2001::1||index 5] "
1090 "next A:: next B:: next C:: (weight 1) (fib-table 2) (encap|insert)",
1092 "Manipulation of SR policies.\n"
1093 "A Segment Routing policy may contain several SID lists. Each SID list has\n"
1094 "an associated weight (default 1), which will result in wECMP (uECMP).\n"
1095 "Segment Routing policies might be of type encapsulation or srh insertion\n"
1096 "Each SR policy will be associated with a unique BindingSID.\n"
1097 "A BindingSID is a locally allocated SegmentID. For every packet that arrives\n"
1098 "with IPv6_DA:BSID such traffic will be steered into the SR policy.\n"
1099 "The add command will create a SR policy with its first segment list (sl)\n"
1100 "The mod command allows you to add, remove, or modify the existing segment lists\n"
1101 "within an SR policy.\n"
1102 "The del command allows you to delete a SR policy along with all its associated\n"
1120 ip6_address_t *
addr;
1128 {
vec_add1 (vec_policies, sr_policy); }
1133 sr_policy = vec_policies[
i];
1138 (sr_policy->
is_encap ?
"Encapsulation" :
1157 s =
format (s,
"\b\b > ");
1168 .path =
"show sr policies",
1169 .short_help =
"show sr policies",
1189 .path =
"show sr encaps source addr",
1190 .short_help =
"show sr encaps source addr",
1210 .path =
"show sr encaps hop-limit",
1211 .short_help =
"show sr encaps hop-limit",
1229 (s,
"SR-policy-rewrite: src %U dst %U",
1255 (clib_net_to_host_u32 (
1258 (flow_label & 0x0000ffff));
1276 int encap_pkts = 0, bsid_pkts = 0;
1287 u32 bi0, bi1, bi2, bi3;
1289 u32 next0, next1, next2, next3;
1290 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1292 ip6_header_t *ip0_encap, *ip1_encap, *ip2_encap, *ip3_encap;
1316 to_next[0] = bi0 =
from[0];
1317 to_next[1] = bi1 =
from[1];
1318 to_next[2] = bi2 =
from[2];
1319 to_next[3] = bi3 =
from[3];
1323 n_left_to_next -= 4;
1393 sizeof (tr->
src.as_u8));
1395 sizeof (tr->
dst.as_u8));
1403 sizeof (tr->
src.as_u8));
1405 sizeof (tr->
dst.as_u8));
1413 sizeof (tr->
src.as_u8));
1415 sizeof (tr->
dst.as_u8));
1423 sizeof (tr->
src.as_u8));
1425 sizeof (tr->
dst.as_u8));
1431 n_left_to_next, bi0, bi1, bi2, bi3,
1432 next0, next1, next2, next3);
1442 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1449 n_left_to_next -= 1;
1476 sizeof (tr->
src.as_u8));
1478 sizeof (tr->
dst.as_u8));
1483 n_left_to_next, bi0, next0);
1491 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
1494 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
1503 .name =
"sr-pl-rewrite-encaps",
1504 .vector_size =
sizeof (
u32),
1511 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
1533 ip0_encap->
ttl -= 1;
1534 checksum0 = ip0_encap->
checksum + clib_host_to_net_u16 (0x0100);
1535 checksum0 += checksum0 >= 0xffff;
1543 0 | ((6 & 0xF) << 28) | ((ip0_encap->
tos & 0xFF) << 20) |
1544 (flow_label & 0x0000ffff));
1545 if (ip0->
protocol == IP_PROTOCOL_IPV6_ROUTE)
1547 sr0 = (
void *) (ip0 + 1);
1548 sr0->
protocol = IP_PROTOCOL_IP_IN_IP;
1551 ip0->
protocol = IP_PROTOCOL_IP_IN_IP;
1569 int encap_pkts = 0, bsid_pkts = 0;
1580 u32 bi0, bi1, bi2, bi3;
1582 u32 next0, next1, next2, next3;
1583 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1585 ip4_header_t *ip0_encap, *ip1_encap, *ip2_encap, *ip3_encap;
1609 to_next[0] = bi0 =
from[0];
1610 to_next[1] = bi1 =
from[1];
1611 to_next[2] = bi2 =
from[2];
1612 to_next[3] = bi3 =
from[3];
1616 n_left_to_next -= 4;
1685 sizeof (tr->
src.as_u8));
1687 sizeof (tr->
dst.as_u8));
1695 sizeof (tr->
src.as_u8));
1697 sizeof (tr->
dst.as_u8));
1705 sizeof (tr->
src.as_u8));
1707 sizeof (tr->
dst.as_u8));
1715 sizeof (tr->
src.as_u8));
1717 sizeof (tr->
dst.as_u8));
1723 n_left_to_next, bi0, bi1, bi2, bi3,
1724 next0, next1, next2, next3);
1735 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1742 n_left_to_next -= 1;
1769 sizeof (tr->
src.as_u8));
1771 sizeof (tr->
dst.as_u8));
1776 n_left_to_next, bi0, next0);
1784 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
1787 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
1796 .name =
"sr-pl-rewrite-encaps-v4",
1797 .vector_size =
sizeof (
u32),
1804 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
1825 return (*((
u64 *) m) & 0xffffffffffff);
1833 uword is_ip, eh_size;
1837 eh_type = clib_net_to_host_u16 (eh->
type);
1840 is_ip = (eh_type == ETHERNET_TYPE_IP4 || eh_type == ETHERNET_TYPE_IP6);
1870 int encap_pkts = 0, bsid_pkts = 0;
1881 u32 bi0, bi1, bi2, bi3;
1883 u32 next0, next1, next2, next3;
1884 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
1890 u32 flow_label0, flow_label1, flow_label2, flow_label3;
1913 to_next[0] = bi0 =
from[0];
1914 to_next[1] = bi1 =
from[1];
1915 to_next[2] = bi2 =
from[2];
1916 to_next[3] = bi3 =
from[3];
1920 n_left_to_next -= 4;
2046 if (ip0->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2048 sr0 = (
void *) (ip0 + 1);
2054 if (ip1->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2056 sr1 = (
void *) (ip1 + 1);
2062 if (ip2->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2064 sr2 = (
void *) (ip2 + 1);
2070 if (ip3->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2072 sr3 = (
void *) (ip3 + 1);
2081 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label0 & 0xffff));
2083 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label1 & 0xffff));
2085 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label2 & 0xffff));
2087 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label3 & 0xffff));
2096 sizeof (tr->
src.as_u8));
2098 sizeof (tr->
dst.as_u8));
2106 sizeof (tr->
src.as_u8));
2108 sizeof (tr->
dst.as_u8));
2116 sizeof (tr->
src.as_u8));
2118 sizeof (tr->
dst.as_u8));
2126 sizeof (tr->
src.as_u8));
2128 sizeof (tr->
dst.as_u8));
2134 n_left_to_next, bi0, bi1, bi2, bi3,
2135 next0, next1, next2, next3);
2148 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2156 n_left_to_next -= 1;
2194 if (ip0->
protocol == IP_PROTOCOL_IPV6_ROUTE)
2196 sr0 = (
void *) (ip0 + 1);
2203 0 | ((6 & 0xF) << 28) | ((0x00) << 20) | (flow_label0 & 0xffff));
2211 sizeof (tr->
src.as_u8));
2213 sizeof (tr->
dst.as_u8));
2218 n_left_to_next, bi0, next0);
2226 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
2229 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
2238 .name =
"sr-pl-rewrite-encaps-l2",
2239 .vector_size =
sizeof (
u32),
2246 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
2268 int insert_pkts = 0, bsid_pkts = 0;
2279 u32 bi0, bi1, bi2, bi3;
2281 u32 next0, next1, next2, next3;
2282 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2286 u16 new_l0, new_l1, new_l2, new_l3;
2309 to_next[0] = bi0 =
from[0];
2310 to_next[1] = bi1 =
from[1];
2311 to_next[2] = bi2 =
from[2];
2312 to_next[3] = bi3 =
from[3];
2316 n_left_to_next -= 4;
2349 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2356 if (ip1->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2363 if (ip2->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2370 if (ip3->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2378 (
void *) sr0 - (
void *) ip0);
2380 (
void *) sr1 - (
void *) ip1);
2382 (
void *) sr2 - (
void *) ip2);
2384 (
void *) sr3 - (
void *) ip3);
2405 ip0->hop_limit -= 1;
2406 ip1->hop_limit -= 1;
2407 ip2->hop_limit -= 1;
2408 ip3->hop_limit -= 1;
2411 clib_net_to_host_u16 (ip0->payload_length) +
2414 clib_net_to_host_u16 (ip1->payload_length) +
2417 clib_net_to_host_u16 (ip2->payload_length) +
2420 clib_net_to_host_u16 (ip3->payload_length) +
2423 ip0->payload_length = clib_host_to_net_u16 (new_l0);
2424 ip1->payload_length = clib_host_to_net_u16 (new_l1);
2425 ip2->payload_length = clib_host_to_net_u16 (new_l2);
2426 ip3->payload_length = clib_host_to_net_u16 (new_l3);
2433 sr0->
segments->as_u64[0] = ip0->dst_address.as_u64[0];
2434 sr0->
segments->as_u64[1] = ip0->dst_address.as_u64[1];
2435 sr1->
segments->as_u64[0] = ip1->dst_address.as_u64[0];
2436 sr1->
segments->as_u64[1] = ip1->dst_address.as_u64[1];
2437 sr2->
segments->as_u64[0] = ip2->dst_address.as_u64[0];
2438 sr2->
segments->as_u64[1] = ip2->dst_address.as_u64[1];
2439 sr3->
segments->as_u64[0] = ip3->dst_address.as_u64[0];
2440 sr3->
segments->as_u64[1] = ip3->dst_address.as_u64[1];
2442 ip0->dst_address.as_u64[0] =
2444 ip0->dst_address.as_u64[1] =
2446 ip1->dst_address.as_u64[0] =
2448 ip1->dst_address.as_u64[1] =
2450 ip2->dst_address.as_u64[0] =
2452 ip2->dst_address.as_u64[1] =
2454 ip3->dst_address.as_u64[0] =
2456 ip3->dst_address.as_u64[1] =
2459 ip6_ext_header_t *ip_ext;
2460 if (ip0 + 1 == (
void *) sr0)
2463 ip0->protocol = IP_PROTOCOL_IPV6_ROUTE;
2467 ip_ext = (
void *) (ip0 + 1);
2469 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2472 if (ip1 + 1 == (
void *) sr1)
2475 ip1->protocol = IP_PROTOCOL_IPV6_ROUTE;
2479 ip_ext = (
void *) (ip2 + 1);
2481 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2484 if (ip2 + 1 == (
void *) sr2)
2487 ip2->protocol = IP_PROTOCOL_IPV6_ROUTE;
2491 ip_ext = (
void *) (ip2 + 1);
2493 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2496 if (ip3 + 1 == (
void *) sr3)
2499 ip3->protocol = IP_PROTOCOL_IPV6_ROUTE;
2503 ip_ext = (
void *) (ip3 + 1);
2505 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2517 sizeof (tr->
src.as_u8));
2519 sizeof (tr->
dst.as_u8));
2527 sizeof (tr->
src.as_u8));
2529 sizeof (tr->
dst.as_u8));
2537 sizeof (tr->
src.as_u8));
2539 sizeof (tr->
dst.as_u8));
2547 sizeof (tr->
src.as_u8));
2549 sizeof (tr->
dst.as_u8));
2554 n_left_to_next, bi0, bi1, bi2, bi3,
2555 next0, next1, next2, next3);
2566 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2574 n_left_to_next -= 1;
2585 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2593 (
void *) sr0 - (
void *) ip0);
2600 ip0->hop_limit -= 1;
2602 clib_net_to_host_u16 (ip0->payload_length) +
2604 ip0->payload_length = clib_host_to_net_u16 (new_l0);
2607 sr0->
segments->as_u64[0] = ip0->dst_address.as_u64[0];
2608 sr0->
segments->as_u64[1] = ip0->dst_address.as_u64[1];
2610 ip0->dst_address.as_u64[0] =
2612 ip0->dst_address.as_u64[1] =
2615 if (ip0 + 1 == (
void *) sr0)
2618 ip0->protocol = IP_PROTOCOL_IPV6_ROUTE;
2622 ip6_ext_header_t *ip_ext = (
void *) (ip0 + 1);
2624 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2633 sizeof (tr->
src.as_u8));
2635 sizeof (tr->
dst.as_u8));
2641 n_left_to_next, bi0, next0);
2649 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
2652 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
2660 .name =
"sr-pl-rewrite-insert",
2661 .vector_size =
sizeof (
u32),
2668 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
2690 int insert_pkts = 0, bsid_pkts = 0;
2701 u32 bi0, bi1, bi2, bi3;
2703 u32 next0, next1, next2, next3;
2704 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2708 u16 new_l0, new_l1, new_l2, new_l3;
2731 to_next[0] = bi0 =
from[0];
2732 to_next[1] = bi1 =
from[1];
2733 to_next[2] = bi2 =
from[2];
2734 to_next[3] = bi3 =
from[3];
2738 n_left_to_next -= 4;
2771 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2778 if (ip1->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2785 if (ip2->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2792 if (ip3->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
2800 (
u8 *) ip0, (
void *) sr0 - (
void *) ip0);
2802 (
u8 *) ip1, (
void *) sr1 - (
void *) ip1);
2804 (
u8 *) ip2, (
void *) sr2 - (
void *) ip2);
2806 (
u8 *) ip3, (
void *) sr3 - (
void *) ip3);
2827 ip0->hop_limit -= 1;
2828 ip1->hop_limit -= 1;
2829 ip2->hop_limit -= 1;
2830 ip3->hop_limit -= 1;
2833 clib_net_to_host_u16 (ip0->payload_length) +
2836 clib_net_to_host_u16 (ip1->payload_length) +
2839 clib_net_to_host_u16 (ip2->payload_length) +
2842 clib_net_to_host_u16 (ip3->payload_length) +
2845 ip0->payload_length = clib_host_to_net_u16 (new_l0);
2846 ip1->payload_length = clib_host_to_net_u16 (new_l1);
2847 ip2->payload_length = clib_host_to_net_u16 (new_l2);
2848 ip3->payload_length = clib_host_to_net_u16 (new_l3);
2855 ip0->dst_address.as_u64[0] =
2857 ip0->dst_address.as_u64[1] =
2859 ip1->dst_address.as_u64[0] =
2861 ip1->dst_address.as_u64[1] =
2863 ip2->dst_address.as_u64[0] =
2865 ip2->dst_address.as_u64[1] =
2867 ip3->dst_address.as_u64[0] =
2869 ip3->dst_address.as_u64[1] =
2872 ip6_ext_header_t *ip_ext;
2873 if (ip0 + 1 == (
void *) sr0)
2876 ip0->protocol = IP_PROTOCOL_IPV6_ROUTE;
2880 ip_ext = (
void *) (ip0 + 1);
2882 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2885 if (ip1 + 1 == (
void *) sr1)
2888 ip1->protocol = IP_PROTOCOL_IPV6_ROUTE;
2892 ip_ext = (
void *) (ip2 + 1);
2894 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2897 if (ip2 + 1 == (
void *) sr2)
2900 ip2->protocol = IP_PROTOCOL_IPV6_ROUTE;
2904 ip_ext = (
void *) (ip2 + 1);
2906 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2909 if (ip3 + 1 == (
void *) sr3)
2912 ip3->protocol = IP_PROTOCOL_IPV6_ROUTE;
2916 ip_ext = (
void *) (ip3 + 1);
2918 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
2930 sizeof (tr->
src.as_u8));
2932 sizeof (tr->
dst.as_u8));
2940 sizeof (tr->
src.as_u8));
2942 sizeof (tr->
dst.as_u8));
2950 sizeof (tr->
src.as_u8));
2952 sizeof (tr->
dst.as_u8));
2960 sizeof (tr->
src.as_u8));
2962 sizeof (tr->
dst.as_u8));
2967 n_left_to_next, bi0, bi1, bi2, bi3,
2968 next0, next1, next2, next3);
2979 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
2987 n_left_to_next -= 1;
2998 if (ip0->
protocol == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
3006 (
u8 *) ip0, (
void *) sr0 - (
void *) ip0);
3013 ip0->hop_limit -= 1;
3015 clib_net_to_host_u16 (ip0->payload_length) +
3017 ip0->payload_length = clib_host_to_net_u16 (new_l0);
3021 ip0->dst_address.as_u64[0] =
3023 ip0->dst_address.as_u64[1] =
3026 if (ip0 + 1 == (
void *) sr0)
3029 ip0->protocol = IP_PROTOCOL_IPV6_ROUTE;
3033 ip6_ext_header_t *ip_ext = (
void *) (ip0 + 1);
3035 ip_ext->next_hdr = IP_PROTOCOL_IPV6_ROUTE;
3044 sizeof (tr->
src.as_u8));
3046 sizeof (tr->
dst.as_u8));
3052 n_left_to_next, bi0, next0);
3060 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
3063 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
3071 .name =
"sr-pl-rewrite-b-insert",
3072 .vector_size =
sizeof (
u32),
3079 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
3095 ip6_address_t *new_dst0;
3098 goto error_bsid_encaps;
3105 new_dst0 = (ip6_address_t *) (sr0->
segments);
3114 *next0 = SR_POLICY_REWRITE_NEXT_ERROR;
3115 b0->
error =
node->errors[SR_POLICY_REWRITE_ERROR_BSID_ZERO];
3133 int encap_pkts = 0, bsid_pkts = 0;
3144 u32 bi0, bi1, bi2, bi3;
3146 u32 next0, next1, next2, next3;
3147 next0 = next1 = next2 = next3 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
3149 ip6_header_t *ip0_encap, *ip1_encap, *ip2_encap, *ip3_encap;
3174 to_next[0] = bi0 =
from[0];
3175 to_next[1] = bi1 =
from[1];
3176 to_next[2] = bi2 =
from[2];
3177 to_next[3] = bi3 =
from[3];
3181 n_left_to_next -= 4;
3263 sizeof (tr->
src.as_u8));
3265 sizeof (tr->
dst.as_u8));
3273 sizeof (tr->
src.as_u8));
3275 sizeof (tr->
dst.as_u8));
3283 sizeof (tr->
src.as_u8));
3285 sizeof (tr->
dst.as_u8));
3293 sizeof (tr->
src.as_u8));
3295 sizeof (tr->
dst.as_u8));
3301 n_left_to_next, bi0, bi1, bi2, bi3,
3302 next0, next1, next2, next3);
3313 u32 next0 = SR_POLICY_REWRITE_NEXT_IP6_LOOKUP;
3320 n_left_to_next -= 1;
3349 sizeof (tr->
src.as_u8));
3351 sizeof (tr->
dst.as_u8));
3356 n_left_to_next, bi0, next0);
3364 SR_POLICY_REWRITE_ERROR_COUNTER_TOTAL,
3367 SR_POLICY_REWRITE_ERROR_COUNTER_BSID,
3376 .name =
"sr-pl-rewrite-b-encaps",
3377 .vector_size =
sizeof (
u32),
3384 #define _(s,n) [SR_POLICY_REWRITE_NEXT_##s] = n,
3459 {
vec_add1 (plugins_vec, plugin); }
3465 plugin = plugins_vec[
i];
3475 .path =
"show sr policy behaviors",
3476 .short_help =
"show sr policy behaviors",
3486 ip6_address_t *
addr;
3491 s =
format (s,
"SR: Segment List index:[%d]",
index);
3492 s =
format (s,
"\n\tSegments:");
3501 s =
format (s,
"\b\b > - ");
3514 "sr-pl-rewrite-encaps",
3519 "sr-pl-rewrite-encaps-v4",
3529 "sr-pl-rewrite-insert",
3538 "sr-pl-rewrite-b-insert",
3547 "sr-pl-rewrite-b-encaps",
3566 sizeof (ip6_address_t));