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/dpo/replicate_dpo.h>
38 #include <vnet/dpo/mpls_label_dpo.h>
39 #include <vnet/dpo/lookup_dpo.h>
40 #include <vnet/ip/ip.h>
42 #include <vppinfra/error.h>
43 #include <vppinfra/elog.h>
45 mpls_sr_main_t sr_mpls_main;
47 /*************************** SR LB helper functions **************************/
49 * @brief Creates a Segment List and adds it to an SR policy
51 * Creates a Segment List and adds it to the SR policy. Notice that the SL are
52 * not necessarily unique. Hence there might be two Segment List within the
53 * same SR Policy with exactly the same segments and same weight.
55 * @param sr_policy is the SR policy where the SL will be added
56 * @param sl is a vector of IPv6 addresses composing the Segment List
57 * @param weight is the weight of the SegmentList (for load-balancing purposes)
58 * @param is_encap represents the mode (SRH insertion vs Encapsulation)
60 * @return pointer to the just created segment list
62 static inline mpls_sr_sl_t *
63 create_sl (mpls_sr_policy_t * sr_policy, mpls_label_t * sl, u32 weight)
65 mpls_sr_main_t *sm = &sr_mpls_main;
66 mpls_sr_sl_t *segment_list;
68 pool_get (sm->sid_lists, segment_list);
69 memset (segment_list, 0, sizeof (*segment_list));
71 vec_add1 (sr_policy->segments_lists, segment_list - sm->sid_lists);
73 /* Fill in segment list */
74 segment_list->weight =
75 (weight != (u32) ~ 0 ? weight : SR_SEGMENT_LIST_WEIGHT_DEFAULT);
76 segment_list->segments = vec_dup (sl);
79 FOR_EACH_MPLS_EOS_BIT (eos)
81 fib_route_path_t path = {
82 .frp_proto = DPO_PROTO_MPLS,
83 .frp_sw_if_index = ~0,
85 .frp_weight = segment_list->weight,
86 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
87 .frp_label_stack = NULL,
88 .frp_local_label = sl[0],
91 vec_add (path.frp_label_stack, sl + 1, vec_len (sl) - 1);
93 fib_route_path_t *paths = NULL;
94 vec_add1 (paths, path);
99 .fp_proto = FIB_PROTOCOL_MPLS,
100 .fp_label = sr_policy->bsid,
102 .fp_payload_proto = DPO_PROTO_MPLS,
106 fib_table_entry_path_add2 (0,
109 (sr_policy->type == SR_POLICY_TYPE_DEFAULT ?
110 FIB_ENTRY_FLAG_NONE :
111 FIB_ENTRY_FLAG_MULTICAST), paths);
118 /******************************* SR rewrite API *******************************/
120 * Three functions for handling sr policies: -> sr_mpls_policy_add ->
121 * sr_mpls_policy_del -> sr_mpls_policy_mod All of them are API. CLI function
122 * on sr_policy_command_fn
126 * @brief Create a new SR policy
128 * @param bsid is the bindingSID of the SR Policy
129 * @param segments is a vector of MPLS labels composing the segment list
130 * @param behavior is the behavior of the SR policy. (default//spray)
131 * @param fib_table is the VRF where to install the FIB entry for the BSID
132 * @param weight is the weight of this specific SID list
134 * @return 0 if correct, else error
137 sr_mpls_policy_add (mpls_label_t bsid, mpls_label_t * segments,
138 u8 behavior, u32 weight)
140 mpls_sr_main_t *sm = &sr_mpls_main;
141 mpls_sr_policy_t *sr_policy = 0;
144 if (!sm->sr_policies_index_hash)
145 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
147 /* Search for existing keys (BSID) */
148 p = hash_get (sm->sr_policies_index_hash, bsid);
151 /* Add SR policy that already exists; complain */
154 /* Add an SR policy object */
155 pool_get (sm->sr_policies, sr_policy);
156 memset (sr_policy, 0, sizeof (*sr_policy));
157 sr_policy->bsid = bsid;
158 sr_policy->type = behavior;
159 sr_policy->endpoint_type = 0;
160 ip6_address_set_zero (&sr_policy->endpoint.ip6);
161 sr_policy->color = (u32) ~ 0;
164 hash_set (sm->sr_policies_index_hash, bsid, sr_policy - sm->sr_policies);
166 /* Create a segment list and add the index to the SR policy */
167 create_sl (sr_policy, segments, weight);
173 * @brief Delete a SR policy
175 * @param bsid is the bindingSID of the SR Policy
176 * @param index is the index of the SR policy
178 * @return 0 if correct, else error
181 sr_mpls_policy_del (mpls_label_t bsid)
183 mpls_sr_main_t *sm = &sr_mpls_main;
184 mpls_sr_policy_t *sr_policy = 0;
185 mpls_sr_sl_t *segment_list;
190 if (!sm->sr_policies_index_hash)
191 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
193 p = hash_get (sm->sr_policies_index_hash, bsid);
195 sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
199 /* Clean SID Lists */
200 vec_foreach (sl_index, sr_policy->segments_lists)
202 segment_list = pool_elt_at_index (sm->sid_lists, *sl_index);
204 fib_route_path_t path = {
205 .frp_proto = DPO_PROTO_MPLS,
206 .frp_sw_if_index = ~0,
208 .frp_weight = segment_list->weight,
209 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
210 .frp_local_label = segment_list->segments[0],
213 vec_add (path.frp_label_stack, segment_list + 1,
214 vec_len (segment_list) - 1);
216 fib_route_path_t *paths = NULL;
217 vec_add1 (paths, path);
219 /* remove each of the MPLS routes */
220 FOR_EACH_MPLS_EOS_BIT (eos)
225 .fp_proto = FIB_PROTOCOL_MPLS,
226 .fp_label = sr_policy->bsid,
228 .fp_payload_proto = DPO_PROTO_MPLS,
232 fib_table_entry_path_remove2 (0, &pfx, FIB_SOURCE_SR, paths);
235 vec_free (segment_list->segments);
236 pool_put_index (sm->sid_lists, *sl_index);
239 /* If there is still traces of TE, make sure locks are released */
240 if (sr_policy->endpoint_type != 0 && sr_policy->color != (u32) ~ 0)
242 sr_mpls_policy_assign_endpoint_color (bsid, NULL, 0, (u32) ~ 0);
245 /* Remove SR policy entry */
246 hash_unset (sm->sr_policies_index_hash, sr_policy->bsid);
247 pool_put (sm->sr_policies, sr_policy);
253 * @brief Modify an existing SR policy
255 * The possible modifications are adding a new Segment List, modifying an
256 * existing Segment List (modify the weight only) and delete a given
257 * Segment List from the SR Policy.
259 * @param bsid is the bindingSID of the SR Policy
260 * @param fib_table is the VRF where to install the FIB entry for the BSID
261 * @param operation is the operation to perform (among the top ones)
262 * @param segments is a vector of IPv6 address composing the segment list
263 * @param sl_index is the index of the Segment List to modify/delete
264 * @param weight is the weight of the sid list. optional.
266 * @return 0 ok, >0 index of SL, <0 error
269 sr_mpls_policy_mod (mpls_label_t bsid, u8 operation,
270 mpls_label_t * segments, u32 sl_index, u32 weight)
272 mpls_sr_main_t *sm = &sr_mpls_main;
273 mpls_sr_policy_t *sr_policy = 0;
274 mpls_sr_sl_t *segment_list;
275 u32 *sl_index_iterate;
278 if (!sm->sr_policies_index_hash)
279 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
281 p = hash_get (sm->sr_policies_index_hash, bsid);
283 sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
288 { /* Add SR List to an existing SR policy */
289 /* Create the new SL */
290 segment_list = create_sl (sr_policy, segments, weight);
291 return segment_list - sm->sid_lists;
293 else if (operation == 2)
294 { /* Delete SR List from an existing SR
296 /* Check that currently there are more than one SID list */
297 if (vec_len (sr_policy->segments_lists) == 1)
301 * Check that the SR list does exist and is assigned to the
304 vec_foreach (sl_index_iterate, sr_policy->segments_lists)
305 if (*sl_index_iterate == sl_index)
308 if (*sl_index_iterate != sl_index)
311 /* Remove the lucky SR list that is being kicked out */
312 segment_list = pool_elt_at_index (sm->sid_lists, sl_index);
315 fib_route_path_t path = {
316 .frp_proto = DPO_PROTO_MPLS,
317 .frp_sw_if_index = ~0,
319 .frp_weight = segment_list->weight,
320 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
321 .frp_local_label = segment_list->segments[0],
324 vec_add (path.frp_label_stack, segment_list + 1,
325 vec_len (segment_list) - 1);
327 fib_route_path_t *paths = NULL;
328 vec_add1 (paths, path);
330 FOR_EACH_MPLS_EOS_BIT (eos)
335 .fp_proto = FIB_PROTOCOL_MPLS,
336 .fp_label = sr_policy->bsid,
338 .fp_payload_proto = DPO_PROTO_MPLS,
342 fib_table_entry_path_remove2 (0, &pfx, FIB_SOURCE_SR, paths);
346 vec_free (segment_list->segments);
347 pool_put_index (sm->sid_lists, sl_index);
348 vec_del1 (sr_policy->segments_lists,
349 sl_index_iterate - sr_policy->segments_lists);
351 else if (operation == 3)
352 { /* Modify the weight of an existing
354 /* Find the corresponding SL */
355 vec_foreach (sl_index_iterate, sr_policy->segments_lists)
356 if (*sl_index_iterate == sl_index)
359 if (*sl_index_iterate != sl_index)
362 /* Change the weight */
363 segment_list = pool_elt_at_index (sm->sid_lists, sl_index);
367 fib_route_path_t path = {
368 .frp_proto = DPO_PROTO_MPLS,
369 .frp_sw_if_index = ~0,
371 .frp_weight = segment_list->weight,
372 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
373 .frp_local_label = segment_list->segments[0],
376 vec_add (path.frp_label_stack, segment_list + 1,
377 vec_len (segment_list) - 1);
379 fib_route_path_t *paths = NULL;
380 vec_add1 (paths, path);
382 FOR_EACH_MPLS_EOS_BIT (eos)
387 .fp_proto = FIB_PROTOCOL_MPLS,
388 .fp_label = sr_policy->bsid,
390 .fp_payload_proto = DPO_PROTO_MPLS,
394 fib_table_entry_path_remove2 (0, &pfx, FIB_SOURCE_SR, paths);
397 segment_list->weight = weight;
399 path.frp_weight = segment_list->weight;
403 vec_add1 (paths, path);
405 FOR_EACH_MPLS_EOS_BIT (eos)
410 .fp_proto = FIB_PROTOCOL_MPLS,
411 .fp_label = sr_policy->bsid,
413 .fp_payload_proto = DPO_PROTO_MPLS,
417 fib_table_entry_path_add2 (0,
421 SR_POLICY_TYPE_DEFAULT ?
422 FIB_ENTRY_FLAG_NONE :
423 FIB_ENTRY_FLAG_MULTICAST), paths);
430 * @brief CLI for 'sr mpls policies' command family
432 static clib_error_t *
433 sr_mpls_policy_command_fn (vlib_main_t * vm, unformat_input_t * input,
434 vlib_cli_command_t * cmd)
437 char is_del = 0, is_add = 0, is_mod = 0;
439 mpls_label_t bsid, next_label;
440 u32 sl_index = (u32) ~ 0;
441 u32 weight = (u32) ~ 0;
442 mpls_label_t *segments = 0;
446 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
448 if (!is_add && !is_mod && !is_del && unformat (input, "add"))
450 else if (!is_add && !is_mod && !is_del && unformat (input, "del"))
452 else if (!is_add && !is_mod && !is_del && unformat (input, "mod"))
455 && unformat (input, "bsid %U", unformat_mpls_unicast_label,
458 else if (unformat (input, "weight %d", &weight));
460 (input, "next %U", unformat_mpls_unicast_label, &next_label))
462 vec_add (segments, &next_label, 1);
464 else if (unformat (input, "add sl"))
466 else if (unformat (input, "del sl index %d", &sl_index))
468 else if (unformat (input, "mod sl index %d", &sl_index))
470 else if (unformat (input, "spray"))
476 if (!is_add && !is_mod && !is_del)
477 return clib_error_return (0, "Incorrect CLI");
480 return clib_error_return (0, "No SR policy BSID or index specified");
484 if (vec_len (segments) == 0)
485 return clib_error_return (0, "No Segment List specified");
487 rv = sr_mpls_policy_add (bsid, segments,
488 (is_spray ? SR_POLICY_TYPE_SPRAY :
489 SR_POLICY_TYPE_DEFAULT), weight);
492 rv = sr_mpls_policy_del (bsid);
496 return clib_error_return (0, "No SL modification specified");
497 if (operation != 1 && sl_index == (u32) ~ 0)
498 return clib_error_return (0, "No Segment List index specified");
499 if (operation == 1 && vec_len (segments) == 0)
500 return clib_error_return (0, "No Segment List specified");
501 if (operation == 3 && weight == (u32) ~ 0)
502 return clib_error_return (0, "No new weight for the SL specified");
503 rv = sr_mpls_policy_mod (bsid, operation, segments, sl_index, weight);
512 return clib_error_return (0,
513 "There is already a FIB entry for the BindingSID address.\n"
514 "The SR policy could not be created.");
516 return clib_error_return (0,
517 "The selected SR policy only contains ONE segment list. "
518 "Please remove the SR policy instead");
520 return clib_error_return (0,
521 "Could not delete the segment list. "
522 "It is not associated with that SR policy.");
524 return clib_error_return (0,
525 "Could not delete the segment list. "
526 "It is not associated with that SR policy.");
528 return clib_error_return (0,
529 "Could not modify the segment list. "
530 "The given SL is not associated with such SR policy.");
532 return clib_error_return (0, "BUG: sr policy returns %d", rv);
538 VLIB_CLI_COMMAND(sr_mpls_policy_command, static)=
540 .path = "sr mpls policy",
541 .short_help = "sr mpls policy [add||del||mod] bsid 2999 "
542 "next 10 next 20 next 30 (weight 1) (spray)",
543 .long_help = "TBD.\n",
544 .function = sr_mpls_policy_command_fn,
549 * @brief CLI to display onscreen all the SR MPLS policies
551 static clib_error_t *
552 show_sr_mpls_policies_command_fn (vlib_main_t * vm, unformat_input_t * input,
553 vlib_cli_command_t * cmd)
555 mpls_sr_main_t *sm = &sr_mpls_main;
556 mpls_sr_sl_t *segment_list = 0;
557 mpls_sr_policy_t *sr_policy = 0;
558 mpls_sr_policy_t **vec_policies = 0;
564 vlib_cli_output (vm, "SR MPLS policies:");
567 pool_foreach(sr_policy, sm->sr_policies, {
568 vec_add1(vec_policies, sr_policy);
572 vec_foreach_index (i, vec_policies)
574 sr_policy = vec_policies[i];
575 vlib_cli_output (vm, "[%u].-\tBSID: %U",
576 (u32) (sr_policy - sm->sr_policies),
577 format_mpls_unicast_label, sr_policy->bsid);
578 switch (sr_policy->endpoint_type)
581 vlib_cli_output (vm, "\tEndpoint: %U", format_ip6_address,
582 &sr_policy->endpoint.ip6);
583 vlib_cli_output (vm, "\tColor: %u", sr_policy->color);
586 vlib_cli_output (vm, "\tEndpoint: %U", format_ip4_address,
587 &sr_policy->endpoint.ip4);
588 vlib_cli_output (vm, "\tColor: %u", sr_policy->color);
591 vlib_cli_output (vm, "\tTE disabled");
593 vlib_cli_output (vm, "\tType: %s",
595 SR_POLICY_TYPE_DEFAULT ? "Default" : "Spray"));
596 vlib_cli_output (vm, "\tSegment Lists:");
597 vec_foreach (sl_index, sr_policy->segments_lists)
600 segment_list = pool_elt_at_index (sm->sid_lists, *sl_index);
601 s = format (s, "\t[%u].- ", *sl_index);
602 s = format (s, "< ");
603 vec_foreach (label, segment_list->segments)
605 s = format (s, "%U, ", format_mpls_unicast_label, *label);
607 s = format (s, "\b\b > ");
608 vlib_cli_output (vm, " %s", s);
610 vlib_cli_output (vm, "-----------");
612 vec_free (vec_policies);
617 VLIB_CLI_COMMAND(show_sr_mpls_policies_command, static)=
619 .path = "show sr mpls policies",
620 .short_help = "show sr mpls policies",
621 .function = show_sr_mpls_policies_command_fn,
626 * @brief Update the Endpoint,Color tuple of an SR policy
628 * @param bsid is the bindingSID of the SR Policy
629 * @param endpoint represents the IP46 of the endpoint
630 * @param color represents the color (u32)
632 * To reset to NULL use ~0 as parameters.
634 * @return 0 if correct, else error
637 sr_mpls_policy_assign_endpoint_color (mpls_label_t bsid,
638 ip46_address_t * endpoint,
639 u8 endpoint_type, u32 color)
641 mpls_sr_main_t *sm = &sr_mpls_main;
642 mpls_sr_policy_t *sr_policy = 0;
643 uword *endpoint_table, *p, *old_value;
646 any.as_u64[0] = any.as_u64[1] = (u64) ~ 0;
648 if (!sm->sr_policies_index_hash)
649 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
651 p = hash_get (sm->sr_policies_index_hash, bsid);
653 sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
657 /* If previous Endpoint, color existed, remove (NH,C) and (ANY,C) */
658 if (sr_policy->endpoint_type)
661 mhash_get (&sm->sr_policies_c2e2eclabel_hash, &sr_policy->color);
665 mhash_get ((mhash_t *) endpoint_table, &sr_policy->endpoint);
667 fib_prefix_t pfx = { 0 };
668 pfx.fp_proto = FIB_PROTOCOL_MPLS;
670 pfx.fp_label = (u32) * old_value;
673 FOR_EACH_MPLS_EOS_BIT (eos)
676 fib_table_entry_path_remove (sm->fib_table_EC,
681 ~0, 0, 1, FIB_ROUTE_PATH_FLAG_NONE);
684 old_value = mhash_get ((mhash_t *) endpoint_table, &any);
685 pfx.fp_label = (u32) * old_value;
687 FOR_EACH_MPLS_EOS_BIT (eos)
690 fib_table_entry_path_remove (sm->fib_table_EC,
695 ~0, 0, 1, FIB_ROUTE_PATH_FLAG_NONE);
698 /* Release the lock on (NH, Color) and (ANY, Color) */
699 internal_label_unlock (sr_policy->endpoint, sr_policy->color);
700 internal_label_unlock (any, sr_policy->color);
702 /* Reset the values on the SR policy */
703 sr_policy->endpoint_type = 0;
704 sr_policy->endpoint.as_u64[0] = sr_policy->endpoint.as_u64[1] =
706 sr_policy->color = (u32) ~ 0;
711 sr_policy->endpoint_type = endpoint_type;
712 sr_policy->endpoint.as_u64[0] = endpoint->as_u64[0];
713 sr_policy->endpoint.as_u64[1] = endpoint->as_u64[1];
714 sr_policy->color = color;
716 u32 label = find_or_create_internal_label (*endpoint, color);
717 internal_label_lock (*endpoint, sr_policy->color);
719 /* If FIB doesnt exist, create them */
720 if (sm->fib_table_EC == (u32) ~ 0)
722 sm->fib_table_EC = fib_table_create_and_lock (FIB_PROTOCOL_MPLS,
724 "SR-MPLS Traffic Engineering (NextHop,Color)");
726 fib_table_flush (sm->fib_table_EC, FIB_PROTOCOL_MPLS,
730 fib_prefix_t pfx = { 0 };
731 pfx.fp_proto = FIB_PROTOCOL_MPLS;
734 fib_route_path_t path = {
735 .frp_proto = DPO_PROTO_MPLS,
736 .frp_sw_if_index = ~0,
739 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
742 path.frp_local_label = sr_policy->bsid;
744 //Add the entry to ANY,Color
745 u32 any_label = find_or_create_internal_label (any, color);
746 internal_label_lock (any, sr_policy->color);
748 pfx.fp_eos = MPLS_EOS;
749 path.frp_eos = MPLS_EOS;
751 fib_route_path_t *paths = NULL;
752 vec_add1 (paths, path);
754 pfx.fp_label = label;
755 fib_table_entry_update (sm->fib_table_EC,
758 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
760 pfx.fp_label = any_label;
761 fib_table_entry_update (sm->fib_table_EC,
764 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
766 vec_add1 (path.frp_label_stack, MPLS_IETF_IMPLICIT_NULL_LABEL);
767 pfx.fp_eos = MPLS_NON_EOS;
768 path.frp_eos = MPLS_NON_EOS;
771 vec_add1 (paths, path);
773 pfx.fp_label = label;
774 fib_table_entry_update (sm->fib_table_EC,
777 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
779 pfx.fp_label = any_label;
780 fib_table_entry_update (sm->fib_table_EC,
783 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
789 * @brief CLI to modify the Endpoint,Color of an SR policy
791 static clib_error_t *
792 cli_sr_mpls_policy_ec_command_fn (vlib_main_t * vm, unformat_input_t * input,
793 vlib_cli_command_t * cmd)
795 ip46_address_t endpoint;
796 u32 color = (u32) ~ 0;
798 u8 endpoint_type = 0;
799 char clear = 0, color_set = 0, bsid_set = 0;
801 memset (&endpoint, 0, sizeof (ip46_address_t));
804 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
807 && unformat (input, "endpoint %U", unformat_ip6_address,
809 endpoint_type = SR_STEER_IPV6;
810 else if (!endpoint_type
811 && unformat (input, "endpoint %U", unformat_ip4_address,
813 endpoint_type = SR_STEER_IPV4;
814 else if (!color_set && unformat (input, "color %u", &color))
817 && unformat (input, "bsid %U", unformat_mpls_unicast_label,
820 else if (!clear && unformat (input, "clear"))
827 return clib_error_return (0, "No BSID specified");
828 if (!endpoint_type && !clear)
829 return clib_error_return (0, "No Endpoint specified");
830 if (!color_set && !clear)
831 return clib_error_return (0, "No Color set");
833 /* In case its a cleanup */
836 ip6_address_set_zero (&endpoint.ip6);
840 sr_mpls_policy_assign_endpoint_color (bsid, &endpoint, endpoint_type,
844 clib_error_return (0, "Error on Endpoint,Color");
850 VLIB_CLI_COMMAND(cli_sr_mpls_policy_ec_command, static)=
852 .path = "sr mpls policy te",
853 .short_help = "sr mpls policy te bsid xxxxx endpoint x.x.x.x color 12341234",
854 .function = cli_sr_mpls_policy_ec_command_fn,
858 /********************* SR MPLS Policy initialization ***********************/
860 * @brief SR MPLS Policy initialization
863 sr_mpls_policy_rewrite_init (vlib_main_t * vm)
865 mpls_sr_main_t *sm = &sr_mpls_main;
867 /* Init memory for sr policy keys (bsid <-> ip6_address_t) */
868 sm->sr_policies_index_hash = NULL;
869 sm->sr_policies_c2e2eclabel_hash.hash = NULL;
873 VLIB_INIT_FUNCTION (sr_mpls_policy_rewrite_init);
876 * fd.io coding-style-patch-verification: ON
878 * Local Variables: eval: (c-set-style "gnu") End: