Line data Source code
1 : /*
2 : * Copyright (c) 2016 Cisco and/or its affiliates.
3 : * Licensed under the Apache License, Version 2.0 (the "License");
4 : * you may not use this file except in compliance with the License.
5 : * You may obtain a copy of the License at:
6 : *
7 : * http://www.apache.org/licenses/LICENSE-2.0
8 : *
9 : * Unless required by applicable law or agreed to in writing, software
10 : * distributed under the License is distributed on an "AS IS" BASIS,
11 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : * See the License for the specific language governing permissions and
13 : * limitations under the License.
14 : */
15 :
16 : #include <vnet/buffer.h>
17 : #include <vlib/vlib.h>
18 : #include <vnet/dpo/dpo.h>
19 :
20 : #include <vnet/bier/bier_hdr_inlines.h>
21 :
22 : typedef struct bier_drop_trace_t_
23 : {
24 : index_t dpi;
25 : } bier_drop_trace_t;
26 :
27 : static void
28 5 : bier_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 5 : n_left = frame->n_vectors;
35 5 : from = vlib_frame_vector_args (frame);
36 266 : while (n_left >= 1)
37 : {
38 : u32 bi0;
39 : vlib_buffer_t *b0;
40 : bier_drop_trace_t *t0;
41 :
42 261 : bi0 = from[0];
43 :
44 261 : b0 = vlib_get_buffer (vm, bi0);
45 :
46 261 : if (b0->flags & VLIB_BUFFER_IS_TRACED)
47 : {
48 261 : t0 = vlib_add_trace (vm, node, b0, sizeof(*t0));
49 :
50 261 : t0->dpi = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
51 : }
52 261 : from += 1;
53 261 : n_left -= 1;
54 : }
55 5 : }
56 :
57 : static uword
58 5 : bier_drop (vlib_main_t * vm,
59 : vlib_node_runtime_t * node,
60 : vlib_frame_t * frame)
61 : {
62 5 : u32 *buffers = vlib_frame_vector_args (frame);
63 5 : uword n_packets = frame->n_vectors;
64 :
65 5 : if (node->flags & VLIB_NODE_FLAG_TRACE)
66 5 : bier_drop_trace (vm, node, frame);
67 :
68 5 : vlib_error_drop_buffers (vm, node, buffers,
69 : /* stride */ 1,
70 : n_packets,
71 : /* next */ 0,
72 : 0, // bier_input_node.index,
73 : 0);
74 :
75 5 : return n_packets;
76 : }
77 :
78 : static u8 *
79 312 : format_bier_drop_trace (u8 * s, va_list * args)
80 : {
81 312 : CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
82 312 : CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
83 312 : bier_drop_trace_t *t = va_arg (*args, bier_drop_trace_t *);
84 :
85 312 : s = format (s, "dpo-idx %d", t->dpi);
86 :
87 312 : return s;
88 : }
89 :
90 178120 : VLIB_REGISTER_NODE (bier_drop_node, static) =
91 : {
92 : .function = bier_drop,
93 : .name = "bier-drop",
94 : .vector_size = sizeof (u32),
95 : .format_trace = format_bier_drop_trace,
96 : .n_next_nodes = 1,
97 : .next_nodes = {
98 : [0] = "error-drop",
99 : },
100 : };
|