2 * mpls_features.c: MPLS input and output features
4 * Copyright (c) 2016 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <vnet/mpls/mpls.h>
21 mpls_terminate (vlib_main_t * vm,
22 vlib_node_runtime_t * node,
26 u32 * buffers = vlib_frame_vector_args (frame);
27 uword n_packets = frame->n_vectors;
29 vlib_error_drop_buffers (vm, node,
34 mpls_input_node.index,
41 mpls_punt (vlib_main_t * vm,
42 vlib_node_runtime_t * node,
45 return (mpls_terminate(vm, node, frame, MPLS_ERROR_PUNT));
48 VLIB_REGISTER_NODE (mpls_punt_node) = {
49 .function = mpls_punt,
51 .vector_size = sizeof (u32),
59 VLIB_NODE_FUNCTION_MULTIARCH (mpls_punt_node, mpls_punt)
62 mpls_drop (vlib_main_t * vm,
63 vlib_node_runtime_t * node,
66 return (mpls_terminate(vm, node, frame, MPLS_ERROR_DROP));
69 VLIB_REGISTER_NODE (mpls_drop_node) = {
70 .function = mpls_drop,
72 .vector_size = sizeof (u32),
80 VLIB_NODE_FUNCTION_MULTIARCH (mpls_drop_node, mpls_drop)
83 mpls_not_enabled (vlib_main_t * vm,
84 vlib_node_runtime_t * node,
87 return (mpls_terminate(vm, node, frame, MPLS_ERROR_NOT_ENABLED));
90 VLIB_REGISTER_NODE (mpls_not_enabled_node) = {
91 .function = mpls_not_enabled,
92 .name = "mpls-not-enabled",
93 .vector_size = sizeof (u32),
101 VLIB_NODE_FUNCTION_MULTIARCH (mpls_not_enabled_node, mpls_not_enabled)
103 VNET_FEATURE_ARC_INIT (mpls_input, static) =
105 .arc_name = "mpls-input",
106 .start_nodes = VNET_FEATURES ("mpls-input"),
107 .arc_index_ptr = &mpls_main.input_feature_arc_index,
110 VNET_FEATURE_INIT (mpls_not_enabled, static) = {
111 .arc_name = "mpls-input",
112 .node_name = "mpls-not-enabled",
113 .runs_before = VNET_FEATURES ("mpls-lookup"),
116 VNET_FEATURE_INIT (mpls_lookup, static) = {
117 .arc_name = "mpls-input",
118 .node_name = "mpls-lookup",
119 .runs_before = VNET_FEATURES (0), /* not before any other features */
122 VNET_FEATURE_ARC_INIT (mpls_output, static) =
124 .arc_name = "mpls-output",
125 .start_nodes = VNET_FEATURES ("mpls-output", "mpls-midchain"),
126 .arc_index_ptr = &mpls_main.output_feature_arc_index,
129 /* Built-in ip4 tx feature path definition */
130 VNET_FEATURE_INIT (mpls_interface_output, static) = {
131 .arc_name = "mpls-output",
132 .node_name = "interface-output",
133 .runs_before = 0, /* not before any other features */
136 static clib_error_t *
137 mpls_sw_interface_add_del (vnet_main_t * vnm,
141 mpls_main_t * mm = &mpls_main;
143 vec_validate_init_empty (mm->mpls_enabled_by_sw_if_index, sw_if_index, 0);
144 vec_validate_init_empty (mm->fib_index_by_sw_if_index, sw_if_index, 0);
146 vnet_feature_enable_disable ("mpls-input", "mpls-not-enabled", sw_if_index,
148 vnet_feature_enable_disable ("mpls-output", "interface-output", sw_if_index,
151 return /* no error */ 0;
154 VNET_SW_INTERFACE_ADD_DEL_FUNCTION (mpls_sw_interface_add_del);