acl-plugin: move to per-frame buffer pointer calculations and enqueue to next nodes
[vpp.git] / src / plugins / acl / dataplane_node.c
1 /*
2  * Copyright (c) 2016-2018 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 <stddef.h>
16 #include <netinet/in.h>
17
18 #include <vlib/vlib.h>
19 #include <vnet/vnet.h>
20 #include <vnet/pg/pg.h>
21 #include <vppinfra/error.h>
22
23
24 #include <acl/acl.h>
25 #include <vnet/ip/icmp46_packet.h>
26
27 #include <plugins/acl/fa_node.h>
28 #include <plugins/acl/acl.h>
29 #include <plugins/acl/lookup_context.h>
30 #include <plugins/acl/public_inlines.h>
31 #include <plugins/acl/session_inlines.h>
32
33 #include <vppinfra/bihash_40_8.h>
34 #include <vppinfra/bihash_template.h>
35
36 typedef struct
37 {
38   u32 next_index;
39   u32 sw_if_index;
40   u32 lc_index;
41   u32 match_acl_in_index;
42   u32 match_rule_index;
43   u64 packet_info[6];
44   u32 trace_bitmap;
45   u8 action;
46 } acl_fa_trace_t;
47
48 /* *INDENT-OFF* */
49 #define foreach_acl_fa_error \
50 _(ACL_DROP, "ACL deny packets")  \
51 _(ACL_PERMIT, "ACL permit packets")  \
52 _(ACL_NEW_SESSION, "new sessions added") \
53 _(ACL_EXIST_SESSION, "existing session packets") \
54 _(ACL_CHECK, "checked packets") \
55 _(ACL_RESTART_SESSION_TIMER, "restart session timer") \
56 _(ACL_TOO_MANY_SESSIONS, "too many sessions to add new") \
57 /* end  of errors */
58
59 typedef enum
60 {
61 #define _(sym,str) ACL_FA_ERROR_##sym,
62   foreach_acl_fa_error
63 #undef _
64     ACL_FA_N_ERROR,
65 } acl_fa_error_t;
66
67 /* *INDENT-ON* */
68
69
70 always_inline uword
71 acl_fa_node_fn (vlib_main_t * vm,
72                 vlib_node_runtime_t * node, vlib_frame_t * frame, int is_ip6,
73                 int is_input, int is_l2_path, u32 * l2_feat_next_node_index,
74                 vlib_node_registration_t * acl_fa_node)
75 {
76   u32 n_left, *from;
77   u32 pkts_acl_checked = 0;
78   u32 pkts_new_session = 0;
79   u32 pkts_exist_session = 0;
80   u32 pkts_acl_permit = 0;
81   u32 pkts_restart_session_timer = 0;
82   u32 trace_bitmap = 0;
83   acl_main_t *am = &acl_main;
84   fa_5tuple_t fa_5tuple;
85   clib_bihash_kv_40_8_t value_sess;
86   vlib_node_runtime_t *error_node;
87   u64 now = clib_cpu_time_now ();
88   uword thread_index = os_get_thread_index ();
89   acl_fa_per_worker_data_t *pw = &am->per_worker_data[thread_index];
90
91   u16 nexts[VLIB_FRAME_SIZE], *next;
92   vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
93
94   from = vlib_frame_vector_args (frame);
95
96   error_node = vlib_node_get_runtime (vm, acl_fa_node->index);
97
98   vlib_get_buffers (vm, from, bufs, frame->n_vectors);
99   /* set the initial values for the current buffer the next pointers */
100   b = bufs;
101   next = nexts;
102
103   n_left = frame->n_vectors;
104   while (n_left > 0)
105     {
106       u32 next0 = 0;
107       u8 action = 0;
108       u32 sw_if_index0;
109       u32 lc_index0 = ~0;
110       int acl_check_needed = 1;
111       u32 match_acl_in_index = ~0;
112       u32 match_acl_pos = ~0;
113       u32 match_rule_index = ~0;
114       u8 error0 = 0;
115
116       n_left -= 1;
117
118       if (is_input)
119         sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
120       else
121         sw_if_index0 = vnet_buffer (b[0])->sw_if_index[VLIB_TX];
122
123       if (is_input)
124         lc_index0 = am->input_lc_index_by_sw_if_index[sw_if_index0];
125       else
126         lc_index0 = am->output_lc_index_by_sw_if_index[sw_if_index0];
127
128
129       u32 **p_epoch_vec =
130         is_input ? &am->input_policy_epoch_by_sw_if_index :
131         &am->output_policy_epoch_by_sw_if_index;
132       u16 current_policy_epoch =
133         sw_if_index0 < vec_len (*p_epoch_vec) ? vec_elt (*p_epoch_vec,
134                                                          sw_if_index0)
135         : (is_input * FA_POLICY_EPOCH_IS_INPUT);
136       /*
137        * Extract the L3/L4 matching info into a 5-tuple structure.
138        */
139
140       acl_plugin_fill_5tuple_inline (lc_index0, b[0], is_ip6, is_input,
141                                      is_l2_path,
142                                      (fa_5tuple_opaque_t *) & fa_5tuple);
143       fa_5tuple.l4.lsb_of_sw_if_index = sw_if_index0 & 0xffff;
144       fa_5tuple.pkt.mask_type_index_lsb = ~0;
145 #ifdef FA_NODE_VERBOSE_DEBUG
146       clib_warning
147         ("ACL_FA_NODE_DBG: packet 5-tuple %016llx %016llx %016llx %016llx %016llx %016llx",
148          fa_5tuple.kv.key[0], fa_5tuple.kv.key[1], fa_5tuple.kv.key[2],
149          fa_5tuple.kv.key[3], fa_5tuple.kv.key[4], fa_5tuple.kv.value);
150 #endif
151
152       /* Try to match an existing session first */
153
154       if (acl_fa_ifc_has_sessions (am, sw_if_index0))
155         {
156           if (acl_fa_find_session (am, sw_if_index0, &fa_5tuple, &value_sess))
157             {
158               trace_bitmap |= 0x80000000;
159               error0 = ACL_FA_ERROR_ACL_EXIST_SESSION;
160               fa_full_session_id_t f_sess_id;
161
162               f_sess_id.as_u64 = value_sess.value;
163               ASSERT (f_sess_id.thread_index < vec_len (vlib_mains));
164
165               fa_session_t *sess =
166                 get_session_ptr (am, f_sess_id.thread_index,
167                                  f_sess_id.session_index);
168               int old_timeout_type = fa_session_get_timeout_type (am, sess);
169               action =
170                 acl_fa_track_session (am, is_input, sw_if_index0, now,
171                                       sess, &fa_5tuple);
172               /* expose the session id to the tracer */
173               match_rule_index = f_sess_id.session_index;
174               int new_timeout_type = fa_session_get_timeout_type (am, sess);
175               acl_check_needed = 0;
176               pkts_exist_session += 1;
177               /* Tracking might have changed the session timeout type, e.g. from transient to established */
178               if (PREDICT_FALSE (old_timeout_type != new_timeout_type))
179                 {
180                   acl_fa_restart_timer_for_session (am, now, f_sess_id);
181                   pkts_restart_session_timer++;
182                   trace_bitmap |=
183                     0x00010000 + ((0xff & old_timeout_type) << 8) +
184                     (0xff & new_timeout_type);
185                 }
186               /*
187                * I estimate the likelihood to be very low - the VPP needs
188                * to have >64K interfaces to start with and then on
189                * exactly 64K indices apart needs to be exactly the same
190                * 5-tuple... Anyway, since this probability is nonzero -
191                * print an error and drop the unlucky packet.
192                * If this shows up in real world, we would need to bump
193                * the hash key length.
194                */
195               if (PREDICT_FALSE (sess->sw_if_index != sw_if_index0))
196                 {
197                   clib_warning
198                     ("BUG: session LSB16(sw_if_index) and 5-tuple collision!");
199                   acl_check_needed = 0;
200                   action = 0;
201                 }
202               if (PREDICT_FALSE (am->reclassify_sessions))
203                 {
204                   /* if the MSB of policy epoch matches but not the LSB means it is a stale session */
205                   if ((0 ==
206                        ((current_policy_epoch ^
207                          f_sess_id.intf_policy_epoch) &
208                         FA_POLICY_EPOCH_IS_INPUT))
209                       && (current_policy_epoch !=
210                           f_sess_id.intf_policy_epoch))
211                     {
212                       /* delete session and increment the counter */
213                       vec_validate
214                         (pw->fa_session_epoch_change_by_sw_if_index,
215                          sw_if_index0);
216                       vec_elt (pw->fa_session_epoch_change_by_sw_if_index,
217                                sw_if_index0)++;
218                       if (acl_fa_conn_list_delete_session (am, f_sess_id))
219                         {
220                           /* delete the session only if we were able to unlink it */
221                           acl_fa_delete_session (am, sw_if_index0, f_sess_id);
222                         }
223                       acl_check_needed = 1;
224                       trace_bitmap |= 0x40000000;
225                     }
226                 }
227             }
228         }
229
230       if (acl_check_needed)
231         {
232           action = 0;           /* deny by default */
233           acl_plugin_match_5tuple_inline (lc_index0,
234                                           (fa_5tuple_opaque_t *) &
235                                           fa_5tuple, is_ip6, &action,
236                                           &match_acl_pos,
237                                           &match_acl_in_index,
238                                           &match_rule_index, &trace_bitmap);
239           error0 = action;
240           if (1 == action)
241             pkts_acl_permit += 1;
242           if (2 == action)
243             {
244               if (!acl_fa_can_add_session (am, is_input, sw_if_index0))
245                 acl_fa_try_recycle_session (am, is_input, thread_index,
246                                             sw_if_index0);
247
248               if (acl_fa_can_add_session (am, is_input, sw_if_index0))
249                 {
250                   fa_session_t *sess =
251                     acl_fa_add_session (am, is_input, is_ip6,
252                                         sw_if_index0,
253                                         now, &fa_5tuple,
254                                         current_policy_epoch);
255                   acl_fa_track_session (am, is_input, sw_if_index0,
256                                         now, sess, &fa_5tuple);
257                   pkts_new_session += 1;
258                 }
259               else
260                 {
261                   action = 0;
262                   error0 = ACL_FA_ERROR_ACL_TOO_MANY_SESSIONS;
263                 }
264             }
265         }
266
267
268
269       if (action > 0)
270         {
271           if (is_l2_path)
272             next0 = vnet_l2_feature_next (b[0], l2_feat_next_node_index, 0);
273           else
274             vnet_feature_next (sw_if_index0, &next0, b[0]);
275         }
276 #ifdef FA_NODE_VERBOSE_DEBUG
277       clib_warning
278         ("ACL_FA_NODE_DBG: sw_if_index %d lc_index %d action %d acl_index %d rule_index %d",
279          sw_if_index0, lc_index0, action, match_acl_in_index,
280          match_rule_index);
281 #endif
282
283       if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
284                          && (b[0]->flags & VLIB_BUFFER_IS_TRACED)))
285         {
286           acl_fa_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
287           t->sw_if_index = sw_if_index0;
288           t->lc_index = lc_index0;
289           t->next_index = next0;
290           t->match_acl_in_index = match_acl_in_index;
291           t->match_rule_index = match_rule_index;
292           t->packet_info[0] = fa_5tuple.kv.key[0];
293           t->packet_info[1] = fa_5tuple.kv.key[1];
294           t->packet_info[2] = fa_5tuple.kv.key[2];
295           t->packet_info[3] = fa_5tuple.kv.key[3];
296           t->packet_info[4] = fa_5tuple.kv.key[4];
297           t->packet_info[5] = fa_5tuple.kv.value;
298           t->action = action;
299           t->trace_bitmap = trace_bitmap;
300         }
301
302       next0 = next0 < node->n_next_nodes ? next0 : 0;
303       if (0 == next0)
304         b[0]->error = error_node->errors[error0];
305       next[0] = next0;
306
307       next++;
308       b++;
309       pkts_acl_checked += 1;
310     }
311
312   vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
313
314   vlib_node_increment_counter (vm, acl_fa_node->index,
315                                ACL_FA_ERROR_ACL_CHECK, pkts_acl_checked);
316   vlib_node_increment_counter (vm, acl_fa_node->index,
317                                ACL_FA_ERROR_ACL_PERMIT, pkts_acl_permit);
318   vlib_node_increment_counter (vm, acl_fa_node->index,
319                                ACL_FA_ERROR_ACL_NEW_SESSION,
320                                pkts_new_session);
321   vlib_node_increment_counter (vm, acl_fa_node->index,
322                                ACL_FA_ERROR_ACL_EXIST_SESSION,
323                                pkts_exist_session);
324   vlib_node_increment_counter (vm, acl_fa_node->index,
325                                ACL_FA_ERROR_ACL_RESTART_SESSION_TIMER,
326                                pkts_restart_session_timer);
327   return frame->n_vectors;
328 }
329
330 vlib_node_function_t __clib_weak acl_in_ip4_l2_node_fn_avx512;
331 vlib_node_function_t __clib_weak acl_in_ip4_l2_node_fn_avx2;
332
333 vlib_node_function_t __clib_weak acl_out_ip4_l2_node_fn_avx512;
334 vlib_node_function_t __clib_weak acl_out_ip4_l2_node_fn_avx2;
335
336 vlib_node_function_t __clib_weak acl_in_ip6_l2_node_fn_avx512;
337 vlib_node_function_t __clib_weak acl_in_ip6_l2_node_fn_avx2;
338
339 vlib_node_function_t __clib_weak acl_out_ip6_l2_node_fn_avx512;
340 vlib_node_function_t __clib_weak acl_out_ip6_l2_node_fn_avx2;
341
342 vlib_node_function_t __clib_weak acl_in_ip4_fa_node_fn_avx512;
343 vlib_node_function_t __clib_weak acl_in_ip4_fa_node_fn_avx2;
344
345 vlib_node_function_t __clib_weak acl_out_ip4_fa_node_fn_avx512;
346 vlib_node_function_t __clib_weak acl_out_ip4_fa_node_fn_avx2;
347
348 vlib_node_function_t __clib_weak acl_in_ip6_fa_node_fn_avx512;
349 vlib_node_function_t __clib_weak acl_in_ip6_fa_node_fn_avx2;
350
351 vlib_node_function_t __clib_weak acl_out_ip6_fa_node_fn_avx512;
352 vlib_node_function_t __clib_weak acl_out_ip6_fa_node_fn_avx2;
353
354
355 vlib_node_registration_t acl_in_l2_ip6_node;
356 uword CLIB_CPU_OPTIMIZED
357 CLIB_MULTIARCH_FN (acl_in_ip6_l2_node_fn) (vlib_main_t * vm,
358                                            vlib_node_runtime_t * node,
359                                            vlib_frame_t * frame)
360 {
361   acl_main_t *am = &acl_main;
362   return acl_fa_node_fn (vm, node, frame, 1, 1, 1,
363                          am->fa_acl_in_ip6_l2_node_feat_next_node_index,
364                          &acl_in_l2_ip6_node);
365 }
366
367 vlib_node_registration_t acl_in_l2_ip4_node;
368 uword CLIB_CPU_OPTIMIZED
369 CLIB_MULTIARCH_FN (acl_in_ip4_l2_node_fn) (vlib_main_t * vm,
370                                            vlib_node_runtime_t * node,
371                                            vlib_frame_t * frame)
372 {
373   acl_main_t *am = &acl_main;
374   return acl_fa_node_fn (vm, node, frame, 0, 1, 1,
375                          am->fa_acl_in_ip4_l2_node_feat_next_node_index,
376                          &acl_in_l2_ip4_node);
377 }
378
379 vlib_node_registration_t acl_out_l2_ip6_node;
380 uword CLIB_CPU_OPTIMIZED
381 CLIB_MULTIARCH_FN (acl_out_ip6_l2_node_fn) (vlib_main_t * vm,
382                                             vlib_node_runtime_t * node,
383                                             vlib_frame_t * frame)
384 {
385   acl_main_t *am = &acl_main;
386   return acl_fa_node_fn (vm, node, frame, 1, 0, 1,
387                          am->fa_acl_out_ip6_l2_node_feat_next_node_index,
388                          &acl_out_l2_ip6_node);
389 }
390
391 vlib_node_registration_t acl_out_l2_ip4_node;
392 uword CLIB_CPU_OPTIMIZED
393 CLIB_MULTIARCH_FN (acl_out_ip4_l2_node_fn) (vlib_main_t * vm,
394                                             vlib_node_runtime_t * node,
395                                             vlib_frame_t * frame)
396 {
397   acl_main_t *am = &acl_main;
398   return acl_fa_node_fn (vm, node, frame, 0, 0, 1,
399                          am->fa_acl_out_ip4_l2_node_feat_next_node_index,
400                          &acl_out_l2_ip4_node);
401 }
402
403 /**** L3 processing path nodes ****/
404
405 vlib_node_registration_t acl_in_fa_ip6_node;
406 uword CLIB_CPU_OPTIMIZED
407 CLIB_MULTIARCH_FN (acl_in_ip6_fa_node_fn) (vlib_main_t * vm,
408                                            vlib_node_runtime_t * node,
409                                            vlib_frame_t * frame)
410 {
411   return acl_fa_node_fn (vm, node, frame, 1, 1, 0, 0, &acl_in_fa_ip6_node);
412 }
413
414 vlib_node_registration_t acl_in_fa_ip4_node;
415 uword CLIB_CPU_OPTIMIZED
416 CLIB_MULTIARCH_FN (acl_in_ip4_fa_node_fn) (vlib_main_t * vm,
417                                            vlib_node_runtime_t * node,
418                                            vlib_frame_t * frame)
419 {
420   return acl_fa_node_fn (vm, node, frame, 0, 1, 0, 0, &acl_in_fa_ip4_node);
421 }
422
423 vlib_node_registration_t acl_out_fa_ip6_node;
424 uword CLIB_CPU_OPTIMIZED
425 CLIB_MULTIARCH_FN (acl_out_ip6_fa_node_fn) (vlib_main_t * vm,
426                                             vlib_node_runtime_t * node,
427                                             vlib_frame_t * frame)
428 {
429   return acl_fa_node_fn (vm, node, frame, 1, 0, 0, 0, &acl_out_fa_ip6_node);
430 }
431
432 vlib_node_registration_t acl_out_fa_ip4_node;
433 uword CLIB_CPU_OPTIMIZED
434 CLIB_MULTIARCH_FN (acl_out_ip4_fa_node_fn) (vlib_main_t * vm,
435                                             vlib_node_runtime_t * node,
436                                             vlib_frame_t * frame)
437 {
438   return acl_fa_node_fn (vm, node, frame, 0, 0, 0, 0, &acl_out_fa_ip4_node);
439 }
440
441
442
443 #if __x86_64__
444 static void __clib_constructor
445 acl_plugin_multiarch_select (void)
446 {
447   if (acl_in_ip4_l2_node_fn_avx512 && clib_cpu_supports_avx512f ())
448     acl_in_l2_ip4_node.function = acl_in_ip4_l2_node_fn_avx512;
449   else if (acl_in_ip4_l2_node_fn_avx2 && clib_cpu_supports_avx2 ())
450     acl_in_l2_ip4_node.function = acl_in_ip4_l2_node_fn_avx2;
451
452   if (acl_out_ip4_l2_node_fn_avx512 && clib_cpu_supports_avx512f ())
453     acl_out_l2_ip4_node.function = acl_out_ip4_l2_node_fn_avx512;
454   else if (acl_out_ip4_l2_node_fn_avx2 && clib_cpu_supports_avx2 ())
455     acl_out_l2_ip4_node.function = acl_out_ip4_l2_node_fn_avx2;
456
457   if (acl_in_ip6_l2_node_fn_avx512 && clib_cpu_supports_avx512f ())
458     acl_in_l2_ip6_node.function = acl_in_ip6_l2_node_fn_avx512;
459   else if (acl_in_ip6_l2_node_fn_avx2 && clib_cpu_supports_avx2 ())
460     acl_in_l2_ip6_node.function = acl_in_ip6_l2_node_fn_avx2;
461
462   if (acl_out_ip6_l2_node_fn_avx512 && clib_cpu_supports_avx512f ())
463     acl_out_l2_ip6_node.function = acl_out_ip6_l2_node_fn_avx512;
464   else if (acl_out_ip6_l2_node_fn_avx2 && clib_cpu_supports_avx2 ())
465     acl_out_l2_ip6_node.function = acl_out_ip6_l2_node_fn_avx2;
466
467   if (acl_in_ip4_fa_node_fn_avx512 && clib_cpu_supports_avx512f ())
468     acl_in_fa_ip4_node.function = acl_in_ip4_fa_node_fn_avx512;
469   else if (acl_in_ip4_fa_node_fn_avx2 && clib_cpu_supports_avx2 ())
470     acl_in_fa_ip4_node.function = acl_in_ip4_fa_node_fn_avx2;
471
472   if (acl_out_ip4_fa_node_fn_avx512 && clib_cpu_supports_avx512f ())
473     acl_out_fa_ip4_node.function = acl_out_ip4_fa_node_fn_avx512;
474   else if (acl_out_ip4_fa_node_fn_avx2 && clib_cpu_supports_avx2 ())
475     acl_out_fa_ip4_node.function = acl_out_ip4_fa_node_fn_avx2;
476
477   if (acl_in_ip6_fa_node_fn_avx512 && clib_cpu_supports_avx512f ())
478     acl_in_fa_ip6_node.function = acl_in_ip6_fa_node_fn_avx512;
479   else if (acl_in_ip6_fa_node_fn_avx2 && clib_cpu_supports_avx2 ())
480     acl_in_fa_ip6_node.function = acl_in_ip6_fa_node_fn_avx2;
481
482   if (acl_out_ip6_fa_node_fn_avx512 && clib_cpu_supports_avx512f ())
483     acl_out_fa_ip6_node.function = acl_out_ip6_fa_node_fn_avx512;
484   else if (acl_out_ip6_fa_node_fn_avx2 && clib_cpu_supports_avx2 ())
485     acl_out_fa_ip6_node.function = acl_out_ip6_fa_node_fn_avx2;
486
487 }
488 #endif
489
490
491
492 #ifndef CLIB_MULTIARCH_VARIANT
493 static u8 *
494 format_fa_5tuple (u8 * s, va_list * args)
495 {
496   fa_5tuple_t *p5t = va_arg (*args, fa_5tuple_t *);
497
498   return format (s, "lc_index %d (lsb16 of sw_if_index %d) l3 %s%s %U -> %U"
499                  " l4 proto %d l4_valid %d port %d -> %d tcp flags (%s) %02x rsvd %x",
500                  p5t->pkt.lc_index, p5t->l4.lsb_of_sw_if_index,
501                  p5t->pkt.is_ip6 ? "ip6" : "ip4",
502                  p5t->pkt.is_nonfirst_fragment ? " non-initial fragment" : "",
503                  format_ip46_address, &p5t->addr[0],
504                  p5t->pkt.is_ip6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
505                  format_ip46_address, &p5t->addr[1],
506                  p5t->pkt.is_ip6 ? IP46_TYPE_IP6 : IP46_TYPE_IP4,
507                  p5t->l4.proto, p5t->pkt.l4_valid, p5t->l4.port[0],
508                  p5t->l4.port[1],
509                  p5t->pkt.tcp_flags_valid ? "valid" : "invalid",
510                  p5t->pkt.tcp_flags, p5t->pkt.flags_reserved);
511 }
512
513 u8 *
514 format_acl_plugin_5tuple (u8 * s, va_list * args)
515 {
516   return format_fa_5tuple (s, args);
517 }
518
519 /* packet trace format function */
520 u8 *
521 format_acl_plugin_trace (u8 * s, va_list * args)
522 {
523   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
524   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
525   acl_fa_trace_t *t = va_arg (*args, acl_fa_trace_t *);
526
527   s =
528     format (s,
529             "acl-plugin: lc_index: %d, sw_if_index %d, next index %d, action: %d, match: acl %d rule %d trace_bits %08x\n"
530             "  pkt info %016llx %016llx %016llx %016llx %016llx %016llx",
531             t->lc_index, t->sw_if_index, t->next_index, t->action,
532             t->match_acl_in_index, t->match_rule_index, t->trace_bitmap,
533             t->packet_info[0], t->packet_info[1], t->packet_info[2],
534             t->packet_info[3], t->packet_info[4], t->packet_info[5]);
535
536   /* Now also print out the packet_info in a form usable by humans */
537   s = format (s, "\n   %U", format_fa_5tuple, t->packet_info);
538   return s;
539 }
540
541
542 /* *INDENT-OFF* */
543
544 static char *acl_fa_error_strings[] = {
545 #define _(sym,string) string,
546   foreach_acl_fa_error
547 #undef _
548 };
549
550 VLIB_REGISTER_NODE (acl_in_l2_ip6_node) =
551 {
552   .function = acl_in_ip6_l2_node_fn,
553   .name = "acl-plugin-in-ip6-l2",
554   .vector_size = sizeof (u32),
555   .format_trace = format_acl_plugin_trace,
556   .type = VLIB_NODE_TYPE_INTERNAL,
557   .n_errors = ARRAY_LEN (acl_fa_error_strings),
558   .error_strings = acl_fa_error_strings,
559   .n_next_nodes = ACL_FA_N_NEXT,
560   .next_nodes =
561   {
562     [ACL_FA_ERROR_DROP] = "error-drop",
563   }
564 };
565
566 VLIB_REGISTER_NODE (acl_in_l2_ip4_node) =
567 {
568   .function = acl_in_ip4_l2_node_fn,
569   .name = "acl-plugin-in-ip4-l2",
570   .vector_size = sizeof (u32),
571   .format_trace = format_acl_plugin_trace,
572   .type = VLIB_NODE_TYPE_INTERNAL,
573   .n_errors = ARRAY_LEN (acl_fa_error_strings),
574   .error_strings = acl_fa_error_strings,
575   .n_next_nodes = ACL_FA_N_NEXT,
576   .next_nodes =
577   {
578     [ACL_FA_ERROR_DROP] = "error-drop",
579   }
580 };
581
582 VLIB_REGISTER_NODE (acl_out_l2_ip6_node) =
583 {
584   .function = acl_out_ip6_l2_node_fn,
585   .name = "acl-plugin-out-ip6-l2",
586   .vector_size = sizeof (u32),
587   .format_trace = format_acl_plugin_trace,
588   .type = VLIB_NODE_TYPE_INTERNAL,
589   .n_errors = ARRAY_LEN (acl_fa_error_strings),
590   .error_strings = acl_fa_error_strings,
591   .n_next_nodes = ACL_FA_N_NEXT,
592   .next_nodes =
593   {
594     [ACL_FA_ERROR_DROP] = "error-drop",
595   }
596 };
597
598 VLIB_REGISTER_NODE (acl_out_l2_ip4_node) =
599 {
600   .function = acl_out_ip4_l2_node_fn,
601   .name = "acl-plugin-out-ip4-l2",
602   .vector_size = sizeof (u32),
603   .format_trace = format_acl_plugin_trace,
604   .type = VLIB_NODE_TYPE_INTERNAL,
605   .n_errors = ARRAY_LEN (acl_fa_error_strings),
606   .error_strings = acl_fa_error_strings,
607   .n_next_nodes = ACL_FA_N_NEXT,
608   .next_nodes =
609   {
610     [ACL_FA_ERROR_DROP] = "error-drop",
611   }
612 };
613
614
615 VLIB_REGISTER_NODE (acl_in_fa_ip6_node) =
616 {
617   .function = acl_in_ip6_fa_node_fn,
618   .name = "acl-plugin-in-ip6-fa",
619   .vector_size = sizeof (u32),
620   .format_trace = format_acl_plugin_trace,
621   .type = VLIB_NODE_TYPE_INTERNAL,
622   .n_errors = ARRAY_LEN (acl_fa_error_strings),
623   .error_strings = acl_fa_error_strings,
624   .n_next_nodes = ACL_FA_N_NEXT,
625   .next_nodes =
626   {
627     [ACL_FA_ERROR_DROP] = "error-drop",
628   }
629 };
630
631 VNET_FEATURE_INIT (acl_in_ip6_fa_feature, static) =
632 {
633   .arc_name = "ip6-unicast",
634   .node_name = "acl-plugin-in-ip6-fa",
635   .runs_before = VNET_FEATURES ("ip6-flow-classify"),
636 };
637
638 VLIB_REGISTER_NODE (acl_in_fa_ip4_node) =
639 {
640   .function = acl_in_ip4_fa_node_fn,
641   .name = "acl-plugin-in-ip4-fa",
642   .vector_size = sizeof (u32),
643   .format_trace = format_acl_plugin_trace,
644   .type = VLIB_NODE_TYPE_INTERNAL,
645   .n_errors = ARRAY_LEN (acl_fa_error_strings),
646   .error_strings = acl_fa_error_strings,
647   .n_next_nodes = ACL_FA_N_NEXT,
648   .next_nodes =
649   {
650     [ACL_FA_ERROR_DROP] = "error-drop",
651   }
652 };
653
654 VNET_FEATURE_INIT (acl_in_ip4_fa_feature, static) =
655 {
656   .arc_name = "ip4-unicast",
657   .node_name = "acl-plugin-in-ip4-fa",
658   .runs_before = VNET_FEATURES ("ip4-flow-classify"),
659 };
660
661
662 VLIB_REGISTER_NODE (acl_out_fa_ip6_node) =
663 {
664   .function = acl_out_ip6_fa_node_fn,
665   .name = "acl-plugin-out-ip6-fa",
666   .vector_size = sizeof (u32),
667   .format_trace = format_acl_plugin_trace,
668   .type = VLIB_NODE_TYPE_INTERNAL,
669   .n_errors = ARRAY_LEN (acl_fa_error_strings),
670   .error_strings = acl_fa_error_strings,
671   .n_next_nodes = ACL_FA_N_NEXT,
672   .next_nodes =
673   {
674     [ACL_FA_ERROR_DROP] = "error-drop",
675   }
676 };
677
678 VNET_FEATURE_INIT (acl_out_ip6_fa_feature, static) =
679 {
680   .arc_name = "ip6-output",
681   .node_name = "acl-plugin-out-ip6-fa",
682   .runs_before = VNET_FEATURES ("interface-output"),
683 };
684
685 VLIB_REGISTER_NODE (acl_out_fa_ip4_node) =
686 {
687   .function = acl_out_ip4_fa_node_fn,
688   .name = "acl-plugin-out-ip4-fa",
689   .vector_size = sizeof (u32),
690   .format_trace = format_acl_plugin_trace,
691   .type = VLIB_NODE_TYPE_INTERNAL,
692   .n_errors = ARRAY_LEN (acl_fa_error_strings),
693   .error_strings = acl_fa_error_strings,
694   .n_next_nodes = ACL_FA_N_NEXT,
695     /* edit / add dispositions here */
696   .next_nodes =
697   {
698     [ACL_FA_ERROR_DROP] = "error-drop",
699   }
700 };
701
702 VNET_FEATURE_INIT (acl_out_ip4_fa_feature, static) =
703 {
704   .arc_name = "ip4-output",
705   .node_name = "acl-plugin-out-ip4-fa",
706   .runs_before = VNET_FEATURES ("interface-output"),
707 };
708 #endif
709
710 /* *INDENT-ON* */
711
712 /*
713  * fd.io coding-style-patch-verification: ON
714  *
715  * Local Variables:
716  * eval: (c-set-style "gnu")
717  * End:
718  */