FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
mpls_features.c
Go to the documentation of this file.
1 /*
2  * mpls_features.c: MPLS input and output features
3  *
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:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  */
17 
18 #include <vnet/mpls/mpls.h>
19 
22  vlib_node_runtime_t * node,
23  vlib_frame_t * frame,
24  int error_code)
25 {
26  u32 * buffers = vlib_frame_vector_args (frame);
27  uword n_packets = frame->n_vectors;
28 
29  vlib_error_drop_buffers (vm, node,
30  buffers,
31  /* stride */ 1,
32  n_packets,
33  /* next */ 0,
34  mpls_input_node.index,
35  error_code);
36 
37  return n_packets;
38 }
39 
40 static uword
42  vlib_node_runtime_t * node,
43  vlib_frame_t * frame)
44 {
45  return (mpls_terminate(vm, node, frame, MPLS_ERROR_PUNT));
46 }
47 
49  .function = mpls_punt,
50  .name = "mpls-punt",
51  .vector_size = sizeof (u32),
52 
53  .n_next_nodes = 1,
54  .next_nodes = {
55  [0] = "error-punt",
56  },
57 };
58 
60 
61 static uword
63  vlib_node_runtime_t * node,
64  vlib_frame_t * frame)
65 {
66  return (mpls_terminate(vm, node, frame, MPLS_ERROR_DROP));
67 }
68 
70  .function = mpls_drop,
71  .name = "mpls-drop",
72  .vector_size = sizeof (u32),
73 
74  .n_next_nodes = 1,
75  .next_nodes = {
76  [0] = "error-drop",
77  },
78 };
79 
81 
82 static uword
84  vlib_node_runtime_t * node,
85  vlib_frame_t * frame)
86 {
87  return (mpls_terminate(vm, node, frame, MPLS_ERROR_NOT_ENABLED));
88 }
89 
91  .function = mpls_not_enabled,
92  .name = "mpls-not-enabled",
93  .vector_size = sizeof (u32),
94 
95  .n_next_nodes = 1,
96  .next_nodes = {
97  [0] = "error-drop",
98  },
99 };
100 
102 
104 {
105  .arc_name = "mpls-input",
106  .start_nodes = VNET_FEATURES ("mpls-input"),
107  .last_in_arc = "mpls-lookup",
108  .arc_index_ptr = &mpls_main.input_feature_arc_index,
109 };
110 
112  .arc_name = "mpls-input",
113  .node_name = "mpls-not-enabled",
114  .runs_before = VNET_FEATURES ("mpls-lookup"),
115 };
116 
117 VNET_FEATURE_INIT (mpls_lookup, static) = {
118  .arc_name = "mpls-input",
119  .node_name = "mpls-lookup",
120  .runs_before = VNET_FEATURES (0), /* not before any other features */
121 };
122 
124 {
125  .arc_name = "mpls-output",
126  .start_nodes = VNET_FEATURES ("mpls-output", "mpls-midchain"),
127  .last_in_arc = "interface-output",
128  .arc_index_ptr = &mpls_main.output_feature_arc_index,
129 };
130 
131 /* Built-in ip4 tx feature path definition */
132 VNET_FEATURE_INIT (mpls_interface_output, static) = {
133  .arc_name = "mpls-output",
134  .node_name = "interface-output",
135  .runs_before = 0, /* not before any other features */
136 };
137 
138 static clib_error_t *
141  u32 is_add)
142 {
143  mpls_main_t * mm = &mpls_main;
144 
147 
148  vnet_feature_enable_disable ("mpls-input", "mpls-not-enabled", sw_if_index,
149  is_add, 0, 0);
150 
151  return /* no error */ 0;
152 }
153 
155 
156 
vlib_node_registration_t mpls_drop_node
(constructor) VLIB_REGISTER_NODE (mpls_drop_node)
Definition: mpls_features.c:69
vlib_node_registration_t mpls_not_enabled_node
(constructor) VLIB_REGISTER_NODE (mpls_not_enabled_node)
Definition: mpls_features.c:90
u8 input_feature_arc_index
Definition: mpls.h:56
u32 * fib_index_by_sw_if_index
Definition: mpls.h:44
VNET_FEATURE_INIT(mpls_not_enabled, static)
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(mpls_sw_interface_add_del)
u8 * mpls_enabled_by_sw_if_index
Definition: mpls.h:60
static uword mpls_terminate(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int error_code)
Definition: mpls_features.c:21
u32 sw_if_index
Definition: vxlan_gbp.api:37
#define always_inline
Definition: clib.h:98
unsigned int u32
Definition: types.h:88
vlib_node_registration_t mpls_punt_node
(constructor) VLIB_REGISTER_NODE (mpls_punt_node)
Definition: mpls_features.c:48
u8 output_feature_arc_index
Definition: mpls.h:57
static uword mpls_lookup(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: mpls_lookup.c:61
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:223
static clib_error_t * mpls_sw_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
uword vlib_error_drop_buffers(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u32 next_buffer_stride, u32 n_buffers, u32 next_index, u32 drop_error_node, u32 drop_error_code)
Definition: error.c:44
vlib_node_registration_t mpls_input_node
(constructor) VLIB_REGISTER_NODE (mpls_input_node)
Definition: mpls_input.c:248
static uword mpls_output(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: mpls_output.c:317
VNET_FEATURE_ARC_INIT(mpls_input, static)
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
u16 n_vectors
Definition: node.h:420
mpls_main_t mpls_main
Definition: mpls.c:25
vlib_main_t * vm
Definition: buffer.c:301
#define VNET_FEATURES(...)
Definition: feature.h:435
static uword mpls_punt(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: mpls_features.c:41
static uword mpls_input(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: mpls_input.c:235
u64 uword
Definition: types.h:112
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:244
static uword mpls_drop(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: mpls_features.c:62
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
Definition: vec.h:488
static uword mpls_not_enabled(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: mpls_features.c:83
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: feature.c:274