blob: eb873acf7ba3ceccb36cad6b6edb201d95fb6e96 [file] [log] [blame]
Neale Rannsd792d9c2017-10-21 10:53:20 -07001/*
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/buffer.h>
17#include <vlib/vlib.h>
18#include <vnet/dpo/dpo.h>
19
20#include <vnet/bier/bier_hdr_inlines.h>
21
22typedef struct bier_drop_trace_t_
23{
24 index_t dpi;
25} bier_drop_trace_t;
26
27static void
28bier_drop_trace (vlib_main_t * vm,
29 vlib_node_runtime_t * node,
30 vlib_frame_t * frame)
31{
32 u32 *from, n_left;
33
34 n_left = frame->n_vectors;
35 from = vlib_frame_vector_args (frame);
36 while (n_left >= 1)
37 {
38 u32 bi0;
39 vlib_buffer_t *b0;
40 bier_drop_trace_t *t0;
41
42 bi0 = from[0];
43
44 b0 = vlib_get_buffer (vm, bi0);
45
46 if (b0->flags & VLIB_BUFFER_IS_TRACED)
47 {
48 t0 = vlib_add_trace (vm, node, b0, sizeof(*t0));
49
50 t0->dpi = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
51 }
52 from += 1;
53 n_left -= 1;
54 }
55}
56
57static uword
58bier_drop (vlib_main_t * vm,
59 vlib_node_runtime_t * node,
60 vlib_frame_t * frame)
61{
62 u32 *buffers = vlib_frame_vector_args (frame);
63 uword n_packets = frame->n_vectors;
64
65 vlib_error_drop_buffers (vm, node, buffers,
66 /* stride */ 1,
67 n_packets,
68 /* next */ 0,
69 0, // bier_input_node.index,
70 0);
71
72 if (node->flags & VLIB_NODE_FLAG_TRACE)
73 bier_drop_trace (vm, node, frame);
74
75 return n_packets;
76}
77
78static u8 *
79format_bier_drop_trace (u8 * s, va_list * args)
80{
81 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
82 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
83 bier_drop_trace_t *t = va_arg (*args, bier_drop_trace_t *);
84
85 s = format (s, "dpo-idx %d", t->dpi);
86
87 return s;
88}
89
90/* *INDENT-OFF* */
91VLIB_REGISTER_NODE (bier_drop_node, static) =
92{
93 .function = bier_drop,.
94 name = "bier-drop",
95 .vector_size = sizeof (u32),
96 .format_trace = format_bier_drop_trace,
97 .n_next_nodes = 1,
98 .next_nodes = {
99 [0] = "error-drop",
100 },
101};