FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
adj_midchain.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 #include <vnet/adj/adj_nbr.h>
17 #include <vnet/adj/adj_internal.h>
18 #include <vnet/adj/adj_l2.h>
19 #include <vnet/adj/adj_nsh.h>
20 #include <vnet/adj/adj_midchain.h>
22 #include <vnet/dpo/drop_dpo.h>
23 #include <vnet/dpo/load_balance.h>
24 #include <vnet/fib/fib_walk.h>
25 #include <vnet/fib/fib_entry.h>
26 
27 /**
28  * @brief Trace data for packets traversing the midchain tx node
29  */
31 {
32  /**
33  * @brief the midchain adj we are traversing
34  */
37 
42  int interface_count)
43 {
44  vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
45  u16 nexts[VLIB_FRAME_SIZE], *next;
46  u32 * from, n_left, thread_index;
47  vnet_main_t *vnm = vnet_get_main ();
49 
50  thread_index = vm->thread_index;
51  n_left = frame->n_vectors;
52  from = vlib_frame_vector_args (frame);
53 
54  vlib_get_buffers (vm, from, bufs, n_left);
55 
56  next = nexts;
57  b = bufs;
58 
59  while (n_left > 8)
60  {
61  u32 adj_index0, adj_index1, adj_index2, adj_index3;
62  const ip_adjacency_t *adj0, *adj1, *adj2, *adj3;
63  const dpo_id_t *dpo0, *dpo1, *dpo2, *dpo3;
64 
65  /* Prefetch next iteration. */
66  {
67  vlib_prefetch_buffer_header (b[4], LOAD);
68  vlib_prefetch_buffer_header (b[5], LOAD);
69  vlib_prefetch_buffer_header (b[6], LOAD);
70  vlib_prefetch_buffer_header (b[7], LOAD);
71  }
72 
73  /* Follow the DPO on which the midchain is stacked */
74  adj_index0 = vnet_buffer(b[0])->ip.adj_index[VLIB_TX];
75  adj_index1 = vnet_buffer(b[1])->ip.adj_index[VLIB_TX];
76  adj_index2 = vnet_buffer(b[2])->ip.adj_index[VLIB_TX];
77  adj_index3 = vnet_buffer(b[3])->ip.adj_index[VLIB_TX];
78 
79  adj0 = adj_get(adj_index0);
80  adj1 = adj_get(adj_index1);
81  adj2 = adj_get(adj_index2);
82  adj3 = adj_get(adj_index3);
83 
84  dpo0 = &adj0->sub_type.midchain.next_dpo;
85  dpo1 = &adj1->sub_type.midchain.next_dpo;
86  dpo2 = &adj2->sub_type.midchain.next_dpo;
87  dpo3 = &adj3->sub_type.midchain.next_dpo;
88 
89  next[0] = dpo0->dpoi_next_node;
90  next[1] = dpo1->dpoi_next_node;
91  next[2] = dpo2->dpoi_next_node;
92  next[3] = dpo3->dpoi_next_node;
93 
94  vnet_buffer(b[0])->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
95  vnet_buffer(b[1])->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
96  vnet_buffer(b[2])->ip.adj_index[VLIB_TX] = dpo2->dpoi_index;
97  vnet_buffer(b[3])->ip.adj_index[VLIB_TX] = dpo3->dpoi_index;
98 
99  if (interface_count)
100  {
103  thread_index,
104  adj0->rewrite_header.sw_if_index,
105  1,
106  vlib_buffer_length_in_chain (vm, b[0]));
109  thread_index,
110  adj1->rewrite_header.sw_if_index,
111  1,
112  vlib_buffer_length_in_chain (vm, b[1]));
115  thread_index,
116  adj2->rewrite_header.sw_if_index,
117  1,
118  vlib_buffer_length_in_chain (vm, b[2]));
121  thread_index,
122  adj3->rewrite_header.sw_if_index,
123  1,
124  vlib_buffer_length_in_chain (vm, b[3]));
125  }
126 
128  {
129  if (PREDICT_FALSE(b[0]->flags & VLIB_BUFFER_IS_TRACED))
130  {
131  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
132  b[0], sizeof (*tr));
133  tr->ai = adj_index0;
134  }
135  if (PREDICT_FALSE(b[1]->flags & VLIB_BUFFER_IS_TRACED))
136  {
137  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
138  b[1], sizeof (*tr));
139  tr->ai = adj_index1;
140  }
141  if (PREDICT_FALSE(b[2]->flags & VLIB_BUFFER_IS_TRACED))
142  {
143  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
144  b[2], sizeof (*tr));
145  tr->ai = adj_index2;
146  }
147  if (PREDICT_FALSE(b[3]->flags & VLIB_BUFFER_IS_TRACED))
148  {
149  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
150  b[3], sizeof (*tr));
151  tr->ai = adj_index3;
152  }
153  }
154  n_left -= 4;
155  b += 4;
156  next += 4;
157  }
158 
159  while (n_left)
160  {
161  const ip_adjacency_t * adj0;
162  const dpo_id_t *dpo0;
163  u32 adj_index0;
164 
165  /* Follow the DPO on which the midchain is stacked */
166  adj_index0 = vnet_buffer(b[0])->ip.adj_index[VLIB_TX];
167  adj0 = adj_get(adj_index0);
168  dpo0 = &adj0->sub_type.midchain.next_dpo;
169  next[0] = dpo0->dpoi_next_node;
170  vnet_buffer(b[0])->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
171 
172  if (interface_count)
173  {
176  thread_index,
177  adj0->rewrite_header.sw_if_index,
178  1,
179  vlib_buffer_length_in_chain (vm, b[0]));
180  }
181 
182  if (PREDICT_FALSE(b[0]->flags & VLIB_BUFFER_IS_TRACED))
183  {
184  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
185  b[0], sizeof (*tr));
186  tr->ai = adj_index0;
187  }
188 
189  n_left -= 1;
190  b += 1;
191  next += 1;
192  }
193 
194  vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
195 
196  return frame->n_vectors;
197 }
198 
199 static u8 *
200 format_adj_midchain_tx_trace (u8 * s, va_list * args)
201 {
202  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
203  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
204  adj_midchain_tx_trace_t *tr = va_arg (*args, adj_midchain_tx_trace_t*);
205 
206  s = format(s, "adj-midchain:[%d]:%U", tr->ai,
207  format_ip_adjacency, tr->ai,
209 
210  return (s);
211 }
212 
213 static uword
217 {
218  return (adj_midchain_tx_inline(vm, node, frame, 1));
219 }
220 
222  .function = adj_midchain_tx,
223  .name = "adj-midchain-tx",
224  .vector_size = sizeof (u32),
225 
226  .format_trace = format_adj_midchain_tx_trace,
227 
228  .n_next_nodes = 1,
229  .next_nodes = {
230  [0] = "error-drop",
231  },
232 };
233 
234 static uword
238 {
239  return (adj_midchain_tx_inline(vm, node, frame, 0));
240 }
241 
243  .function = adj_midchain_tx_no_count,
244  .name = "adj-midchain-tx-no-count",
245  .vector_size = sizeof (u32),
246 
247  .format_trace = format_adj_midchain_tx_trace,
248  .sibling_of = "adj-midchain-tx",
249 };
250 
251 #ifndef CLIB_MARCH_VARIANT
252 
253 u8
255 {
256  ip_adjacency_t *adj;
257 
258  adj = adj_get(ai);
259 
260  switch (adj->lookup_next_index)
261  {
264  return (1);
265  case IP_LOOKUP_NEXT_ARP:
269  case IP_LOOKUP_NEXT_DROP:
270  case IP_LOOKUP_NEXT_PUNT:
274  case IP_LOOKUP_N_NEXT:
275  return (0);
276  }
277 
278  return (0);
279 }
280 
281 static inline u32
283 {
284  switch (link) {
285  case VNET_LINK_IP4:
286  return (ip4_midchain_node.index);
287  case VNET_LINK_IP6:
288  return (ip6_midchain_node.index);
289  case VNET_LINK_MPLS:
290  return (mpls_midchain_node.index);
291  case VNET_LINK_ETHERNET:
292  return (adj_l2_midchain_node.index);
293  case VNET_LINK_NSH:
294  return (adj_nsh_midchain_node.index);
295  case VNET_LINK_ARP:
296  break;
297  }
298  ASSERT(0);
299  return (0);
300 }
301 
302 static u8
304 {
305  u8 arc = (u8) ~0;
306  switch (adj->ia_link)
307  {
308  case VNET_LINK_IP4:
309  {
311  break;
312  }
313  case VNET_LINK_IP6:
314  {
316  break;
317  }
318  case VNET_LINK_MPLS:
319  {
321  break;
322  }
323  case VNET_LINK_ETHERNET:
324  {
326  break;
327  }
328  case VNET_LINK_NSH:
329  {
330  arc = nsh_main_placeholder.output_feature_arc_index;
331  break;
332  }
333  case VNET_LINK_ARP:
334  ASSERT(0);
335  break;
336  }
337 
338  ASSERT (arc != (u8) ~0);
339 
340  return (arc);
341 }
342 
343 static u32
345 {
346  return ((adj->ia_flags & ADJ_FLAG_MIDCHAIN_NO_COUNT) ?
348  adj_midchain_tx_node.index);
349 }
350 
351 /**
352  * adj_midchain_setup
353  *
354  * Setup the adj as a mid-chain
355  */
356 void
358 {
360 
361  dpo_reset(&adj->sub_type.midchain.next_dpo);
362 
366  adj->rewrite_header.sw_if_index,
368  (u8*) "interface-output")->index);
370 }
371 
372 /**
373  * adj_midchain_setup
374  *
375  * Setup the adj as a mid-chain
376  */
377 void
379  adj_midchain_fixup_t fixup,
380  const void *data,
382 {
384  ip_adjacency_t *adj;
385  u32 tx_node;
386 
387  ASSERT(ADJ_INDEX_INVALID != adj_index);
388 
389  adj = adj_get(adj_index);
390 
391  adj->sub_type.midchain.fixup_func = fixup;
392  adj->sub_type.midchain.fixup_data = data;
394  adj->ia_flags |= flags;
395 
397  {
398  adj->rewrite_header.flags |= VNET_REWRITE_FIXUP_IP4_O_4;
399  }
400  else
401  {
402  adj->rewrite_header.flags &= ~VNET_REWRITE_FIXUP_IP4_O_4;
403  }
404 
405  tx_node = adj_nbr_midchain_get_tx_node(adj);
406 
410  adj->rewrite_header.sw_if_index,
411  tx_node);
413 
414  /*
415  * stack the midchain on the drop so it's ready to forward in the adj-midchain-tx.
416  * The graph arc used/created here is from the midchain-tx node to the
417  * child's registered node. This is because post adj processing the next
418  * node are any output features, then the midchain-tx. from there we
419  * need to get to the stacked child's node.
420  */
421  dpo_stack_from_node(tx_node,
422  &adj->sub_type.midchain.next_dpo,
424 }
425 
426 /**
427  * adj_nbr_midchain_update_rewrite
428  *
429  * Update the adjacency's rewrite string. A NULL string implies the
430  * rewrite is reset (i.e. when ARP/ND entry is gone).
431  * NB: the adj being updated may be handling traffic in the DP.
432  */
433 void
435  adj_midchain_fixup_t fixup,
436  const void *fixup_data,
438  u8 *rewrite)
439 {
440  ip_adjacency_t *adj;
441 
442  ASSERT(ADJ_INDEX_INVALID != adj_index);
443 
444  adj = adj_get(adj_index);
445 
446  /*
447  * one time only update. since we don't support changing the tunnel
448  * src,dst, this is all we need.
449  */
452  {
453  adj_midchain_setup(adj_index, fixup, fixup_data, flags);
454  }
455 
456  /*
457  * update the rewrite with the workers paused.
458  */
463  rewrite);
464 }
465 
466 void
468  u32 next_node)
469 {
470  ip_adjacency_t *adj;
471  vlib_main_t * vm;
472 
473  ASSERT(ADJ_INDEX_INVALID != adj_index);
474 
475  adj = adj_get(adj_index);
476  vm = vlib_get_main();
477 
479 
480  adj->rewrite_header.next_index = vlib_node_add_next(vlib_get_main(),
481  adj->ia_node_index,
482  next_node);
483 
486  adj->rewrite_header.sw_if_index,
487  next_node);
488 
490 }
491 
492 void
494 {
495  ip_adjacency_t *adj;
496  vlib_main_t * vm;
497 
498  ASSERT(ADJ_INDEX_INVALID != adj_index);
499 
500  adj = adj_get(adj_index);
501  vm = vlib_get_main();
502 
504 
505  adj->rewrite_header.next_index =
507  adj->ia_node_index,
509 
512  adj->rewrite_header.sw_if_index,
514 
516 }
517 
518 /**
519  * adj_nbr_midchain_unstack
520  *
521  * Unstack the adj. stack it on drop
522  */
523 void
525 {
526  fib_node_index_t *entry_indicies, tmp;
527  ip_adjacency_t *adj;
528 
529  ASSERT(ADJ_INDEX_INVALID != adj_index);
530  adj = adj_get (adj_index);
531 
532  /*
533  * check to see if this unstacking breaks a recursion loop
534  */
535  entry_indicies = NULL;
536  tmp = adj->sub_type.midchain.fei;
538 
539  if (FIB_NODE_INDEX_INVALID != tmp)
540  {
541  fib_entry_recursive_loop_detect(tmp, &entry_indicies);
542  vec_free(entry_indicies);
543  }
544 
545  /*
546  * stack on the drop
547  */
550  &adj->sub_type.midchain.next_dpo,
553 }
554 
555 void
557  fib_node_index_t fei,
559 {
560  fib_node_index_t *entry_indicies;
561  dpo_id_t tmp = DPO_INVALID;
562  ip_adjacency_t *adj;
563 
564  adj = adj_get (ai);
565 
566  /*
567  * check to see if this stacking will form a recursion loop
568  */
569  entry_indicies = NULL;
570  adj->sub_type.midchain.fei = fei;
571 
572  if (fib_entry_recursive_loop_detect(adj->sub_type.midchain.fei, &entry_indicies))
573  {
574  /*
575  * loop formed, stack on the drop.
576  */
578  }
579  else
580  {
581  fib_entry_contribute_forwarding (fei, fct, &tmp);
582 
583  if ((adj->ia_flags & ADJ_FLAG_MIDCHAIN_IP_STACK) &&
584  (DPO_LOAD_BALANCE == tmp.dpoi_type))
585  {
586  /*
587  * do that hash now and stack on the choice.
588  * If the choice is an incomplete adj then we will need a poke when
589  * it becomes complete. This happens since the adj update walk propagates
590  * as far a recursive paths.
591  */
592  const dpo_id_t *choice;
593  load_balance_t *lb;
594  int hash;
595 
596  lb = load_balance_get (tmp.dpoi_index);
597 
599  {
601  lb->lb_hash_config);
602  }
603  else if (FIB_FORW_CHAIN_TYPE_UNICAST_IP6 == fct)
604  {
606  lb->lb_hash_config);
607  }
608  else
609  {
610  hash = 0;
611  ASSERT(0);
612  }
613 
614  choice = load_balance_get_bucket_i (lb, hash & lb->lb_n_buckets_minus_1);
615  dpo_copy (&tmp, choice);
616  }
617  }
618  adj_nbr_midchain_stack (ai, &tmp);
619  dpo_reset(&tmp);
620  vec_free(entry_indicies);
621 }
622 
623 /**
624  * adj_nbr_midchain_stack
625  */
626 void
628  const dpo_id_t *next)
629 {
630  ip_adjacency_t *adj;
631 
632  ASSERT(ADJ_INDEX_INVALID != adj_index);
633 
634  adj = adj_get(adj_index);
635 
638 
640  &adj->sub_type.midchain.next_dpo,
641  next);
642 }
643 
644 int
646  fib_node_index_t **entry_indicies)
647 {
648  fib_node_index_t *entry_index, *entries;
649  ip_adjacency_t * adj;
650 
651  adj = adj_get(ai);
652  entries = *entry_indicies;
653 
654  vec_foreach(entry_index, entries)
655  {
656  if (*entry_index == adj->sub_type.midchain.fei)
657  {
658  /*
659  * The entry this midchain links to is already in the set
660  * of visited entries, this is a loop
661  */
663  return (1);
664  }
665  }
666 
668  return (0);
669 }
670 
671 u8*
672 format_adj_midchain (u8* s, va_list *ap)
673 {
674  index_t index = va_arg(*ap, index_t);
675  u32 indent = va_arg(*ap, u32);
676  ip_adjacency_t * adj = adj_get(index);
677 
678  s = format (s, "%U", format_vnet_link, adj->ia_link);
679  if (adj->rewrite_header.flags & VNET_REWRITE_HAS_FEATURES)
680  s = format(s, " [features]");
681  s = format (s, " via %U",
682  format_ip46_address, &adj->sub_type.nbr.next_hop,
684  s = format (s, " %U",
686  &adj->rewrite_header, sizeof (adj->rewrite_data), indent);
687  s = format (s, "\n%Ustacked-on",
688  format_white_space, indent);
689 
690  if (FIB_NODE_INDEX_INVALID != adj->sub_type.midchain.fei)
691  {
692  s = format (s, " entry:%d", adj->sub_type.midchain.fei);
693 
694  }
695  s = format (s, ":\n%U%U",
696  format_white_space, indent+2,
697  format_dpo_id, &adj->sub_type.midchain.next_dpo, indent+2);
698 
699  return (s);
700 }
701 
702 static void
704 {
705  adj_lock(dpo->dpoi_index);
706 }
707 static void
709 {
710  adj_unlock(dpo->dpoi_index);
711 }
712 
713 const static dpo_vft_t adj_midchain_dpo_vft = {
715  .dv_unlock = adj_dpo_unlock,
716  .dv_format = format_adj_midchain,
717  .dv_get_urpf = adj_dpo_get_urpf,
718 };
719 
720 /**
721  * @brief The per-protocol VLIB graph nodes that are assigned to a midchain
722  * object.
723  *
724  * this means that these graph nodes are ones from which a midchain is the
725  * parent object in the DPO-graph.
726  */
727 const static char* const midchain_ip4_nodes[] =
728 {
729  "ip4-midchain",
730  NULL,
731 };
732 const static char* const midchain_ip6_nodes[] =
733 {
734  "ip6-midchain",
735  NULL,
736 };
737 const static char* const midchain_mpls_nodes[] =
738 {
739  "mpls-midchain",
740  NULL,
741 };
742 const static char* const midchain_ethernet_nodes[] =
743 {
744  "adj-l2-midchain",
745  NULL,
746 };
747 const static char* const midchain_nsh_nodes[] =
748 {
749  "adj-nsh-midchain",
750  NULL,
751 };
752 
753 const static char* const * const midchain_nodes[DPO_PROTO_NUM] =
754 {
760 };
761 
762 void
764 {
765  dpo_register(DPO_ADJACENCY_MIDCHAIN, &adj_midchain_dpo_vft, midchain_nodes);
766 }
767 
768 #endif
static uword adj_midchain_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: adj_midchain.c:214
static const char *const midchain_nsh_nodes[]
Definition: adj_midchain.c:747
static const char *const midchain_ip6_nodes[]
Definition: adj_midchain.c:732
void dpo_stack_from_node(u32 child_node_index, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child parent relationship.
Definition: dpo.c:531
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:406
adj_flags_t ia_flags
Flags on the adjacency 1-bytes.
Definition: adj.h:348
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:113
vlib_node_registration_t ip6_midchain_node
(constructor) VLIB_REGISTER_NODE (ip6_midchain_node)
Definition: ip6_forward.c:2190
#define CLIB_UNUSED(x)
Definition: clib.h:87
A virtual function table regisitered for a DPO type.
Definition: dpo.h:401
vlib_node_registration_t adj_midchain_tx_node
(constructor) VLIB_REGISTER_NODE (adj_midchain_tx_node)
Definition: adj_midchain.c:221
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:103
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
Definition: counter.h:220
void adj_lock(adj_index_t adj_index)
Take a reference counting lock on the adjacency.
Definition: adj.c:331
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
static uword adj_midchain_tx_no_count(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: adj_midchain.c:235
vnet_interface_main_t interface_main
Definition: vnet.h:59
static const char *const midchain_ip4_nodes[]
The per-protocol VLIB graph nodes that are assigned to a midchain object.
Definition: adj_midchain.c:727
const u8 * adj_get_rewrite(adj_index_t ai)
Return the rewrite string of the adjacency.
Definition: adj.c:543
Multicast Adjacency.
Definition: adj.h:82
static u32 ip4_compute_flow_hash(const ip4_header_t *ip, flow_hash_config_t flow_hash_config)
Definition: ip4.h:310
Broadcast Adjacency.
Definition: adj.h:85
IP unicast adjacency.
Definition: adj.h:227
void fib_entry_contribute_forwarding(fib_node_index_t fib_entry_index, fib_forward_chain_type_t fct, dpo_id_t *dpo)
Definition: fib_entry.c:437
flow_hash_config_t lb_hash_config
the hash config to use when selecting a bucket.
Definition: load_balance.h:161
vlib_node_registration_t ip4_midchain_node
(constructor) VLIB_REGISTER_NODE (ip4_midchain_node)
Definition: ip4_forward.c:2706
u32 thread_index
Definition: main.h:249
dpo_proto_t fib_forw_chain_type_to_dpo_proto(fib_forward_chain_type_t fct)
Convert from a chain type to the DPO proto it will install.
Definition: fib_types.c:497
This packet is to be rewritten and forwarded to the next processing node.
Definition: adj.h:73
void dpo_copy(dpo_id_t *dst, const dpo_id_t *src)
atomic copy a data-plane object.
Definition: dpo.c:262
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:41
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:109
ip_lookup_main_t lookup_main
Definition: ip4.h:108
vlib_main_t * vm
Definition: in2out_ed.c:1582
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
void(* adj_midchain_fixup_t)(vlib_main_t *vm, const struct ip_adjacency_t_ *adj, vlib_buffer_t *b0, const void *data)
A function type for post-rewrite fixups on midchain adjacency.
Definition: adj.h:152
void adj_nbr_update_rewrite_internal(ip_adjacency_t *adj, ip_lookup_next_t adj_next_index, u32 complete_next_index, u32 next_index, u8 *rewrite)
adj_nbr_update_rewrite_internal
Definition: adj_nbr.c:361
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:402
u32 adj_dpo_get_urpf(const dpo_id_t *dpo)
Definition: adj.c:321
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1173
unsigned char u8
Definition: types.h:56
u8 data[128]
Definition: ipsec_types.api:89
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:205
vnet_link_t ia_link
link/ether-type 1 bytes
Definition: adj.h:335
Adjacency to punt this packet.
Definition: adj.h:55
const dpo_id_t * drop_dpo_get(dpo_proto_t proto)
Definition: drop_dpo.c:25
u8 output_feature_arc_index
Definition: lookup.h:169
ethernet_main_t ethernet_main
Definition: init.c:45
static ip_adjacency_t * adj_get(adj_index_t adj_index)
Get a pointer to an adjacency object from its index.
Definition: adj.h:459
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:322
vlib_node_registration_t adj_nsh_midchain_node
(constructor) VLIB_REGISTER_NODE (adj_nsh_midchain_node)
Definition: adj_nsh.c:180
this adj performs IP4 over IP4 fixup
Definition: rewrite.h:62
dpo_proto_t vnet_link_to_dpo_proto(vnet_link_t linkt)
Definition: dpo.c:96
format_function_t format_ip_adjacency
Definition: format.h:58
u16 lb_n_buckets_minus_1
number of buckets in the load-balance - 1.
Definition: load_balance.h:121
vlib_combined_counter_main_t * combined_sw_if_counters
Definition: interface.h:881
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:203
void adj_nbr_midchain_update_next_node(adj_index_t adj_index, u32 next_node)
Update the VLIB node to which packets are sent post processing.
Definition: adj_midchain.c:467
static const char *const *const midchain_nodes[DPO_PROTO_NUM]
Definition: adj_midchain.c:753
void adj_nbr_midchain_stack_on_fib_entry(adj_index_t ai, fib_node_index_t fei, fib_forward_chain_type_t fct)
[re]stack a midchain.
Definition: adj_midchain.c:556
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
Definition: adj.c:348
vlib_node_registration_t mpls_midchain_node
(constructor) VLIB_REGISTER_NODE (mpls_midchain_node)
Definition: mpls_output.c:361
unsigned int u32
Definition: types.h:88
format_function_t format_vnet_rewrite
Definition: rewrite.h:263
static uword adj_midchain_tx_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int interface_count)
Definition: adj_midchain.c:39
#define VLIB_FRAME_SIZE
Definition: node.h:377
u8 output_feature_arc_index
Definition: mpls.h:57
struct ip_adjacency_t_::@149::@151 midchain
IP_LOOKUP_NEXT_MIDCHAIN.
union ip_adjacency_t_::@149 sub_type
vlib_node_registration_t adj_l2_midchain_node
(constructor) VLIB_REGISTER_NODE (adj_l2_midchain_node)
Definition: adj_l2.c:197
static const char *const midchain_mpls_nodes[]
Definition: adj_midchain.c:737
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:170
#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
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
static u32 adj_get_midchain_node(vnet_link_t link)
Definition: adj_midchain.c:282
dpo_type_t dpoi_type
the type
Definition: dpo.h:174
static const dpo_id_t * load_balance_get_bucket_i(const load_balance_t *lb, u32 bucket)
Definition: load_balance.h:229
Trace data for packets traversing the midchain tx node.
Definition: adj_midchain.c:30
nsh_main_placeholder_t nsh_main_placeholder
Definition: adj_nsh.c:21
void adj_midchain_module_init(void)
Module initialisation.
Definition: adj_midchain.c:763
int adj_ndr_midchain_recursive_loop_detect(adj_index_t ai, fib_node_index_t **entry_indicies)
descend the FIB graph looking for loops
Definition: adj_midchain.c:645
unsigned short u16
Definition: types.h:57
adj_index_t ai
the midchain adj we are traversing
Definition: adj_midchain.c:35
load-balancing over a choice of [un]equal cost paths
Definition: dpo.h:102
static u32 ip6_compute_flow_hash(const ip6_header_t *ip, flow_hash_config_t flow_hash_config)
Definition: ip6.h:382
The FIB DPO provieds;.
Definition: load_balance.h:106
u32 ia_node_index
The VLIB node in which this adj is used to forward packets.
Definition: adj.h:322
#define PREDICT_FALSE(x)
Definition: clib.h:120
This packet matches an "interface route" and packets need to be passed to ARP to find rewrite string ...
Definition: adj.h:68
#define always_inline
Definition: ipsec.h:28
ip6_main_t ip6_main
Definition: ip6_forward.c:2781
u32 vnet_feature_modify_end_node(u8 arc_index, u32 sw_if_index, u32 end_node_index)
Definition: feature.c:380
static u8 adj_midchain_get_feature_arc_index_for_link_type(const ip_adjacency_t *adj)
Definition: adj_midchain.c:303
vlib_node_registration_t adj_midchain_tx_no_count_node
(constructor) VLIB_REGISTER_NODE (adj_midchain_tx_no_count_node)
Definition: adj_midchain.c:242
format_function_t format_ip46_address
Definition: ip46_address.h:50
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
Definition: adj.h:63
Adjacency to drop this packet.
Definition: adj.h:53
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
u16 n_vectors
Definition: node.h:396
mpls_main_t mpls_main
Definition: mpls.c:25
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
Definition: buffer_node.h:339
static void adj_dpo_unlock(dpo_id_t *dpo)
Definition: adj_midchain.c:708
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
Multicast Midchain Adjacency.
Definition: adj.h:89
static u8 * format_adj_midchain_tx_trace(u8 *s, va_list *args)
Definition: adj_midchain.c:200
void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *fixup_data, adj_flags_t flags, u8 *rewrite)
adj_nbr_midchain_update_rewrite
Definition: adj_midchain.c:434
int fib_entry_recursive_loop_detect(fib_node_index_t entry_index, fib_node_index_t **entry_indicies)
Definition: fib_entry.c:1407
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:30
void adj_midchain_teardown(ip_adjacency_t *adj)
adj_midchain_setup
Definition: adj_midchain.c:357
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
vlib_main_t vlib_node_runtime_t * node
Definition: in2out_ed.c:1582
u8 * format_adj_midchain(u8 *s, va_list *ap)
Format a midchain adjacency.
Definition: adj_midchain.c:672
This packets follow a mid-chain adjacency.
Definition: adj.h:76
static u32 adj_nbr_midchain_get_tx_node(ip_adjacency_t *adj)
Definition: adj_midchain.c:344
#define ASSERT(truth)
void adj_nbr_midchain_stack(adj_index_t adj_index, const dpo_id_t *next)
adj_nbr_midchain_stack
Definition: adj_midchain.c:627
ip_lookup_main_t lookup_main
Definition: ip6.h:181
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
static load_balance_t * load_balance_get(index_t lbi)
Definition: load_balance.h:220
struct ip_adjacency_t_::@149::@150 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
u32 ia_cfg_index
feature [arc] config index
Definition: adj.h:239
void adj_nbr_midchain_unstack(adj_index_t adj_index)
adj_nbr_midchain_unstack
Definition: adj_midchain.c:524
u8 * format_dpo_id(u8 *s, va_list *args)
Format a DPO_id_t oject.
Definition: dpo.c:148
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u32 entries
static void adj_dpo_lock(dpo_id_t *dpo)
Definition: adj_midchain.c:703
enum adj_flags_t_ adj_flags_t
Flags on an IP adjacency.
This packets needs to go to ICMP error.
Definition: adj.h:79
This packet is for one of our own IP addresses.
Definition: adj.h:58
fib_protocol_t ia_nh_proto
The protocol of the neighbor/peer.
Definition: adj.h:342
Definition: defs.h:47
#define DPO_PROTO_NUM
Definition: dpo.h:70
u8 adj_is_midchain(adj_index_t ai)
Definition: adj_midchain.c:254
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:186
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:31
ip_lookup_next_t lookup_next_index
Next hop after ip4-lookup.
Definition: adj.h:329
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: in2out_ed.c:1583
void adj_midchain_setup(adj_index_t adj_index, adj_midchain_fixup_t fixup, const void *data, adj_flags_t flags)
adj_midchain_setup
Definition: adj_midchain.c:378
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
struct adj_midchain_tx_trace_t_ adj_midchain_tx_trace_t
Trace data for packets traversing the midchain tx node.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:297
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:197
u32 index
Definition: flow_types.api:221
#define vnet_buffer(b)
Definition: buffer.h:417
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1554
void adj_nbr_midchain_reset_next_node(adj_index_t adj_index)
Return the adjacency&#39;s next node to its default value.
Definition: adj_midchain.c:493
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1144
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:232
#define vec_foreach(var, vec)
Vector iterator.
u16 flags
Copy of main node flags.
Definition: node.h:500
#define CLIB_MEMORY_BARRIER()
Definition: clib.h:132
u8 * format_vnet_link(u8 *s, va_list *ap)
Definition: fib_types.c:41
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:577
u16 dpoi_next_node
The next VLIB node to follow.
Definition: dpo.h:182
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
Definition: buffer_funcs.h:280
#define VLIB_NODE_FLAG_TRACE
Definition: node.h:301
This adjacency/interface has output features configured.
Definition: rewrite.h:57
static const char *const midchain_ethernet_nodes[]
Definition: adj_midchain.c:742
u8 output_feature_arc_index
Definition: ethernet.h:317
static ip46_type_t adj_proto_to_46(fib_protocol_t proto)
Definition: adj_internal.h:82
void dpo_stack(dpo_type_t child_type, dpo_proto_t child_proto, dpo_id_t *dpo, const dpo_id_t *parent)
Stack one DPO object on another, and thus establish a child-parent relationship.
Definition: dpo.c:516