FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
l3_proxy_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 l3_proxying the packet, i.e. it's for-us
18  */
19 #include <vlib/vlib.h>
20 #include <vnet/ip/ip.h>
21 #include <vnet/dpo/l3_proxy_dpo.h>
22 
23 /**
24  * @brief pool of all l3_proxy DPOs
25  */
27 
28 static l3_proxy_dpo_t *
30 {
31  l3_proxy_dpo_t *l3p;
32 
34  clib_memset(l3p, 0, sizeof(*l3p));
35 
36  return (l3p);
37 }
38 
39 static l3_proxy_dpo_t *
41 {
42  ASSERT(DPO_L3_PROXY == dpo->dpoi_type);
43 
44  return (l3_proxy_dpo_get(dpo->dpoi_index));
45 }
46 
47 
48 /*
49  * l3_proxy_dpo_add_or_lock
50  *
51  * The next_hop address here is used for source address selection in the DP.
52  * The local adj is added to an interface's l3_proxy prefix, the next-hop
53  * passed here is the local prefix on the same interface.
54  */
55 void
58  dpo_id_t *dpo)
59 {
60  l3_proxy_dpo_t *l3p;
61 
62  l3p = l3_proxy_dpo_alloc();
63 
65 
67 }
68 
69 static void
71 {
72  l3_proxy_dpo_t *l3p;
73 
74  l3p = l3_proxy_dpo_get_from_dpo(dpo);
75  l3p->l3p_locks++;
76 }
77 
78 static void
80 {
81  l3_proxy_dpo_t *l3p;
82 
83  l3p = l3_proxy_dpo_get_from_dpo(dpo);
84  l3p->l3p_locks--;
85 
86  if (0 == l3p->l3p_locks)
87  {
89  }
90 }
91 
92 static u32
94 {
95  l3_proxy_dpo_t *l3p;
96 
97  l3p = l3_proxy_dpo_get_from_dpo(dpo);
98 
99  return (l3p->l3p_sw_if_index);
100 }
101 
102 static u8*
103 format_l3_proxy_dpo (u8 *s, va_list *ap)
104 {
105  CLIB_UNUSED(index_t index) = va_arg(*ap, index_t);
106  CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
107  vnet_main_t * vnm = vnet_get_main();
108  l3_proxy_dpo_t *l3p;
109 
111  {
112  return (format(s, "dpo-l3_proxy DELETED"));
113  }
114 
115  l3p = l3_proxy_dpo_get(index);
116 
117  if (~0 != l3p->l3p_sw_if_index)
118  {
119  return (format(s, "dpo-l3_proxy: %U",
122  }
123  else
124  {
125  return (format(s, "dpo-l3-proxy"));
126  }
127 }
128 
129 static void
131 {
132  fib_show_memory_usage("L3 Proxy",
135  sizeof(l3_proxy_dpo_t));
136 }
137 
138 const static dpo_vft_t l3_proxy_vft = {
140  .dv_unlock = l3_proxy_dpo_unlock,
141  .dv_format = format_l3_proxy_dpo,
142  .dv_get_urpf = l3_proxy_dpo_get_urpf,
143  .dv_mem_show = l3_proxy_dpo_mem_show,
144 };
145 
146 /**
147  * @brief The per-protocol VLIB graph nodes that are assigned to a l3_proxy
148  * object.
149  *
150  * this means that these graph nodes are ones from which a l3_proxy is the
151  * parent object in the DPO-graph.
152  */
153 const static char* const l3_proxy_ip4_nodes[] =
154 {
155  "ip4-local",
156  NULL,
157 };
158 const static char* const l3_proxy_ip6_nodes[] =
159 {
160  "ip6-local",
161  NULL,
162 };
163 
164 const static char* const * const l3_proxy_nodes[DPO_PROTO_NUM] =
165 {
168  [DPO_PROTO_MPLS] = NULL,
169 };
170 
171 void
173 {
175 }
vlib.h
dpo_id_t_::dpoi_index
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:190
l3_proxy_dpo_lock
static void l3_proxy_dpo_lock(dpo_id_t *dpo)
Definition: l3_proxy_dpo.c:70
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
l3_proxy_dpo.h
dpo_id_t_::dpoi_type
dpo_type_t dpoi_type
the type
Definition: dpo.h:178
l3_proxy_dpo_t_::l3p_locks
u16 l3p_locks
number oflocks.
Definition: l3_proxy_dpo.h:42
pool_get_aligned
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
Definition: pool.h:249
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vnet_get_sw_interface
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:58
l3_proxy_dpo_unlock
static void l3_proxy_dpo_unlock(dpo_id_t *dpo)
Definition: l3_proxy_dpo.c:79
l3_proxy_vft
const static dpo_vft_t l3_proxy_vft
Definition: l3_proxy_dpo.c:138
pool_is_free_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
l3_proxy_ip4_nodes
const static char *const l3_proxy_ip4_nodes[]
The per-protocol VLIB graph nodes that are assigned to a l3_proxy object.
Definition: l3_proxy_dpo.c:153
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
l3_proxy_dpo_get
static l3_proxy_dpo_t * l3_proxy_dpo_get(index_t index)
Definition: l3_proxy_dpo.h:57
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
fib_show_memory_usage
void fib_show_memory_usage(const char *name, u32 in_use_elts, u32 allocd_elts, size_t size_elt)
Show the memory usage for a type.
Definition: fib_node.c:220
l3_proxy_dpo_get_urpf
static u32 l3_proxy_dpo_get_urpf(const dpo_id_t *dpo)
Definition: l3_proxy_dpo.c:93
l3_proxy_dpo_t_
The data-path object representing L3 proxy.
Definition: l3_proxy_dpo.h:26
l3_proxy_dpo_alloc
static l3_proxy_dpo_t * l3_proxy_dpo_alloc(void)
Definition: l3_proxy_dpo.c:29
dpo_vft_t_::dv_lock
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:428
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
l3_proxy_dpo_get_from_dpo
static l3_proxy_dpo_t * l3_proxy_dpo_get_from_dpo(const dpo_id_t *dpo)
Definition: l3_proxy_dpo.c:40
l3_proxy_dpo_pool
l3_proxy_dpo_t * l3_proxy_dpo_pool
The data-path object representing l3_proxying the packet, i.e.
Definition: l3_proxy_dpo.c:26
DPO_L3_PROXY
@ DPO_L3_PROXY
Definition: dpo.h:122
vnet_main_t
Definition: vnet.h:76
pool_len
#define pool_len(p)
Number of elements in pool vector.
Definition: pool.h:139
index
u32 index
Definition: flow_types.api:221
l3_proxy_dpo_t_::l3p_sw_if_index
u32 l3p_sw_if_index
The Software interface index on which traffic is l3_proxyd.
Definition: l3_proxy_dpo.h:37
l3_proxy_nodes
const static char *const *const l3_proxy_nodes[DPO_PROTO_NUM]
Definition: l3_proxy_dpo.c:164
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
l3_proxy_dpo_add_or_lock
void l3_proxy_dpo_add_or_lock(dpo_proto_t proto, u32 sw_if_index, dpo_id_t *dpo)
Definition: l3_proxy_dpo.c:56
DPO_PROTO_MPLS
@ DPO_PROTO_MPLS
Definition: dpo.h:66
ip.h
u32
unsigned int u32
Definition: types.h:88
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
dpo_vft_t_
A virtual function table regisitered for a DPO type.
Definition: dpo.h:423
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
l3_proxy_dpo_mem_show
static void l3_proxy_dpo_mem_show(void)
Definition: l3_proxy_dpo.c:130
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
l3_proxy_ip6_nodes
const static char *const l3_proxy_ip6_nodes[]
Definition: l3_proxy_dpo.c:158
format_l3_proxy_dpo
static u8 * format_l3_proxy_dpo(u8 *s, va_list *ap)
Definition: l3_proxy_dpo.c:103
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
l3_proxy_dpo_module_init
void l3_proxy_dpo_module_init(void)
Definition: l3_proxy_dpo.c:172
DPO_PROTO_NUM
#define DPO_PROTO_NUM
Definition: dpo.h:72
format_vnet_sw_interface_name
format_function_t format_vnet_sw_interface_name
Definition: interface_funcs.h:456
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