FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
drop_dpo.c
Go to the documentation of this file.
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  * @brief
17  * The data-path object representing dropping the packet
18  */
19 
20 #include <vnet/dpo/dpo.h>
21 
23 
24 const dpo_id_t *
26 {
28 
29  return (&drop_dpos[proto]);
30 }
31 
32 int
33 dpo_is_drop (const dpo_id_t *dpo)
34 {
35  return (dpo->dpoi_type == DPO_DROP);
36 }
37 
38 static void
40 {
41  /*
42  * not maintaining a lock count on the drop
43  * more trouble than it's worth.
44  * There always needs to be one around. no point it managing its lifetime
45  */
46 }
47 static void
49 {
50 }
51 
52 static u8*
53 format_drop_dpo (u8 *s, va_list *ap)
54 {
55  CLIB_UNUSED(index_t index) = va_arg(*ap, index_t);
56  CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
57 
58  return (format(s, "dpo-drop %U", format_dpo_proto, index));
59 }
60 
61 const static dpo_vft_t drop_vft = {
63  .dv_unlock = drop_dpo_unlock,
64  .dv_format = format_drop_dpo,
65 };
66 
67 /**
68  * @brief The per-protocol VLIB graph nodes that are assigned to a drop
69  * object.
70  *
71  * this means that these graph nodes are ones from which a drop is the
72  * parent object in the DPO-graph.
73  */
74 const static char* const drop_ip4_nodes[] =
75 {
76  "ip4-drop",
77  NULL,
78 };
79 const static char* const drop_ip6_nodes[] =
80 {
81  "ip6-drop",
82  NULL,
83 };
84 const static char* const drop_mpls_nodes[] =
85 {
86  "mpls-drop",
87  NULL,
88 };
89 const static char* const drop_ethernet_nodes[] =
90 {
91  "error-drop",
92  NULL,
93 };
94 const static char* const drop_nsh_nodes[] =
95 {
96  "error-drop",
97  NULL,
98 };
99 const static char* const drop_bier_nodes[] =
100 {
101  "bier-drop",
102  NULL,
103 };
104 const static char* const * const drop_nodes[DPO_PROTO_NUM] =
105 {
112 };
113 
114 void
116 {
118 }
dpo_is_drop
int dpo_is_drop(const dpo_id_t *dpo)
The Drop DPO will drop all packets, no questions asked.
Definition: drop_dpo.c:33
drop_ethernet_nodes
const static char *const drop_ethernet_nodes[]
Definition: drop_dpo.c:89
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
dpo_id_t_::dpoi_type
dpo_type_t dpoi_type
the type
Definition: dpo.h:178
DPO_DROP
@ DPO_DROP
Definition: dpo.h:98
DPO_PROTO_BIER
@ DPO_PROTO_BIER
Definition: dpo.h:68
drop_nsh_nodes
const static char *const drop_nsh_nodes[]
Definition: drop_dpo.c:94
drop_ip4_nodes
const static char *const drop_ip4_nodes[]
The per-protocol VLIB graph nodes that are assigned to a drop object.
Definition: drop_dpo.c:74
drop_bier_nodes
const static char *const drop_bier_nodes[]
Definition: drop_dpo.c:99
dpo.h
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
drop_dpo_lock
static void drop_dpo_lock(dpo_id_t *dpo)
Definition: drop_dpo.c:39
index_t
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:43
drop_nodes
const static char *const *const drop_nodes[DPO_PROTO_NUM]
Definition: drop_dpo.c:104
drop_dpo_unlock
static void drop_dpo_unlock(dpo_id_t *dpo)
Definition: drop_dpo.c:48
drop_ip6_nodes
const static char *const drop_ip6_nodes[]
Definition: drop_dpo.c:79
drop_vft
const static dpo_vft_t drop_vft
Definition: drop_dpo.c:61
dpo_vft_t_::dv_lock
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:428
drop_mpls_nodes
const static char *const drop_mpls_nodes[]
Definition: drop_dpo.c:84
index
u32 index
Definition: flow_types.api:221
format_drop_dpo
static u8 * format_drop_dpo(u8 *s, va_list *ap)
Definition: drop_dpo.c:53
format
description fragment has unexpected format
Definition: map.api:433
drop_dpos
static dpo_id_t drop_dpos[DPO_PROTO_NUM]
The data-path object representing dropping the packet.
Definition: drop_dpo.c:22
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
DPO_PROTO_MPLS
@ DPO_PROTO_MPLS
Definition: dpo.h:66
u32
unsigned int u32
Definition: types.h:88
drop_dpo_get
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
Definition: drop_dpo.c:25
dpo_vft_t_
A virtual function table regisitered for a DPO type.
Definition: dpo.h:423
format_dpo_proto
u8 * format_dpo_proto(u8 *s, va_list *args)
format a DPO protocol
Definition: dpo.c:180
u8
unsigned char u8
Definition: types.h:56
DPO_PROTO_IP4
@ DPO_PROTO_IP4
Definition: dpo.h:64
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
DPO_PROTO_NSH
@ DPO_PROTO_NSH
Definition: dpo.h:69
DPO_PROTO_ETHERNET
@ DPO_PROTO_ETHERNET
Definition: dpo.h:67
dpo_set
void dpo_set(dpo_id_t *dpo, dpo_type_t type, dpo_proto_t proto, index_t index)
Set/create a DPO ID The DPO will be locked.
Definition: dpo.c:188
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
DPO_PROTO_NUM
#define DPO_PROTO_NUM
Definition: dpo.h:72
dpo_register
void dpo_register(dpo_type_t type, const dpo_vft_t *vft, const char *const *const *nodes)
For a given DPO type Register:
Definition: dpo.c:329
drop_dpo_module_init
void drop_dpo_module_init(void)
Definition: drop_dpo.c:115