FD.io VPP  v21.01.1
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 #include <vnet/ip/ip4_inlines.h>
27 #include <vnet/ip/ip6_inlines.h>
28 
29 /**
30  * @brief Trace data for packets traversing the midchain tx node
31  */
33 {
34  /**
35  * @brief the midchain adj we are traversing
36  */
39 
44  int interface_count)
45 {
47  u16 nexts[VLIB_FRAME_SIZE], *next;
48  u32 * from, n_left, thread_index;
49  vnet_main_t *vnm = vnet_get_main ();
51 
52  thread_index = vm->thread_index;
53  n_left = frame->n_vectors;
54  from = vlib_frame_vector_args (frame);
55 
56  vlib_get_buffers (vm, from, bufs, n_left);
57 
58  next = nexts;
59  b = bufs;
60 
61  while (n_left > 8)
62  {
63  u32 adj_index0, adj_index1, adj_index2, adj_index3;
64  const ip_adjacency_t *adj0, *adj1, *adj2, *adj3;
65  const dpo_id_t *dpo0, *dpo1, *dpo2, *dpo3;
66 
67  /* Prefetch next iteration. */
68  {
69  vlib_prefetch_buffer_header (b[4], LOAD);
70  vlib_prefetch_buffer_header (b[5], LOAD);
71  vlib_prefetch_buffer_header (b[6], LOAD);
72  vlib_prefetch_buffer_header (b[7], LOAD);
73  }
74 
75  /* Follow the DPO on which the midchain is stacked */
76  adj_index0 = vnet_buffer(b[0])->ip.adj_index[VLIB_TX];
77  adj_index1 = vnet_buffer(b[1])->ip.adj_index[VLIB_TX];
78  adj_index2 = vnet_buffer(b[2])->ip.adj_index[VLIB_TX];
79  adj_index3 = vnet_buffer(b[3])->ip.adj_index[VLIB_TX];
80 
81  adj0 = adj_get(adj_index0);
82  adj1 = adj_get(adj_index1);
83  adj2 = adj_get(adj_index2);
84  adj3 = adj_get(adj_index3);
85 
86  dpo0 = &adj0->sub_type.midchain.next_dpo;
87  dpo1 = &adj1->sub_type.midchain.next_dpo;
88  dpo2 = &adj2->sub_type.midchain.next_dpo;
89  dpo3 = &adj3->sub_type.midchain.next_dpo;
90 
91  next[0] = dpo0->dpoi_next_node;
92  next[1] = dpo1->dpoi_next_node;
93  next[2] = dpo2->dpoi_next_node;
94  next[3] = dpo3->dpoi_next_node;
95 
96  vnet_buffer(b[0])->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
97  vnet_buffer(b[1])->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
98  vnet_buffer(b[2])->ip.adj_index[VLIB_TX] = dpo2->dpoi_index;
99  vnet_buffer(b[3])->ip.adj_index[VLIB_TX] = dpo3->dpoi_index;
100 
101  if (interface_count)
102  {
105  thread_index,
106  adj0->rewrite_header.sw_if_index,
107  1,
108  vlib_buffer_length_in_chain (vm, b[0]));
111  thread_index,
112  adj1->rewrite_header.sw_if_index,
113  1,
114  vlib_buffer_length_in_chain (vm, b[1]));
117  thread_index,
118  adj2->rewrite_header.sw_if_index,
119  1,
120  vlib_buffer_length_in_chain (vm, b[2]));
123  thread_index,
124  adj3->rewrite_header.sw_if_index,
125  1,
126  vlib_buffer_length_in_chain (vm, b[3]));
127  }
128 
130  {
131  if (PREDICT_FALSE(b[0]->flags & VLIB_BUFFER_IS_TRACED))
132  {
133  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
134  b[0], sizeof (*tr));
135  tr->ai = adj_index0;
136  }
137  if (PREDICT_FALSE(b[1]->flags & VLIB_BUFFER_IS_TRACED))
138  {
139  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
140  b[1], sizeof (*tr));
141  tr->ai = adj_index1;
142  }
143  if (PREDICT_FALSE(b[2]->flags & VLIB_BUFFER_IS_TRACED))
144  {
145  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
146  b[2], sizeof (*tr));
147  tr->ai = adj_index2;
148  }
149  if (PREDICT_FALSE(b[3]->flags & VLIB_BUFFER_IS_TRACED))
150  {
151  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
152  b[3], sizeof (*tr));
153  tr->ai = adj_index3;
154  }
155  }
156  n_left -= 4;
157  b += 4;
158  next += 4;
159  }
160 
161  while (n_left)
162  {
163  const ip_adjacency_t * adj0;
164  const dpo_id_t *dpo0;
165  u32 adj_index0;
166 
167  /* Follow the DPO on which the midchain is stacked */
168  adj_index0 = vnet_buffer(b[0])->ip.adj_index[VLIB_TX];
169  adj0 = adj_get(adj_index0);
170  dpo0 = &adj0->sub_type.midchain.next_dpo;
171  next[0] = dpo0->dpoi_next_node;
172  vnet_buffer(b[0])->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
173 
174  if (interface_count)
175  {
178  thread_index,
179  adj0->rewrite_header.sw_if_index,
180  1,
181  vlib_buffer_length_in_chain (vm, b[0]));
182  }
183 
184  if (PREDICT_FALSE(b[0]->flags & VLIB_BUFFER_IS_TRACED))
185  {
186  adj_midchain_tx_trace_t *tr = vlib_add_trace (vm, node,
187  b[0], sizeof (*tr));
188  tr->ai = adj_index0;
189  }
190 
191  n_left -= 1;
192  b += 1;
193  next += 1;
194  }
195 
196  vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors);
197 
198  return frame->n_vectors;
199 }
200 
201 static u8 *
202 format_adj_midchain_tx_trace (u8 * s, va_list * args)
203 {
204  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
205  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
206  adj_midchain_tx_trace_t *tr = va_arg (*args, adj_midchain_tx_trace_t*);
207 
208  s = format(s, "adj-midchain:[%d]:%U", tr->ai,
209  format_ip_adjacency, tr->ai,
211 
212  return (s);
213 }
214 
215 static uword
219 {
220  return (adj_midchain_tx_inline(vm, node, frame, 1));
221 }
222 
224  .function = adj_midchain_tx,
225  .name = "adj-midchain-tx",
226  .vector_size = sizeof (u32),
227 
228  .format_trace = format_adj_midchain_tx_trace,
229 
230  .n_next_nodes = 1,
231  .next_nodes = {
232  [0] = "error-drop",
233  },
234 };
235 
236 static uword
240 {
241  return (adj_midchain_tx_inline(vm, node, frame, 0));
242 }
243 
245  .function = adj_midchain_tx_no_count,
246  .name = "adj-midchain-tx-no-count",
247  .vector_size = sizeof (u32),
248 
249  .format_trace = format_adj_midchain_tx_trace,
250  .sibling_of = "adj-midchain-tx",
251 };
252 
253 #ifndef CLIB_MARCH_VARIANT
254 
255 u8
257 {
258  ip_adjacency_t *adj;
259 
260  adj = adj_get(ai);
261 
262  switch (adj->lookup_next_index)
263  {
266  return (1);
267  case IP_LOOKUP_NEXT_ARP:
271  case IP_LOOKUP_NEXT_DROP:
272  case IP_LOOKUP_NEXT_PUNT:
276  case IP_LOOKUP_N_NEXT:
277  return (0);
278  }
279 
280  return (0);
281 }
282 
283 static inline u32
285 {
286  switch (link) {
287  case VNET_LINK_IP4:
288  return (ip4_midchain_node.index);
289  case VNET_LINK_IP6:
290  return (ip6_midchain_node.index);
291  case VNET_LINK_MPLS:
292  return (mpls_midchain_node.index);
293  case VNET_LINK_ETHERNET:
294  return (adj_l2_midchain_node.index);
295  case VNET_LINK_NSH:
296  return (adj_nsh_midchain_node.index);
297  case VNET_LINK_ARP:
298  break;
299  }
300  ASSERT(0);
301  return (0);
302 }
303 
304 static u8
306 {
307  u8 arc = (u8) ~0;
308  switch (adj->ia_link)
309  {
310  case VNET_LINK_IP4:
311  {
313  break;
314  }
315  case VNET_LINK_IP6:
316  {
318  break;
319  }
320  case VNET_LINK_MPLS:
321  {
323  break;
324  }
325  case VNET_LINK_ETHERNET:
326  {
328  break;
329  }
330  case VNET_LINK_NSH:
331  {
332  arc = nsh_main_placeholder.output_feature_arc_index;
333  break;
334  }
335  case VNET_LINK_ARP:
336  ASSERT(0);
337  break;
338  }
339 
340  ASSERT (arc != (u8) ~0);
341 
342  return (arc);
343 }
344 
345 static u32
347 {
348  return ((adj->ia_flags & ADJ_FLAG_MIDCHAIN_NO_COUNT) ?
350  adj_midchain_tx_node.index);
351 }
352 
353 /**
354  * adj_midchain_setup
355  *
356  * Setup the adj as a mid-chain
357  */
358 void
360 {
362 
363  dpo_reset(&adj->sub_type.midchain.next_dpo);
364 
368  adj->rewrite_header.sw_if_index,
370  (u8*) "interface-output")->index);
372 }
373 
374 /**
375  * adj_midchain_setup
376  *
377  * Setup the adj as a mid-chain
378  */
379 void
381  adj_midchain_fixup_t fixup,
382  const void *data,
384 {
386  ip_adjacency_t *adj;
387  u32 tx_node;
388 
389  ASSERT(ADJ_INDEX_INVALID != adj_index);
390 
391  adj = adj_get(adj_index);
392 
393  adj->sub_type.midchain.fixup_func = fixup;
394  adj->sub_type.midchain.fixup_data = data;
396  adj->ia_flags |= flags;
397 
399  {
400  adj->rewrite_header.flags |= VNET_REWRITE_FIXUP_IP4_O_4;
401  }
402  else
403  {
404  adj->rewrite_header.flags &= ~VNET_REWRITE_FIXUP_IP4_O_4;
405  }
406  if (!(flags & ADJ_FLAG_MIDCHAIN_FIXUP_FLOW_HASH))
407  {
408  adj->rewrite_header.flags &= ~VNET_REWRITE_FIXUP_FLOW_HASH;
409  }
410 
411  tx_node = adj_nbr_midchain_get_tx_node(adj);
412 
416  adj->rewrite_header.sw_if_index,
417  tx_node);
419 
420  /*
421  * stack the midchain on the drop so it's ready to forward in the adj-midchain-tx.
422  * The graph arc used/created here is from the midchain-tx node to the
423  * child's registered node. This is because post adj processing the next
424  * node are any output features, then the midchain-tx. from there we
425  * need to get to the stacked child's node.
426  */
427  dpo_stack_from_node(tx_node,
428  &adj->sub_type.midchain.next_dpo,
430 }
431 
432 /**
433  * adj_nbr_midchain_update_rewrite
434  *
435  * Update the adjacency's rewrite string. A NULL string implies the
436  * rewrite is reset (i.e. when ARP/ND entry is gone).
437  * NB: the adj being updated may be handling traffic in the DP.
438  */
439 void
441  adj_midchain_fixup_t fixup,
442  const void *fixup_data,
444  u8 *rewrite)
445 {
446  ip_adjacency_t *adj;
447 
448  ASSERT(ADJ_INDEX_INVALID != adj_index);
449 
450  adj = adj_get(adj_index);
451 
452  /*
453  * one time only update. since we don't support changing the tunnel
454  * src,dst, this is all we need.
455  */
458  {
459  adj_midchain_setup(adj_index, fixup, fixup_data, flags);
460  }
461 
462  /*
463  * update the rewrite with the workers paused.
464  */
469  rewrite);
470 }
471 
472 void
474  u32 next_node)
475 {
476  ip_adjacency_t *adj;
477  vlib_main_t * vm;
478 
479  ASSERT(ADJ_INDEX_INVALID != adj_index);
480 
481  adj = adj_get(adj_index);
482  vm = vlib_get_main();
483 
485 
486  adj->rewrite_header.next_index = vlib_node_add_next(vlib_get_main(),
487  adj->ia_node_index,
488  next_node);
489 
492  adj->rewrite_header.sw_if_index,
493  next_node);
494 
496 }
497 
498 void
500 {
501  ip_adjacency_t *adj;
502  vlib_main_t * vm;
503 
504  ASSERT(ADJ_INDEX_INVALID != adj_index);
505 
506  adj = adj_get(adj_index);
507  vm = vlib_get_main();
508 
510 
511  adj->rewrite_header.next_index =
513  adj->ia_node_index,
515 
518  adj->rewrite_header.sw_if_index,
520 
522 }
523 
524 /**
525  * adj_nbr_midchain_unstack
526  *
527  * Unstack the adj. stack it on drop
528  */
529 void
531 {
532  fib_node_index_t *entry_indicies, tmp;
533  ip_adjacency_t *adj;
534 
535  ASSERT(ADJ_INDEX_INVALID != adj_index);
536  adj = adj_get (adj_index);
537 
538  /*
539  * check to see if this unstacking breaks a recursion loop
540  */
541  entry_indicies = NULL;
542  tmp = adj->sub_type.midchain.fei;
544 
545  if (FIB_NODE_INDEX_INVALID != tmp)
546  {
547  fib_entry_recursive_loop_detect(tmp, &entry_indicies);
548  vec_free(entry_indicies);
549  }
550 
551  /*
552  * stack on the drop
553  */
556  &adj->sub_type.midchain.next_dpo,
559 }
560 
561 void
563  fib_node_index_t fei,
565 {
566  fib_node_index_t *entry_indicies;
567  dpo_id_t tmp = DPO_INVALID;
568  ip_adjacency_t *adj;
569 
570  adj = adj_get (ai);
571 
572  /*
573  * check to see if this stacking will form a recursion loop
574  */
575  entry_indicies = NULL;
576  adj->sub_type.midchain.fei = fei;
577 
578  if (fib_entry_recursive_loop_detect(adj->sub_type.midchain.fei, &entry_indicies))
579  {
580  /*
581  * loop formed, stack on the drop.
582  */
584  }
585  else
586  {
587  fib_entry_contribute_forwarding (fei, fct, &tmp);
588 
589  if (DPO_LOAD_BALANCE == tmp.dpoi_type)
590  {
591  load_balance_t *lb;
592 
593  lb = load_balance_get (tmp.dpoi_index);
594 
595  if ((adj->ia_flags & ADJ_FLAG_MIDCHAIN_IP_STACK) ||
596  lb->lb_n_buckets == 1)
597  {
598  /*
599  * do that hash now and stack on the choice.
600  * If the choice is an incomplete adj then we will need a poke when
601  * it becomes complete. This happens since the adj update walk propagates
602  * as far a recursive paths.
603  */
604  const dpo_id_t *choice;
605  int hash;
606 
608  {
610  lb->lb_hash_config);
611  }
612  else if (FIB_FORW_CHAIN_TYPE_UNICAST_IP6 == fct)
613  {
615  lb->lb_hash_config);
616  }
617  else
618  {
619  hash = 0;
620  ASSERT(0);
621  }
622 
623  choice = load_balance_get_bucket_i (lb, hash & lb->lb_n_buckets_minus_1);
624  dpo_copy (&tmp, choice);
625  }
627  {
628  adj->rewrite_header.flags |= VNET_REWRITE_FIXUP_FLOW_HASH;
629  }
630  }
631  }
632  adj_nbr_midchain_stack (ai, &tmp);
633  dpo_reset(&tmp);
634  vec_free(entry_indicies);
635 }
636 
637 /**
638  * adj_nbr_midchain_stack
639  */
640 void
642  const dpo_id_t *next)
643 {
644  ip_adjacency_t *adj;
645 
646  ASSERT(ADJ_INDEX_INVALID != adj_index);
647 
648  adj = adj_get(adj_index);
649 
652 
654  &adj->sub_type.midchain.next_dpo,
655  next);
656 }
657 
658 int
660  fib_node_index_t **entry_indicies)
661 {
662  fib_node_index_t *entry_index, *entries;
663  ip_adjacency_t * adj;
664 
665  adj = adj_get(ai);
666  entries = *entry_indicies;
667 
668  vec_foreach(entry_index, entries)
669  {
670  if (*entry_index == adj->sub_type.midchain.fei)
671  {
672  /*
673  * The entry this midchain links to is already in the set
674  * of visited entries, this is a loop
675  */
677  return (1);
678  }
679  }
680 
682  return (0);
683 }
684 
685 u8*
686 format_adj_midchain (u8* s, va_list *ap)
687 {
688  index_t index = va_arg(*ap, index_t);
689  u32 indent = va_arg(*ap, u32);
690  ip_adjacency_t * adj = adj_get(index);
691 
692  s = format (s, "%U", format_vnet_link, adj->ia_link);
693  if (adj->rewrite_header.flags & VNET_REWRITE_HAS_FEATURES)
694  s = format(s, " [features]");
695  s = format (s, " via %U",
696  format_ip46_address, &adj->sub_type.nbr.next_hop,
698  s = format (s, " %U",
700  &adj->rewrite_header, sizeof (adj->rewrite_data), indent);
701  s = format (s, "\n%Ustacked-on",
702  format_white_space, indent);
703 
704  if (FIB_NODE_INDEX_INVALID != adj->sub_type.midchain.fei)
705  {
706  s = format (s, " entry:%d", adj->sub_type.midchain.fei);
707 
708  }
709  s = format (s, ":\n%U%U",
710  format_white_space, indent+2,
711  format_dpo_id, &adj->sub_type.midchain.next_dpo, indent+2);
712 
713  return (s);
714 }
715 
716 static void
718 {
719  adj_lock(dpo->dpoi_index);
720 }
721 static void
723 {
724  adj_unlock(dpo->dpoi_index);
725 }
726 
727 const static dpo_vft_t adj_midchain_dpo_vft = {
729  .dv_unlock = adj_dpo_unlock,
730  .dv_format = format_adj_midchain,
731  .dv_get_urpf = adj_dpo_get_urpf,
732 };
733 
734 /**
735  * @brief The per-protocol VLIB graph nodes that are assigned to a midchain
736  * object.
737  *
738  * this means that these graph nodes are ones from which a midchain is the
739  * parent object in the DPO-graph.
740  */
741 const static char* const midchain_ip4_nodes[] =
742 {
743  "ip4-midchain",
744  NULL,
745 };
746 const static char* const midchain_ip6_nodes[] =
747 {
748  "ip6-midchain",
749  NULL,
750 };
751 const static char* const midchain_mpls_nodes[] =
752 {
753  "mpls-midchain",
754  NULL,
755 };
756 const static char* const midchain_ethernet_nodes[] =
757 {
758  "adj-l2-midchain",
759  NULL,
760 };
761 const static char* const midchain_nsh_nodes[] =
762 {
763  "adj-nsh-midchain",
764  NULL,
765 };
766 
767 const static char* const * const midchain_nodes[DPO_PROTO_NUM] =
768 {
774 };
775 
776 void
778 {
779  dpo_register(DPO_ADJACENCY_MIDCHAIN, &adj_midchain_dpo_vft, midchain_nodes);
780 }
781 
782 #endif
static uword adj_midchain_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: adj_midchain.c:216
static const char *const midchain_nsh_nodes[]
Definition: adj_midchain.c:761
static const char *const midchain_ip6_nodes[]
Definition: adj_midchain.c:746
u16 lb_n_buckets
number of buckets in the load-balance.
Definition: load_balance.h:116
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:536
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:411
adj_flags_t ia_flags
Flags on the adjacency 1-bytes.
Definition: adj.h:356
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:112
vlib_node_registration_t ip6_midchain_node
(constructor) VLIB_REGISTER_NODE (ip6_midchain_node)
Definition: ip6_forward.c:2194
#define CLIB_UNUSED(x)
Definition: clib.h:87
A virtual function table regisitered for a DPO type.
Definition: dpo.h:406
vlib_node_registration_t adj_midchain_tx_node
(constructor) VLIB_REGISTER_NODE (adj_midchain_tx_node)
Definition: adj_midchain.c:223
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105
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:239
void adj_lock(adj_index_t adj_index)
Take a reference counting lock on the adjacency.
Definition: adj.c:330
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:237
vnet_interface_main_t interface_main
Definition: vnet.h:65
static const char *const midchain_ip4_nodes[]
The per-protocol VLIB graph nodes that are assigned to a midchain object.
Definition: adj_midchain.c:741
const u8 * adj_get_rewrite(adj_index_t ai)
Return the rewrite string of the adjacency.
Definition: adj.c:542
static u32 ip4_compute_flow_hash(const ip4_header_t *ip, flow_hash_config_t flow_hash_config)
Definition: ip4_inlines.h:51
Multicast Adjacency.
Definition: adj.h:82
Broadcast Adjacency.
Definition: adj.h:85
IP unicast adjacency.
Definition: adj.h:235
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:2669
u32 thread_index
Definition: main.h:250
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:516
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:108
ip_lookup_main_t lookup_main
Definition: ip4.h:109
struct ip_adjacency_t_::@161::@163 midchain
IP_LOOKUP_NEXT_MIDCHAIN.
vlib_main_t * vm
Definition: in2out_ed.c:1580
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:320
this adj performs the flow hash fixup
Definition: rewrite.h:67
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:90
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:205
vnet_link_t ia_link
link/ether-type 1 bytes
Definition: adj.h:343
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:145
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:467
struct ip_adjacency_t_::@161::@162 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
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:327
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:882
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
description fragment has unexpected format
Definition: map.api:433
#define vlib_prefetch_buffer_header(b, type)
Prefetch buffer metadata.
Definition: buffer.h:207
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:473
static const char *const *const midchain_nodes[DPO_PROTO_NUM]
Definition: adj_midchain.c:767
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:562
const cJSON *const b
Definition: cJSON.h:255
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
Definition: adj.c:347
vlib_node_registration_t mpls_midchain_node
(constructor) VLIB_REGISTER_NODE (mpls_midchain_node)
Definition: mpls_output.c:360
unsigned int u32
Definition: types.h:88
format_function_t format_vnet_rewrite
Definition: rewrite.h:268
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:41
#define VLIB_FRAME_SIZE
Definition: node.h:378
u8 output_feature_arc_index
Definition: mpls.h:57
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:751
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:284
dpo_type_t dpoi_type
the type
Definition: dpo.h:176
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:32
nsh_main_placeholder_t nsh_main_placeholder
Definition: adj_nsh.c:21
void adj_midchain_module_init(void)
Module initialisation.
Definition: adj_midchain.c:777
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:659
unsigned short u16
Definition: types.h:57
adj_index_t ai
the midchain adj we are traversing
Definition: adj_midchain.c:37
load-balancing over a choice of [un]equal cost paths
Definition: dpo.h:102
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:330
#define PREDICT_FALSE(x)
Definition: clib.h:121
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:2785
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:305
vlib_node_registration_t adj_midchain_tx_no_count_node
(constructor) VLIB_REGISTER_NODE (adj_midchain_tx_no_count_node)
Definition: adj_midchain.c:244
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:170
u16 n_vectors
Definition: node.h:397
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:722
#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:202
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:440
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:29
void adj_midchain_teardown(ip_adjacency_t *adj)
adj_midchain_setup
Definition: adj_midchain.c:359
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:1580
u8 * format_adj_midchain(u8 *s, va_list *ap)
Format a midchain adjacency.
Definition: adj_midchain.c:686
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:346
#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:641
ip_lookup_main_t lookup_main
Definition: ip6.h:112
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
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:247
void adj_nbr_midchain_unstack(adj_index_t adj_index)
adj_nbr_midchain_unstack
Definition: adj_midchain.c:530
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:717
enum adj_flags_t_ adj_flags_t
Flags on an IP adjacency.
static u32 ip6_compute_flow_hash(const ip6_header_t *ip, flow_hash_config_t flow_hash_config)
Definition: ip6_inlines.h:49
union ip_adjacency_t_::@161 sub_type
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:350
Definition: defs.h:47
#define DPO_PROTO_NUM
Definition: dpo.h:70
u8 adj_is_midchain(adj_index_t ai)
Definition: adj_midchain.c:256
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:188
#define FIB_NODE_INDEX_INVALID
Definition: fib_types.h:30
ip_lookup_next_t lookup_next_index
Next hop after ip4-lookup.
Definition: adj.h:337
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
Definition: in2out_ed.c:1581
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:380
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:202
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:1561
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:499
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
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:501
#define CLIB_MEMORY_BARRIER()
Definition: clib.h:133
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:634
u16 dpoi_next_node
The next VLIB node to follow.
Definition: dpo.h:184
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:302
This adjacency/interface has output features configured.
Definition: rewrite.h:57
static const char *const midchain_ethernet_nodes[]
Definition: adj_midchain.c:756
u8 output_feature_arc_index
Definition: ethernet.h:328
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:521