VPP-369 Add an L2 output classification feature
[vpp.git] / vnet / vnet / l2 / l2_output_classify.c
1 /*
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 /*
16  * l2_classify.c
17  */
18
19 #include <vnet/l2/l2_classify.h>
20 #include <vnet/api_errno.h>
21
22 /**
23  * @file
24  * @brief L2 input classifier
25  *
26  * See also .../vnet/vnet/classify/vnet_classify.[ch]
27  */
28
29 typedef struct
30 {
31   /** interface handle for the ith packet */
32   u32 sw_if_index;
33   /** graph arc index selected for this packet */
34   u32 next_index;
35   /** classifier table which provided the final result */
36   u32 table_index;
37   /** offset in classifier heap of the corresponding session */
38   u32 session_offset;
39 } l2_output_classify_trace_t;
40
41 typedef struct
42 {
43   /** use-case independent main object pointer */
44   vnet_classify_main_t *vcm;
45   /** l2 input classifier main object pointer */
46   l2_output_classify_main_t *l2cm;
47 } l2_output_classify_runtime_t;
48
49 /** packet trace format function */
50 static u8 *
51 format_l2_output_classify_trace (u8 * s, va_list * args)
52 {
53   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
54   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
55   l2_output_classify_trace_t *t =
56     va_arg (*args, l2_output_classify_trace_t *);
57
58   s = format (s, "l2-classify: sw_if_index %d, table %d, offset %x, next %d",
59               t->sw_if_index, t->table_index, t->session_offset,
60               t->next_index);
61   return s;
62 }
63
64 /** l2 output classifier main data structure */
65 l2_output_classify_main_t l2_output_classify_main;
66
67 vlib_node_registration_t l2_output_classify_node;
68
69 #define foreach_l2_output_classify_error               \
70 _(MISS, "Classify misses")                      \
71 _(HIT, "Classify hits")                         \
72 _(CHAIN_HIT, "Classify hits after chain walk")  \
73 _(DROP, "L2 Classify Drops")
74
75 typedef enum
76 {
77 #define _(sym,str) L2_OUTPUT_CLASSIFY_ERROR_##sym,
78   foreach_l2_output_classify_error
79 #undef _
80     L2_OUTPUT_CLASSIFY_N_ERROR,
81 } l2_output_classify_error_t;
82
83 static char *l2_output_classify_error_strings[] = {
84 #define _(sym,string) string,
85   foreach_l2_output_classify_error
86 #undef _
87 };
88
89 /**
90  * @brief l2 output classifier node.
91  * @node l2-output-classify
92  *
93  * This is the l2 output classifier dispatch node
94  *
95  * @param vm    vlib_main_t corresponding to the current thread.
96  * @param node  vlib_node_runtime_t data for this node.
97  * @param frame vlib_frame_t whose contents should be dispatched.
98  *
99  * @par Graph mechanics: buffer metadata, next index usage
100  *
101  * @em Uses:
102  * - <code>(l2_input_classify_runtime_t *)
103  *         rt->classify_table_index_by_sw_if_index</code>
104  *         Head of the per-interface, perprotocol classifier table chain
105  *         for a specific interface. ~0 => send pkts to the next
106  *         feature in the L2 feature chain.
107  * - <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code>
108  *      - Indicates the @c sw_if_index value of the interface that the
109  *      packet was received on.
110  * - <code>vnet_buffer (b0)->l2.feature_bitmap</code>
111  *      - Used to steer packets across l2 features enabled on the interface
112  * - <code>(vnet_classify_entry_t) e0->next_index</code>
113  *      - Used to steer traffic when the classifier hits on a session
114  * - <code>(vnet_classify_entry_t) e0->advance</code>
115  *      - Signed quantity applied via <code>vlib_buffer_advance</code>
116  *      when the classifier hits on a session
117  * - <code>(vnet_classify_table_t) t0->miss_next_index</code>
118  *      - Used to steer traffic when the classifier misses
119  *
120  * @em Sets:
121  * - <code>vnet_buffer (b0)->l2_classify.table_index</code>
122  *      - Classifier table index of the first classifier table in
123  *      the classifier table chain
124  * - <code>vnet_buffer (b0)->l2_classify.hash</code>
125  *      - Bounded-index extensible hash corresponding to the
126  *      masked fields in the current packet
127  * - <code>vnet_buffer (b0)->l2.feature_bitmap</code>
128  *      - Used to steer packets across l2 features enabled on the interface
129  * - <code>vnet_buffer (b0)->l2_classify.opaque_index</code>
130  *      - Copied from the classifier session object upon classifier hit
131  *
132  * @em Counters:
133  * - <code>L2_OUTPUT_CLASSIFY_ERROR_MISS</code> Classifier misses
134  * - <code>L2_OUTPUT_CLASSIFY_ERROR_HIT</code> Classifier hits
135  * - <code>L2_OUTPUT_CLASSIFY_ERROR_CHAIN_HIT</code>
136  *   Classifier hits in other than the first table
137  */
138
139 static uword
140 l2_output_classify_node_fn (vlib_main_t * vm,
141                             vlib_node_runtime_t * node, vlib_frame_t * frame)
142 {
143   u32 n_left_from, *from, *to_next;
144   l2_output_classify_next_t next_index;
145   l2_output_classify_main_t *cm = &l2_output_classify_main;
146   vnet_classify_main_t *vcm = cm->vnet_classify_main;
147   l2_output_classify_runtime_t *rt =
148     (l2_output_classify_runtime_t *) node->runtime_data;
149   u32 feature_bitmap0;
150   u32 hits = 0;
151   u32 misses = 0;
152   u32 chain_hits = 0;
153   f64 now;
154   u32 n_next_nodes;
155   u32 cached_sw_if_index = (u32) ~ 0;
156   u32 cached_next_index = (u32) ~ 0;
157   u32 sw_if_index0;
158
159   n_next_nodes = node->n_next_nodes;
160
161   now = vlib_time_now (vm);
162
163   n_left_from = frame->n_vectors;
164   from = vlib_frame_vector_args (frame);
165
166   /* First pass: compute hash */
167
168   while (n_left_from > 2)
169     {
170       vlib_buffer_t *b0, *b1;
171       u32 bi0, bi1;
172       ethernet_header_t *h0, *h1;
173       u32 sw_if_index0, sw_if_index1;
174       u16 type0, type1;
175       int type_index0, type_index1;
176       vnet_classify_table_t *t0, *t1;
177       u32 table_index0, table_index1;
178       u64 hash0, hash1;
179
180
181       /* prefetch next iteration */
182       {
183         vlib_buffer_t *p1, *p2;
184
185         p1 = vlib_get_buffer (vm, from[1]);
186         p2 = vlib_get_buffer (vm, from[2]);
187
188         vlib_prefetch_buffer_header (p1, STORE);
189         CLIB_PREFETCH (p1->data, CLIB_CACHE_LINE_BYTES, STORE);
190         vlib_prefetch_buffer_header (p2, STORE);
191         CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE);
192       }
193
194       bi0 = from[0];
195       b0 = vlib_get_buffer (vm, bi0);
196       h0 = vlib_buffer_get_current (b0);
197
198       bi1 = from[1];
199       b1 = vlib_get_buffer (vm, bi1);
200       h1 = vlib_buffer_get_current (b1);
201
202       sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
203       vnet_buffer (b0)->l2_classify.table_index = ~0;
204
205       sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
206       vnet_buffer (b1)->l2_classify.table_index = ~0;
207
208       /* Select classifier table based on ethertype */
209       type0 = clib_net_to_host_u16 (h0->type);
210       type1 = clib_net_to_host_u16 (h1->type);
211
212       type_index0 = (type0 == ETHERNET_TYPE_IP4)
213         ? L2_OUTPUT_CLASSIFY_TABLE_IP4 : L2_OUTPUT_CLASSIFY_TABLE_OTHER;
214       type_index0 = (type0 == ETHERNET_TYPE_IP6)
215         ? L2_OUTPUT_CLASSIFY_TABLE_IP6 : type_index0;
216
217       type_index1 = (type1 == ETHERNET_TYPE_IP4)
218         ? L2_OUTPUT_CLASSIFY_TABLE_IP4 : L2_OUTPUT_CLASSIFY_TABLE_OTHER;
219       type_index1 = (type1 == ETHERNET_TYPE_IP6)
220         ? L2_OUTPUT_CLASSIFY_TABLE_IP6 : type_index1;
221
222       vnet_buffer (b0)->l2_classify.table_index =
223         table_index0 =
224         rt->l2cm->classify_table_index_by_sw_if_index
225         [type_index0][sw_if_index0];
226
227       if (table_index0 != ~0)
228         {
229           t0 = pool_elt_at_index (vcm->tables, table_index0);
230
231           vnet_buffer (b0)->l2_classify.hash = hash0 =
232             vnet_classify_hash_packet (t0, (u8 *) h0);
233           vnet_classify_prefetch_bucket (t0, hash0);
234         }
235
236       vnet_buffer (b1)->l2_classify.table_index =
237         table_index1 =
238         rt->l2cm->classify_table_index_by_sw_if_index
239         [type_index1][sw_if_index1];
240
241       if (table_index1 != ~0)
242         {
243           t1 = pool_elt_at_index (vcm->tables, table_index1);
244
245           vnet_buffer (b1)->l2_classify.hash = hash1 =
246             vnet_classify_hash_packet (t1, (u8 *) h1);
247           vnet_classify_prefetch_bucket (t1, hash1);
248         }
249
250       from += 2;
251       n_left_from -= 2;
252     }
253
254   while (n_left_from > 0)
255     {
256       vlib_buffer_t *b0;
257       u32 bi0;
258       ethernet_header_t *h0;
259       u16 type0;
260       u32 type_index0;
261       vnet_classify_table_t *t0;
262       u32 table_index0;
263       u64 hash0;
264
265       bi0 = from[0];
266       b0 = vlib_get_buffer (vm, bi0);
267       h0 = vlib_buffer_get_current (b0);
268
269       sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
270       vnet_buffer (b0)->l2_classify.table_index = ~0;
271
272       /* Select classifier table based on ethertype */
273       type0 = clib_net_to_host_u16 (h0->type);
274
275       type_index0 = (type0 == ETHERNET_TYPE_IP4)
276         ? L2_OUTPUT_CLASSIFY_TABLE_IP4 : L2_OUTPUT_CLASSIFY_TABLE_OTHER;
277       type_index0 = (type0 == ETHERNET_TYPE_IP6)
278         ? L2_OUTPUT_CLASSIFY_TABLE_IP6 : type_index0;
279
280       vnet_buffer (b0)->l2_classify.table_index =
281         table_index0 = rt->l2cm->classify_table_index_by_sw_if_index
282         [type_index0][sw_if_index0];
283
284       if (table_index0 != ~0)
285         {
286           t0 = pool_elt_at_index (vcm->tables, table_index0);
287
288           vnet_buffer (b0)->l2_classify.hash = hash0 =
289             vnet_classify_hash_packet (t0, (u8 *) h0);
290           vnet_classify_prefetch_bucket (t0, hash0);
291         }
292       from++;
293       n_left_from--;
294     }
295
296   next_index = node->cached_next_index;
297   from = vlib_frame_vector_args (frame);
298   n_left_from = frame->n_vectors;
299
300   while (n_left_from > 0)
301     {
302       u32 n_left_to_next;
303
304       vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
305
306       /* Not enough load/store slots to dual loop... */
307       while (n_left_from > 0 && n_left_to_next > 0)
308         {
309           u32 bi0;
310           vlib_buffer_t *b0;
311           u32 next0 = ~0;
312           ethernet_header_t *h0;
313           u32 table_index0;
314           u64 hash0;
315           vnet_classify_table_t *t0;
316           vnet_classify_entry_t *e0;
317
318           if (PREDICT_TRUE (n_left_from > 2))
319             {
320               vlib_buffer_t *p2 = vlib_get_buffer (vm, from[2]);
321               u64 phash2;
322               u32 table_index2;
323               vnet_classify_table_t *tp2;
324
325               /*
326                * Prefetch table entry two ahead. Buffer / data
327                * were prefetched above...
328                */
329               table_index2 = vnet_buffer (p2)->l2_classify.table_index;
330
331               if (PREDICT_TRUE (table_index2 != ~0))
332                 {
333                   tp2 = pool_elt_at_index (vcm->tables, table_index2);
334                   phash2 = vnet_buffer (p2)->l2_classify.hash;
335                   vnet_classify_prefetch_entry (tp2, phash2);
336                 }
337             }
338
339           /* speculatively enqueue b0 to the current next frame */
340           bi0 = from[0];
341           to_next[0] = bi0;
342           from += 1;
343           to_next += 1;
344           n_left_from -= 1;
345           n_left_to_next -= 1;
346
347           b0 = vlib_get_buffer (vm, bi0);
348           h0 = vlib_buffer_get_current (b0);
349           table_index0 = vnet_buffer (b0)->l2_classify.table_index;
350           e0 = 0;
351           vnet_buffer (b0)->l2_classify.opaque_index = ~0;
352           /* Remove ourself from the feature bitmap */
353           feature_bitmap0 = vnet_buffer (b0)->l2.feature_bitmap
354             & ~L2OUTPUT_FEAT_OUTPUT_CLASSIFY;
355
356           /* save for next feature graph nodes */
357           vnet_buffer (b0)->l2.feature_bitmap = feature_bitmap0;
358
359           if (PREDICT_TRUE (table_index0 != ~0))
360             {
361               hash0 = vnet_buffer (b0)->l2_classify.hash;
362               t0 = pool_elt_at_index (vcm->tables, table_index0);
363
364               e0 = vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
365               if (e0)
366                 {
367                   vnet_buffer (b0)->l2_classify.opaque_index
368                     = e0->opaque_index;
369                   vlib_buffer_advance (b0, e0->advance);
370                   next0 = (e0->next_index < n_next_nodes) ?
371                     e0->next_index : next0;
372                   hits++;
373                 }
374               else
375                 {
376                   while (1)
377                     {
378                       if (t0->next_table_index != ~0)
379                         t0 = pool_elt_at_index (vcm->tables,
380                                                 t0->next_table_index);
381                       else
382                         {
383                           next0 = (t0->miss_next_index < n_next_nodes) ?
384                             t0->miss_next_index : next0;
385                           misses++;
386                           break;
387                         }
388
389                       hash0 = vnet_classify_hash_packet (t0, (u8 *) h0);
390                       e0 =
391                         vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
392                       if (e0)
393                         {
394                           vnet_buffer (b0)->l2_classify.opaque_index
395                             = e0->opaque_index;
396                           vlib_buffer_advance (b0, e0->advance);
397                           next0 = (e0->next_index < n_next_nodes) ?
398                             e0->next_index : next0;
399                           hits++;
400                           chain_hits++;
401                           break;
402                         }
403                     }
404                 }
405             }
406
407           if (PREDICT_FALSE (next0 == 0))
408             b0->error = node->errors[L2_OUTPUT_CLASSIFY_ERROR_DROP];
409
410           if (PREDICT_FALSE (next0 == ~0))
411             {
412               sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
413
414               /* Determine next node */
415               l2_output_dispatch (cm->vlib_main,
416                                   cm->vnet_main,
417                                   node,
418                                   l2_output_classify_node.index,
419                                   &cached_sw_if_index,
420                                   &cached_next_index,
421                                   &cm->next_nodes,
422                                   b0, sw_if_index0, feature_bitmap0, &next0);
423             }
424
425           if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
426                              && (b0->flags & VLIB_BUFFER_IS_TRACED)))
427             {
428               l2_output_classify_trace_t *t =
429                 vlib_add_trace (vm, node, b0, sizeof (*t));
430               t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX];
431               t->table_index = table_index0;
432               t->next_index = next0;
433               t->session_offset = e0 ? vnet_classify_get_offset (t0, e0) : 0;
434             }
435
436           /* verify speculative enqueue, maybe switch current next frame */
437           vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
438                                            to_next, n_left_to_next,
439                                            bi0, next0);
440         }
441
442       vlib_put_next_frame (vm, node, next_index, n_left_to_next);
443     }
444
445   vlib_node_increment_counter (vm, node->node_index,
446                                L2_OUTPUT_CLASSIFY_ERROR_MISS, misses);
447   vlib_node_increment_counter (vm, node->node_index,
448                                L2_OUTPUT_CLASSIFY_ERROR_HIT, hits);
449   vlib_node_increment_counter (vm, node->node_index,
450                                L2_OUTPUT_CLASSIFY_ERROR_CHAIN_HIT,
451                                chain_hits);
452   return frame->n_vectors;
453 }
454
455 /* *INDENT-OFF* */
456 VLIB_REGISTER_NODE (l2_output_classify_node) = {
457   .function = l2_output_classify_node_fn,
458   .name = "l2-output-classify",
459   .vector_size = sizeof (u32),
460   .format_trace = format_l2_output_classify_trace,
461   .type = VLIB_NODE_TYPE_INTERNAL,
462
463   .n_errors = ARRAY_LEN(l2_output_classify_error_strings),
464   .error_strings = l2_output_classify_error_strings,
465
466   .runtime_data_bytes = sizeof (l2_output_classify_runtime_t),
467
468   .n_next_nodes = L2_OUTPUT_CLASSIFY_N_NEXT,
469
470   /* edit / add dispositions here */
471   .next_nodes = {
472     [L2_OUTPUT_CLASSIFY_NEXT_DROP]  = "error-drop",
473   },
474 };
475 /* *INDENT-ON* */
476
477 VLIB_NODE_FUNCTION_MULTIARCH (l2_output_classify_node,
478                               l2_output_classify_node_fn);
479
480 /** l2 output classsifier feature initialization */
481 clib_error_t *
482 l2_output_classify_init (vlib_main_t * vm)
483 {
484   l2_output_classify_main_t *cm = &l2_output_classify_main;
485   l2_output_classify_runtime_t *rt;
486
487   rt = vlib_node_get_runtime_data (vm, l2_output_classify_node.index);
488
489   cm->vlib_main = vm;
490   cm->vnet_main = vnet_get_main ();
491   cm->vnet_classify_main = &vnet_classify_main;
492
493   /* Initialize the feature next-node indexes */
494   feat_bitmap_init_next_nodes (vm,
495                                l2_output_classify_node.index,
496                                L2OUTPUT_N_FEAT,
497                                l2output_get_feat_names (),
498                                cm->feat_next_node_index);
499   rt->l2cm = cm;
500   rt->vcm = cm->vnet_classify_main;
501
502   /* Initialize the output node mapping table */
503   l2output_init_output_node_vec (&cm->next_nodes.output_node_index_vec);
504
505   return 0;
506 }
507
508 VLIB_INIT_FUNCTION (l2_output_classify_init);
509
510 /** enable/disable l2 input classification on a specific interface */
511 void
512 vnet_l2_output_classify_enable_disable (u32 sw_if_index, int enable_disable)
513 {
514
515   l2output_intf_bitmap_enable (sw_if_index, L2OUTPUT_FEAT_OUTPUT_CLASSIFY,
516                                (u32) enable_disable);
517 }
518
519 /** @brief Set l2 per-protocol, per-interface output classification tables
520  *
521  *  @param sw_if_index  interface handle
522  *  @param ip4_table_index  ip4 classification table index, or ~0
523  *  @param ip6_table_index  ip6 classification table index, or ~0
524  *  @param other_table_index  non-ip4, non-ip6 classification table index,
525  *         or ~0
526  *  @returns 0 on success, VNET_API_ERROR_NO_SUCH_TABLE, TABLE2, TABLE3
527  *  if the indicated (non-~0) table does not exist.
528  */
529
530 int
531 vnet_l2_output_classify_set_tables (u32 sw_if_index,
532                                     u32 ip4_table_index,
533                                     u32 ip6_table_index,
534                                     u32 other_table_index)
535 {
536   l2_output_classify_main_t *cm = &l2_output_classify_main;
537   vnet_classify_main_t *vcm = cm->vnet_classify_main;
538
539   /* Assume that we've validated sw_if_index in the API layer */
540
541   if (ip4_table_index != ~0 &&
542       pool_is_free_index (vcm->tables, ip4_table_index))
543     return VNET_API_ERROR_NO_SUCH_TABLE;
544
545   if (ip6_table_index != ~0 &&
546       pool_is_free_index (vcm->tables, ip6_table_index))
547     return VNET_API_ERROR_NO_SUCH_TABLE2;
548
549   if (other_table_index != ~0 &&
550       pool_is_free_index (vcm->tables, other_table_index))
551     return VNET_API_ERROR_NO_SUCH_TABLE3;
552
553   vec_validate
554     (cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP4],
555      sw_if_index);
556
557   vec_validate
558     (cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP6],
559      sw_if_index);
560
561   vec_validate
562     (cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_OTHER],
563      sw_if_index);
564
565   cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP4]
566     [sw_if_index] = ip4_table_index;
567
568   cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_IP6]
569     [sw_if_index] = ip6_table_index;
570
571   cm->classify_table_index_by_sw_if_index[L2_OUTPUT_CLASSIFY_TABLE_OTHER]
572     [sw_if_index] = other_table_index;
573
574   return 0;
575 }
576
577 static clib_error_t *
578 int_l2_output_classify_command_fn (vlib_main_t * vm,
579                                    unformat_input_t * input,
580                                    vlib_cli_command_t * cmd)
581 {
582   vnet_main_t *vnm = vnet_get_main ();
583   u32 sw_if_index = ~0;
584   u32 ip4_table_index = ~0;
585   u32 ip6_table_index = ~0;
586   u32 other_table_index = ~0;
587   int rv;
588
589   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
590     {
591       if (unformat (input, "intfc %U", unformat_vnet_sw_interface,
592                     vnm, &sw_if_index))
593         ;
594       else if (unformat (input, "ip4-table %d", &ip4_table_index))
595         ;
596       else if (unformat (input, "ip6-table %d", &ip6_table_index))
597         ;
598       else if (unformat (input, "other-table %d", &other_table_index))
599         ;
600       else
601         break;
602     }
603
604   if (sw_if_index == ~0)
605     return clib_error_return (0, "interface must be specified");
606
607
608   if (ip4_table_index == ~0 && ip6_table_index == ~0
609       && other_table_index == ~0)
610     {
611       vlib_cli_output (vm, "L2 classification disabled");
612       vnet_l2_output_classify_enable_disable (sw_if_index, 0 /* enable */ );
613       return 0;
614     }
615
616   rv = vnet_l2_output_classify_set_tables (sw_if_index, ip4_table_index,
617                                            ip6_table_index,
618                                            other_table_index);
619   switch (rv)
620     {
621     case 0:
622       vnet_l2_output_classify_enable_disable (sw_if_index, 1 /* enable */ );
623       break;
624
625     default:
626       return clib_error_return (0, "vnet_l2_output_classify_set_tables: %d",
627                                 rv);
628       break;
629     }
630
631   return 0;
632 }
633
634 /*?
635  * Configure l2 input classification.
636  *
637  * @cliexpar
638  * @cliexstart {set interface l2 output classify intfc <interface-name>
639  *             [ip4-table <index>]
640  *             [ip6-table <index>]
641  *             [other-table <index>]}
642  * @cliexend
643  ?*/
644
645 /* *INDENT-OFF* */
646 VLIB_CLI_COMMAND (int_l2_output_classify_cli, static) = {
647   .path = "set interface l2 output classify",
648   .short_help =
649   "set interface l2 output classify intfc <int> [ip4-table <n>]\n"
650   "  [ip6-table <n>] [other-table <n>]",
651   .function = int_l2_output_classify_command_fn,
652 };
653 /* *INDENT-ON* */
654
655 /*
656  * fd.io coding-style-patch-verification: ON
657  *
658  * Local Variables:
659  * eval: (c-set-style "gnu")
660  * End:
661  */