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);
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],
88 vec_add (path.frp_label_stack, sl + 1, vec_len (sl) - 1);
90 fib_route_path_t *paths = NULL;
91 vec_add1 (paths, path);
94 FOR_EACH_MPLS_EOS_BIT (eos)
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);
119 /******************************* SR rewrite API *******************************/
121 * Three functions for handling sr policies: -> sr_mpls_policy_add ->
122 * sr_mpls_policy_del -> sr_mpls_policy_mod All of them are API. CLI function
123 * on sr_policy_command_fn
127 * @brief Create a new SR policy
129 * @param bsid is the bindingSID of the SR Policy
130 * @param segments is a vector of MPLS labels composing the segment list
131 * @param behavior is the behavior of the SR policy. (default//spray)
132 * @param fib_table is the VRF where to install the FIB entry for the BSID
133 * @param weight is the weight of this specific SID list
135 * @return 0 if correct, else error
138 sr_mpls_policy_add (mpls_label_t bsid, mpls_label_t * segments,
139 u8 behavior, u32 weight)
141 mpls_sr_main_t *sm = &sr_mpls_main;
142 mpls_sr_policy_t *sr_policy = 0;
145 if (!sm->sr_policies_index_hash)
146 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
148 /* Search for existing keys (BSID) */
149 p = hash_get (sm->sr_policies_index_hash, bsid);
152 /* Add SR policy that already exists; complain */
155 /* Add an SR policy object */
156 pool_get (sm->sr_policies, sr_policy);
157 memset (sr_policy, 0, sizeof (*sr_policy));
158 sr_policy->bsid = bsid;
159 sr_policy->type = behavior;
160 sr_policy->endpoint_type = 0;
161 ip6_address_set_zero (&sr_policy->endpoint.ip6);
162 sr_policy->color = (u32) ~ 0;
165 hash_set (sm->sr_policies_index_hash, bsid, sr_policy - sm->sr_policies);
167 /* Create a segment list and add the index to the SR policy */
168 create_sl (sr_policy, segments, weight);
174 * @brief Delete a SR policy
176 * @param bsid is the bindingSID of the SR Policy
177 * @param index is the index of the SR policy
179 * @return 0 if correct, else error
182 sr_mpls_policy_del (mpls_label_t bsid)
184 mpls_sr_main_t *sm = &sr_mpls_main;
185 mpls_sr_policy_t *sr_policy = 0;
186 mpls_sr_sl_t *segment_list;
191 if (!sm->sr_policies_index_hash)
192 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
194 p = hash_get (sm->sr_policies_index_hash, bsid);
196 sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
200 /* Clean SID Lists */
201 vec_foreach (sl_index, sr_policy->segments_lists)
203 segment_list = pool_elt_at_index (sm->sid_lists, *sl_index);
205 fib_route_path_t path = {
206 .frp_proto = DPO_PROTO_MPLS,
207 .frp_sw_if_index = ~0,
209 .frp_weight = segment_list->weight,
210 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
211 .frp_local_label = segment_list->segments[0],
214 vec_add (path.frp_label_stack, segment_list + 1,
215 vec_len (segment_list) - 1);
217 fib_route_path_t *paths = NULL;
218 vec_add1 (paths, path);
220 /* remove each of the MPLS routes */
221 FOR_EACH_MPLS_EOS_BIT (eos)
226 .fp_proto = FIB_PROTOCOL_MPLS,
227 .fp_label = sr_policy->bsid,
229 .fp_payload_proto = DPO_PROTO_MPLS,
233 fib_table_entry_path_remove2 (0, &pfx, FIB_SOURCE_SR, paths);
236 vec_free (segment_list->segments);
237 pool_put_index (sm->sid_lists, *sl_index);
240 /* If there is still traces of TE, make sure locks are released */
241 if (sr_policy->endpoint_type != 0 && sr_policy->color != (u32) ~ 0)
243 sr_mpls_policy_assign_endpoint_color (bsid, NULL, 0, (u32) ~ 0);
246 /* Remove SR policy entry */
247 hash_unset (sm->sr_policies_index_hash, sr_policy->bsid);
248 pool_put (sm->sr_policies, sr_policy);
254 * @brief Modify an existing SR policy
256 * The possible modifications are adding a new Segment List, modifying an
257 * existing Segment List (modify the weight only) and delete a given
258 * Segment List from the SR Policy.
260 * @param bsid is the bindingSID of the SR Policy
261 * @param fib_table is the VRF where to install the FIB entry for the BSID
262 * @param operation is the operation to perform (among the top ones)
263 * @param segments is a vector of IPv6 address composing the segment list
264 * @param sl_index is the index of the Segment List to modify/delete
265 * @param weight is the weight of the sid list. optional.
267 * @return 0 ok, >0 index of SL, <0 error
270 sr_mpls_policy_mod (mpls_label_t bsid, u8 operation,
271 mpls_label_t * segments, u32 sl_index, u32 weight)
273 mpls_sr_main_t *sm = &sr_mpls_main;
274 mpls_sr_policy_t *sr_policy = 0;
275 mpls_sr_sl_t *segment_list;
276 u32 *sl_index_iterate;
279 if (!sm->sr_policies_index_hash)
280 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
282 p = hash_get (sm->sr_policies_index_hash, bsid);
284 sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
289 { /* Add SR List to an existing SR policy */
290 /* Create the new SL */
291 segment_list = create_sl (sr_policy, segments, weight);
292 return segment_list - sm->sid_lists;
294 else if (operation == 2)
295 { /* Delete SR List from an existing SR
297 /* Check that currently there are more than one SID list */
298 if (vec_len (sr_policy->segments_lists) == 1)
302 * Check that the SR list does exist and is assigned to the
305 vec_foreach (sl_index_iterate, sr_policy->segments_lists)
306 if (*sl_index_iterate == sl_index)
309 if (*sl_index_iterate != sl_index)
312 /* Remove the lucky SR list that is being kicked out */
313 segment_list = pool_elt_at_index (sm->sid_lists, sl_index);
316 fib_route_path_t path = {
317 .frp_proto = DPO_PROTO_MPLS,
318 .frp_sw_if_index = ~0,
320 .frp_weight = segment_list->weight,
321 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
322 .frp_local_label = segment_list->segments[0],
325 vec_add (path.frp_label_stack, segment_list + 1,
326 vec_len (segment_list) - 1);
328 fib_route_path_t *paths = NULL;
329 vec_add1 (paths, path);
331 FOR_EACH_MPLS_EOS_BIT (eos)
336 .fp_proto = FIB_PROTOCOL_MPLS,
337 .fp_label = sr_policy->bsid,
339 .fp_payload_proto = DPO_PROTO_MPLS,
343 fib_table_entry_path_remove2 (0, &pfx, FIB_SOURCE_SR, paths);
347 vec_free (segment_list->segments);
348 pool_put_index (sm->sid_lists, sl_index);
349 vec_del1 (sr_policy->segments_lists,
350 sl_index_iterate - sr_policy->segments_lists);
352 else if (operation == 3)
353 { /* Modify the weight of an existing
355 /* Find the corresponding SL */
356 vec_foreach (sl_index_iterate, sr_policy->segments_lists)
357 if (*sl_index_iterate == sl_index)
360 if (*sl_index_iterate != sl_index)
363 /* Change the weight */
364 segment_list = pool_elt_at_index (sm->sid_lists, sl_index);
368 fib_route_path_t path = {
369 .frp_proto = DPO_PROTO_MPLS,
370 .frp_sw_if_index = ~0,
372 .frp_weight = segment_list->weight,
373 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
374 .frp_local_label = segment_list->segments[0],
377 vec_add (path.frp_label_stack, segment_list + 1,
378 vec_len (segment_list) - 1);
380 fib_route_path_t *paths = NULL;
381 vec_add1 (paths, path);
383 FOR_EACH_MPLS_EOS_BIT (eos)
388 .fp_proto = FIB_PROTOCOL_MPLS,
389 .fp_label = sr_policy->bsid,
391 .fp_payload_proto = DPO_PROTO_MPLS,
395 fib_table_entry_path_remove2 (0, &pfx, FIB_SOURCE_SR, paths);
398 segment_list->weight = weight;
400 path.frp_weight = segment_list->weight;
404 vec_add1 (paths, path);
406 FOR_EACH_MPLS_EOS_BIT (eos)
411 .fp_proto = FIB_PROTOCOL_MPLS,
412 .fp_label = sr_policy->bsid,
414 .fp_payload_proto = DPO_PROTO_MPLS,
418 fib_table_entry_path_add2 (0,
422 SR_POLICY_TYPE_DEFAULT ?
423 FIB_ENTRY_FLAG_NONE :
424 FIB_ENTRY_FLAG_MULTICAST), paths);
431 * @brief CLI for 'sr mpls policies' command family
433 static clib_error_t *
434 sr_mpls_policy_command_fn (vlib_main_t * vm, unformat_input_t * input,
435 vlib_cli_command_t * cmd)
438 char is_del = 0, is_add = 0, is_mod = 0;
440 mpls_label_t bsid, next_label;
441 u32 sl_index = (u32) ~ 0;
442 u32 weight = (u32) ~ 0;
443 mpls_label_t *segments = 0;
447 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
449 if (!is_add && !is_mod && !is_del && unformat (input, "add"))
451 else if (!is_add && !is_mod && !is_del && unformat (input, "del"))
453 else if (!is_add && !is_mod && !is_del && unformat (input, "mod"))
456 && unformat (input, "bsid %U", unformat_mpls_unicast_label,
459 else if (unformat (input, "weight %d", &weight));
461 (input, "next %U", unformat_mpls_unicast_label, &next_label))
463 vec_add (segments, &next_label, 1);
465 else if (unformat (input, "add sl"))
467 else if (unformat (input, "del sl index %d", &sl_index))
469 else if (unformat (input, "mod sl index %d", &sl_index))
471 else if (unformat (input, "spray"))
477 if (!is_add && !is_mod && !is_del)
478 return clib_error_return (0, "Incorrect CLI");
481 return clib_error_return (0, "No SR policy BSID or index specified");
485 if (vec_len (segments) == 0)
486 return clib_error_return (0, "No Segment List specified");
488 rv = sr_mpls_policy_add (bsid, segments,
489 (is_spray ? SR_POLICY_TYPE_SPRAY :
490 SR_POLICY_TYPE_DEFAULT), weight);
493 rv = sr_mpls_policy_del (bsid);
497 return clib_error_return (0, "No SL modification specified");
498 if (operation != 1 && sl_index == (u32) ~ 0)
499 return clib_error_return (0, "No Segment List index specified");
500 if (operation == 1 && vec_len (segments) == 0)
501 return clib_error_return (0, "No Segment List specified");
502 if (operation == 3 && weight == (u32) ~ 0)
503 return clib_error_return (0, "No new weight for the SL specified");
504 rv = sr_mpls_policy_mod (bsid, operation, segments, sl_index, weight);
513 return clib_error_return (0,
514 "There is already a FIB entry for the BindingSID address.\n"
515 "The SR policy could not be created.");
517 return clib_error_return (0,
518 "The selected SR policy only contains ONE segment list. "
519 "Please remove the SR policy instead");
521 return clib_error_return (0,
522 "Could not delete the segment list. "
523 "It is not associated with that SR policy.");
525 return clib_error_return (0,
526 "Could not delete the segment list. "
527 "It is not associated with that SR policy.");
529 return clib_error_return (0,
530 "Could not modify the segment list. "
531 "The given SL is not associated with such SR policy.");
533 return clib_error_return (0, "BUG: sr policy returns %d", rv);
539 VLIB_CLI_COMMAND(sr_mpls_policy_command, static)=
541 .path = "sr mpls policy",
542 .short_help = "sr mpls policy [add||del||mod] bsid 2999 "
543 "next 10 next 20 next 30 (weight 1) (spray)",
544 .long_help = "TBD.\n",
545 .function = sr_mpls_policy_command_fn,
550 * @brief CLI to display onscreen all the SR MPLS policies
552 static clib_error_t *
553 show_sr_mpls_policies_command_fn (vlib_main_t * vm, unformat_input_t * input,
554 vlib_cli_command_t * cmd)
556 mpls_sr_main_t *sm = &sr_mpls_main;
557 mpls_sr_sl_t *segment_list = 0;
558 mpls_sr_policy_t *sr_policy = 0;
559 mpls_sr_policy_t **vec_policies = 0;
565 vlib_cli_output (vm, "SR MPLS policies:");
568 pool_foreach(sr_policy, sm->sr_policies, {
569 vec_add1(vec_policies, sr_policy);
573 vec_foreach_index (i, vec_policies)
575 sr_policy = vec_policies[i];
576 vlib_cli_output (vm, "[%u].-\tBSID: %U",
577 (u32) (sr_policy - sm->sr_policies),
578 format_mpls_unicast_label, sr_policy->bsid);
579 switch (sr_policy->endpoint_type)
582 vlib_cli_output (vm, "\tEndpoint: %U", format_ip6_address,
583 &sr_policy->endpoint.ip6);
584 vlib_cli_output (vm, "\tColor: %u", sr_policy->color);
587 vlib_cli_output (vm, "\tEndpoint: %U", format_ip4_address,
588 &sr_policy->endpoint.ip4);
589 vlib_cli_output (vm, "\tColor: %u", sr_policy->color);
592 vlib_cli_output (vm, "\tTE disabled");
594 vlib_cli_output (vm, "\tType: %s",
596 SR_POLICY_TYPE_DEFAULT ? "Default" : "Spray"));
597 vlib_cli_output (vm, "\tSegment Lists:");
598 vec_foreach (sl_index, sr_policy->segments_lists)
601 segment_list = pool_elt_at_index (sm->sid_lists, *sl_index);
602 s = format (s, "\t[%u].- ", *sl_index);
603 s = format (s, "< ");
604 vec_foreach (label, segment_list->segments)
606 s = format (s, "%U, ", format_mpls_unicast_label, *label);
608 s = format (s, "\b\b > ");
609 vlib_cli_output (vm, " %s", s);
611 vlib_cli_output (vm, "-----------");
613 vec_free (vec_policies);
618 VLIB_CLI_COMMAND(show_sr_mpls_policies_command, static)=
620 .path = "show sr mpls policies",
621 .short_help = "show sr mpls policies",
622 .function = show_sr_mpls_policies_command_fn,
627 * @brief Update the Endpoint,Color tuple of an SR policy
629 * @param bsid is the bindingSID of the SR Policy
630 * @param endpoint represents the IP46 of the endpoint
631 * @param color represents the color (u32)
633 * To reset to NULL use ~0 as parameters.
635 * @return 0 if correct, else error
638 sr_mpls_policy_assign_endpoint_color (mpls_label_t bsid,
639 ip46_address_t * endpoint,
640 u8 endpoint_type, u32 color)
642 mpls_sr_main_t *sm = &sr_mpls_main;
643 mpls_sr_policy_t *sr_policy = 0;
644 uword *endpoint_table, *p, *old_value;
647 any.as_u64[0] = any.as_u64[1] = (u64) ~ 0;
649 if (!sm->sr_policies_index_hash)
650 sm->sr_policies_index_hash = hash_create (0, sizeof (mpls_label_t));
652 p = hash_get (sm->sr_policies_index_hash, bsid);
654 sr_policy = pool_elt_at_index (sm->sr_policies, p[0]);
658 /* If previous Endpoint, color existed, remove (NH,C) and (ANY,C) */
659 if (sr_policy->endpoint_type)
662 mhash_get (&sm->sr_policies_c2e2eclabel_hash, &sr_policy->color);
666 mhash_get ((mhash_t *) endpoint_table, &sr_policy->endpoint);
668 fib_prefix_t pfx = { 0 };
669 pfx.fp_proto = FIB_PROTOCOL_MPLS;
671 pfx.fp_label = (u32) * old_value;
674 FOR_EACH_MPLS_EOS_BIT (eos)
677 fib_table_entry_path_remove (sm->fib_table_EC,
682 ~0, 0, 1, FIB_ROUTE_PATH_FLAG_NONE);
685 old_value = mhash_get ((mhash_t *) endpoint_table, &any);
686 pfx.fp_label = (u32) * old_value;
688 FOR_EACH_MPLS_EOS_BIT (eos)
691 fib_table_entry_path_remove (sm->fib_table_EC,
696 ~0, 0, 1, FIB_ROUTE_PATH_FLAG_NONE);
699 /* Release the lock on (NH, Color) and (ANY, Color) */
700 internal_label_unlock (sr_policy->endpoint, sr_policy->color);
701 internal_label_unlock (any, sr_policy->color);
703 /* Reset the values on the SR policy */
704 sr_policy->endpoint_type = 0;
705 sr_policy->endpoint.as_u64[0] = sr_policy->endpoint.as_u64[1] =
707 sr_policy->color = (u32) ~ 0;
712 sr_policy->endpoint_type = endpoint_type;
713 sr_policy->endpoint.as_u64[0] = endpoint->as_u64[0];
714 sr_policy->endpoint.as_u64[1] = endpoint->as_u64[1];
715 sr_policy->color = color;
717 u32 label = find_or_create_internal_label (*endpoint, color);
718 internal_label_lock (*endpoint, sr_policy->color);
720 /* If FIB doesnt exist, create them */
721 if (sm->fib_table_EC == (u32) ~ 0)
723 sm->fib_table_EC = fib_table_create_and_lock (FIB_PROTOCOL_MPLS,
725 "SR-MPLS Traffic Engineering (NextHop,Color)");
727 fib_table_flush (sm->fib_table_EC, FIB_PROTOCOL_MPLS,
731 fib_prefix_t pfx = { 0 };
732 pfx.fp_proto = FIB_PROTOCOL_MPLS;
735 fib_route_path_t path = {
736 .frp_proto = DPO_PROTO_MPLS,
737 .frp_sw_if_index = ~0,
740 .frp_flags = FIB_ROUTE_PATH_FLAG_NONE,
743 path.frp_local_label = sr_policy->bsid;
745 //Add the entry to ANY,Color
746 u32 any_label = find_or_create_internal_label (any, color);
747 internal_label_lock (any, sr_policy->color);
749 pfx.fp_eos = MPLS_EOS;
750 path.frp_eos = MPLS_EOS;
752 fib_route_path_t *paths = NULL;
753 vec_add1 (paths, path);
755 pfx.fp_label = label;
756 fib_table_entry_update (sm->fib_table_EC,
759 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
761 pfx.fp_label = any_label;
762 fib_table_entry_update (sm->fib_table_EC,
765 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
767 vec_add1 (path.frp_label_stack, MPLS_IETF_IMPLICIT_NULL_LABEL);
768 pfx.fp_eos = MPLS_NON_EOS;
769 path.frp_eos = MPLS_NON_EOS;
772 vec_add1 (paths, path);
774 pfx.fp_label = label;
775 fib_table_entry_update (sm->fib_table_EC,
778 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
780 pfx.fp_label = any_label;
781 fib_table_entry_update (sm->fib_table_EC,
784 FIB_ENTRY_FLAG_LOOSE_URPF_EXEMPT, paths);
790 * @brief CLI to modify the Endpoint,Color of an SR policy
792 static clib_error_t *
793 cli_sr_mpls_policy_ec_command_fn (vlib_main_t * vm, unformat_input_t * input,
794 vlib_cli_command_t * cmd)
796 ip46_address_t endpoint;
797 u32 color = (u32) ~ 0;
799 u8 endpoint_type = 0;
800 char clear = 0, color_set = 0, bsid_set = 0;
802 memset (&endpoint, 0, sizeof (ip46_address_t));
805 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
808 && unformat (input, "endpoint %U", unformat_ip6_address,
810 endpoint_type = SR_STEER_IPV6;
811 else if (!endpoint_type
812 && unformat (input, "endpoint %U", unformat_ip4_address,
814 endpoint_type = SR_STEER_IPV4;
815 else if (!color_set && unformat (input, "color %u", &color))
818 && unformat (input, "bsid %U", unformat_mpls_unicast_label,
821 else if (!clear && unformat (input, "clear"))
828 return clib_error_return (0, "No BSID specified");
829 if (!endpoint_type && !clear)
830 return clib_error_return (0, "No Endpoint specified");
831 if (!color_set && !clear)
832 return clib_error_return (0, "No Color set");
834 /* In case its a cleanup */
837 ip6_address_set_zero (&endpoint.ip6);
841 sr_mpls_policy_assign_endpoint_color (bsid, &endpoint, endpoint_type,
845 clib_error_return (0, "Error on Endpoint,Color");
851 VLIB_CLI_COMMAND(cli_sr_mpls_policy_ec_command, static)=
853 .path = "sr mpls policy te",
854 .short_help = "sr mpls policy te bsid xxxxx endpoint x.x.x.x color 12341234",
855 .function = cli_sr_mpls_policy_ec_command_fn,
859 /********************* SR MPLS Policy initialization ***********************/
861 * @brief SR MPLS Policy initialization
864 sr_mpls_policy_rewrite_init (vlib_main_t * vm)
866 mpls_sr_main_t *sm = &sr_mpls_main;
868 /* Init memory for sr policy keys (bsid <-> ip6_address_t) */
869 sm->sr_policies_index_hash = NULL;
870 sm->sr_policies_c2e2eclabel_hash.hash = NULL;
874 VLIB_INIT_FUNCTION (sr_mpls_policy_rewrite_init);
877 * fd.io coding-style-patch-verification: ON
879 * Local Variables: eval: (c-set-style "gnu") End: