Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #include <vnet/adj/adj_nbr.h> |
| 17 | #include <vnet/adj/adj_internal.h> |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 18 | #include <vnet/adj/adj_l2.h> |
Florin Coras | ce1b4c7 | 2017-01-26 14:25:34 -0800 | [diff] [blame] | 19 | #include <vnet/adj/adj_nsh.h> |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 20 | #include <vnet/adj/adj_midchain.h> |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 21 | #include <vnet/ethernet/arp_packet.h> |
| 22 | #include <vnet/dpo/drop_dpo.h> |
| 23 | #include <vnet/fib/fib_walk.h> |
| 24 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 25 | /** |
| 26 | * The two midchain tx feature node indices |
| 27 | */ |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 28 | static u32 adj_midchain_tx_feature_node[VNET_LINK_NUM]; |
| 29 | static u32 adj_midchain_tx_no_count_feature_node[VNET_LINK_NUM]; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * @brief Trace data for packets traversing the midchain tx node |
| 33 | */ |
| 34 | typedef struct adj_midchain_tx_trace_t_ |
| 35 | { |
| 36 | /** |
| 37 | * @brief the midchain adj we are traversing |
| 38 | */ |
| 39 | adj_index_t ai; |
| 40 | } adj_midchain_tx_trace_t; |
| 41 | |
| 42 | always_inline uword |
Damjan Marion | 77766a1 | 2016-11-02 01:21:05 +0100 | [diff] [blame] | 43 | adj_midchain_tx_inline (vlib_main_t * vm, |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 44 | vlib_node_runtime_t * node, |
| 45 | vlib_frame_t * frame, |
| 46 | int interface_count) |
| 47 | { |
| 48 | u32 * from, * to_next, n_left_from, n_left_to_next; |
| 49 | u32 next_index; |
| 50 | vnet_main_t *vnm = vnet_get_main (); |
| 51 | vnet_interface_main_t *im = &vnm->interface_main; |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 52 | u32 thread_index = vm->thread_index; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 53 | |
| 54 | /* Vector of buffer / pkt indices we're supposed to process */ |
| 55 | from = vlib_frame_vector_args (frame); |
| 56 | |
| 57 | /* Number of buffers / pkts */ |
| 58 | n_left_from = frame->n_vectors; |
| 59 | |
| 60 | /* Speculatively send the first buffer to the last disposition we used */ |
| 61 | next_index = node->cached_next_index; |
| 62 | |
| 63 | while (n_left_from > 0) |
| 64 | { |
| 65 | /* set up to enqueue to our disposition with index = next_index */ |
| 66 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
| 67 | |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 68 | while (n_left_from >= 8 && n_left_to_next > 4) |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 69 | { |
| 70 | u32 bi0, adj_index0, next0; |
| 71 | const ip_adjacency_t * adj0; |
| 72 | const dpo_id_t *dpo0; |
| 73 | vlib_buffer_t * b0; |
| 74 | u32 bi1, adj_index1, next1; |
| 75 | const ip_adjacency_t * adj1; |
| 76 | const dpo_id_t *dpo1; |
| 77 | vlib_buffer_t * b1; |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 78 | u32 bi2, adj_index2, next2; |
| 79 | const ip_adjacency_t * adj2; |
| 80 | const dpo_id_t *dpo2; |
| 81 | vlib_buffer_t * b2; |
| 82 | u32 bi3, adj_index3, next3; |
| 83 | const ip_adjacency_t * adj3; |
| 84 | const dpo_id_t *dpo3; |
| 85 | vlib_buffer_t * b3; |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 86 | |
| 87 | /* Prefetch next iteration. */ |
| 88 | { |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 89 | vlib_buffer_t * p4, * p5; |
| 90 | vlib_buffer_t * p6, * p7; |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 91 | |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 92 | p4 = vlib_get_buffer (vm, from[4]); |
| 93 | p5 = vlib_get_buffer (vm, from[5]); |
| 94 | p6 = vlib_get_buffer (vm, from[6]); |
| 95 | p7 = vlib_get_buffer (vm, from[7]); |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 96 | |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 97 | vlib_prefetch_buffer_header (p4, LOAD); |
| 98 | vlib_prefetch_buffer_header (p5, LOAD); |
| 99 | vlib_prefetch_buffer_header (p6, LOAD); |
| 100 | vlib_prefetch_buffer_header (p7, LOAD); |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | bi0 = from[0]; |
| 104 | to_next[0] = bi0; |
| 105 | bi1 = from[1]; |
| 106 | to_next[1] = bi1; |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 107 | bi2 = from[2]; |
| 108 | to_next[2] = bi2; |
| 109 | bi3 = from[3]; |
| 110 | to_next[3] = bi3; |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 111 | |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 112 | from += 4; |
| 113 | to_next += 4; |
| 114 | n_left_from -= 4; |
| 115 | n_left_to_next -= 4; |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 116 | |
| 117 | b0 = vlib_get_buffer(vm, bi0); |
| 118 | b1 = vlib_get_buffer(vm, bi1); |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 119 | b2 = vlib_get_buffer(vm, bi2); |
| 120 | b3 = vlib_get_buffer(vm, bi3); |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 121 | |
| 122 | /* Follow the DPO on which the midchain is stacked */ |
| 123 | adj_index0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX]; |
| 124 | adj_index1 = vnet_buffer(b1)->ip.adj_index[VLIB_TX]; |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 125 | adj_index2 = vnet_buffer(b2)->ip.adj_index[VLIB_TX]; |
| 126 | adj_index3 = vnet_buffer(b3)->ip.adj_index[VLIB_TX]; |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 127 | |
| 128 | adj0 = adj_get(adj_index0); |
| 129 | adj1 = adj_get(adj_index1); |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 130 | adj2 = adj_get(adj_index2); |
| 131 | adj3 = adj_get(adj_index3); |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 132 | |
| 133 | dpo0 = &adj0->sub_type.midchain.next_dpo; |
| 134 | dpo1 = &adj1->sub_type.midchain.next_dpo; |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 135 | dpo2 = &adj2->sub_type.midchain.next_dpo; |
| 136 | dpo3 = &adj3->sub_type.midchain.next_dpo; |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 137 | |
| 138 | next0 = dpo0->dpoi_next_node; |
| 139 | next1 = dpo1->dpoi_next_node; |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 140 | next2 = dpo2->dpoi_next_node; |
| 141 | next3 = dpo3->dpoi_next_node; |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 142 | |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 143 | vnet_buffer(b1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index; |
| 144 | vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; |
| 145 | vnet_buffer(b2)->ip.adj_index[VLIB_TX] = dpo2->dpoi_index; |
| 146 | vnet_buffer(b3)->ip.adj_index[VLIB_TX] = dpo3->dpoi_index; |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 147 | |
| 148 | if (interface_count) |
| 149 | { |
| 150 | vlib_increment_combined_counter (im->combined_sw_if_counters |
| 151 | + VNET_INTERFACE_COUNTER_TX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 152 | thread_index, |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 153 | adj0->rewrite_header.sw_if_index, |
| 154 | 1, |
| 155 | vlib_buffer_length_in_chain (vm, b0)); |
| 156 | vlib_increment_combined_counter (im->combined_sw_if_counters |
| 157 | + VNET_INTERFACE_COUNTER_TX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 158 | thread_index, |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 159 | adj1->rewrite_header.sw_if_index, |
| 160 | 1, |
| 161 | vlib_buffer_length_in_chain (vm, b1)); |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 162 | vlib_increment_combined_counter (im->combined_sw_if_counters |
| 163 | + VNET_INTERFACE_COUNTER_TX, |
| 164 | thread_index, |
| 165 | adj2->rewrite_header.sw_if_index, |
| 166 | 1, |
| 167 | vlib_buffer_length_in_chain (vm, b2)); |
| 168 | vlib_increment_combined_counter (im->combined_sw_if_counters |
| 169 | + VNET_INTERFACE_COUNTER_TX, |
| 170 | thread_index, |
| 171 | adj3->rewrite_header.sw_if_index, |
| 172 | 1, |
| 173 | vlib_buffer_length_in_chain (vm, b3)); |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) |
| 177 | { |
| 178 | adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node, |
| 179 | b0, sizeof (*tr)); |
| 180 | tr->ai = adj_index0; |
| 181 | } |
| 182 | if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED)) |
| 183 | { |
| 184 | adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node, |
| 185 | b1, sizeof (*tr)); |
| 186 | tr->ai = adj_index1; |
| 187 | } |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 188 | if (PREDICT_FALSE(b2->flags & VLIB_BUFFER_IS_TRACED)) |
| 189 | { |
| 190 | adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node, |
| 191 | b2, sizeof (*tr)); |
| 192 | tr->ai = adj_index2; |
| 193 | } |
| 194 | if (PREDICT_FALSE(b3->flags & VLIB_BUFFER_IS_TRACED)) |
| 195 | { |
| 196 | adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node, |
| 197 | b3, sizeof (*tr)); |
| 198 | tr->ai = adj_index3; |
| 199 | } |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 200 | |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 201 | vlib_validate_buffer_enqueue_x4 (vm, node, next_index, |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 202 | to_next, n_left_to_next, |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 203 | bi0, bi1, bi2, bi3, |
| 204 | next0, next1, next2, next3); |
Neale Ranns | d3b85b0 | 2016-10-22 15:17:21 -0700 | [diff] [blame] | 205 | } |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 206 | while (n_left_from > 0 && n_left_to_next > 0) |
| 207 | { |
| 208 | u32 bi0, adj_index0, next0; |
| 209 | const ip_adjacency_t * adj0; |
| 210 | const dpo_id_t *dpo0; |
| 211 | vlib_buffer_t * b0; |
| 212 | |
| 213 | bi0 = from[0]; |
| 214 | to_next[0] = bi0; |
| 215 | from += 1; |
| 216 | to_next += 1; |
| 217 | n_left_from -= 1; |
| 218 | n_left_to_next -= 1; |
| 219 | |
| 220 | b0 = vlib_get_buffer(vm, bi0); |
| 221 | |
| 222 | /* Follow the DPO on which the midchain is stacked */ |
| 223 | adj_index0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX]; |
| 224 | adj0 = adj_get(adj_index0); |
| 225 | dpo0 = &adj0->sub_type.midchain.next_dpo; |
| 226 | next0 = dpo0->dpoi_next_node; |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 227 | vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 228 | |
| 229 | if (interface_count) |
| 230 | { |
| 231 | vlib_increment_combined_counter (im->combined_sw_if_counters |
| 232 | + VNET_INTERFACE_COUNTER_TX, |
Damjan Marion | 586afd7 | 2017-04-05 19:18:20 +0200 | [diff] [blame] | 233 | thread_index, |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 234 | adj0->rewrite_header.sw_if_index, |
| 235 | 1, |
| 236 | vlib_buffer_length_in_chain (vm, b0)); |
| 237 | } |
| 238 | |
| 239 | if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) |
| 240 | { |
| 241 | adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node, |
| 242 | b0, sizeof (*tr)); |
| 243 | tr->ai = adj_index0; |
| 244 | } |
| 245 | |
| 246 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 247 | to_next, n_left_to_next, |
| 248 | bi0, next0); |
| 249 | } |
| 250 | |
| 251 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 252 | } |
| 253 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 254 | return frame->n_vectors; |
| 255 | } |
| 256 | |
| 257 | static u8 * |
| 258 | format_adj_midchain_tx_trace (u8 * s, va_list * args) |
| 259 | { |
| 260 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 261 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
| 262 | adj_midchain_tx_trace_t *tr = va_arg (*args, adj_midchain_tx_trace_t*); |
| 263 | |
| 264 | s = format(s, "adj-midchain:[%d]:%U", tr->ai, |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 265 | format_ip_adjacency, tr->ai, |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 266 | FORMAT_IP_ADJACENCY_NONE); |
| 267 | |
| 268 | return (s); |
| 269 | } |
| 270 | |
| 271 | static uword |
| 272 | adj_midchain_tx (vlib_main_t * vm, |
| 273 | vlib_node_runtime_t * node, |
| 274 | vlib_frame_t * frame) |
| 275 | { |
Damjan Marion | 77766a1 | 2016-11-02 01:21:05 +0100 | [diff] [blame] | 276 | return (adj_midchain_tx_inline(vm, node, frame, 1)); |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | VLIB_REGISTER_NODE (adj_midchain_tx_node, static) = { |
| 280 | .function = adj_midchain_tx, |
| 281 | .name = "adj-midchain-tx", |
| 282 | .vector_size = sizeof (u32), |
| 283 | |
| 284 | .format_trace = format_adj_midchain_tx_trace, |
| 285 | |
| 286 | .n_next_nodes = 1, |
| 287 | .next_nodes = { |
| 288 | [0] = "error-drop", |
| 289 | }, |
| 290 | }; |
| 291 | |
| 292 | static uword |
| 293 | adj_midchain_tx_no_count (vlib_main_t * vm, |
| 294 | vlib_node_runtime_t * node, |
| 295 | vlib_frame_t * frame) |
| 296 | { |
Damjan Marion | 77766a1 | 2016-11-02 01:21:05 +0100 | [diff] [blame] | 297 | return (adj_midchain_tx_inline(vm, node, frame, 0)); |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | VLIB_REGISTER_NODE (adj_midchain_tx_no_count_node, static) = { |
| 301 | .function = adj_midchain_tx_no_count, |
| 302 | .name = "adj-midchain-tx-no-count", |
| 303 | .vector_size = sizeof (u32), |
| 304 | |
| 305 | .format_trace = format_adj_midchain_tx_trace, |
| 306 | |
| 307 | .n_next_nodes = 1, |
| 308 | .next_nodes = { |
| 309 | [0] = "error-drop", |
| 310 | }, |
| 311 | }; |
| 312 | |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 313 | VNET_FEATURE_INIT (adj_midchain_tx_ip4, static) = { |
| 314 | .arc_name = "ip4-output", |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 315 | .node_name = "adj-midchain-tx", |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 316 | .runs_before = VNET_FEATURES ("interface-output"), |
| 317 | .feature_index_ptr = &adj_midchain_tx_feature_node[VNET_LINK_IP4], |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 318 | }; |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 319 | VNET_FEATURE_INIT (adj_midchain_tx_no_count_ip4, static) = { |
| 320 | .arc_name = "ip4-output", |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 321 | .node_name = "adj-midchain-tx-no-count", |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 322 | .runs_before = VNET_FEATURES ("interface-output"), |
| 323 | .feature_index_ptr = &adj_midchain_tx_no_count_feature_node[VNET_LINK_IP4], |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 324 | }; |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 325 | VNET_FEATURE_INIT (adj_midchain_tx_ip6, static) = { |
| 326 | .arc_name = "ip6-output", |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 327 | .node_name = "adj-midchain-tx", |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 328 | .runs_before = VNET_FEATURES ("interface-output"), |
| 329 | .feature_index_ptr = &adj_midchain_tx_feature_node[VNET_LINK_IP6], |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 330 | }; |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 331 | VNET_FEATURE_INIT (adj_midchain_tx_no_count_ip6, static) = { |
| 332 | .arc_name = "ip6-output", |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 333 | .node_name = "adj-midchain-tx-no-count", |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 334 | .runs_before = VNET_FEATURES ("interface-output"), |
| 335 | .feature_index_ptr = &adj_midchain_tx_no_count_feature_node[VNET_LINK_IP6], |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 336 | }; |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 337 | VNET_FEATURE_INIT (adj_midchain_tx_mpls, static) = { |
| 338 | .arc_name = "mpls-output", |
Damjan Marion | 77766a1 | 2016-11-02 01:21:05 +0100 | [diff] [blame] | 339 | .node_name = "adj-midchain-tx", |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 340 | .runs_before = VNET_FEATURES ("interface-output"), |
| 341 | .feature_index_ptr = &adj_midchain_tx_feature_node[VNET_LINK_MPLS], |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 342 | }; |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 343 | VNET_FEATURE_INIT (adj_midchain_tx_no_count_mpls, static) = { |
| 344 | .arc_name = "mpls-output", |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 345 | .node_name = "adj-midchain-tx-no-count", |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 346 | .runs_before = VNET_FEATURES ("interface-output"), |
| 347 | .feature_index_ptr = &adj_midchain_tx_no_count_feature_node[VNET_LINK_MPLS], |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 348 | }; |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 349 | VNET_FEATURE_INIT (adj_midchain_tx_ethernet, static) = { |
| 350 | .arc_name = "ethernet-output", |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 351 | .node_name = "adj-midchain-tx", |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 352 | .runs_before = VNET_FEATURES ("error-drop"), |
| 353 | .feature_index_ptr = &adj_midchain_tx_feature_node[VNET_LINK_ETHERNET], |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 354 | }; |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 355 | VNET_FEATURE_INIT (adj_midchain_tx_no_count_ethernet, static) = { |
| 356 | .arc_name = "ethernet-output", |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 357 | .node_name = "adj-midchain-tx-no-count", |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 358 | .runs_before = VNET_FEATURES ("error-drop"), |
| 359 | .feature_index_ptr = &adj_midchain_tx_no_count_feature_node[VNET_LINK_ETHERNET], |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 360 | }; |
Florin Coras | ce1b4c7 | 2017-01-26 14:25:34 -0800 | [diff] [blame] | 361 | VNET_FEATURE_INIT (adj_midchain_tx_nsh, static) = { |
| 362 | .arc_name = "nsh-output", |
| 363 | .node_name = "adj-midchain-tx", |
| 364 | .runs_before = VNET_FEATURES ("error-drop"), |
| 365 | .feature_index_ptr = &adj_midchain_tx_feature_node[VNET_LINK_NSH], |
| 366 | }; |
| 367 | VNET_FEATURE_INIT (adj_midchain_tx_no_count_nsh, static) = { |
| 368 | .arc_name = "nsh-output", |
| 369 | .node_name = "adj-midchain-tx-no-count", |
| 370 | .runs_before = VNET_FEATURES ("error-drop"), |
| 371 | .feature_index_ptr = &adj_midchain_tx_no_count_feature_node[VNET_LINK_NSH], |
| 372 | }; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 373 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 374 | static inline u32 |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 375 | adj_get_midchain_node (vnet_link_t link) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 376 | { |
| 377 | switch (link) { |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 378 | case VNET_LINK_IP4: |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 379 | return (ip4_midchain_node.index); |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 380 | case VNET_LINK_IP6: |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 381 | return (ip6_midchain_node.index); |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 382 | case VNET_LINK_MPLS: |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 383 | return (mpls_midchain_node.index); |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 384 | case VNET_LINK_ETHERNET: |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 385 | return (adj_l2_midchain_node.index); |
Florin Coras | ce1b4c7 | 2017-01-26 14:25:34 -0800 | [diff] [blame] | 386 | case VNET_LINK_NSH: |
| 387 | return (adj_nsh_midchain_node.index); |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 388 | case VNET_LINK_ARP: |
| 389 | break; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 390 | } |
| 391 | ASSERT(0); |
| 392 | return (0); |
| 393 | } |
| 394 | |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 395 | static u8 |
| 396 | adj_midchain_get_feature_arc_index_for_link_type (const ip_adjacency_t *adj) |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 397 | { |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 398 | u8 arc = (u8) ~0; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 399 | switch (adj->ia_link) |
| 400 | { |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 401 | case VNET_LINK_IP4: |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 402 | { |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 403 | arc = ip4_main.lookup_main.output_feature_arc_index; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 404 | break; |
| 405 | } |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 406 | case VNET_LINK_IP6: |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 407 | { |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 408 | arc = ip6_main.lookup_main.output_feature_arc_index; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 409 | break; |
| 410 | } |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 411 | case VNET_LINK_MPLS: |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 412 | { |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 413 | arc = mpls_main.output_feature_arc_index; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 414 | break; |
| 415 | } |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 416 | case VNET_LINK_ETHERNET: |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 417 | { |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 418 | arc = ethernet_main.output_feature_arc_index; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 419 | break; |
| 420 | } |
Florin Coras | ce1b4c7 | 2017-01-26 14:25:34 -0800 | [diff] [blame] | 421 | case VNET_LINK_NSH: |
| 422 | { |
| 423 | arc = nsh_main_dummy.output_feature_arc_index; |
| 424 | break; |
| 425 | } |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 426 | case VNET_LINK_ARP: |
| 427 | ASSERT(0); |
| 428 | break; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 429 | } |
| 430 | |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 431 | ASSERT (arc != (u8) ~0); |
| 432 | |
| 433 | return (arc); |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 434 | } |
| 435 | |
Neale Ranns | fa5d198 | 2017-02-20 14:19:51 -0800 | [diff] [blame] | 436 | static u32 |
| 437 | adj_nbr_midchain_get_tx_node (ip_adjacency_t *adj) |
| 438 | { |
| 439 | return ((adj->ia_flags & ADJ_FLAG_MIDCHAIN_NO_COUNT) ? |
| 440 | adj_midchain_tx_no_count_node.index : |
| 441 | adj_midchain_tx_node.index); |
| 442 | } |
| 443 | |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 444 | static u32 |
| 445 | adj_nbr_midchain_get_feature_node (ip_adjacency_t *adj) |
| 446 | { |
| 447 | if (adj->ia_flags & ADJ_FLAG_MIDCHAIN_NO_COUNT) |
| 448 | { |
| 449 | return (adj_midchain_tx_no_count_feature_node[adj->ia_link]); |
| 450 | } |
| 451 | |
| 452 | return (adj_midchain_tx_feature_node[adj->ia_link]); |
| 453 | } |
| 454 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 455 | /** |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 456 | * adj_midchain_setup |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 457 | * |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 458 | * Setup the adj as a mid-chain |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 459 | */ |
| 460 | void |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 461 | adj_midchain_setup (adj_index_t adj_index, |
| 462 | adj_midchain_fixup_t fixup, |
| 463 | adj_flags_t flags) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 464 | { |
Neale Ranns | fa5d198 | 2017-02-20 14:19:51 -0800 | [diff] [blame] | 465 | u32 feature_index, tx_node; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 466 | ip_adjacency_t *adj; |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 467 | u8 arc_index; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 468 | |
| 469 | ASSERT(ADJ_INDEX_INVALID != adj_index); |
| 470 | |
| 471 | adj = adj_get(adj_index); |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 472 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 473 | adj->sub_type.midchain.fixup_func = fixup; |
Neale Ranns | fa5d198 | 2017-02-20 14:19:51 -0800 | [diff] [blame] | 474 | adj->ia_flags |= flags; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 475 | |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 476 | arc_index = adj_midchain_get_feature_arc_index_for_link_type (adj); |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 477 | feature_index = adj_nbr_midchain_get_feature_node(adj); |
Neale Ranns | fa5d198 | 2017-02-20 14:19:51 -0800 | [diff] [blame] | 478 | tx_node = adj_nbr_midchain_get_tx_node(adj); |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 479 | |
Damjan Marion | 8b3191e | 2016-11-09 19:54:20 +0100 | [diff] [blame] | 480 | vnet_feature_enable_disable_with_index (arc_index, feature_index, |
| 481 | adj->rewrite_header.sw_if_index, |
| 482 | 1 /* enable */, 0, 0); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 483 | |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 484 | /* |
| 485 | * stack the midchain on the drop so it's ready to forward in the adj-midchain-tx. |
| 486 | * The graph arc used/created here is from the midchain-tx node to the |
| 487 | * child's registered node. This is because post adj processing the next |
| 488 | * node are any output features, then the midchain-tx. from there we |
| 489 | * need to get to the stacked child's node. |
| 490 | */ |
Neale Ranns | fa5d198 | 2017-02-20 14:19:51 -0800 | [diff] [blame] | 491 | dpo_stack_from_node(tx_node, |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 492 | &adj->sub_type.midchain.next_dpo, |
| 493 | drop_dpo_get(vnet_link_to_dpo_proto(adj->ia_link))); |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | /** |
| 497 | * adj_nbr_midchain_update_rewrite |
| 498 | * |
| 499 | * Update the adjacency's rewrite string. A NULL string implies the |
| 500 | * rewrite is reset (i.e. when ARP/ND etnry is gone). |
| 501 | * NB: the adj being updated may be handling traffic in the DP. |
| 502 | */ |
| 503 | void |
| 504 | adj_nbr_midchain_update_rewrite (adj_index_t adj_index, |
| 505 | adj_midchain_fixup_t fixup, |
| 506 | adj_flags_t flags, |
| 507 | u8 *rewrite) |
| 508 | { |
| 509 | ip_adjacency_t *adj; |
| 510 | |
| 511 | ASSERT(ADJ_INDEX_INVALID != adj_index); |
| 512 | |
| 513 | adj = adj_get(adj_index); |
| 514 | |
| 515 | /* |
| 516 | * one time only update. since we don't support chainging the tunnel |
| 517 | * src,dst, this is all we need. |
| 518 | */ |
| 519 | ASSERT(adj->lookup_next_index == IP_LOOKUP_NEXT_ARP); |
| 520 | /* |
| 521 | * tunnels can always provide a rewrite. |
| 522 | */ |
| 523 | ASSERT(NULL != rewrite); |
| 524 | |
| 525 | adj_midchain_setup(adj_index, fixup, flags); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 526 | |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 527 | /* |
| 528 | * update the rewirte with the workers paused. |
| 529 | */ |
| 530 | adj_nbr_update_rewrite_internal(adj, |
| 531 | IP_LOOKUP_NEXT_MIDCHAIN, |
| 532 | adj_get_midchain_node(adj->ia_link), |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 533 | adj_nbr_midchain_get_tx_node(adj), |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 534 | rewrite); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | /** |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 538 | * adj_nbr_midchain_unstack |
| 539 | * |
| 540 | * Unstack the adj. stack it on drop |
| 541 | */ |
| 542 | void |
| 543 | adj_nbr_midchain_unstack (adj_index_t adj_index) |
| 544 | { |
| 545 | ip_adjacency_t *adj; |
| 546 | |
| 547 | ASSERT(ADJ_INDEX_INVALID != adj_index); |
| 548 | |
| 549 | adj = adj_get(adj_index); |
| 550 | |
| 551 | /* |
| 552 | * stack on the drop |
| 553 | */ |
| 554 | dpo_stack(DPO_ADJACENCY_MIDCHAIN, |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 555 | vnet_link_to_dpo_proto(adj->ia_link), |
| 556 | &adj->sub_type.midchain.next_dpo, |
| 557 | drop_dpo_get(vnet_link_to_dpo_proto(adj->ia_link))); |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 558 | CLIB_MEMORY_BARRIER(); |
| 559 | } |
| 560 | |
| 561 | /** |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 562 | * adj_nbr_midchain_stack |
| 563 | */ |
| 564 | void |
| 565 | adj_nbr_midchain_stack (adj_index_t adj_index, |
| 566 | const dpo_id_t *next) |
| 567 | { |
| 568 | ip_adjacency_t *adj; |
| 569 | |
| 570 | ASSERT(ADJ_INDEX_INVALID != adj_index); |
| 571 | |
| 572 | adj = adj_get(adj_index); |
| 573 | |
Neale Ranns | 0f26c5a | 2017-03-01 15:12:11 -0800 | [diff] [blame] | 574 | ASSERT((IP_LOOKUP_NEXT_MIDCHAIN == adj->lookup_next_index) || |
| 575 | (IP_LOOKUP_NEXT_MCAST_MIDCHAIN == adj->lookup_next_index)); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 576 | |
Neale Ranns | fa5d198 | 2017-02-20 14:19:51 -0800 | [diff] [blame] | 577 | dpo_stack_from_node(adj_nbr_midchain_get_tx_node(adj), |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 578 | &adj->sub_type.midchain.next_dpo, |
| 579 | next); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | u8* |
| 583 | format_adj_midchain (u8* s, va_list *ap) |
| 584 | { |
Billy McFall | cfcf1e2 | 2016-10-14 09:51:49 -0400 | [diff] [blame] | 585 | index_t index = va_arg(*ap, index_t); |
| 586 | u32 indent = va_arg(*ap, u32); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 587 | ip_adjacency_t * adj = adj_get(index); |
| 588 | |
Neale Ranns | 924d03a | 2016-10-19 08:25:46 +0100 | [diff] [blame] | 589 | s = format (s, "%U", format_vnet_link, adj->ia_link); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 590 | s = format (s, " via %U ", |
| 591 | format_ip46_address, &adj->sub_type.nbr.next_hop); |
| 592 | s = format (s, " %U", |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 593 | format_vnet_rewrite, |
Neale Ranns | b069a69 | 2017-03-15 12:34:25 -0400 | [diff] [blame] | 594 | &adj->rewrite_header, sizeof (adj->rewrite_data), indent); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 595 | s = format (s, "\n%Ustacked-on:\n%U%U", |
Neale Ranns | 43161a8 | 2017-08-12 02:12:00 -0700 | [diff] [blame] | 596 | format_white_space, indent, |
| 597 | format_white_space, indent+2, |
| 598 | format_dpo_id, &adj->sub_type.midchain.next_dpo, indent+2); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 599 | |
| 600 | return (s); |
| 601 | } |
| 602 | |
| 603 | static void |
| 604 | adj_dpo_lock (dpo_id_t *dpo) |
| 605 | { |
| 606 | adj_lock(dpo->dpoi_index); |
| 607 | } |
| 608 | static void |
| 609 | adj_dpo_unlock (dpo_id_t *dpo) |
| 610 | { |
| 611 | adj_unlock(dpo->dpoi_index); |
| 612 | } |
| 613 | |
| 614 | const static dpo_vft_t adj_midchain_dpo_vft = { |
| 615 | .dv_lock = adj_dpo_lock, |
| 616 | .dv_unlock = adj_dpo_unlock, |
| 617 | .dv_format = format_adj_midchain, |
Andrew Yourtchenko | 5f3fcb9 | 2017-10-25 05:50:37 -0700 | [diff] [blame^] | 618 | .dv_get_urpf = adj_dpo_get_urpf, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 619 | }; |
| 620 | |
| 621 | /** |
| 622 | * @brief The per-protocol VLIB graph nodes that are assigned to a midchain |
| 623 | * object. |
| 624 | * |
| 625 | * this means that these graph nodes are ones from which a midchain is the |
| 626 | * parent object in the DPO-graph. |
| 627 | */ |
| 628 | const static char* const midchain_ip4_nodes[] = |
| 629 | { |
| 630 | "ip4-midchain", |
| 631 | NULL, |
| 632 | }; |
| 633 | const static char* const midchain_ip6_nodes[] = |
| 634 | { |
| 635 | "ip6-midchain", |
| 636 | NULL, |
| 637 | }; |
| 638 | const static char* const midchain_mpls_nodes[] = |
| 639 | { |
| 640 | "mpls-midchain", |
| 641 | NULL, |
| 642 | }; |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 643 | const static char* const midchain_ethernet_nodes[] = |
| 644 | { |
| 645 | "adj-l2-midchain", |
| 646 | NULL, |
| 647 | }; |
Florin Coras | b69111e | 2017-02-13 23:55:27 -0800 | [diff] [blame] | 648 | const static char* const midchain_nsh_nodes[] = |
| 649 | { |
| 650 | "adj-nsh-midchain", |
| 651 | NULL, |
| 652 | }; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 653 | |
| 654 | const static char* const * const midchain_nodes[DPO_PROTO_NUM] = |
| 655 | { |
| 656 | [DPO_PROTO_IP4] = midchain_ip4_nodes, |
| 657 | [DPO_PROTO_IP6] = midchain_ip6_nodes, |
| 658 | [DPO_PROTO_MPLS] = midchain_mpls_nodes, |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 659 | [DPO_PROTO_ETHERNET] = midchain_ethernet_nodes, |
Florin Coras | b69111e | 2017-02-13 23:55:27 -0800 | [diff] [blame] | 660 | [DPO_PROTO_NSH] = midchain_nsh_nodes, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 661 | }; |
| 662 | |
| 663 | void |
| 664 | adj_midchain_module_init (void) |
| 665 | { |
| 666 | dpo_register(DPO_ADJACENCY_MIDCHAIN, &adj_midchain_dpo_vft, midchain_nodes); |
| 667 | } |