FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
svs.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 #include <plugins/svs/svs.h>
17 
18 #include <vlib/vlib.h>
19 #include <vnet/plugin/plugin.h>
20 #include <vnet/fib/fib_table.h>
21 #include <vnet/fib/ip6_fib.h>
22 #include <vnet/fib/ip4_fib.h>
23 #include <vnet/dpo/lookup_dpo.h>
24 #include <vnet/dpo/load_balance.h>
26 
28 
30 
31 int
33 {
35 
36  return (0);
37 }
38 
39 int
41 {
42  u32 fib_index, ii;
43 
44  fib_index = fib_table_find (fproto, table_id);
45 
46  vec_foreach_index (ii, svs_itf_db[fproto])
47  {
48  if (svs_itf_db[fproto][ii] == fib_index)
49  return VNET_API_ERROR_INSTANCE_IN_USE;
50  }
51 
52  if (~0 == fib_index)
53  return VNET_API_ERROR_NO_SUCH_FIB;
54 
55  fib_table_unlock (fib_index, fproto, svs_fib_src);
56 
57  return (0);
58 }
59 
60 static int
61 svs_route_add_i (u32 fib_index, const fib_prefix_t * pfx, u32 src_fib_index)
62 {
63  dpo_id_t dpo = DPO_INVALID;
64 
65 
71 
72  fib_table_entry_special_dpo_add (fib_index, pfx,
75 
76  dpo_unlock (&dpo);
77 
78  return (0);
79 }
80 
81 int
82 svs_route_add (u32 table_id, const fib_prefix_t * pfx, u32 source_table_id)
83 {
84  u32 fib_index, src_fib_index;
85  int rv;
86 
87  fib_index = fib_table_find (pfx->fp_proto, table_id);
88 
89  if (~0 == fib_index)
90  return VNET_API_ERROR_NO_SUCH_FIB;
91 
92  src_fib_index = fib_table_find (pfx->fp_proto, source_table_id);
93 
94  if (~0 == src_fib_index)
95  return (VNET_API_ERROR_NO_SUCH_FIB);
96 
97  rv = svs_route_add_i (fib_index, pfx, src_fib_index);
98 
99  return (rv);
100 }
101 
102 int
104 {
105  u32 fib_index;
106 
107  fib_index = fib_table_find (pfx->fp_proto, table_id);
108 
109  if (~0 == fib_index)
110  return VNET_API_ERROR_NO_SUCH_FIB;
111 
113 
114  return (0);
115 }
116 
117 int
119 {
120  fib_prefix_t pfx = {
121  .fp_proto = fproto,
122  };
123  u32 fib_index;
124 
125  fib_index = fib_table_find (fproto, table_id);
126 
127  if (~0 == fib_index)
128  return VNET_API_ERROR_NO_SUCH_FIB;
129 
130  /*
131  * now we know which interface the table will serve, we can add the default
132  * route to use the table that the interface is bound to.
133  */
134  svs_route_add_i (fib_index, &pfx,
136 
138 
139  svs_itf_db[fproto][sw_if_index] = fib_index;
140 
142  "ip4-unicast" :
143  "ip6-unicast"),
144  (FIB_PROTOCOL_IP4 == fproto ?
145  "svs-ip4" :
146  "svs-ip6"), sw_if_index, 1, NULL, 0);
147 
148  return (0);
149 }
150 
151 static void
153 {
154  /*
155  * update the default route to use the interface's newly bound FIB
156  */
157  u32 svs_fib_index;
158 
160  return;
161 
162  svs_fib_index = svs_itf_db[FIB_PROTOCOL_IP6][sw_if_index];
163 
164  if (~0 != svs_fib_index)
165  {
166  fib_prefix_t pfx = {
167  .fp_proto = fproto,
168  };
169 
170  svs_route_add (svs_fib_index, &pfx, itf_fib_index);
171  }
172  /*
173  * else
174  * no SVS enable on this interface
175  */
176 }
177 
178 static void
180  uword opaque,
181  u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
182 {
183  svs_table_bind (FIB_PROTOCOL_IP6, sw_if_index, new_fib_index);
184 }
185 
186 static void
188  uword opaque,
189  u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
190 {
191  svs_table_bind (FIB_PROTOCOL_IP4, sw_if_index, new_fib_index);
192 }
193 
194 int
196 {
197  fib_prefix_t pfx = {
198  .fp_proto = fproto,
199  };
200  u32 fib_index;
201 
202  fib_index = fib_table_find (fproto, table_id);
203 
204  if (~0 == fib_index)
205  return VNET_API_ERROR_NO_SUCH_FIB;
206 
207  if (sw_if_index >= vec_len (svs_itf_db[fproto]))
208  return VNET_API_ERROR_INVALID_SW_IF_INDEX;
209 
210  svs_itf_db[fproto][sw_if_index] = ~0;
211 
213  "ip4-unicast" :
214  "ip6-unicast"),
215  (FIB_PROTOCOL_IP4 == fproto ?
216  "svs-ip4" :
217  "svs-ip6"), sw_if_index, 0, NULL, 0);
218 
219  fib_table_entry_special_remove (fib_index, &pfx, svs_fib_src);
220 
221  return (0);
222 }
223 
224 void
226 {
227  fib_protocol_t fproto;
228  u32 ii, fib_index;
229 
230  FOR_EACH_FIB_IP_PROTOCOL (fproto)
231  {
232  vec_foreach_index (ii, svs_itf_db[fproto])
233  {
234  fib_index = svs_itf_db[fproto][ii];
235 
236  if (~0 != fib_index)
237  {
238  if (WALK_CONTINUE != fn (fproto,
239  fib_table_get_table_id (fib_index, fproto),
240  ii, ctx))
241  return;
242  }
243  }
244  }
245 }
246 
247 typedef enum svs_next_t_
248 {
251 } svs_next_t;
252 
253 typedef struct svs_input_trace_t_
254 {
257 
262 {
263  u32 n_left_from, *from, *to_next, next_index;
264 
266  n_left_from = frame->n_vectors;
267  next_index = node->cached_next_index;
268 
269  while (n_left_from > 0)
270  {
271  u32 n_left_to_next;
272 
273  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
274 
275  while (n_left_from > 0 && n_left_to_next > 0)
276  {
277  const load_balance_t *lb0;
278  const lookup_dpo_t *lk0;
279  u32 bi0, sw_if_index0;
280  const dpo_id_t *dpo0;
281  vlib_buffer_t *b0;
282  svs_next_t next0;
283  index_t lbi0;
284 
285  bi0 = from[0];
286  to_next[0] = bi0;
287  from += 1;
288  to_next += 1;
289  n_left_from -= 1;
290  n_left_to_next -= 1;
291 
292  b0 = vlib_get_buffer (vm, bi0);
293  sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
294 
295  if (FIB_PROTOCOL_IP4 == fproto)
296  {
297  ip4_header_t *ip0;
298 
299  ip0 = vlib_buffer_get_current (b0);
300  lbi0 =
301  ip4_fib_forwarding_lookup (svs_itf_db[fproto][sw_if_index0],
302  &ip0->src_address);
303  }
304  else
305  {
306  ip6_header_t *ip0;
307 
308  ip0 = vlib_buffer_get_current (b0);
310  [sw_if_index0],
311  &ip0->src_address);
312  }
313  lb0 = load_balance_get (lbi0);
314  dpo0 = load_balance_get_fwd_bucket (lb0, 0);
315  lk0 = lookup_dpo_get (dpo0->dpoi_index);
316 
317  vnet_buffer (b0)->sw_if_index[VLIB_TX] = lk0->lkd_fib_index;
318 
319  vnet_feature_next (&next0, b0);
320 
321  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
322  {
323  svs_input_trace_t *tr;
324 
325  tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
326  tr->fib_index = vnet_buffer (b0)->sw_if_index[VLIB_TX];
327  }
328 
329  /* verify speculative enqueue, maybe switch current next frame */
331  to_next, n_left_to_next, bi0,
332  next0);
333  }
334 
335  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
336  }
337 
338  return frame->n_vectors;
339 }
340 
341 static uword
344 {
346 }
347 
348 static uword
351 {
353 }
354 
355 static u8 *
356 format_svs_input_trace (u8 * s, va_list * args)
357 {
358  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
359  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
360  svs_input_trace_t *t = va_arg (*args, svs_input_trace_t *);
361 
362  s = format (s, " fib_index %d", t->fib_index);
363  return s;
364 }
365 
366 /* *INDENT-OFF* */
368 {
369  .function = svs_input_ip4,
370  .name = "svs-ip4",
371  .vector_size = sizeof (u32),
372  .format_trace = format_svs_input_trace,
374  .n_next_nodes = SVS_N_NEXT,
375  .next_nodes =
376  {
377  [SVS_NEXT_DROP] = "error-drop",
378  }
379 };
380 
382 {
383  .function = svs_input_ip6,
384  .name = "svs-ip6",
385  .vector_size = sizeof (u32),
386  .format_trace = format_svs_input_trace,
388  .next_nodes =
389  {
390  [SVS_NEXT_DROP] = "error-drop",
391  }
392 };
393 
394 VNET_FEATURE_INIT (svs_ip4_feat, static) =
395 {
396  .arc_name = "ip4-unicast",
397  .node_name = "svs-ip4",
398 };
399 
400 VNET_FEATURE_INIT (svs_ip6_feat, static) =
401 {
402  .arc_name = "ip6-unicast",
403  .node_name = "svs-ip6",
404 };
405 /* *INDENT-ON* */
406 
407 static clib_error_t *
409  unformat_input_t * input, vlib_cli_command_t * cmd)
410 {
411  fib_protocol_t fproto;
412  u32 table_id;
413  u8 add;
414 
415  fproto = FIB_PROTOCOL_IP4;
416  table_id = ~0;
417  add = 1;
418 
420  {
421  if (unformat (input, "add"))
422  add = 1;
423  else if (unformat (input, "del"))
424  add = 0;
425  else if (unformat (input, "ip4"))
426  fproto = FIB_PROTOCOL_IP4;
427  else if (unformat (input, "ip6"))
428  fproto = FIB_PROTOCOL_IP6;
429  else if (unformat (input, "table-id %d", &table_id))
430  ;
431  else
432  break;
433  }
434 
435  if (~0 == table_id)
436  return clib_error_return (0, "table-id must be specified");
437 
438  if (add)
439  svs_table_add (fproto, table_id);
440  else
441  svs_table_delete (fproto, table_id);
442 
443  return (NULL);
444 }
445 
446 /* *INDENT-OFF* */
448  .path = "svs table",
449  .short_help = "Source VRF select table [add|delete] [ip4|ip6] table-id X",
450  .function = svs_table_cli,
451 };
452 /* *INDENT-ON* */
453 
454 static clib_error_t *
456  unformat_input_t * input, vlib_cli_command_t * cmd)
457 {
459  fib_protocol_t fproto;
460  vnet_main_t *vnm;
461  u8 enable;
462 
463  vnm = vnet_get_main ();
464  sw_if_index = table_id = ~0;
465  fproto = FIB_PROTOCOL_IP4;
466  enable = 1;
467 
469  {
470  if (unformat (input, "%U", unformat_vnet_sw_interface,
471  vnm, &sw_if_index))
472  ;
473  else if (unformat (input, "enable"))
474  enable = 1;
475  else if (unformat (input, "disable"))
476  enable = 0;
477  else if (unformat (input, "ip4"))
478  fproto = FIB_PROTOCOL_IP4;
479  else if (unformat (input, "ip6"))
480  fproto = FIB_PROTOCOL_IP6;
481  else if (unformat (input, "table-id %d", &table_id))
482  ;
483  else
484  break;
485  }
486 
487  if (~0 == sw_if_index)
488  return clib_error_return (0, "interface must be specified");
489  if (~0 == table_id)
490  return clib_error_return (0, "table-id must be specified");
491 
492  if (enable)
493  svs_enable (fproto, table_id, sw_if_index);
494  else
495  svs_disable (fproto, table_id, sw_if_index);
496 
497  return (NULL);
498 }
499 
500 /* *INDENT-OFF* */
502  .path = "svs enable",
503  .short_help = "Source VRF select [enable|disable] [ip4|ip6] <table-id> X <interface>",
504  .function = svs_enable_cli,
505 };
506 /* *INDENT-ON* */
507 
508 static clib_error_t *
510  unformat_input_t * input, vlib_cli_command_t * cmd)
511 {
512  u32 table_id, src_table_id;
513  fib_prefix_t pfx;
514  int rv;
515  u8 add;
516 
517  src_table_id = table_id = ~0;
518  add = 1;
519 
521  {
522  if (unformat (input, "add"))
523  add = 1;
524  else if (unformat (input, "del"))
525  add = 0;
526  else if (unformat (input, "table-id %d", &table_id))
527  ;
528  else if (unformat (input, "src-table-id %d", &src_table_id))
529  ;
530  else if (unformat (input, "%U/%d",
531  unformat_ip4_address, &pfx.fp_addr.ip4, &pfx.fp_len))
532  {
534  }
535  else if (unformat (input, "%U/%d",
536  unformat_ip6_address, &pfx.fp_addr.ip6, &pfx.fp_len))
537  {
539  }
540  else
541  break;
542  }
543 
544  if (~0 == table_id)
545  return clib_error_return (0, "table-id must be specified");
546  if (~0 == src_table_id)
547  return clib_error_return (0, "src-table-id must be specified");
548 
549  if (add)
550  rv = svs_route_add (table_id, &pfx, src_table_id);
551  else
552  rv = svs_route_delete (table_id, &pfx);
553 
554  if (rv != 0)
555  return clib_error_return (0,
556  "failed, rv=%d:%U",
557  (int) rv, format_vnet_api_errno, rv);
558 
559  return (NULL);
560 }
561 
562 /* *INDENT-OFF* */
564  .path = "svs route",
565  .short_help = "Source VRF select route [add|delete] <table-id> <prefix> <src-table-id>",
566  .function = svs_route_cli,
567 };
568 /* *INDENT-ON* */
569 
570 static clib_error_t *
572  unformat_input_t * input, vlib_cli_command_t * cmd)
573 {
574  fib_protocol_t fproto;
575  u32 ii;
576 
577  vlib_cli_output (vm, "Source VRF select interface to fib-index mappings:");
578  FOR_EACH_FIB_IP_PROTOCOL (fproto)
579  {
580  vlib_cli_output (vm, " %U", format_fib_protocol, fproto);
581  vec_foreach_index (ii, svs_itf_db[fproto])
582  {
583  if (~0 != svs_itf_db[fproto][ii])
585  vnet_get_main (), ii, svs_itf_db[fproto][ii]);
586  }
587  }
588  return (NULL);
589 }
590 
591 /* *INDENT-OFF* */
593  .path = "show svs",
594  .short_help = "Source VRF select show",
595  .function = svs_show_cli,
596 };
597 /* *INDENT-ON* */
598 
599 static clib_error_t *
601 {
604  };
606 
609  };
611 
615 
616  return (NULL);
617 }
618 
620 
621 /*
622  * fd.io coding-style-patch-verification: ON
623  *
624  * Local Variables:
625  * eval: (c-set-style "gnu")
626  * End:
627  */
load_balance.h
vlib.h
svs_table_bind
static void svs_table_bind(fib_protocol_t fproto, u32 sw_if_index, u32 itf_fib_index)
Definition: svs.c:152
svs_input_ip6
static uword svs_input_ip6(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: svs.c:349
im
vnet_interface_main_t * im
Definition: interface_output.c:395
dpo_id_t_::dpoi_index
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:190
DPO_INVALID
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:204
fib_table_entry_special_dpo_add
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
Definition: fib_table.c:324
svs_input_trace_t
struct svs_input_trace_t_ svs_input_trace_t
frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: nat44_ei.c:3048
WALK_CONTINUE
@ WALK_CONTINUE
Definition: interface_funcs.h:174
svs_ip4_node
vlib_node_registration_t svs_ip4_node
(constructor) VLIB_REGISTER_NODE (svs_ip4_node)
Definition: svs.c:367
fib_table_get_table_id
u32 fib_table_get_table_id(u32 fib_index, fib_protocol_t proto)
Get the Table-ID of the FIB from protocol and index.
Definition: fib_table.c:1095
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
ip4_main_t::table_bind_callbacks
ip4_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
Definition: ip4.h:148
FOR_EACH_FIB_IP_PROTOCOL
#define FOR_EACH_FIB_IP_PROTOCOL(_item)
Definition: fib_types.h:69
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
load_balance_map.h
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
lookup_dpo_get
static lookup_dpo_t * lookup_dpo_get(index_t index)
Definition: lookup_dpo.h:127
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
vlib_cli_command_t::path
char * path
Definition: cli.h:96
lookup_dpo_t
A representation of an MPLS label for imposition in the data-path.
Definition: lookup_dpo.h:65
fib_table.h
svs_show_cli
static clib_error_t * svs_show_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: svs.c:571
svs_route_add
int svs_route_add(u32 table_id, const fib_prefix_t *pfx, u32 source_table_id)
Definition: svs.c:82
fib_prefix_t_::fp_len
u16 fp_len
The mask length.
Definition: fib_types.h:206
svs_enable
int svs_enable(fib_protocol_t fproto, u32 table_id, u32 sw_if_index)
Definition: svs.c:118
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
svs_show_cli_cmd
static vlib_cli_command_t svs_show_cli_cmd
(constructor) VLIB_CLI_COMMAND (svs_show_cli_cmd)
Definition: svs.c:592
svs.h
format_vnet_api_errno
static u8 * format_vnet_api_errno(u8 *s, va_list *args)
Definition: api_errno.h:172
svs_enable_cli_cmd
static vlib_cli_command_t svs_enable_cli_cmd
(constructor) VLIB_CLI_COMMAND (svs_enable_cli_cmd)
Definition: svs.c:501
FIB_ENTRY_FLAG_EXCLUSIVE
@ FIB_ENTRY_FLAG_EXCLUSIVE
Definition: fib_entry.h:116
unformat_input_t
struct _unformat_input_t unformat_input_t
svs_input_trace_t_
Definition: svs.c:253
vlib_frame_t
Definition: node.h:372
LOOKUP_INPUT_SRC_ADDR
@ LOOKUP_INPUT_SRC_ADDR
Definition: lookup_dpo.h:27
ip4_header_t
Definition: ip4_packet.h:87
ip6_table_bind_callback_t::function
ip6_table_bind_function_t * function
Definition: ip6.h:106
svs_table_delete
int svs_table_delete(fib_protocol_t fproto, u32 table_id)
Definition: svs.c:40
svs_input_ip4
static uword svs_input_ip4(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: svs.c:342
svs_input_trace_t_::fib_index
u32 fib_index
Definition: svs.c:255
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
SVS_N_NEXT
@ SVS_N_NEXT
Definition: svs.c:250
fib_table_entry_special_remove
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a 'special' entry from the FIB.
Definition: fib_table.c:424
load_balance_get_fwd_bucket
static const dpo_id_t * load_balance_get_fwd_bucket(const load_balance_t *lb, u16 bucket)
Definition: load_balance_map.h:94
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
svs_walk
void svs_walk(svs_walk_fn_t fn, void *ctx)
Definition: svs.c:225
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:437
FIB_PROTOCOL_IP_MAX
#define FIB_PROTOCOL_IP_MAX
Definition outside of enum so it does not need to be included in non-defaulted switch statements.
Definition: fib_types.h:57
svs_disable
int svs_disable(fib_protocol_t fproto, u32 table_id, u32 sw_if_index)
Definition: svs.c:195
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
VNET_FEATURE_INIT
VNET_FEATURE_INIT(svs_ip4_feat, static)
svs_route_cmd_cli
static vlib_cli_command_t svs_route_cmd_cli
(constructor) VLIB_CLI_COMMAND (svs_route_cmd_cli)
Definition: svs.c:563
svs_fib_src
static fib_source_t svs_fib_src
Definition: svs.c:29
fib_table_find_or_create_and_lock
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, fib_source_t src)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1165
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
vnet_feature_next
static_always_inline void vnet_feature_next(u32 *next0, vlib_buffer_t *b0)
Definition: feature.h:322
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
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
LOOKUP_UNICAST
@ LOOKUP_UNICAST
Definition: lookup_dpo.h:53
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
uword
u64 uword
Definition: types.h:112
ip6_main_t::table_bind_callbacks
ip6_table_bind_callback_t * table_bind_callbacks
Functions to call when interface to table biding changes.
Definition: ip6.h:151
svs_ip4_table_bind
static void svs_ip4_table_bind(ip4_main_t *im, uword opaque, u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
Definition: svs.c:187
svs_input_inline
static uword svs_input_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, fib_protocol_t fproto)
Definition: svs.c:259
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
format_svs_input_trace
static u8 * format_svs_input_trace(u8 *s, va_list *args)
Definition: svs.c:356
LOOKUP_TABLE_FROM_CONFIG
@ LOOKUP_TABLE_FROM_CONFIG
Definition: lookup_dpo.h:41
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
ip6_table_bind_callback_t
Definition: ip6.h:104
fib_source_allocate
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
Definition: fib_source.c:118
ip4_table_bind_callback_t
Definition: ip4.h:92
ip6_fib_table_fwding_lookup
static u32 ip6_fib_table_fwding_lookup(u32 fib_index, const ip6_address_t *dst)
Definition: ip6_fib.h:115
fib_proto_to_dpo
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:343
fib_prefix_t_::fp_addr
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:225
svs_ip6_node
vlib_node_registration_t svs_ip6_node
(constructor) VLIB_REGISTER_NODE (svs_ip6_node)
Definition: svs.c:381
svs_next_t
enum svs_next_t_ svs_next_t
plugin.h
ip6_main
ip6_main_t ip6_main
Definition: ip6_forward.c:2787
SVS_NEXT_DROP
@ SVS_NEXT_DROP
Definition: svs.c:249
vnet_main_t
Definition: vnet.h:76
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
svs_table_add
int svs_table_add(fib_protocol_t fproto, u32 table_id)
Definition: svs.c:32
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
format_fib_protocol
u8 * format_fib_protocol(u8 *s, va_list *ap)
Definition: fib_types.c:33
ip4_header_t::src_address
ip4_address_t src_address
Definition: ip4_packet.h:125
svs_enable_cli
static clib_error_t * svs_enable_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: svs.c:455
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:455
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:459
format
description fragment has unexpected format
Definition: map.api:433
vec_validate_init_empty
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
Definition: vec.h:570
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
fib_table_get_index_for_sw_if_index
u32 fib_table_get_index_for_sw_if_index(fib_protocol_t proto, u32 sw_if_index)
Get the index of the FIB bound to the interface.
Definition: fib_table.c:998
svs_init
static clib_error_t * svs_init(vlib_main_t *vm)
Definition: svs.c:600
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
table_id
u32 table_id
Definition: wireguard.api:102
lookup_dpo.h
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
svs_table_cmd_cli
static vlib_cli_command_t svs_table_cmd_cli
(constructor) VLIB_CLI_COMMAND (svs_table_cmd_cli)
Definition: svs.c:447
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
svs_itf_db
u32 * svs_itf_db[FIB_PROTOCOL_IP_MAX]
Definition: svs.c:27
load_balance_get
static load_balance_t * load_balance_get(index_t lbi)
Definition: load_balance.h:220
ip4_table_bind_callback_t::function
ip4_table_bind_function_t * function
Definition: ip4.h:94
svs_route_delete
int svs_route_delete(u32 table_id, const fib_prefix_t *pfx)
Definition: svs.c:103
fib_prefix_t_::fp_proto
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:211
ip6_header_t
Definition: ip6_packet.h:294
ip6_main_t
Definition: ip6.h:110
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
ip4_fib.h
dpo_unlock
void dpo_unlock(dpo_id_t *dpo)
Release a reference counting lock on the DPO.
Definition: dpo.c:380
ip6_fib.h
ip6_header_t::src_address
ip6_address_t src_address
Definition: ip6_packet.h:310
vlib_main_t
Definition: main.h:102
vlib_node_t
Definition: node.h:247
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
clib_error_t
Definition: clib_error.h:21
svs_route_add_i
static int svs_route_add_i(u32 fib_index, const fib_prefix_t *pfx, u32 src_fib_index)
Definition: svs.c:61
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
fib_table_unlock
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
Definition: fib_table.c:1336
FIB_SOURCE_BH_SIMPLE
@ FIB_SOURCE_BH_SIMPLE
add paths without path extensions
Definition: fib_source.h:210
svs_next_t_
svs_next_t_
Definition: svs.c:247
FIB_SOURCE_PRIORITY_LOW
#define FIB_SOURCE_PRIORITY_LOW
Definition: fib_source.h:285
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
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
unformat_ip6_address
unformat_function_t unformat_ip6_address
Definition: format.h:89
rv
int __clib_unused rv
Definition: application.c:491
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
ip4_fib_forwarding_lookup
static index_t ip4_fib_forwarding_lookup(u32 fib_index, const ip4_address_t *addr)
Definition: ip4_fib.h:160
lookup_dpo_t::lkd_fib_index
fib_node_index_t lkd_fib_index
The FIB, or interface from which to get a FIB, in which to perform the next lookup;.
Definition: lookup_dpo.h:77
load_balance_t_
The FIB DPO provieds;.
Definition: load_balance.h:106
vlib_node_runtime_t
Definition: node.h:454
vlib_cli_command_t
Definition: cli.h:92
from
from
Definition: nat44_ei_hairpinning.c:415
ip4_main_t
IPv4 main type.
Definition: ip4.h:107
fib_table_find
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1106
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
lookup_dpo_add_or_lock_w_fib_index
void lookup_dpo_add_or_lock_w_fib_index(fib_node_index_t fib_index, dpo_proto_t proto, lookup_cast_t cast, lookup_input_t input, lookup_table_t table_config, dpo_id_t *dpo)
Definition: lookup_dpo.c:137
svs_walk_fn_t
walk_rc_t(* svs_walk_fn_t)(fib_protocol_t fproto, u32 table_id, u32 sw_if_index, void *ctx)
Definition: svs.h:40
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
svs_table_cli
static clib_error_t * svs_table_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: svs.c:408
svs_ip6_table_bind
static void svs_ip6_table_bind(ip6_main_t *im, uword opaque, u32 sw_if_index, u32 new_fib_index, u32 old_fib_index)
Definition: svs.c:179
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
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
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
svs_route_cli
static clib_error_t * svs_route_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: svs.c:509