blob: e858c8ed9cc8cb7d2ba9735407cda1c9f45dd047 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * Copyright (c) 2015 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#include <vnet/ip/ip.h>
16#include <vnet/classify/vnet_classify.h>
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +010017#include <vnet/classify/in_out_acl.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070018
Dave Barachd7cb1b52016-12-09 09:52:16 -050019typedef struct
20{
Ed Warnickecb9cada2015-12-08 15:45:58 -070021 u32 sw_if_index;
22 u32 next_index;
23 u32 table_index;
24 u32 offset;
Ray Kinsella8899ce02020-03-12 15:52:41 +000025}
26ip_in_out_acl_trace_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070027
28/* packet trace format function */
Dave Barachd7cb1b52016-12-09 09:52:16 -050029static u8 *
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +010030format_ip_in_out_acl_trace (u8 * s, u32 is_output, va_list * args)
Ed Warnickecb9cada2015-12-08 15:45:58 -070031{
32 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
33 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +010034 ip_in_out_acl_trace_t *t = va_arg (*args, ip_in_out_acl_trace_t *);
Ed Warnickecb9cada2015-12-08 15:45:58 -070035
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +010036 s = format (s, "%s: sw_if_index %d, next_index %d, table %d, offset %d",
37 is_output ? "OUTACL" : "INACL",
Dave Barachd7cb1b52016-12-09 09:52:16 -050038 t->sw_if_index, t->next_index, t->table_index, t->offset);
Ed Warnickecb9cada2015-12-08 15:45:58 -070039 return s;
40}
41
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +010042static u8 *
43format_ip_inacl_trace (u8 * s, va_list * args)
44{
45 return format_ip_in_out_acl_trace (s, 0 /* is_output */ , args);
46}
47
48static u8 *
49format_ip_outacl_trace (u8 * s, va_list * args)
50{
51 return format_ip_in_out_acl_trace (s, 1 /* is_output */ , args);
52}
53
Filip Tehlar26ea14e2019-03-11 05:30:21 -070054extern vlib_node_registration_t ip4_inacl_node;
55extern vlib_node_registration_t ip4_outacl_node;
56extern vlib_node_registration_t ip6_inacl_node;
57extern vlib_node_registration_t ip6_outacl_node;
Ed Warnickecb9cada2015-12-08 15:45:58 -070058
59#define foreach_ip_inacl_error \
60_(MISS, "input ACL misses") \
61_(HIT, "input ACL hits") \
62_(CHAIN_HIT, "input ACL hits after chain walk")
63
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +010064#define foreach_ip_outacl_error \
65_(MISS, "output ACL misses") \
66_(HIT, "output ACL hits") \
67_(CHAIN_HIT, "output ACL hits after chain walk")
68
Dave Barachd7cb1b52016-12-09 09:52:16 -050069typedef enum
70{
Ed Warnickecb9cada2015-12-08 15:45:58 -070071#define _(sym,str) IP_INACL_ERROR_##sym,
72 foreach_ip_inacl_error
73#undef _
Dave Barachd7cb1b52016-12-09 09:52:16 -050074 IP_INACL_N_ERROR,
Ray Kinsella8899ce02020-03-12 15:52:41 +000075}
76ip_inacl_error_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070077
Dave Barachd7cb1b52016-12-09 09:52:16 -050078static char *ip_inacl_error_strings[] = {
Ed Warnickecb9cada2015-12-08 15:45:58 -070079#define _(sym,string) string,
80 foreach_ip_inacl_error
81#undef _
82};
83
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +010084typedef enum
85{
86#define _(sym,str) IP_OUTACL_ERROR_##sym,
87 foreach_ip_outacl_error
88#undef _
89 IP_OUTACL_N_ERROR,
Ray Kinsella8899ce02020-03-12 15:52:41 +000090}
91ip_outacl_error_t;
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +010092
93static char *ip_outacl_error_strings[] = {
94#define _(sym,string) string,
95 foreach_ip_outacl_error
96#undef _
97};
98
Ray Kinsella8899ce02020-03-12 15:52:41 +000099static_always_inline void
Benoît Ganneabb2a422021-09-30 13:41:00 +0200100ip_in_out_acl_inline_trace (vlib_main_t *vm, vlib_node_runtime_t *node,
101 vlib_frame_t *frame, vlib_buffer_t **b, u16 *next,
102 u32 n_left, u32 *hits__, u32 *misses__,
103 u32 *chain_hits__, const vlib_error_t error_none,
104 const vlib_error_t error_deny,
105 const vlib_error_t error_miss,
106 vnet_classify_table_t *tables,
107 const u32 *table_index_by_sw_if_index,
108 vnet_config_main_t *cm, const vlib_rx_or_tx_t way,
109 const int is_output, const int do_trace)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700110{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700111 f64 now = vlib_time_now (vm);
112 u32 hits = 0;
113 u32 misses = 0;
114 u32 chain_hits = 0;
Benoît Ganneabb2a422021-09-30 13:41:00 +0200115 u32 n_next_nodes = node->n_next_nodes;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000116 u8 *h[4];
117 u32 sw_if_index[4];
118 u32 table_index[4];
119 vnet_classify_table_t *t[4] = { 0, 0 };
120 u64 hash[4];
121
Ray Kinsella8899ce02020-03-12 15:52:41 +0000122 /* calculate hashes for b[0] & b[1] */
123 if (n_left >= 2)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700124 {
Benoît Ganneabb2a422021-09-30 13:41:00 +0200125 /* ~0 is used as a wildcard to say 'always use sw_if_index 0'
126 * aka local0. It is used when we do not care about the sw_if_index, as
127 * when punting */
128 sw_if_index[2] = ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way];
129 sw_if_index[3] = ~0 == way ? 0 : vnet_buffer (b[1])->sw_if_index[way];
Ed Warnickecb9cada2015-12-08 15:45:58 -0700130
Benoît Ganneabb2a422021-09-30 13:41:00 +0200131 table_index[2] = table_index_by_sw_if_index[sw_if_index[2]];
132 table_index[3] = table_index_by_sw_if_index[sw_if_index[3]];
Ed Warnickecb9cada2015-12-08 15:45:58 -0700133
Benoît Ganneabb2a422021-09-30 13:41:00 +0200134 t[2] = pool_elt_at_index (tables, table_index[2]);
135 t[3] = pool_elt_at_index (tables, table_index[3]);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700136
Ray Kinsella8899ce02020-03-12 15:52:41 +0000137 if (t[2]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA)
138 h[2] =
139 (void *) vlib_buffer_get_current (b[0]) + t[2]->current_data_offset;
Steve Shin25e26dc2016-11-08 10:47:10 -0800140 else
Ray Kinsella8899ce02020-03-12 15:52:41 +0000141 h[2] = b[0]->data;
142
143 if (t[3]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA)
144 h[3] =
145 (void *) vlib_buffer_get_current (b[1]) + t[3]->current_data_offset;
146 else
147 h[3] = b[1]->data;
Steve Shin25e26dc2016-11-08 10:47:10 -0800148
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100149 if (is_output)
150 {
151 /* Save the rewrite length, since we are using the l2_classify struct */
Ray Kinsella8899ce02020-03-12 15:52:41 +0000152 vnet_buffer (b[0])->l2_classify.pad.l2_len =
153 vnet_buffer (b[0])->ip.save_rewrite_length;
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100154 /* advance the match pointer so the matching happens on IP header */
Ray Kinsella8899ce02020-03-12 15:52:41 +0000155 h[2] += vnet_buffer (b[0])->l2_classify.pad.l2_len;
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100156
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100157 /* Save the rewrite length, since we are using the l2_classify struct */
Ray Kinsella8899ce02020-03-12 15:52:41 +0000158 vnet_buffer (b[1])->l2_classify.pad.l2_len =
159 vnet_buffer (b[1])->ip.save_rewrite_length;
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100160 /* advance the match pointer so the matching happens on IP header */
Ray Kinsella8899ce02020-03-12 15:52:41 +0000161 h[3] += vnet_buffer (b[1])->l2_classify.pad.l2_len;
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100162 }
163
Ray Kinsella8899ce02020-03-12 15:52:41 +0000164 hash[2] = vnet_classify_hash_packet_inline (t[2], (u8 *) h[2]);
165 hash[3] = vnet_classify_hash_packet_inline (t[3], (u8 *) h[3]);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700166
Ray Kinsella8899ce02020-03-12 15:52:41 +0000167 vnet_buffer (b[0])->l2_classify.hash = hash[2];
168 vnet_buffer (b[1])->l2_classify.hash = hash[3];
Ed Warnickecb9cada2015-12-08 15:45:58 -0700169
Ray Kinsella8899ce02020-03-12 15:52:41 +0000170 vnet_buffer (b[0])->l2_classify.table_index = table_index[2];
171 vnet_buffer (b[1])->l2_classify.table_index = table_index[3];
Ed Warnickecb9cada2015-12-08 15:45:58 -0700172
Ray Kinsella8899ce02020-03-12 15:52:41 +0000173 vnet_buffer (b[0])->l2_classify.opaque_index = ~0;
174 vnet_buffer (b[1])->l2_classify.opaque_index = ~0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700175
Ray Kinsella8899ce02020-03-12 15:52:41 +0000176 vnet_classify_prefetch_bucket (t[2],
177 vnet_buffer (b[0])->l2_classify.hash);
178 vnet_classify_prefetch_bucket (t[3],
179 vnet_buffer (b[1])->l2_classify.hash);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700180 }
181
Ray Kinsella8899ce02020-03-12 15:52:41 +0000182 while (n_left >= 2)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700183 {
Ray Kinsella8899ce02020-03-12 15:52:41 +0000184 vnet_classify_entry_t *e[2] = { 0, 0 };
185 u32 _next[2] = { ACL_NEXT_INDEX_DENY, ACL_NEXT_INDEX_DENY };
Ray Kinsella8899ce02020-03-12 15:52:41 +0000186
187 h[0] = h[2];
188 h[1] = h[3];
189 t[0] = t[2];
190 t[1] = t[3];
191
192 sw_if_index[0] = sw_if_index[2];
193 sw_if_index[1] = sw_if_index[3];
194
195 table_index[0] = table_index[2];
196 table_index[1] = table_index[3];
197
198 hash[0] = hash[2];
199 hash[1] = hash[3];
200
201 /* prefetch next iteration */
202 if (n_left >= 6)
203 {
204 vlib_prefetch_buffer_header (b[4], LOAD);
205 vlib_prefetch_buffer_header (b[5], LOAD);
206
Damjan Marionaf7fb042021-07-15 11:54:41 +0200207 clib_prefetch_load (b[4]->data);
208 clib_prefetch_load (b[5]->data);
Ray Kinsella8899ce02020-03-12 15:52:41 +0000209 }
210
211 /* calculate hashes for b[2] & b[3] */
212 if (n_left >= 4)
213 {
214 sw_if_index[2] =
Benoît Ganneabb2a422021-09-30 13:41:00 +0200215 ~0 == way ? 0 : vnet_buffer (b[2])->sw_if_index[way];
Ray Kinsella8899ce02020-03-12 15:52:41 +0000216 sw_if_index[3] =
Benoît Ganneabb2a422021-09-30 13:41:00 +0200217 ~0 == way ? 0 : vnet_buffer (b[3])->sw_if_index[way];
Ray Kinsella8899ce02020-03-12 15:52:41 +0000218
Benoît Ganneabb2a422021-09-30 13:41:00 +0200219 table_index[2] = table_index_by_sw_if_index[sw_if_index[2]];
220 table_index[3] = table_index_by_sw_if_index[sw_if_index[3]];
Ray Kinsella8899ce02020-03-12 15:52:41 +0000221
Benoît Ganneabb2a422021-09-30 13:41:00 +0200222 t[2] = pool_elt_at_index (tables, table_index[2]);
223 t[3] = pool_elt_at_index (tables, table_index[3]);
Ray Kinsella8899ce02020-03-12 15:52:41 +0000224
225 if (t[2]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA)
226 h[2] =
227 (void *) vlib_buffer_get_current (b[2]) +
228 t[2]->current_data_offset;
229 else
230 h[2] = b[2]->data;
231
232 if (t[3]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA)
233 h[3] =
234 (void *) vlib_buffer_get_current (b[3]) +
235 t[3]->current_data_offset;
236 else
237 h[3] = b[3]->data;
238
239 if (is_output)
240 {
241 /* Save the rewrite length, since we are using the l2_classify struct */
242 vnet_buffer (b[2])->l2_classify.pad.l2_len =
243 vnet_buffer (b[2])->ip.save_rewrite_length;
244 /* advance the match pointer so the matching happens on IP header */
245 h[2] += vnet_buffer (b[2])->l2_classify.pad.l2_len;
246
247 /* Save the rewrite length, since we are using the l2_classify struct */
248 vnet_buffer (b[3])->l2_classify.pad.l2_len =
249 vnet_buffer (b[3])->ip.save_rewrite_length;
250 /* advance the match pointer so the matching happens on IP header */
251 h[3] += vnet_buffer (b[3])->l2_classify.pad.l2_len;
252 }
253
254 hash[2] = vnet_classify_hash_packet_inline (t[2], (u8 *) h[2]);
255 hash[3] = vnet_classify_hash_packet_inline (t[3], (u8 *) h[3]);
256
257 vnet_buffer (b[2])->l2_classify.hash = hash[2];
258 vnet_buffer (b[3])->l2_classify.hash = hash[3];
259
260 vnet_buffer (b[2])->l2_classify.table_index = table_index[2];
261 vnet_buffer (b[3])->l2_classify.table_index = table_index[3];
262
263 vnet_buffer (b[2])->l2_classify.opaque_index = ~0;
264 vnet_buffer (b[3])->l2_classify.opaque_index = ~0;
265
266 vnet_classify_prefetch_bucket (t[2],
267 vnet_buffer (b[2])->
268 l2_classify.hash);
269 vnet_classify_prefetch_bucket (t[3],
270 vnet_buffer (b[3])->
271 l2_classify.hash);
272 }
273
274 /* find entry for b[0] & b[1] */
Benoît Ganneabb2a422021-09-30 13:41:00 +0200275 vnet_get_config_data (cm, &b[0]->current_config_index, &_next[0],
Ray Kinsella8899ce02020-03-12 15:52:41 +0000276 /* # bytes of config data */ 0);
Benoît Ganneabb2a422021-09-30 13:41:00 +0200277 vnet_get_config_data (cm, &b[1]->current_config_index, &_next[1],
Ray Kinsella8899ce02020-03-12 15:52:41 +0000278 /* # bytes of config data */ 0);
279
280 if (PREDICT_TRUE (table_index[0] != ~0))
281 {
282 e[0] =
283 vnet_classify_find_entry_inline (t[0], (u8 *) h[0], hash[0], now);
284 if (e[0])
285 {
286 vnet_buffer (b[0])->l2_classify.opaque_index
287 = e[0]->opaque_index;
288 vlib_buffer_advance (b[0], e[0]->advance);
289
290 _next[0] = (e[0]->next_index < n_next_nodes) ?
291 e[0]->next_index : _next[0];
292
293 hits++;
294
Benoît Ganneabb2a422021-09-30 13:41:00 +0200295 b[0]->error =
296 (_next[0] == ACL_NEXT_INDEX_DENY) ? error_deny : error_none;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000297
298 if (!is_output)
299 {
300 if (e[0]->action == CLASSIFY_ACTION_SET_IP4_FIB_INDEX ||
301 e[0]->action == CLASSIFY_ACTION_SET_IP6_FIB_INDEX)
302 vnet_buffer (b[0])->sw_if_index[VLIB_TX] = e[0]->metadata;
303 else if (e[0]->action == CLASSIFY_ACTION_SET_METADATA)
304 vnet_buffer (b[0])->ip.adj_index[VLIB_TX] =
305 e[0]->metadata;
306 }
307 }
308 else
309 {
310 while (1)
311 {
312 if (PREDICT_TRUE (t[0]->next_table_index != ~0))
Benoît Ganneabb2a422021-09-30 13:41:00 +0200313 t[0] = pool_elt_at_index (tables, t[0]->next_table_index);
Ray Kinsella8899ce02020-03-12 15:52:41 +0000314 else
315 {
316 _next[0] = (t[0]->miss_next_index < n_next_nodes) ?
317 t[0]->miss_next_index : _next[0];
318
319 misses++;
320
Benoît Ganneabb2a422021-09-30 13:41:00 +0200321 b[0]->error = (_next[0] == ACL_NEXT_INDEX_DENY) ?
322 error_miss :
323 error_none;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000324 break;
325 }
326
327 if (t[0]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA)
328 h[0] =
329 (void *) vlib_buffer_get_current (b[0]) +
330 t[0]->current_data_offset;
331 else
332 h[0] = b[0]->data;
333
334 /* advance the match pointer so the matching happens on IP header */
335 if (is_output)
336 h[0] += vnet_buffer (b[0])->l2_classify.pad.l2_len;
337
338 hash[0] =
339 vnet_classify_hash_packet_inline (t[0], (u8 *) h[0]);
340 e[0] =
341 vnet_classify_find_entry_inline (t[0], (u8 *) h[0],
342 hash[0], now);
343 if (e[0])
344 {
345 vnet_buffer (b[0])->l2_classify.opaque_index
346 = e[0]->opaque_index;
347 vlib_buffer_advance (b[0], e[0]->advance);
348 _next[0] = (e[0]->next_index < n_next_nodes) ?
349 e[0]->next_index : _next[0];
350 hits++;
351 chain_hits++;
352
Benoît Ganneabb2a422021-09-30 13:41:00 +0200353 b[0]->error = (_next[0] == ACL_NEXT_INDEX_DENY) ?
354 error_deny :
355 error_none;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000356
357 if (!is_output)
358 {
359 if (e[0]->action ==
360 CLASSIFY_ACTION_SET_IP4_FIB_INDEX
361 || e[0]->action ==
362 CLASSIFY_ACTION_SET_IP6_FIB_INDEX)
363 vnet_buffer (b[0])->sw_if_index[VLIB_TX] =
364 e[0]->metadata;
365 else if (e[0]->action ==
366 CLASSIFY_ACTION_SET_METADATA)
367 vnet_buffer (b[0])->ip.adj_index[VLIB_TX] =
368 e[0]->metadata;
369 }
370 break;
371 }
372 }
373 }
374 }
375
376 if (PREDICT_TRUE (table_index[1] != ~0))
377 {
378 e[1] =
379 vnet_classify_find_entry_inline (t[1], (u8 *) h[1], hash[1], now);
380 if (e[1])
381 {
382 vnet_buffer (b[1])->l2_classify.opaque_index
383 = e[1]->opaque_index;
384 vlib_buffer_advance (b[1], e[1]->advance);
385
386 _next[1] = (e[1]->next_index < n_next_nodes) ?
387 e[1]->next_index : _next[1];
388
389 hits++;
390
Benoît Ganneabb2a422021-09-30 13:41:00 +0200391 b[1]->error =
392 (_next[1] == ACL_NEXT_INDEX_DENY) ? error_deny : error_none;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000393
394 if (!is_output)
395 {
396 if (e[1]->action == CLASSIFY_ACTION_SET_IP4_FIB_INDEX ||
397 e[1]->action == CLASSIFY_ACTION_SET_IP6_FIB_INDEX)
398 vnet_buffer (b[1])->sw_if_index[VLIB_TX] = e[1]->metadata;
399 else if (e[1]->action == CLASSIFY_ACTION_SET_METADATA)
400 vnet_buffer (b[1])->ip.adj_index[VLIB_TX] =
401 e[1]->metadata;
402 }
403 }
404 else
405 {
406 while (1)
407 {
408 if (PREDICT_TRUE (t[1]->next_table_index != ~0))
Benoît Ganneabb2a422021-09-30 13:41:00 +0200409 t[1] = pool_elt_at_index (tables, t[1]->next_table_index);
Ray Kinsella8899ce02020-03-12 15:52:41 +0000410 else
411 {
412 _next[1] = (t[1]->miss_next_index < n_next_nodes) ?
413 t[1]->miss_next_index : _next[1];
414
415 misses++;
416
Benoît Ganneabb2a422021-09-30 13:41:00 +0200417 b[1]->error = (_next[1] == ACL_NEXT_INDEX_DENY) ?
418 error_miss :
419 error_none;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000420 break;
421 }
422
423 if (t[1]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA)
424 h[1] =
425 (void *) vlib_buffer_get_current (b[1]) +
426 t[1]->current_data_offset;
427 else
428 h[1] = b[1]->data;
429
430 /* advance the match pointer so the matching happens on IP header */
431 if (is_output)
432 h[1] += vnet_buffer (b[1])->l2_classify.pad.l2_len;
433
434 hash[1] =
435 vnet_classify_hash_packet_inline (t[1], (u8 *) h[1]);
436 e[1] =
437 vnet_classify_find_entry_inline (t[1], (u8 *) h[1],
438 hash[1], now);
439 if (e[1])
440 {
441 vnet_buffer (b[1])->l2_classify.opaque_index
442 = e[1]->opaque_index;
443 vlib_buffer_advance (b[1], e[1]->advance);
444 _next[1] = (e[1]->next_index < n_next_nodes) ?
445 e[1]->next_index : _next[1];
446 hits++;
447 chain_hits++;
448
Benoît Ganneabb2a422021-09-30 13:41:00 +0200449 b[1]->error = (_next[1] == ACL_NEXT_INDEX_DENY) ?
450 error_deny :
451 error_none;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000452
453 if (!is_output)
454 {
455 if (e[1]->action ==
456 CLASSIFY_ACTION_SET_IP4_FIB_INDEX
457 || e[1]->action ==
458 CLASSIFY_ACTION_SET_IP6_FIB_INDEX)
459 vnet_buffer (b[1])->sw_if_index[VLIB_TX] =
460 e[1]->metadata;
461 else if (e[1]->action ==
462 CLASSIFY_ACTION_SET_METADATA)
463 vnet_buffer (b[1])->ip.adj_index[VLIB_TX] =
464 e[1]->metadata;
465 }
466 break;
467 }
468 }
469 }
470 }
471
472 if (do_trace && b[0]->flags & VLIB_BUFFER_IS_TRACED)
473 {
474 ip_in_out_acl_trace_t *_t =
475 vlib_add_trace (vm, node, b[0], sizeof (*_t));
476 _t->sw_if_index =
Benoît Ganneabb2a422021-09-30 13:41:00 +0200477 ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way];
Ray Kinsella8899ce02020-03-12 15:52:41 +0000478 _t->next_index = _next[0];
Benoît Ganneabb2a422021-09-30 13:41:00 +0200479 _t->table_index = t[0] ? t[0] - tables : ~0;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000480 _t->offset = (e[0]
481 && t[0]) ? vnet_classify_get_offset (t[0], e[0]) : ~0;
482 }
483
484 if (do_trace && b[1]->flags & VLIB_BUFFER_IS_TRACED)
485 {
486 ip_in_out_acl_trace_t *_t =
487 vlib_add_trace (vm, node, b[1], sizeof (*_t));
488 _t->sw_if_index =
Benoît Ganneabb2a422021-09-30 13:41:00 +0200489 ~0 == way ? 0 : vnet_buffer (b[1])->sw_if_index[way];
Ray Kinsella8899ce02020-03-12 15:52:41 +0000490 _t->next_index = _next[1];
Benoît Ganneabb2a422021-09-30 13:41:00 +0200491 _t->table_index = t[1] ? t[1] - tables : ~0;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000492 _t->offset = (e[1]
493 && t[1]) ? vnet_classify_get_offset (t[1], e[1]) : ~0;
494 }
495
496 if ((_next[0] == ACL_NEXT_INDEX_DENY) && is_output)
497 {
498 /* on output, for the drop node to work properly, go back to ip header */
499 vlib_buffer_advance (b[0], vnet_buffer (b[0])->l2.l2_len);
500 }
501
502 if ((_next[1] == ACL_NEXT_INDEX_DENY) && is_output)
503 {
504 /* on output, for the drop node to work properly, go back to ip header */
505 vlib_buffer_advance (b[1], vnet_buffer (b[1])->l2.l2_len);
506 }
507
508 next[0] = _next[0];
509 next[1] = _next[1];
510
511 /* _next */
512 next += 2;
513 b += 2;
514 n_left -= 2;
515 }
516
517 while (n_left > 0)
518 {
Dave Barachd7cb1b52016-12-09 09:52:16 -0500519 u8 *h0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700520 u32 sw_if_index0;
521 u32 table_index0;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000522 vnet_classify_table_t *t0 = 0;
523 vnet_classify_entry_t *e0 = 0;
524 u32 next0 = ACL_NEXT_INDEX_DENY;
525 u64 hash0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700526
Benoît Ganneabb2a422021-09-30 13:41:00 +0200527 sw_if_index0 = ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way];
528 table_index0 = table_index_by_sw_if_index[sw_if_index0];
Ed Warnickecb9cada2015-12-08 15:45:58 -0700529
Benoît Ganneabb2a422021-09-30 13:41:00 +0200530 t0 = pool_elt_at_index (tables, table_index0);
Steve Shin25e26dc2016-11-08 10:47:10 -0800531
532 if (t0->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA)
Ray Kinsella8899ce02020-03-12 15:52:41 +0000533 h0 =
534 (void *) vlib_buffer_get_current (b[0]) + t0->current_data_offset;
Steve Shin25e26dc2016-11-08 10:47:10 -0800535 else
Ray Kinsella8899ce02020-03-12 15:52:41 +0000536 h0 = b[0]->data;
Steve Shin25e26dc2016-11-08 10:47:10 -0800537
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100538 if (is_output)
539 {
540 /* Save the rewrite length, since we are using the l2_classify struct */
Ray Kinsella8899ce02020-03-12 15:52:41 +0000541 vnet_buffer (b[0])->l2_classify.pad.l2_len =
542 vnet_buffer (b[0])->ip.save_rewrite_length;
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100543 /* advance the match pointer so the matching happens on IP header */
Ray Kinsella8899ce02020-03-12 15:52:41 +0000544 h0 += vnet_buffer (b[0])->l2_classify.pad.l2_len;
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100545 }
546
Ray Kinsella8899ce02020-03-12 15:52:41 +0000547 vnet_buffer (b[0])->l2_classify.hash =
Dave Barachd7cb1b52016-12-09 09:52:16 -0500548 vnet_classify_hash_packet (t0, (u8 *) h0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700549
Ray Kinsella8899ce02020-03-12 15:52:41 +0000550 vnet_buffer (b[0])->l2_classify.table_index = table_index0;
551 vnet_buffer (b[0])->l2_classify.opaque_index = ~0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700552
Benoît Ganneabb2a422021-09-30 13:41:00 +0200553 vnet_get_config_data (cm, &b[0]->current_config_index, &next0,
Ray Kinsella8899ce02020-03-12 15:52:41 +0000554 /* # bytes of config data */ 0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700555
Ray Kinsella8899ce02020-03-12 15:52:41 +0000556 if (PREDICT_TRUE (table_index0 != ~0))
Dave Barachd7cb1b52016-12-09 09:52:16 -0500557 {
Ray Kinsella8899ce02020-03-12 15:52:41 +0000558 hash0 = vnet_buffer (b[0])->l2_classify.hash;
Benoît Ganneabb2a422021-09-30 13:41:00 +0200559 t0 = pool_elt_at_index (tables, table_index0);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700560
Ray Kinsella8899ce02020-03-12 15:52:41 +0000561 if (t0->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA)
562 h0 =
563 (void *) vlib_buffer_get_current (b[0]) +
564 t0->current_data_offset;
565 else
566 h0 = b[0]->data;
567
568 /* advance the match pointer so the matching happens on IP header */
569 if (is_output)
570 h0 += vnet_buffer (b[0])->l2_classify.pad.l2_len;
571
572 e0 = vnet_classify_find_entry_inline (t0, (u8 *) h0, hash0, now);
573 if (e0)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500574 {
Ray Kinsella8899ce02020-03-12 15:52:41 +0000575 vnet_buffer (b[0])->l2_classify.opaque_index = e0->opaque_index;
576 vlib_buffer_advance (b[0], e0->advance);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700577
Ray Kinsella8899ce02020-03-12 15:52:41 +0000578 next0 = (e0->next_index < n_next_nodes) ?
579 e0->next_index : next0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700580
Ray Kinsella8899ce02020-03-12 15:52:41 +0000581 hits++;
582
Benoît Ganneabb2a422021-09-30 13:41:00 +0200583 b[0]->error =
584 (next0 == ACL_NEXT_INDEX_DENY) ? error_deny : error_none;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000585
586 if (!is_output)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500587 {
Ray Kinsella8899ce02020-03-12 15:52:41 +0000588 if (e0->action == CLASSIFY_ACTION_SET_IP4_FIB_INDEX ||
589 e0->action == CLASSIFY_ACTION_SET_IP6_FIB_INDEX)
590 vnet_buffer (b[0])->sw_if_index[VLIB_TX] = e0->metadata;
591 else if (e0->action == CLASSIFY_ACTION_SET_METADATA)
592 vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = e0->metadata;
Dave Barachd7cb1b52016-12-09 09:52:16 -0500593 }
594 }
Ray Kinsella8899ce02020-03-12 15:52:41 +0000595 else
Dave Barachd7cb1b52016-12-09 09:52:16 -0500596 {
Ray Kinsella8899ce02020-03-12 15:52:41 +0000597 while (1)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500598 {
Ray Kinsella8899ce02020-03-12 15:52:41 +0000599 if (PREDICT_TRUE (t0->next_table_index != ~0))
Benoît Ganneabb2a422021-09-30 13:41:00 +0200600 t0 = pool_elt_at_index (tables, t0->next_table_index);
Dave Barachd7cb1b52016-12-09 09:52:16 -0500601 else
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100602 {
Ray Kinsella8899ce02020-03-12 15:52:41 +0000603 next0 = (t0->miss_next_index < n_next_nodes) ?
604 t0->miss_next_index : next0;
605
606 misses++;
607
Benoît Ganneabb2a422021-09-30 13:41:00 +0200608 b[0]->error = (next0 == ACL_NEXT_INDEX_DENY) ?
609 error_miss :
610 error_none;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000611 break;
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100612 }
Ray Kinsella8899ce02020-03-12 15:52:41 +0000613
614 if (t0->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA)
615 h0 =
616 (void *) vlib_buffer_get_current (b[0]) +
617 t0->current_data_offset;
618 else
619 h0 = b[0]->data;
620
621 /* advance the match pointer so the matching happens on IP header */
622 if (is_output)
623 h0 += vnet_buffer (b[0])->l2_classify.pad.l2_len;
624
625 hash0 = vnet_classify_hash_packet_inline (t0, (u8 *) h0);
626 e0 = vnet_classify_find_entry_inline
627 (t0, (u8 *) h0, hash0, now);
628 if (e0)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500629 {
Ray Kinsella8899ce02020-03-12 15:52:41 +0000630 vnet_buffer (b[0])->l2_classify.opaque_index
631 = e0->opaque_index;
632 vlib_buffer_advance (b[0], e0->advance);
633 next0 = (e0->next_index < n_next_nodes) ?
634 e0->next_index : next0;
635 hits++;
636
Benoît Ganneabb2a422021-09-30 13:41:00 +0200637 b[0]->error = (next0 == ACL_NEXT_INDEX_DENY) ?
638 error_deny :
639 error_none;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000640
641 if (!is_output)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500642 {
Ray Kinsella8899ce02020-03-12 15:52:41 +0000643 if (e0->action ==
644 CLASSIFY_ACTION_SET_IP4_FIB_INDEX
645 || e0->action ==
646 CLASSIFY_ACTION_SET_IP6_FIB_INDEX)
647 vnet_buffer (b[0])->sw_if_index[VLIB_TX] =
648 e0->metadata;
649 else if (e0->action == CLASSIFY_ACTION_SET_METADATA)
650 vnet_buffer (b[0])->ip.adj_index[VLIB_TX] =
651 e0->metadata;
Dave Barachd7cb1b52016-12-09 09:52:16 -0500652 }
Ray Kinsella8899ce02020-03-12 15:52:41 +0000653 break;
Dave Barachd7cb1b52016-12-09 09:52:16 -0500654 }
655 }
656 }
Dave Barachd7cb1b52016-12-09 09:52:16 -0500657 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700658
Ray Kinsella8899ce02020-03-12 15:52:41 +0000659 if (do_trace && b[0]->flags & VLIB_BUFFER_IS_TRACED)
660 {
661 ip_in_out_acl_trace_t *t =
662 vlib_add_trace (vm, node, b[0], sizeof (*t));
663 t->sw_if_index =
Benoît Ganneabb2a422021-09-30 13:41:00 +0200664 ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way];
Ray Kinsella8899ce02020-03-12 15:52:41 +0000665 t->next_index = next0;
Benoît Ganneabb2a422021-09-30 13:41:00 +0200666 t->table_index = t0 ? t0 - tables : ~0;
Ray Kinsella8899ce02020-03-12 15:52:41 +0000667 t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0) : ~0;
668 }
669
670 if ((next0 == ACL_NEXT_INDEX_DENY) && is_output)
671 {
672 /* on output, for the drop node to work properly, go back to ip header */
673 vlib_buffer_advance (b[0], vnet_buffer (b[0])->l2.l2_len);
674 }
675
676 next[0] = next0;
677
678 /* next */
679 next++;
680 b++;
681 n_left--;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700682 }
683
Benoît Ganneabb2a422021-09-30 13:41:00 +0200684 *hits__ = hits;
685 *misses__ = misses;
686 *chain_hits__ = chain_hits;
687}
688
689static_always_inline uword
690ip_in_out_acl_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
691 vlib_frame_t *frame, const in_out_acl_table_id_t tid,
692 const vlib_node_registration_t *parent_error_node,
693 const u32 error_none_index, const u32 error_deny_index,
694 const u32 error_miss_index, const vlib_rx_or_tx_t way,
695 const int is_output)
696{
697 const in_out_acl_main_t *am = &in_out_acl_main;
698 vnet_classify_table_t *tables = am->vnet_classify_main->tables;
699 u32 *from = vlib_frame_vector_args (frame);
700 const u32 *table_index_by_sw_if_index =
701 am->classify_table_index_by_sw_if_index[is_output][tid];
702 vnet_config_main_t *cm = am->vnet_config_main[is_output][tid];
703 const vlib_node_runtime_t *error_node =
704 vlib_node_get_runtime (vm, parent_error_node->index);
705 const vlib_error_t error_none = error_node->errors[error_none_index];
706 const vlib_error_t error_deny = error_node->errors[error_deny_index];
707 const vlib_error_t error_miss = error_node->errors[error_miss_index];
708 vlib_buffer_t *bufs[VLIB_FRAME_SIZE];
709 u16 nexts[VLIB_FRAME_SIZE];
710 u32 hits, misses, chain_hits;
711
712 vlib_get_buffers (vm, from, bufs, frame->n_vectors);
713
714#define ip_in_out_acl_inline_trace__(do_trace) \
715 ip_in_out_acl_inline_trace ( \
716 vm, node, frame, bufs, nexts, frame->n_vectors, &hits, &misses, \
717 &chain_hits, error_deny, error_miss, error_none, tables, \
718 table_index_by_sw_if_index, cm, way, is_output, do_trace)
719
720 if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
721 ip_in_out_acl_inline_trace__ (1 /* do_trace */);
722 else
723 ip_in_out_acl_inline_trace__ (0 /* do_trace */);
724
725 vlib_node_increment_counter (
726 vm, node->node_index,
727 is_output ? IP_OUTACL_ERROR_MISS : IP_INACL_ERROR_MISS, misses);
728 vlib_node_increment_counter (
729 vm, node->node_index, is_output ? IP_OUTACL_ERROR_HIT : IP_INACL_ERROR_HIT,
730 hits);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700731 vlib_node_increment_counter (vm, node->node_index,
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100732 is_output ? IP_OUTACL_ERROR_CHAIN_HIT :
Benoît Ganneabb2a422021-09-30 13:41:00 +0200733 IP_INACL_ERROR_CHAIN_HIT,
734 chain_hits);
Ray Kinsella8899ce02020-03-12 15:52:41 +0000735
736 vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
Ray Kinsella8899ce02020-03-12 15:52:41 +0000737 return frame->n_vectors;
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100738}
739
Benoît Ganneabb2a422021-09-30 13:41:00 +0200740VLIB_NODE_FN (ip4_inacl_node)
741(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100742{
Benoît Ganneabb2a422021-09-30 13:41:00 +0200743 return ip_in_out_acl_inline (
744 vm, node, frame, IN_OUT_ACL_TABLE_IP4, &ip4_input_node, IP4_ERROR_NONE,
745 IP4_ERROR_INACL_SESSION_DENY, IP4_ERROR_INACL_TABLE_MISS, VLIB_RX,
746 0 /* is_output */);
747}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700748
Benoît Ganneabb2a422021-09-30 13:41:00 +0200749VLIB_NODE_FN (ip4_punt_acl_node)
750(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
751{
752 return ip_in_out_acl_inline (
753 vm, node, frame, IN_OUT_ACL_TABLE_IP4_PUNT, &ip4_input_node,
754 IP4_ERROR_NONE, IP4_ERROR_INACL_SESSION_DENY, IP4_ERROR_INACL_TABLE_MISS,
755 ~0 /* way */, 0 /* is_output */);
756}
Ray Kinsella8899ce02020-03-12 15:52:41 +0000757
Benoît Ganneabb2a422021-09-30 13:41:00 +0200758VLIB_NODE_FN (ip4_outacl_node)
759(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
760{
761 return ip_in_out_acl_inline (
762 vm, node, frame, IN_OUT_ACL_TABLE_IP4, &ip4_input_node, IP4_ERROR_NONE,
763 IP4_ERROR_INACL_SESSION_DENY, IP4_ERROR_INACL_TABLE_MISS, VLIB_TX,
764 1 /* is_output */);
Ray Kinsella8899ce02020-03-12 15:52:41 +0000765}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700766
Dave Barachd7cb1b52016-12-09 09:52:16 -0500767/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700768VLIB_REGISTER_NODE (ip4_inacl_node) = {
Ed Warnickecb9cada2015-12-08 15:45:58 -0700769 .name = "ip4-inacl",
770 .vector_size = sizeof (u32),
771 .format_trace = format_ip_inacl_trace,
772 .n_errors = ARRAY_LEN(ip_inacl_error_strings),
773 .error_strings = ip_inacl_error_strings,
774
775 .n_next_nodes = ACL_NEXT_INDEX_N_NEXT,
776 .next_nodes = {
Vijayabhaskar Katamreddyce074122017-11-15 13:50:26 -0800777 [ACL_NEXT_INDEX_DENY] = "ip4-drop",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700778 },
779};
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100780
Benoît Ganneabb2a422021-09-30 13:41:00 +0200781VLIB_REGISTER_NODE (ip4_punt_acl_node) = {
782 .name = "ip4-punt-acl",
783 .vector_size = sizeof (u32),
784 .format_trace = format_ip_inacl_trace,
785 .n_errors = ARRAY_LEN(ip_inacl_error_strings),
786 .error_strings = ip_inacl_error_strings,
787
788 .n_next_nodes = ACL_NEXT_INDEX_N_NEXT,
789 .next_nodes = {
790 [ACL_NEXT_INDEX_DENY] = "ip4-drop",
791 },
792};
793
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100794VLIB_REGISTER_NODE (ip4_outacl_node) = {
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100795 .name = "ip4-outacl",
796 .vector_size = sizeof (u32),
797 .format_trace = format_ip_outacl_trace,
798 .n_errors = ARRAY_LEN(ip_outacl_error_strings),
799 .error_strings = ip_outacl_error_strings,
800
801 .n_next_nodes = ACL_NEXT_INDEX_N_NEXT,
802 .next_nodes = {
803 [ACL_NEXT_INDEX_DENY] = "ip4-drop",
804 },
805};
Dave Barachd7cb1b52016-12-09 09:52:16 -0500806/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700807
Benoît Ganneabb2a422021-09-30 13:41:00 +0200808VNET_FEATURE_INIT (ip4_punt_acl_feature) = {
809 .arc_name = "ip4-punt",
810 .node_name = "ip4-punt-acl",
811 .runs_after = VNET_FEATURES ("ip4-punt-policer"),
812};
813
Filip Tehlar26ea14e2019-03-11 05:30:21 -0700814VLIB_NODE_FN (ip6_inacl_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
815 vlib_frame_t * frame)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700816{
Benoît Ganneabb2a422021-09-30 13:41:00 +0200817 return ip_in_out_acl_inline (
818 vm, node, frame, IN_OUT_ACL_TABLE_IP6, &ip6_input_node, IP6_ERROR_NONE,
819 IP6_ERROR_INACL_SESSION_DENY, IP6_ERROR_INACL_TABLE_MISS, VLIB_RX,
820 0 /* is_output */);
821}
Ray Kinsella8899ce02020-03-12 15:52:41 +0000822
Benoît Ganneabb2a422021-09-30 13:41:00 +0200823VLIB_NODE_FN (ip6_punt_acl_node)
824(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
825{
826 return ip_in_out_acl_inline (
827 vm, node, frame, IN_OUT_ACL_TABLE_IP6_PUNT, &ip6_input_node,
828 IP6_ERROR_NONE, IP6_ERROR_INACL_SESSION_DENY, IP6_ERROR_INACL_TABLE_MISS,
829 ~0 /* way */, 0 /* is_output */);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700830}
831
Filip Tehlar26ea14e2019-03-11 05:30:21 -0700832VLIB_NODE_FN (ip6_outacl_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
833 vlib_frame_t * frame)
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100834{
Benoît Ganneabb2a422021-09-30 13:41:00 +0200835 return ip_in_out_acl_inline (
836 vm, node, frame, IN_OUT_ACL_TABLE_IP6, &ip6_input_node, IP6_ERROR_NONE,
837 IP6_ERROR_INACL_SESSION_DENY, IP6_ERROR_INACL_TABLE_MISS, VLIB_TX,
838 1 /* is_output */);
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100839}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700840
Dave Barachd7cb1b52016-12-09 09:52:16 -0500841/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700842VLIB_REGISTER_NODE (ip6_inacl_node) = {
Ed Warnickecb9cada2015-12-08 15:45:58 -0700843 .name = "ip6-inacl",
844 .vector_size = sizeof (u32),
845 .format_trace = format_ip_inacl_trace,
846 .n_errors = ARRAY_LEN(ip_inacl_error_strings),
847 .error_strings = ip_inacl_error_strings,
848
849 .n_next_nodes = ACL_NEXT_INDEX_N_NEXT,
850 .next_nodes = {
Vijayabhaskar Katamreddyce074122017-11-15 13:50:26 -0800851 [ACL_NEXT_INDEX_DENY] = "ip6-drop",
Ed Warnickecb9cada2015-12-08 15:45:58 -0700852 },
853};
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100854
Benoît Ganneabb2a422021-09-30 13:41:00 +0200855VLIB_REGISTER_NODE (ip6_punt_acl_node) = {
856 .name = "ip6-punt-acl",
857 .vector_size = sizeof (u32),
858 .format_trace = format_ip_inacl_trace,
859 .n_errors = ARRAY_LEN(ip_inacl_error_strings),
860 .error_strings = ip_inacl_error_strings,
861
862 .n_next_nodes = ACL_NEXT_INDEX_N_NEXT,
863 .next_nodes = {
864 [ACL_NEXT_INDEX_DENY] = "ip6-drop",
865 },
866};
867
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100868VLIB_REGISTER_NODE (ip6_outacl_node) = {
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100869 .name = "ip6-outacl",
870 .vector_size = sizeof (u32),
871 .format_trace = format_ip_outacl_trace,
872 .n_errors = ARRAY_LEN(ip_outacl_error_strings),
873 .error_strings = ip_outacl_error_strings,
874
875 .n_next_nodes = ACL_NEXT_INDEX_N_NEXT,
876 .next_nodes = {
877 [ACL_NEXT_INDEX_DENY] = "ip6-drop",
878 },
879};
Dave Barachd7cb1b52016-12-09 09:52:16 -0500880/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700881
Benoît Ganneabb2a422021-09-30 13:41:00 +0200882VNET_FEATURE_INIT (ip6_punt_acl_feature) = {
883 .arc_name = "ip6-punt",
884 .node_name = "ip6-punt-acl",
885 .runs_after = VNET_FEATURES ("ip6-punt-policer"),
886};
887
Filip Tehlar26ea14e2019-03-11 05:30:21 -0700888#ifndef CLIB_MARCH_VARIANT
Ed Warnickecb9cada2015-12-08 15:45:58 -0700889static clib_error_t *
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100890ip_in_out_acl_init (vlib_main_t * vm)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700891{
892 return 0;
893}
894
Andrew Yourtchenko815d7d52018-02-07 11:37:02 +0100895VLIB_INIT_FUNCTION (ip_in_out_acl_init);
Filip Tehlar26ea14e2019-03-11 05:30:21 -0700896#endif /* CLIB_MARCH_VARIANT */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700897
Dave Barachd7cb1b52016-12-09 09:52:16 -0500898
899/*
900 * fd.io coding-style-patch-verification: ON
901 *
902 * Local Variables:
903 * eval: (c-set-style "gnu")
904 * End:
905 */