FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ad-flow.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 /*
17  *------------------------------------------------------------------
18  * ad-flow.c - SRv6 Flow-based Dynamic Proxy (AD.Flow) behavior
19  *------------------------------------------------------------------
20  */
21 
22 #include <vnet/vnet.h>
23 #include <vnet/adj/adj.h>
24 #include <vnet/plugin/plugin.h>
25 #include <vpp/app/version.h>
26 #include <srv6-ad-flow/ad-flow.h>
27 
29 
30 #define SID_CREATE_IFACE_FEATURE_ERROR -1
31 #define SID_CREATE_INVALID_IFACE_TYPE -3
32 #define SID_CREATE_INVALID_IFACE_INDEX -4
33 #define SID_CREATE_INVALID_ADJ_INDEX -5
34 
35 unsigned char function_name[] = "SRv6-AD-Flow-plugin";
36 unsigned char keyword_str[] = "End.AD.Flow";
37 unsigned char def_str[] =
38  "Endpoint with flow-based dynamic proxy to SR-unaware appliance";
39 unsigned char params_str[] = "nh <next-hop> oif <iface-out> iif <iface-in>";
40 
42 
43 static u32
45 {
46  return 1 << (max_log2 (n_elts >> 1) + 1);
47 }
48 
49 static u32
50 ad_flow_calc_bihash_memory (u32 n_buckets, uword kv_size)
51 {
52  return n_buckets * (8 + kv_size * 4);
53 }
54 
55 /*****************************************/
56 /* SRv6 LocalSID instantiation and removal functions */
57 static int
59 {
60  ip6_sr_main_t *srm = &sr_main;
62  srv6_ad_flow_localsid_t *ls_mem = localsid->plugin_mem;
63  u32 localsid_index = localsid - srm->localsids;
64 
65  /* Step 1: Prepare xconnect adjacency for sending packets to the VNF */
66 
67  /* Retrieve the adjacency corresponding to the (OIF, next_hop) */
68  adj_index_t nh_adj_index = ADJ_INDEX_INVALID;
69  if (ls_mem->inner_type == AD_TYPE_IP4)
70  nh_adj_index =
72  ls_mem->sw_if_index_out);
73  else if (ls_mem->inner_type == AD_TYPE_IP6)
74  nh_adj_index =
76  ls_mem->sw_if_index_out);
77 
78  if (nh_adj_index == ADJ_INDEX_INVALID)
79  {
80  clib_mem_free (ls_mem);
82  }
83 
84  ls_mem->nh_adj = nh_adj_index;
85 
86  /* Step 2: Prepare inbound policy for packets returning from the VNF */
87 
88  /* Sanitise the SW_IF_INDEX */
90  ls_mem->sw_if_index_in))
91  {
92  adj_unlock (ls_mem->nh_adj);
93  clib_mem_free (ls_mem);
95  }
96 
100  {
101  adj_unlock (ls_mem->nh_adj);
102  clib_mem_free (ls_mem);
104  }
105 
106  if (ls_mem->inner_type == AD_TYPE_IP4)
107  {
108  /* Enable End.AD4 rewrite node for this interface */
109  int ret =
110  vnet_feature_enable_disable ("ip4-unicast", "srv6-ad4-flow-rewrite",
111  ls_mem->sw_if_index_in, 1, 0, 0);
112  if (ret != 0)
113  {
114  adj_unlock (ls_mem->nh_adj);
115  clib_mem_free (ls_mem);
117  }
118 
119  /* Associate local SID index to this interface (resize vector if needed)
120  */
121  if (ls_mem->sw_if_index_in >= vec_len (sm->sw_iface_localsid4))
122  {
125  vec_len (sm->sw_iface_localsid4)));
126  }
127  sm->sw_iface_localsid4[ls_mem->sw_if_index_in] = localsid_index;
128  }
129  else if (ls_mem->inner_type == AD_TYPE_IP6)
130  {
131  /* Enable End.AD6 rewrite node for this interface */
132  int ret =
133  vnet_feature_enable_disable ("ip6-unicast", "srv6-ad6-flow-rewrite",
134  ls_mem->sw_if_index_in, 1, 0, 0);
135  if (ret != 0)
136  {
137  adj_unlock (ls_mem->nh_adj);
138  clib_mem_free (ls_mem);
140  }
141 
142  /* Associate local SID index to this interface (resize vector if needed)
143  */
144  if (ls_mem->sw_if_index_in >= vec_len (sm->sw_iface_localsid6))
145  {
148  vec_len (sm->sw_iface_localsid6)));
149  }
150  sm->sw_iface_localsid6[ls_mem->sw_if_index_in] = localsid_index;
151  }
152 
153  /* Initialize flow and cache tables */
157  ls_mem->cache_buckets, sizeof (clib_bihash_40_8_t));
158 
159  pool_alloc (ls_mem->cache, ls_mem->cache_size);
160  pool_alloc (ls_mem->lru_pool, ls_mem->cache_size);
161 
162  dlist_elt_t *head;
163  pool_get (ls_mem->lru_pool, head);
164  ls_mem->lru_head_index = head - ls_mem->lru_pool;
165  clib_dlist_init (ls_mem->lru_pool, ls_mem->lru_head_index);
166 
167  clib_bihash_init_40_8 (&ls_mem->ftable, "ad-flow", ls_mem->cache_buckets,
168  ls_mem->cache_memory_size);
169 
170  /* Step 3: Initialize rewrite counters */
172  pool_get (sm->sids, ls_p);
173  *ls_p = ls_mem;
174  ls_mem->index = ls_p - sm->sids;
175 
179  ls_mem->index);
182 
188 
189  return 0;
190 }
191 
192 static int
194 {
196  srv6_ad_flow_localsid_t *ls_mem = localsid->plugin_mem;
197 
198  if (ls_mem->inner_type == AD_TYPE_IP4)
199  {
200  /* Disable End.AD4 rewrite node for this interface */
201  int ret =
202  vnet_feature_enable_disable ("ip4-unicast", "srv6-ad4-flow-rewrite",
203  ls_mem->sw_if_index_in, 0, 0, 0);
204  if (ret != 0)
205  return -1;
206 
207  /* Remove local SID pointer from interface table */
208  sm->sw_iface_localsid4[ls_mem->sw_if_index_in] = ~(u32) 0;
209  }
210  else if (ls_mem->inner_type == AD_TYPE_IP6)
211  {
212  /* Disable End.AD6 rewrite node for this interface */
213  int ret =
214  vnet_feature_enable_disable ("ip6-unicast", "srv6-ad6-flow-rewrite",
215  ls_mem->sw_if_index_in, 0, 0, 0);
216  if (ret != 0)
217  return -1;
218 
219  /* Remove local SID pointer from interface table */
220  sm->sw_iface_localsid6[ls_mem->sw_if_index_in] = ~(u32) 0;
221  }
222 
223  /* Unlock (OIF, NHOP) adjacency */
224  adj_unlock (ls_mem->nh_adj);
225 
226  /* Delete SID entry */
227  pool_put (sm->sids, pool_elt_at_index (sm->sids, ls_mem->index));
228 
229  /* Clean up local SID memory */
231  pool_foreach (e, ls_mem->cache)
232  {
233  vec_free (e->rw_data);
234  }
235  pool_free (ls_mem->cache);
236  pool_free (ls_mem->lru_pool);
237  clib_bihash_free_40_8 (&ls_mem->ftable);
238  clib_mem_free (localsid->plugin_mem);
239 
240  return 0;
241 }
242 
243 /**********************************/
244 /* SRv6 LocalSID format functions */
245 /*
246  * Prints nicely the parameters of a localsid
247  * Example: print "Table 5"
248  */
249 u8 *
250 format_srv6_ad_flow_localsid (u8 *s, va_list *args)
251 {
252  srv6_ad_flow_localsid_t *ls_mem = va_arg (*args, void *);
253 
254  vnet_main_t *vnm = vnet_get_main ();
256 
257  if (ls_mem->inner_type == AD_TYPE_IP4)
258  {
259  s = format (s, "Next-hop:\t%U\n\t", format_ip4_address,
260  &ls_mem->nh_addr.ip4);
261  }
262  else if (ls_mem->inner_type == AD_TYPE_IP6)
263  {
264  s = format (s, "Next-hop:\t%U\n\t", format_ip6_address,
265  &ls_mem->nh_addr.ip6);
266  }
267 
268  s = format (s, "Outgoing iface:\t%U\n", format_vnet_sw_if_index_name, vnm,
269  ls_mem->sw_if_index_out);
270  s = format (s, "\tIncoming iface:\t%U\n", format_vnet_sw_if_index_name, vnm,
271  ls_mem->sw_if_index_in);
272 
273  vlib_counter_t sid_bypass, sid_punt, sid_full, rw_valid, rw_invalid;
275  &sid_bypass);
277  &sid_punt);
279  &sid_full);
281  &rw_valid);
283  &rw_invalid);
284 
285  s =
286  format (s, "\tTraffic that bypassed the NF: \t[%Ld packets : %Ld bytes]\n",
287  sid_bypass.packets, sid_bypass.bytes);
288  s = format (s, "\tPunted traffic: \t[%Ld packets : %Ld bytes]\n",
289  sid_punt.packets, sid_punt.bytes);
290  s =
291  format (s, "\tDropped traffic (cache full): \t[%Ld packets : %Ld bytes]\n",
292  sid_full.packets, sid_full.bytes);
293  s = format (s, "\tGood rewrite traffic: \t[%Ld packets : %Ld bytes]\n",
294  rw_valid.packets, rw_valid.bytes);
295  s = format (s, "\tBad rewrite traffic: \t[%Ld packets : %Ld bytes]\n",
296  rw_invalid.packets, rw_invalid.bytes);
297 
298  return s;
299 }
300 
301 /*
302  * Process the parameters of a localsid
303  * Example: process from:
304  * sr localsid address cafe::1 behavior new_srv6_localsid 5
305  * everything from behavior on... so in this case 'new_srv6_localsid 5'
306  * Notice that it MUST match the keyword_str and params_str defined above.
307  */
308 uword
310 {
311  void **plugin_mem_p = va_arg (*args, void **);
312  srv6_ad_flow_localsid_t *ls_mem;
313 
314  vnet_main_t *vnm = vnet_get_main ();
315 
316  u8 inner_type = AD_TYPE_IP4;
317  ip46_address_t nh_addr;
318  u32 sw_if_index_out;
319  u32 sw_if_index_in;
320 
321  u8 params = 0;
322 #define PARAM_AD_NH (1 << 0)
323 #define PARAM_AD_OIF (1 << 1)
324 #define PARAM_AD_IIF (1 << 2)
325 
326  if (!unformat (input, "end.ad.flow"))
327  return 0;
328 
330  {
331  if (!(params & PARAM_AD_NH) &&
332  unformat (input, "nh %U", unformat_ip4_address, &nh_addr.ip4))
333  {
334  inner_type = AD_TYPE_IP4;
335  params |= PARAM_AD_NH;
336  }
337  if (!(params & PARAM_AD_NH) &&
338  unformat (input, "nh %U", unformat_ip6_address, &nh_addr.ip6))
339  {
340  inner_type = AD_TYPE_IP6;
341  params |= PARAM_AD_NH;
342  }
343  else if (!(params & PARAM_AD_OIF) &&
344  unformat (input, "oif %U", unformat_vnet_sw_interface, vnm,
345  &sw_if_index_out))
346  {
347  params |= PARAM_AD_OIF;
348  }
349  else if (!(params & PARAM_AD_IIF) &&
350  unformat (input, "iif %U", unformat_vnet_sw_interface, vnm,
351  &sw_if_index_in))
352  {
353  params |= PARAM_AD_IIF;
354  }
355  else
356  {
357  break;
358  }
359  }
360 
361  /* Make sure that all parameters are supplied */
362  u8 params_chk = (PARAM_AD_NH | PARAM_AD_OIF | PARAM_AD_IIF);
363  if ((params & params_chk) != params_chk)
364  {
365  return 0;
366  }
367 
368  /* Allocate and initialize memory block for local SID parameters */
369  ls_mem = clib_mem_alloc_aligned_at_offset (sizeof *ls_mem, 0, 0, 1);
370  clib_memset (ls_mem, 0, sizeof *ls_mem);
371  *plugin_mem_p = ls_mem;
372 
373  /* Set local SID parameters */
374  ls_mem->inner_type = inner_type;
375  if (inner_type == AD_TYPE_IP4)
376  ls_mem->nh_addr.ip4 = nh_addr.ip4;
377  else if (inner_type == AD_TYPE_IP6)
378  ls_mem->nh_addr.ip6 = nh_addr.ip6;
379  ls_mem->sw_if_index_out = sw_if_index_out;
380  ls_mem->sw_if_index_in = sw_if_index_in;
381 
382  return 1;
383 }
384 
385 /*************************/
386 /* SRv6 LocalSID FIB DPO */
387 static u8 *
388 format_srv6_ad_flow_dpo (u8 *s, va_list *args)
389 {
390  index_t index = va_arg (*args, index_t);
391  CLIB_UNUSED (u32 indent) = va_arg (*args, u32);
392 
393  return (format (s, "SR: dynamic_proxy_index:[%u]", index));
394 }
395 
396 void
398 {
399 }
400 
401 void
403 {
404 }
405 
406 const static dpo_vft_t srv6_ad_flow_vft = {
408  .dv_unlock = srv6_ad_flow_dpo_unlock,
409  .dv_format = format_srv6_ad_flow_dpo,
410 };
411 
412 const static char *const srv6_ad_flow_ip6_nodes[] = {
413  "srv6-ad-flow-localsid",
414  NULL,
415 };
416 
417 const static char *const *const srv6_ad_flow_nodes[DPO_PROTO_NUM] = {
419 };
420 
421 /**********************/
422 static clib_error_t *
424 {
426  int rv = 0;
427 
428  sm->vlib_main = vm;
429  sm->vnet_main = vnet_get_main ();
430 
431  /* Create DPO */
434 
435  /* Register SRv6 LocalSID */
441  if (rv < 0)
442  clib_error_return (0, "SRv6 LocalSID function could not be registered.");
443  else
445 
446  return 0;
447 }
448 
449 VNET_FEATURE_INIT (srv6_ad4_flow_rewrite, static) = {
450  .arc_name = "ip4-unicast",
451  .node_name = "srv6-ad4-flow-rewrite",
452  .runs_before = 0,
453 };
454 
455 VNET_FEATURE_INIT (srv6_ad6_flow_rewrite, static) = {
456  .arc_name = "ip6-unicast",
457  .node_name = "srv6-ad6-flow-rewrite",
458  .runs_before = 0,
459 };
460 
462 
464  .version = VPP_BUILD_VER,
465  .description = "Dynamic Segment Routing for IPv6 (SRv6) Proxy",
466 };
467 
468 /*
469  * fd.io coding-style-patch-verification: ON
470  *
471  * Local Variables:
472  * eval: (c-set-style "gnu")
473  * End:
474  */
unformat_srv6_ad_flow_localsid
uword unformat_srv6_ad_flow_localsid(unformat_input_t *input, va_list *args)
Definition: ad-flow.c:309
srv6_ad_flow_main_t::srv6_localsid_behavior_id
u32 srv6_localsid_behavior_id
SRv6 LocalSID behavior number.
Definition: ad-flow.h:98
def_str
unsigned char def_str[]
Definition: ad-flow.c:37
clib_dlist_init
static void clib_dlist_init(dlist_elt_t *pool, u32 index)
Definition: dlist.h:36
adj.h
srv6_ad_flow_localsid_t::cache_buckets
u32 cache_buckets
Definition: ad-flow.h:78
dpo_register_new_type
dpo_type_t dpo_register_new_type(const dpo_vft_t *vft, const char *const *const *nodes)
Create and register a new DPO type.
Definition: dpo.c:349
bihash_template.c
vnet_sw_interface_t::type
vnet_sw_interface_type_t type
Definition: interface.h:871
vnet_sw_interface_t
Definition: interface.h:869
format_ip4_address
format_function_t format_ip4_address
Definition: format.h:73
SRV6_AD_FLOW_DEFAULT_CACHE_SIZE
#define SRV6_AD_FLOW_DEFAULT_CACHE_SIZE
Definition: ad-flow.h:32
adj_nbr_add_or_lock
adj_index_t adj_nbr_add_or_lock(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Neighbour Adjacency sub-type.
Definition: adj_nbr.c:257
srv6_ad_flow_localsid_t::cache
srv6_ad_flow_entry_t * cache
Cache table.
Definition: ad-flow.h:82
ADJ_INDEX_INVALID
#define ADJ_INDEX_INVALID
Invalid ADJ index - used when no adj is known likewise blazoned capitals INVALID speak volumes where ...
Definition: adj_types.h:36
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
ip6_sr_localsid_t
SR LocalSID.
Definition: sr.h:123
sr_localsid_register_function
int sr_localsid_register_function(vlib_main_t *vm, u8 *fn_name, u8 *keyword_str, u8 *def_str, u8 *params_str, u8 prefix_length, dpo_type_t *dpo, format_function_t *ls_format, unformat_function_t *ls_unformat, sr_plugin_callback_t *creation_fn, sr_plugin_callback_t *removal_fn)
SR LocalSID plugin registry.
Definition: sr_localsid.c:2347
SID_CREATE_INVALID_IFACE_TYPE
#define SID_CREATE_INVALID_IFACE_TYPE
Definition: ad-flow.c:31
clib_mem_free
static void clib_mem_free(void *p)
Definition: mem.h:314
ip6_sr_localsid_t::plugin_mem
void * plugin_mem
Memory to be used by the plugin callback functions.
Definition: sr.h:156
PARAM_AD_IIF
#define PARAM_AD_IIF
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
PARAM_AD_OIF
#define PARAM_AD_OIF
AD_TYPE_IP4
#define AD_TYPE_IP4
Definition: ad.h:27
adj_unlock
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
Definition: adj.c:358
srv6_ad_flow_localsid_removal_fn
static int srv6_ad_flow_localsid_removal_fn(ip6_sr_localsid_t *localsid)
Definition: ad-flow.c:193
vlib_validate_combined_counter
void vlib_validate_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
validate a combined counter
Definition: counter.c:119
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
srv6_ad_flow_localsid_t::inner_type
u8 inner_type
Definition: ad-flow.h:73
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
unformat_input_t
struct _unformat_input_t unformat_input_t
srv6_ad_flow_localsid_t::cache_memory_size
uword cache_memory_size
Definition: ad-flow.h:79
srv6_ad_flow_main_t::vlib_main
vlib_main_t * vlib_main
[convenience] vlib main
Definition: ad-flow.h:93
srv6_ad_flow_localsid_t::sw_if_index_in
u32 sw_if_index_in
Incoming iface from proxied dev.
Definition: ad-flow.h:75
srv6_ad_flow_main_t::rw_valid_counters
vlib_combined_counter_main_t rw_valid_counters
Valid rewrite counters.
Definition: ad-flow.h:112
srv6_ad_flow_localsid_t::index
u32 index
Definition: ad-flow.h:86
srv6_ad_flow_main_t::sw_iface_localsid6
u32 * sw_iface_localsid6
Retrieve local SID from iface.
Definition: ad-flow.h:102
max_log2
static uword max_log2(uword x)
Definition: clib.h:223
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
ad_flow_calc_bihash_memory
static u32 ad_flow_calc_bihash_memory(u32 n_buckets, uword kv_size)
Definition: ad-flow.c:50
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
ad_flow_calc_bihash_buckets
static u32 ad_flow_calc_bihash_buckets(u32 n_elts)
Definition: ad-flow.c:44
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
AD_TYPE_IP6
#define AD_TYPE_IP6
Definition: ad.h:28
VNET_LINK_IP4
@ VNET_LINK_IP4
Definition: interface.h:344
srv6_ad_flow_localsid_t
Definition: ad-flow.h:68
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
srv6_ad_flow_localsid_t::ftable
clib_bihash_40_8_t ftable
Flow table.
Definition: ad-flow.h:81
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
vlib_counter_t
Combined counter to hold both packets and byte differences.
Definition: counter_types.h:26
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
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
vlib_zero_combined_counter
static void vlib_zero_combined_counter(vlib_combined_counter_main_t *cm, u32 index)
Clear a combined counter Clears the set of per-thread counters.
Definition: counter.h:298
srv6_ad_flow_main_t
Definition: ad-flow.h:89
srv6_ad_flow_main
srv6_ad_flow_main_t srv6_ad_flow_main
Definition: ad-flow.c:41
keyword_str
unsigned char keyword_str[]
Definition: ad-flow.c:36
params_str
unsigned char params_str[]
Definition: ad-flow.c:39
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
dlist_elt_t
Definition: dlist.h:28
srv6_ad_flow_entry_t
Definition: ad-flow.h:38
dpo_vft_t_::dv_lock
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:428
srv6_ad_flow_localsid_t::lru_pool
dlist_elt_t * lru_pool
Definition: ad-flow.h:83
srv6_ad_flow_localsid_t::nh_adj
u32 nh_adj
Adjacency index for out.
Definition: ad-flow.h:72
srv6_ad_flow_dpo_lock
void srv6_ad_flow_dpo_lock(dpo_id_t *dpo)
Definition: ad-flow.c:397
function_name
unsigned char function_name[]
Definition: ad-flow.c:35
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
vlib_counter_t::packets
counter_t packets
packet counter
Definition: counter_types.h:28
format_srv6_ad_flow_localsid
u8 * format_srv6_ad_flow_localsid(u8 *s, va_list *args)
Definition: ad-flow.c:250
vnet_interface_main_t::sw_interfaces
vnet_sw_interface_t * sw_interfaces
Definition: interface.h:1015
sr_main
ip6_sr_main_t sr_main
Definition: sr.c:31
srv6_ad_flow_main_t::srv6_ad_flow_dpo_type
dpo_type_t srv6_ad_flow_dpo_type
DPO type.
Definition: ad-flow.h:96
ip6_sr_main_t::localsids
ip6_sr_localsid_t * localsids
Definition: sr.h:273
VLIB_PLUGIN_REGISTER
VLIB_PLUGIN_REGISTER()
srv6_ad_flow_init
static clib_error_t * srv6_ad_flow_init(vlib_main_t *vm)
Definition: ad-flow.c:423
srv6_ad_flow_main_t::sid_bypass_counters
vlib_combined_counter_main_t sid_bypass_counters
Packets/bytes bypassing NF.
Definition: ad-flow.h:107
plugin.h
format_srv6_ad_flow_dpo
static u8 * format_srv6_ad_flow_dpo(u8 *s, va_list *args)
Definition: ad-flow.c:388
vlib_get_combined_counter
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
Definition: counter.h:272
ip6_sr_main_t
Segment Routing main datastructure.
Definition: sr.h:258
srv6_ad_flow_main_t::sid_punt_counters
vlib_combined_counter_main_t sid_punt_counters
Packets/bytes punted.
Definition: ad-flow.h:108
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
pool_len
#define pool_len(p)
Number of elements in pool vector.
Definition: pool.h:139
srv6_ad_flow_localsid_creation_fn
static int srv6_ad_flow_localsid_creation_fn(ip6_sr_localsid_t *localsid)
Definition: ad-flow.c:58
index
u32 index
Definition: flow_types.api:221
srv6_ad_flow_main_t::vnet_main
vnet_main_t * vnet_main
[convenience] vnet main
Definition: ad-flow.h:94
srv6_ad_flow_localsid_t::sw_if_index_out
u32 sw_if_index_out
Outgoing iface to proxied dev.
Definition: ad-flow.h:71
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:458
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:462
format
description fragment has unexpected format
Definition: map.api:433
srv6_ad_flow_main_t::sw_iface_localsid4
u32 * sw_iface_localsid4
Retrieve local SID from iface.
Definition: ad-flow.h:101
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
srv6_ad_flow_main_t::sids
srv6_ad_flow_localsid_t ** sids
Pool of AD SID pointers.
Definition: ad-flow.h:104
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
SID_CREATE_INVALID_ADJ_INDEX
#define SID_CREATE_INVALID_ADJ_INDEX
Definition: ad-flow.c:33
srv6_ad_flow_main_t::sid_cache_full_counters
vlib_combined_counter_main_t sid_cache_full_counters
Definition: ad-flow.h:109
vlib_counter_t::bytes
counter_t bytes
byte counter
Definition: counter_types.h:29
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
nh_addr
vl_api_address_t nh_addr
Definition: lisp_gpe.api:222
srv6_ad_flow_ip6_nodes
const static char *const srv6_ad_flow_ip6_nodes[]
Definition: ad-flow.c:412
vec_resize
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V,...
Definition: vec.h:296
PARAM_AD_NH
#define PARAM_AD_NH
srv6_ad_flow_main_t::rw_invalid_counters
vlib_combined_counter_main_t rw_invalid_counters
Invalid rewrite counters.
Definition: ad-flow.h:114
vnet_feature_enable_disable
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
Definition: pnat_test_stubs.h:50
adj_index_t
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
VNET_FEATURE_INIT
VNET_FEATURE_INIT(srv6_ad4_flow_rewrite, static)
dpo_vft_t_
A virtual function table regisitered for a DPO type.
Definition: dpo.h:423
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
VNET_LINK_IP6
@ VNET_LINK_IP6
Definition: interface.h:348
srv6_ad_flow_vft
const static dpo_vft_t srv6_ad_flow_vft
Definition: ad-flow.c:406
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
format_ip6_address
format_function_t format_ip6_address
Definition: format.h:91
srv6_ad_flow_localsid_t::cache_size
u32 cache_size
Definition: ad-flow.h:77
ad-flow.h
pool_free
#define pool_free(p)
Free a pool.
Definition: pool.h:447
srv6_ad_flow_localsid_t::lru_head_index
u32 lru_head_index
Definition: ad-flow.h:84
clib_mem_alloc_aligned_at_offset
static void * clib_mem_alloc_aligned_at_offset(uword size, uword align, uword align_offset, int os_out_of_memory_on_failure)
Definition: mem.h:225
pool_alloc
#define pool_alloc(P, N)
Allocate N more free elements to pool (unspecified alignment).
Definition: pool.h:367
srv6_ad_flow_localsid_t::nh_addr
ip46_address_t nh_addr
Proxied device address.
Definition: ad-flow.h:70
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
unformat_ip6_address
unformat_function_t unformat_ip6_address
Definition: format.h:89
srv6_ad_flow_entry_t::rw_data
u8 * rw_data
Definition: ad-flow.h:52
rv
int __clib_unused rv
Definition: application.c:491
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
SID_CREATE_IFACE_FEATURE_ERROR
#define SID_CREATE_IFACE_FEATURE_ERROR
Definition: ad-flow.c:30
vnet.h
VNET_SW_INTERFACE_TYPE_HARDWARE
@ VNET_SW_INTERFACE_TYPE_HARDWARE
Definition: interface.h:764
srv6_ad_flow_dpo_unlock
void srv6_ad_flow_dpo_unlock(dpo_id_t *dpo)
Definition: ad-flow.c:402
SID_CREATE_INVALID_IFACE_INDEX
#define SID_CREATE_INVALID_IFACE_INDEX
Definition: ad-flow.c:32
srv6_ad_flow_nodes
const static char *const *const srv6_ad_flow_nodes[DPO_PROTO_NUM]
Definition: ad-flow.c:417
DPO_PROTO_NUM
#define DPO_PROTO_NUM
Definition: dpo.h:72
vnet_main_t::interface_main
vnet_interface_main_t interface_main
Definition: vnet.h:81
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137