2 * sr_mpls_policy.c: SR-MPLS policies
4 * Copyright (c) 2016 Cisco and/or its affiliates. Licensed under the Apache
5 * License, Version 2.0 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
19 * @brief SR MPLS policy creation and application
21 * Create an SR policy.
22 * An SR policy can be either of 'default' type or 'spray' type
23 * An SR policy has attached a list of SID lists.
24 * In case the SR policy is a default one it will load balance among them.
25 * An SR policy has associated a BindingSID.
26 * In case any packet arrives with MPLS_label == BindingSID then the SR policy
27 * associated to such bindingSID will be applied to such packet.
28 * Also, a BSID can be associated with a (Next-Hop, Color)
32 #include <vlib/vlib.h>
33 #include <vnet/vnet.h>
34 #include <vnet/srmpls/sr_mpls.h>
35 #include <vnet/fib/mpls_fib.h>
36 #include <vnet/dpo/dpo.h>
37 #include <vnet/ip/ip.h>
39 #include <vppinfra/error.h>
40 #include <vppinfra/elog.h>
42 mpls_sr_main_t sr_mpls_main;
44 /*************************** SR LB helper functions **************************/
46 * @brief Creates a Segment List and adds it to an SR policy
48 * Creates a Segment List and adds it to the SR policy. Notice that the SL are
49 * not necessarily unique. Hence there might be two Segment List within the
50 * same SR Policy with exactly the same segments and same weight.
52 * @param sr_policy is the SR policy where the SL will be added
53 * @param sl is a vector of IPv6 addresses composing the Segment List
54 * @param weight is the weight of the SegmentList (for load-balancing purposes)
55 * @param is_encap represents the mode (SRH insertion vs Encapsulation)
57 * @return pointer to the just created segment list
59 static inline mpls_sr_sl_t *
60 create_sl (mpls_sr_policy_t * sr_policy, mpls_label_t * sl, u32 weight)
62 mpls_sr_main_t *sm = &sr_mpls_main;
63 mpls_sr_sl_t *segment_list;
65 pool_get (sm->sid_lists, segment_list);
66 memset (segment_list, 0, sizeof (*segment_list));
68 vec_add1 (sr_policy->segments_lists, segment_list - sm->sid_lists);
70 /* Fill in segment list */
71 segment_list->weight =
72 (weight != (u32) ~ 0 ? weight : SR_SEGMENT_LIST_WEIGHT_DEFAULT);
73 segment_list->segments = vec_dup (sl);
76 FOR_EACH_MPLS_EOS_BIT (eos)
78 fib_route_path_t path = {
79 .frp_proto = DPO_PROTO_MPLS,
80 .frp_sw_if_index = ~0,
82 .frp_weight = segment_list->weight,
83 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
84 .frp_label_stack = NULL,
85 .frp_local_label = sl[0],
89 vec_add (path.frp_label_stack, sl + 1, vec_len (sl) - 1);
91 fib_route_path_t *paths = NULL;
92 vec_add1 (paths, path);
97 .fp_proto = FIB_PROTOCOL_MPLS,
98 .fp_label = sr_policy->bsid,
100 .fp_payload_proto = DPO_PROTO_MPLS,
104 fib_table_entry_path_add2 (0,
107 (sr_policy->type == SR_POLICY_TYPE_DEFAULT ?
108 FIB_ENTRY_FLAG_NONE :
109 FIB_ENTRY_FLAG_MULTICAST), paths);
116 /******************************* SR rewrite API *******************************/
118 * Three functions for handling sr policies: -> sr_mpls_policy_add ->
119 * sr_mpls_policy_del -> sr_mpls_policy_mod All of them are API. CLI function
120 * on sr_policy_command_fn
124 * @brief Create a new SR policy
126 * @param bsid is the bindingSID of the SR Policy
127 * @param segments is a vector of MPLS labels composing the segment list
128 * @param behavior is the behavior of the SR policy. (default//spray)
129 * @param fib_table is the VRF where to install the FIB entry for the BSID
130 * @param weight is the weight of this specific SID list
132 * @return 0 if correct, else error
135 sr_mpls_policy_add (mpls_label_t bsid, mpls_label_t * segments,
136 u8 behavior, u32 weight)
138 mpls_sr_main_t *sm = &sr_mpls_main;
139 mpls_sr_policy_t *sr_policy = 0;
142 if (!sm->sr_policies_index_hash)
143 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
145 /* Search for existing keys (BSID) */
146 p = hash_get (sm->sr_policies_index_hash, bsid);
149 /* Add SR policy that already exists; complain */
152 /* Add an SR policy object */
153 pool_get (sm->sr_policies, sr_policy);
154 memset (sr_policy, 0, sizeof (*sr_policy));
155 sr_policy->bsid = bsid;
156 sr_policy->type = behavior;
157 sr_policy->endpoint_type = 0;
158 ip6_address_set_zero (&sr_policy->endpoint.ip6);
159 sr_policy->color = (u32) ~ 0;
162 hash_set (sm->sr_policies_index_hash, bsid, sr_policy - sm->sr_policies);
164 /* Create a segment list and add the index to the SR policy */
165 create_sl (sr_policy, segments, weight);
171 * @brief Delete a SR policy
173 * @param bsid is the bindingSID of the SR Policy
174 * @param index is the index of the SR policy
176 * @return 0 if correct, else error
179 sr_mpls_policy_del (mpls_label_t bsid)
181 mpls_sr_main_t *sm = &sr_mpls_main;
182 mpls_sr_policy_t *sr_policy = 0;
183 mpls_sr_sl_t *segment_list;
188 if (!sm->sr_policies_index_hash)
189 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
191 p = hash_get (sm->sr_policies_index_hash, bsid);
193 sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
197 /* Clean SID Lists */
198 vec_foreach (sl_index, sr_policy->segments_lists)
200 segment_list = pool_elt_at_index (sm->sid_lists, *sl_index);
202 fib_route_path_t path = {
203 .frp_proto = DPO_PROTO_MPLS,
204 .frp_sw_if_index = ~0,
206 .frp_weight = segment_list->weight,
207 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
208 .frp_local_label = segment_list->segments[0],
211 vec_add (path.frp_label_stack, segment_list + 1,
212 vec_len (segment_list) - 1);
214 fib_route_path_t *paths = NULL;
215 vec_add1 (paths, path);
217 /* remove each of the MPLS routes */
218 FOR_EACH_MPLS_EOS_BIT (eos)
223 .fp_proto = FIB_PROTOCOL_MPLS,
224 .fp_label = sr_policy->bsid,
226 .fp_payload_proto = DPO_PROTO_MPLS,
230 fib_table_entry_path_remove2 (0, &pfx, FIB_SOURCE_SR, paths);
233 vec_free (segment_list->segments);
234 pool_put_index (sm->sid_lists, *sl_index);
237 /* If there is still traces of TE, make sure locks are released */
238 if (sr_policy->endpoint_type != 0 && sr_policy->color != (u32) ~ 0)
240 sr_mpls_policy_assign_endpoint_color (bsid, NULL, 0, (u32) ~ 0);
243 /* Remove SR policy entry */
244 hash_unset (sm->sr_policies_index_hash, sr_policy->bsid);
245 pool_put (sm->sr_policies, sr_policy);
251 * @brief Modify an existing SR policy
253 * The possible modifications are adding a new Segment List, modifying an
254 * existing Segment List (modify the weight only) and delete a given
255 * Segment List from the SR Policy.
257 * @param bsid is the bindingSID of the SR Policy
258 * @param fib_table is the VRF where to install the FIB entry for the BSID
259 * @param operation is the operation to perform (among the top ones)
260 * @param segments is a vector of IPv6 address composing the segment list
261 * @param sl_index is the index of the Segment List to modify/delete
262 * @param weight is the weight of the sid list. optional.
264 * @return 0 ok, >0 index of SL, <0 error
267 sr_mpls_policy_mod (mpls_label_t bsid, u8 operation,
268 mpls_label_t * segments, u32 sl_index, u32 weight)
270 mpls_sr_main_t *sm = &sr_mpls_main;
271 mpls_sr_policy_t *sr_policy = 0;
272 mpls_sr_sl_t *segment_list;
273 u32 *sl_index_iterate;
276 if (!sm->sr_policies_index_hash)
277 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
279 p = hash_get (sm->sr_policies_index_hash, bsid);
281 sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
286 { /* Add SR List to an existing SR policy */
287 /* Create the new SL */
288 segment_list = create_sl (sr_policy, segments, weight);
289 return segment_list - sm->sid_lists;
291 else if (operation == 2)
292 { /* Delete SR List from an existing SR
294 /* Check that currently there are more than one SID list */
295 if (vec_len (sr_policy->segments_lists) == 1)
299 * Check that the SR list does exist and is assigned to the
302 vec_foreach (sl_index_iterate, sr_policy->segments_lists)
303 if (*sl_index_iterate == sl_index)
306 if (*sl_index_iterate != sl_index)
309 /* Remove the lucky SR list that is being kicked out */
310 segment_list = pool_elt_at_index (sm->sid_lists, sl_index);
313 fib_route_path_t path = {
314 .frp_proto = DPO_PROTO_MPLS,
315 .frp_sw_if_index = ~0,
317 .frp_weight = segment_list->weight,
318 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
319 .frp_local_label = segment_list->segments[0],
322 vec_add (path.frp_label_stack, segment_list + 1,
323 vec_len (segment_list) - 1);
325 fib_route_path_t *paths = NULL;
326 vec_add1 (paths, path);
328 FOR_EACH_MPLS_EOS_BIT (eos)
333 .fp_proto = FIB_PROTOCOL_MPLS,
334 .fp_label = sr_policy->bsid,
336 .fp_payload_proto = DPO_PROTO_MPLS,
340 fib_table_entry_path_remove2 (0, &pfx, FIB_SOURCE_SR, paths);
344 vec_free (segment_list->segments);
345 pool_put_index (sm->sid_lists, sl_index);
346 vec_del1 (sr_policy->segments_lists,
347 sl_index_iterate - sr_policy->segments_lists);
349 else if (operation == 3)
350 { /* Modify the weight of an existing
352 /* Find the corresponding SL */
353 vec_foreach (sl_index_iterate, sr_policy->segments_lists)
354 if (*sl_index_iterate == sl_index)
357 if (*sl_index_iterate != sl_index)
360 /* Change the weight */
361 segment_list = pool_elt_at_index (sm->sid_lists, sl_index);
365 fib_route_path_t path = {
366 .frp_proto = DPO_PROTO_MPLS,
367 .frp_sw_if_index = ~0,
369 .frp_weight = segment_list->weight,
370 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
371 .frp_local_label = segment_list->segments[0],
374 vec_add (path.frp_label_stack, segment_list + 1,
375 vec_len (segment_list) - 1);
377 fib_route_path_t *paths = NULL;
378 vec_add1 (paths, path);
380 FOR_EACH_MPLS_EOS_BIT (eos)
385 .fp_proto = FIB_PROTOCOL_MPLS,
386 .fp_label = sr_policy->bsid,
388 .fp_payload_proto = DPO_PROTO_MPLS,
392 fib_table_entry_path_remove2 (0, &pfx, FIB_SOURCE_SR, paths);
395 segment_list->weight = weight;
397 path.frp_weight = segment_list->weight;
401 vec_add1 (paths, path);
403 FOR_EACH_MPLS_EOS_BIT (eos)
408 .fp_proto = FIB_PROTOCOL_MPLS,
409 .fp_label = sr_policy->bsid,
411 .fp_payload_proto = DPO_PROTO_MPLS,
415 fib_table_entry_path_add2 (0,
419 SR_POLICY_TYPE_DEFAULT ?
420 FIB_ENTRY_FLAG_NONE :
421 FIB_ENTRY_FLAG_MULTICAST), paths);
428 * @brief CLI for 'sr mpls policies' command family
430 static clib_error_t *
431 sr_mpls_policy_command_fn (vlib_main_t * vm, unformat_input_t * input,
432 vlib_cli_command_t * cmd)
435 char is_del = 0, is_add = 0, is_mod = 0;
437 mpls_label_t bsid, next_label;
438 u32 sl_index = (u32) ~ 0;
439 u32 weight = (u32) ~ 0;
440 mpls_label_t *segments = 0;
444 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
446 if (!is_add && !is_mod && !is_del && unformat (input, "add"))
448 else if (!is_add && !is_mod && !is_del && unformat (input, "del"))
450 else if (!is_add && !is_mod && !is_del && unformat (input, "mod"))
453 && unformat (input, "bsid %U", unformat_mpls_unicast_label,
456 else if (unformat (input, "weight %d", &weight));
458 (input, "next %U", unformat_mpls_unicast_label, &next_label))
460 vec_add (segments, &next_label, 1);
462 else if (unformat (input, "add sl"))
464 else if (unformat (input, "del sl index %d", &sl_index))
466 else if (unformat (input, "mod sl index %d", &sl_index))
468 else if (unformat (input, "spray"))
474 if (!is_add && !is_mod && !is_del)
475 return clib_error_return (0, "Incorrect CLI");
478 return clib_error_return (0, "No SR policy BSID or index specified");
482 if (vec_len (segments) == 0)
483 return clib_error_return (0, "No Segment List specified");
485 rv = sr_mpls_policy_add (bsid, segments,
486 (is_spray ? SR_POLICY_TYPE_SPRAY :
487 SR_POLICY_TYPE_DEFAULT), weight);
490 rv = sr_mpls_policy_del (bsid);
494 return clib_error_return (0, "No SL modification specified");
495 if (operation != 1 && sl_index == (u32) ~ 0)
496 return clib_error_return (0, "No Segment List index specified");
497 if (operation == 1 && vec_len (segments) == 0)
498 return clib_error_return (0, "No Segment List specified");
499 if (operation == 3 && weight == (u32) ~ 0)
500 return clib_error_return (0, "No new weight for the SL specified");
501 rv = sr_mpls_policy_mod (bsid, operation, segments, sl_index, weight);
510 return clib_error_return (0,
511 "There is already a FIB entry for the BindingSID address.\n"
512 "The SR policy could not be created.");
514 return clib_error_return (0,
515 "The selected SR policy only contains ONE segment list. "
516 "Please remove the SR policy instead");
518 return clib_error_return (0,
519 "Could not delete the segment list. "
520 "It is not associated with that SR policy.");
522 return clib_error_return (0,
523 "Could not delete the segment list. "
524 "It is not associated with that SR policy.");
526 return clib_error_return (0,
527 "Could not modify the segment list. "
528 "The given SL is not associated with such SR policy.");
530 return clib_error_return (0, "BUG: sr policy returns %d", rv);
536 VLIB_CLI_COMMAND(sr_mpls_policy_command, static)=
538 .path = "sr mpls policy",
539 .short_help = "sr mpls policy [add||del||mod] bsid 2999 "
540 "next 10 next 20 next 30 (weight 1) (spray)",
541 .long_help = "TBD.\n",
542 .function = sr_mpls_policy_command_fn,
547 * @brief CLI to display onscreen all the SR MPLS policies
549 static clib_error_t *
550 show_sr_mpls_policies_command_fn (vlib_main_t * vm, unformat_input_t * input,
551 vlib_cli_command_t * cmd)
553 mpls_sr_main_t *sm = &sr_mpls_main;
554 mpls_sr_sl_t *segment_list = 0;
555 mpls_sr_policy_t *sr_policy = 0;
556 mpls_sr_policy_t **vec_policies = 0;
562 vlib_cli_output (vm, "SR MPLS policies:");
565 pool_foreach(sr_policy, sm->sr_policies, {
566 vec_add1(vec_policies, sr_policy);
570 vec_foreach_index (i, vec_policies)
572 sr_policy = vec_policies[i];
573 vlib_cli_output (vm, "[%u].-\tBSID: %U",
574 (u32) (sr_policy - sm->sr_policies),
575 format_mpls_unicast_label, sr_policy->bsid);
576 switch (sr_policy->endpoint_type)
579 vlib_cli_output (vm, "\tEndpoint: %U", format_ip6_address,
580 &sr_policy->endpoint.ip6);
581 vlib_cli_output (vm, "\tColor: %u", sr_policy->color);
584 vlib_cli_output (vm, "\tEndpoint: %U", format_ip4_address,
585 &sr_policy->endpoint.ip4);
586 vlib_cli_output (vm, "\tColor: %u", sr_policy->color);
589 vlib_cli_output (vm, "\tTE disabled");
591 vlib_cli_output (vm, "\tType: %s",
593 SR_POLICY_TYPE_DEFAULT ? "Default" : "Spray"));
594 vlib_cli_output (vm, "\tSegment Lists:");
595 vec_foreach (sl_index, sr_policy->segments_lists)
598 segment_list = pool_elt_at_index (sm->sid_lists, *sl_index);
599 s = format (s, "\t[%u].- ", *sl_index);
600 s = format (s, "< ");
601 vec_foreach (label, segment_list->segments)
603 s = format (s, "%U, ", format_mpls_unicast_label, *label);
605 s = format (s, "\b\b > ");
606 vlib_cli_output (vm, " %s", s);
608 vlib_cli_output (vm, "-----------");
610 vec_free (vec_policies);
615 VLIB_CLI_COMMAND(show_sr_mpls_policies_command, static)=
617 .path = "show sr mpls policies",
618 .short_help = "show sr mpls policies",
619 .function = show_sr_mpls_policies_command_fn,
624 * @brief Update the Endpoint,Color tuple of an SR policy
626 * @param bsid is the bindingSID of the SR Policy
627 * @param endpoint represents the IP46 of the endpoint
628 * @param color represents the color (u32)
630 * To reset to NULL use ~0 as parameters.
632 * @return 0 if correct, else error
635 sr_mpls_policy_assign_endpoint_color (mpls_label_t bsid,
636 ip46_address_t * endpoint,
637 u8 endpoint_type, u32 color)
639 mpls_sr_main_t *sm = &sr_mpls_main;
640 mpls_sr_policy_t *sr_policy = 0;
641 uword *endpoint_table, *p, *old_value;
644 any.as_u64[0] = any.as_u64[1] = (u64) ~ 0;
646 if (!sm->sr_policies_index_hash)
647 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
649 p = hash_get (sm->sr_policies_index_hash, bsid);
651 sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
655 /* If previous Endpoint, color existed, remove (NH,C) and (ANY,C) */
656 if (sr_policy->endpoint_type)
659 mhash_get (&sm->sr_policies_c2e2eclabel_hash, &sr_policy->color);
663 mhash_get ((mhash_t *) endpoint_table, &sr_policy->endpoint);
665 /* CID 180995 This should never be NULL unless the two hash tables
667 ASSERT (old_value != NULL);
669 fib_prefix_t pfx = { 0 };
670 pfx.fp_proto = FIB_PROTOCOL_MPLS;
672 pfx.fp_label = (u32) * old_value;
675 FOR_EACH_MPLS_EOS_BIT (eos)
678 fib_table_entry_path_remove (sm->fib_table_EC,
683 ~0, 0, 1, FIB_ROUTE_PATH_FLAG_NONE);
686 old_value = mhash_get ((mhash_t *) endpoint_table, &any);
687 pfx.fp_label = (u32) * old_value;
689 FOR_EACH_MPLS_EOS_BIT (eos)
692 fib_table_entry_path_remove (sm->fib_table_EC,
697 ~0, 0, 1, FIB_ROUTE_PATH_FLAG_NONE);
700 /* Release the lock on (NH, Color) and (ANY, Color) */
701 internal_label_unlock (sr_policy->endpoint, sr_policy->color);
702 internal_label_unlock (any, sr_policy->color);
704 /* Reset the values on the SR policy */
705 sr_policy->endpoint_type = 0;
706 sr_policy->endpoint.as_u64[0] = sr_policy->endpoint.as_u64[1] =
708 sr_policy->color = (u32) ~ 0;
713 sr_policy->endpoint_type = endpoint_type;
714 sr_policy->endpoint.as_u64[0] = endpoint->as_u64[0];
715 sr_policy->endpoint.as_u64[1] = endpoint->as_u64[1];
716 sr_policy->color = color;
718 u32 label = find_or_create_internal_label (*endpoint, color);
719 internal_label_lock (*endpoint, sr_policy->color);
721 /* If FIB doesnt exist, create them */
722 if (sm->fib_table_EC == (u32) ~ 0)
724 sm->fib_table_EC = fib_table_create_and_lock (FIB_PROTOCOL_MPLS,
726 "SR-MPLS Traffic Engineering (NextHop,Color)");
728 fib_table_flush (sm->fib_table_EC, FIB_PROTOCOL_MPLS,
732 fib_prefix_t pfx = { 0 };
733 pfx.fp_proto = FIB_PROTOCOL_MPLS;
736 fib_route_path_t path = {
737 .frp_proto = DPO_PROTO_MPLS,
738 .frp_sw_if_index = ~0,
741 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
744 path.frp_local_label = sr_policy->bsid;
746 //Add the entry to ANY,Color
747 u32 any_label = find_or_create_internal_label (any, color);
748 internal_label_lock (any, sr_policy->color);
750 pfx.fp_eos = MPLS_EOS;
751 path.frp_eos = MPLS_EOS;
753 fib_route_path_t *paths = NULL;
754 vec_add1 (paths, path);
756 pfx.fp_label = label;
757 fib_table_entry_update (sm->fib_table_EC,
760 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
762 pfx.fp_label = any_label;
763 fib_table_entry_update (sm->fib_table_EC,
766 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
768 fib_mpls_label_t fml = {
769 .fml_value = MPLS_IETF_IMPLICIT_NULL_LABEL,
772 vec_add1 (path.frp_label_stack, fml);
773 pfx.fp_eos = MPLS_NON_EOS;
774 path.frp_eos = MPLS_NON_EOS;
777 vec_add1 (paths, path);
779 pfx.fp_label = label;
780 fib_table_entry_update (sm->fib_table_EC,
783 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
785 pfx.fp_label = any_label;
786 fib_table_entry_update (sm->fib_table_EC,
789 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
795 * @brief CLI to modify the Endpoint,Color of an SR policy
797 static clib_error_t *
798 cli_sr_mpls_policy_ec_command_fn (vlib_main_t * vm, unformat_input_t * input,
799 vlib_cli_command_t * cmd)
801 ip46_address_t endpoint;
802 u32 color = (u32) ~ 0;
804 u8 endpoint_type = 0;
805 char clear = 0, color_set = 0, bsid_set = 0;
807 memset (&endpoint, 0, sizeof (ip46_address_t));
810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
813 && unformat (input, "endpoint %U", unformat_ip6_address,
815 endpoint_type = SR_STEER_IPV6;
816 else if (!endpoint_type
817 && unformat (input, "endpoint %U", unformat_ip4_address,
819 endpoint_type = SR_STEER_IPV4;
820 else if (!color_set && unformat (input, "color %u", &color))
823 && unformat (input, "bsid %U", unformat_mpls_unicast_label,
826 else if (!clear && unformat (input, "clear"))
833 return clib_error_return (0, "No BSID specified");
834 if (!endpoint_type && !clear)
835 return clib_error_return (0, "No Endpoint specified");
836 if (!color_set && !clear)
837 return clib_error_return (0, "No Color set");
839 /* In case its a cleanup */
842 ip6_address_set_zero (&endpoint.ip6);
846 sr_mpls_policy_assign_endpoint_color (bsid, &endpoint, endpoint_type,
850 clib_error_return (0, "Error on Endpoint,Color");
856 VLIB_CLI_COMMAND(cli_sr_mpls_policy_ec_command, static)=
858 .path = "sr mpls policy te",
859 .short_help = "sr mpls policy te bsid xxxxx endpoint x.x.x.x color 12341234",
860 .function = cli_sr_mpls_policy_ec_command_fn,
864 /********************* SR MPLS Policy initialization ***********************/
866 * @brief SR MPLS Policy initialization
869 sr_mpls_policy_rewrite_init (vlib_main_t * vm)
871 mpls_sr_main_t *sm = &sr_mpls_main;
873 /* Init memory for sr policy keys (bsid <-> ip6_address_t) */
874 sm->sr_policies_index_hash = NULL;
875 sm->sr_policies_c2e2eclabel_hash.hash = NULL;
879 VLIB_INIT_FUNCTION (sr_mpls_policy_rewrite_init);
882 * fd.io coding-style-patch-verification: ON
884 * Local Variables: eval: (c-set-style "gnu") End: