summaryrefslogtreecommitdiffstats
path: root/src/vnet/bier/bier_drop.c
blob: eb873acf7ba3ceccb36cad6b6edb201d95fb6e96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Copyright (c) 2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <vnet/buffer.h>
#include <vlib/vlib.h>
#include <vnet/dpo/dpo.h>

#include <vnet/bier/bier_hdr_inlines.h>

typedef struct bier_drop_trace_t_
{
    index_t dpi;
} bier_drop_trace_t;

static void
bier_drop_trace (vlib_main_t * vm,
                 vlib_node_runtime_t * node,
                 vlib_frame_t * frame)
{
  u32 *from, n_left;

  n_left = frame->n_vectors;
  from = vlib_frame_vector_args (frame);
  while (n_left >= 1)
    {
      u32 bi0;
      vlib_buffer_t *b0;
      bier_drop_trace_t *t0;

      bi0 = from[0];

      b0 = vlib_get_buffer (vm, bi0);

      if (b0->flags & VLIB_BUFFER_IS_TRACED)
      {
          t0 = vlib_add_trace (vm, node, b0, sizeof(*t0));

          t0->dpi = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
      }
      from += 1;
      n_left -= 1;
    }
}

static uword
bier_drop (vlib_main_t * vm,
           vlib_node_runtime_t * node,
           vlib_frame_t * frame)
{
    u32 *buffers = vlib_frame_vector_args (frame);
    uword n_packets = frame->n_vectors;

    vlib_error_drop_buffers (vm, node, buffers,
                             /* stride */ 1,
                             n_packets,
                             /* next */ 0,
                             0, // bier_input_node.index,
                             0);

    if (node->flags & VLIB_NODE_FLAG_TRACE)
        bier_drop_trace (vm, node, frame);

    return n_packets;
}

static u8 *
format_bier_drop_trace (u8 * s, va_list * args)
{
  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
  bier_drop_trace_t *t = va_arg (*args, bier_drop_trace_t *);

  s = format (s, "dpo-idx %d", t->dpi);

  return s;
}

/* *INDENT-OFF* */
VLIB_REGISTER_NODE (bier_drop_node, static) =
{
    .function = bier_drop,.
    name = "bier-drop",
    .vector_size = sizeof (u32),
    .format_trace = format_bier_drop_trace,
    .n_next_nodes = 1,
    .next_nodes = {
        [0] = "error-drop",
    },
};
2> /dev/null | grep -v "not inst") .PHONY: build-rpm install-rpm check-rpm $(DEV_RPM): Makefile rpm/vpp-ext-deps.spec @rpmbuild -bb \ --define "_topdir $(CURDIR)/rpm" \ --define "_version $(RPM_VER)" \ --define "_release $(PKG_SUFFIX)" \ $(CURDIR)/rpm/vpp-ext-deps.spec mv rpm/RPMS/$(RPM_ARCH)/*.rpm . @git clean -fdx rpm build-rpm: $(DEV_RPM) install-rpm: ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX)) @$(MAKE) $(DEV_RPM) sudo rpm -e vpp-ext-deps || true sudo rpm -Uih --force $(DEV_RPM) else @echo "==========================================================" @echo " Up-to-date vpp-ext-deps package already installed" @echo "==========================================================" endif check-rpm: ifneq ($(INSTALLED_RPM_VER),$(RPM_VER)-$(PKG_SUFFIX)) @echo "==========================================================" @echo " Out of date vpp-ext-deps package installed." @echo " Installed: $(INSTALLED_RPM_VER)" @echo " Needed: $(RPM_VER)-$(PKG_SUFFIX)" @echo "" @echo " Please upgrade by invoking 'make install-ext-deps'" @echo " from the top level directory." @echo "==========================================================" endif ############################################################################## # ebuild support ############################################################################## .PHONY: ebuild-build ebuild-install ebuild-build: ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),) @echo "==========================================================" @echo "Building vpp-ext-deps from source. Consider installing" @echo "development package by invoking 'make install-ext-deps'" @echo "from the top level directory" @echo "==========================================================" make config else ifneq ($(INSTALLED_VER),) make check-deb endif ifneq ($(INSTALLED_RPM_VER),) make check-rpm endif endif ebuild-install: ifeq ($(INSTALLED_VER)$(INSTALLED_RPM_VER),) make install endif