FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ip6_ll_dpo.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 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 performing a lookup in the IPv6
18  * link local table
19  */
20 
21 #include <vnet/dpo/ip6_ll_dpo.h>
22 #include <vnet/ip/ip6_ll_table.h>
23 
24 /**
25  * @brief the IP6 link-local DPO is global
26  */
27 static dpo_id_t ip6_ll_dpo = {
29  .dpoi_proto = DPO_PROTO_IP6,
30  .dpoi_index = 0,
31 };
32 
33 const dpo_id_t *
35 {
36  return (&ip6_ll_dpo);
37 }
38 
39 static void
41 {
42  /*
43  * not maintaining a lock count on the ip6_ll, they are const global and
44  * never die.
45  */
46 }
47 
48 static void
50 {
51 }
52 
53 static u8 *
54 format_ip6_ll_dpo (u8 * s, va_list * ap)
55 {
56  CLIB_UNUSED (index_t index) = va_arg (*ap, index_t);
57  CLIB_UNUSED (u32 indent) = va_arg (*ap, u32);
58 
59  return (format (s, "ip6-link-local"));
60 }
61 
62 const static dpo_vft_t ip6_ll_vft = {
64  .dv_unlock = ip6_ll_dpo_unlock,
65  .dv_format = format_ip6_ll_dpo,
66 };
67 
68 /**
69  * @brief The per-protocol VLIB graph nodes that are assigned to a ip6_ll
70  * object.
71  *
72  * this means that these graph nodes are ones from which a ip6_ll is the
73  * parent object in the DPO-graph.
74  */
75 const static char *const ip6_null_nodes[] = {
76  "ip6-link-local",
77  NULL,
78 };
79 
80 const static char *const *const ip6_ll_nodes[DPO_PROTO_NUM] = {
82 };
83 
84 typedef struct ip6_ll_dpo_trace_t_
85 {
89 
90 /**
91  * @brief Exit nodes from a IP6_LL
92  */
93 typedef enum ip6_ll_next_t_
94 {
99 
103 {
104  u32 n_left_from, next_index, *from, *to_next;
105 
107  n_left_from = frame->n_vectors;
108  next_index = node->cached_next_index;
109 
110  while (n_left_from > 0)
111  {
112  u32 n_left_to_next;
113 
114  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
115 
116  while (n_left_from > 0 && n_left_to_next > 0)
117  {
118  u32 bi0, fib_index0, next0;
119  vlib_buffer_t *p0;
120 
121  bi0 = from[0];
122  to_next[0] = bi0;
123  from += 1;
124  to_next += 1;
125  n_left_from -= 1;
126  n_left_to_next -= 1;
127  next0 = IP6_LL_NEXT_LOOKUP;
128 
129  p0 = vlib_get_buffer (vm, bi0);
130 
131  /* use the packet's RX interface to pick the link-local FIB */
132  fib_index0 =
134  /* write that fib index into the packet so it's used in the
135  * lookup node next */
136  vnet_buffer (p0)->sw_if_index[VLIB_TX] = fib_index0;
137 
138  if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED))
139  {
141  sizeof (*tr));
142  tr->sw_if_index = vnet_buffer (p0)->sw_if_index[VLIB_RX];
143  tr->fib_index = fib_index0;
144  }
146  n_left_to_next, bi0, next0);
147  }
148 
149  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
150  }
151 
152  return frame->n_vectors;
153 }
154 
155 static u8 *
156 format_ip6_ll_dpo_trace (u8 * s, va_list * args)
157 {
158  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
159  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
160  ip6_ll_dpo_trace_t *t = va_arg (*args, ip6_ll_dpo_trace_t *);
161 
162  s = format (s, "sw_if_index:%d fib_index:%d", t->sw_if_index, t->fib_index);
163  return s;
164 }
165 
166 static uword
169 {
170  return (ip6_ll_dpo_inline (vm, node, frame));
171 }
172 
173 /**
174  * @brief
175  */
176 /* *INDENT-OFF* */
178 {
179  .function = ip6_ll_dpo_switch,
180  .name = "ip6-link-local",
181  .vector_size = sizeof (u32),
182  .format_trace = format_ip6_ll_dpo_trace,
183  .n_next_nodes = IP6_LL_NEXT_NUM,
184  .next_nodes = {
185  [IP6_LL_NEXT_DROP] = "ip6-drop",
186  [IP6_LL_NEXT_LOOKUP] = "ip6-lookup",
187  },
188 };
189 /* *INDENT-ON* */
190 
191 void
193 {
195 }
196 
197 /*
198  * fd.io coding-style-patch-verification: ON
199  *
200  * Local Variables:
201  * eval: (c-set-style "gnu")
202  * End:
203  */
ip6_null_nodes
const static char *const ip6_null_nodes[]
The per-protocol VLIB graph nodes that are assigned to a ip6_ll object.
Definition: ip6_ll_dpo.c:75
ip6_ll_dpo.h
ip6_ll_dpo
static dpo_id_t ip6_ll_dpo
The data-path object representing performing a lookup in the IPv6 link local table.
Definition: ip6_ll_dpo.c:27
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
dpo_id_t_::dpoi_type
dpo_type_t dpoi_type
the type
Definition: dpo.h:178
IP6_LL_NEXT_DROP
@ IP6_LL_NEXT_DROP
Definition: ip6_ll_dpo.c:95
ip6_ll_dpo_get
const dpo_id_t * ip6_ll_dpo_get(void)
The IP6 link-local DPO represents the lookup of a packet in the link-local IPv6 FIB.
Definition: ip6_ll_dpo.c:34
ip6_ll_dpo_trace_t_::fib_index
u32 fib_index
Definition: ip6_ll_dpo.c:86
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
ip6_ll_dpo_module_init
void ip6_ll_dpo_module_init(void)
Definition: ip6_ll_dpo.c:192
ip6_ll_dpo_trace_t_
Definition: ip6_ll_dpo.c:84
ip6_ll_dpo_trace_t
struct ip6_ll_dpo_trace_t_ ip6_ll_dpo_trace_t
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
VLIB_RX
@ VLIB_RX
Definition: defs.h:46
vlib_frame_t
Definition: node.h:372
format_ip6_ll_dpo
static u8 * format_ip6_ll_dpo(u8 *s, va_list *ap)
Definition: ip6_ll_dpo.c:54
ip6_ll_table.h
DPO_IP6_LL
@ DPO_IP6_LL
Definition: dpo.h:128
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
ip6_ll_dpo_unlock
static void ip6_ll_dpo_unlock(dpo_id_t *dpo)
Definition: ip6_ll_dpo.c:49
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
uword
u64 uword
Definition: types.h:112
ip6_ll_next_t_
ip6_ll_next_t_
Exit nodes from a IP6_LL.
Definition: ip6_ll_dpo.c:93
ip6_ll_nodes
const static char *const *const ip6_ll_nodes[DPO_PROTO_NUM]
Definition: ip6_ll_dpo.c:80
dpo_vft_t_::dv_lock
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:428
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
format_ip6_ll_dpo_trace
static u8 * format_ip6_ll_dpo_trace(u8 *s, va_list *args)
Definition: ip6_ll_dpo.c:156
vlib_validate_buffer_enqueue_x1
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:224
index
u32 index
Definition: flow_types.api:221
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
IP6_LL_NEXT_NUM
@ IP6_LL_NEXT_NUM
Definition: ip6_ll_dpo.c:97
ip6_ll_dpo_node
vlib_node_registration_t ip6_ll_dpo_node
(constructor) VLIB_REGISTER_NODE (ip6_ll_dpo_node)
Definition: ip6_ll_dpo.c:177
format
description fragment has unexpected format
Definition: map.api:433
ip6_ll_dpo_inline
static uword ip6_ll_dpo_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ip6_ll_dpo.c:101
ip6_ll_dpo_switch
static uword ip6_ll_dpo_switch(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ip6_ll_dpo.c:167
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
u32
unsigned int u32
Definition: types.h:88
ip6_ll_vft
const static dpo_vft_t ip6_ll_vft
Definition: ip6_ll_dpo.c:62
ip6_ll_dpo_lock
static void ip6_ll_dpo_lock(dpo_id_t *dpo)
Definition: ip6_ll_dpo.c:40
ip6_ll_dpo_trace_t_::sw_if_index
u32 sw_if_index
Definition: ip6_ll_dpo.c:87
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
dpo_vft_t_
A virtual function table regisitered for a DPO type.
Definition: dpo.h:423
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
u8
unsigned char u8
Definition: types.h:56
ip6_ll_next_t
enum ip6_ll_next_t_ ip6_ll_next_t
Exit nodes from a IP6_LL.
ip6_ll_fib_get
u32 ip6_ll_fib_get(u32 sw_if_index)
For use in the data plane.
Definition: ip6_ll_table.c:28
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
IP6_LL_NEXT_LOOKUP
@ IP6_LL_NEXT_LOOKUP
Definition: ip6_ll_dpo.c:96
vlib_node_runtime_t
Definition: node.h:454
from
from
Definition: nat44_ei_hairpinning.c:415
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
vlib_get_next_frame
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:395
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
DPO_PROTO_NUM
#define DPO_PROTO_NUM
Definition: dpo.h:72
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
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
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169