FD.io VPP  v20.05-21-gb1500e9ff
Vector Packet Processing
adj_nbr.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>
19 #include <vnet/fib/fib_walk.h>
20 
21 /*
22  * Vector Hash tables of neighbour (traditional) adjacencies
23  * Key: interface(for the vector index), address (and its proto),
24  * link-type/ether-type.
25  */
27 
28 typedef struct adj_nbr_key_t_
29 {
30  ip46_address_t ank_ip;
33 
34 #define ADJ_NBR_SET_KEY(_key, _lt, _nh) \
35 { \
36  ip46_address_copy(&(_key).ank_ip, (_nh)); \
37  _key.ank_linkt = (_lt); \
38 }
39 
40 #define ADJ_NBR_ITF_OK(_proto, _itf) \
41  (((_itf) < vec_len(adj_nbr_tables[_proto])) && \
42  (NULL != adj_nbr_tables[_proto][sw_if_index]))
43 
44 static void
46  vnet_link_t link_type,
47  const ip46_address_t *nh_addr,
49  adj_index_t adj_index)
50 {
51  adj_nbr_key_t kv;
52 
53  if (sw_if_index >= vec_len(adj_nbr_tables[nh_proto]))
54  {
55  vec_validate(adj_nbr_tables[nh_proto], sw_if_index);
56  }
57  if (NULL == adj_nbr_tables[nh_proto][sw_if_index])
58  {
59  adj_nbr_tables[nh_proto][sw_if_index] =
60  hash_create_mem(0, sizeof(adj_nbr_key_t), sizeof(adj_index_t));
61  }
62 
63  ADJ_NBR_SET_KEY(kv, link_type, nh_addr);
64 
65  hash_set_mem_alloc (&adj_nbr_tables[nh_proto][sw_if_index],
66  &kv, adj_index);
67 }
68 
69 void
71  fib_protocol_t nh_proto,
72  vnet_link_t link_type,
73  const ip46_address_t *nh_addr,
75 {
76  adj_nbr_key_t kv;
77 
78  if (!ADJ_NBR_ITF_OK(nh_proto, sw_if_index))
79  return;
80 
81  ADJ_NBR_SET_KEY(kv, link_type, nh_addr);
82 
83  hash_unset_mem_free(&adj_nbr_tables[nh_proto][sw_if_index], &kv);
84 
85  if (0 == hash_elts(adj_nbr_tables[nh_proto][sw_if_index]))
86  {
87  hash_free(adj_nbr_tables[nh_proto][sw_if_index]);
88  }
89 }
90 
93  vnet_link_t link_type,
94  const ip46_address_t *nh_addr,
96 {
97  adj_nbr_key_t kv;
98  uword *p;
99 
100  ADJ_NBR_SET_KEY(kv, link_type, nh_addr);
101 
102  if (!ADJ_NBR_ITF_OK(nh_proto, sw_if_index))
103  return (ADJ_INDEX_INVALID);
104 
105  p = hash_get_mem(adj_nbr_tables[nh_proto][sw_if_index], &kv);
106 
107  if (p)
108  {
109  return (p[0]);
110  }
111  return (ADJ_INDEX_INVALID);
112 }
113 
114 static inline u32
116 {
117  switch (proto) {
118  case FIB_PROTOCOL_IP4:
119  return (ip4_arp_node.index);
120  case FIB_PROTOCOL_IP6:
121  return (ip6_discover_neighbor_node.index);
122  case FIB_PROTOCOL_MPLS:
123  break;
124  }
125  ASSERT(0);
126  return (ip4_arp_node.index);
127 }
128 
129 /**
130  * @brief Check and set feature flags if o/p interface has any o/p features.
131  */
132 static void
134 {
135  ip_adjacency_t *adj;
137  i16 feature_count;
138  u8 arc_index;
140 
141  adj = adj_get(ai);
142 
143  switch (adj->ia_link)
144  {
145  case VNET_LINK_IP4:
147  break;
148  case VNET_LINK_IP6:
150  break;
151  case VNET_LINK_MPLS:
153  break;
154  default:
155  return;
156  }
157 
158  sw_if_index = adj->rewrite_header.sw_if_index;
159  if (vec_len(fm->feature_count_by_sw_if_index[arc_index]) > sw_if_index)
160  {
161  feature_count = fm->feature_count_by_sw_if_index[arc_index][sw_if_index];
162  if (feature_count > 0)
163  {
165 
166  adj->rewrite_header.flags |= VNET_REWRITE_HAS_FEATURES;
167  cm = &fm->feature_config_mains[arc_index];
168 
170  sw_if_index);
171  }
172  }
173  return;
174 }
175 
176 static ip_adjacency_t*
178  vnet_link_t link_type,
179  const ip46_address_t *nh_addr,
181 {
182  ip_adjacency_t *adj;
183 
184  adj = adj_alloc(nh_proto);
185 
186  adj_nbr_insert(nh_proto, link_type, nh_addr,
187  sw_if_index,
188  adj_get_index(adj));
189 
190  /*
191  * since we just added the ADJ we have no rewrite string for it,
192  * so its for ARP
193  */
195  adj->sub_type.nbr.next_hop = *nh_addr;
196  adj->ia_link = link_type;
197  adj->ia_nh_proto = nh_proto;
198  adj->rewrite_header.sw_if_index = sw_if_index;
200  &adj->rewrite_header);
201 
203  return (adj);
204 }
205 
206 /*
207  * adj_nbr_add_or_lock
208  *
209  * Add an adjacency for the neighbour requested.
210  *
211  * The key for an adj is:
212  * - the Next-hops protocol (i.e. v4 or v6)
213  * - the address of the next-hop
214  * - the interface the next-hop is reachable through
215  */
218  vnet_link_t link_type,
219  const ip46_address_t *nh_addr,
221 {
222  adj_index_t adj_index;
223 
224  adj_index = adj_nbr_find(nh_proto, link_type, nh_addr, sw_if_index);
225 
226  if (ADJ_INDEX_INVALID == adj_index)
227  {
228  ip_adjacency_t *adj;
229  vnet_main_t *vnm;
230 
231  vnm = vnet_get_main();
232  adj = adj_nbr_alloc(nh_proto, link_type, nh_addr, sw_if_index);
233  adj_index = adj_get_index(adj);
234  adj_lock(adj_index);
235 
236  if (ip46_address_is_equal(&ADJ_BCAST_ADDR, nh_addr))
237  {
239  }
240 
241  vnet_rewrite_init(vnm, sw_if_index, link_type,
242  adj_get_nd_node(nh_proto),
243  vnet_tx_node_index_for_sw_interface(vnm, sw_if_index),
244  &adj->rewrite_header);
245 
246  /*
247  * we need a rewrite where the destination IP address is converted
248  * to the appropriate link-layer address. This is interface specific.
249  * So ask the interface to do it.
250  */
251  vnet_update_adjacency_for_sw_interface(vnm, sw_if_index, adj_index);
252  }
253  else
254  {
255  adj_lock(adj_index);
256  }
257 
258  adj_delegate_adj_created(adj_get(adj_index));
259  return (adj_index);
260 }
261 
264  vnet_link_t link_type,
265  const ip46_address_t *nh_addr,
267  u8 *rewrite)
268 {
269  adj_index_t adj_index;
270 
271  adj_index = adj_nbr_find(nh_proto, link_type, nh_addr, sw_if_index);
272 
273  if (ADJ_INDEX_INVALID == adj_index)
274  {
275  ip_adjacency_t *adj;
276 
277  adj = adj_nbr_alloc(nh_proto, link_type, nh_addr, sw_if_index);
278  adj->rewrite_header.sw_if_index = sw_if_index;
279  adj_index = adj_get_index(adj);
280  }
281 
282  adj_lock(adj_index);
283  adj_nbr_update_rewrite(adj_index,
285  rewrite);
286 
287  adj_delegate_adj_created(adj_get(adj_index));
288 
289  return (adj_index);
290 }
291 
292 /**
293  * adj_nbr_update_rewrite
294  *
295  * Update the adjacency's rewrite string. A NULL string implies the
296  * rewrite is reset (i.e. when ARP/ND entry is gone).
297  * NB: the adj being updated may be handling traffic in the DP.
298  */
299 void
302  u8 *rewrite)
303 {
304  ip_adjacency_t *adj;
305 
306  ASSERT(ADJ_INDEX_INVALID != adj_index);
307 
308  adj = adj_get(adj_index);
309 
310  if (flags & ADJ_NBR_REWRITE_FLAG_COMPLETE)
311  {
312  /*
313  * update the adj's rewrite string and build the arc
314  * from the rewrite node to the interface's TX node
315  */
319  vnet_get_main(),
320  adj->rewrite_header.sw_if_index),
321  rewrite);
322  }
323  else
324  {
328  vnet_get_main(),
329  adj->rewrite_header.sw_if_index),
330  rewrite);
331  }
332 }
333 
334 /**
335  * adj_nbr_update_rewrite_internal
336  *
337  * Update the adjacency's rewrite string. A NULL string implies the
338  * rewrite is reset (i.e. when ARP/ND entry is gone).
339  * NB: the adj being updated may be handling traffic in the DP.
340  */
341 void
343  ip_lookup_next_t adj_next_index,
344  u32 this_node,
345  u32 next_node,
346  u8 *rewrite)
347 {
348  ip_adjacency_t *walk_adj;
349  adj_index_t walk_ai, ai;
350  vlib_main_t * vm;
351  u32 old_next;
352  int do_walk;
353 
354  vm = vlib_get_main();
355  old_next = adj->lookup_next_index;
356 
357  ai = walk_ai = adj_get_index(adj);
358  if (VNET_LINK_MPLS == adj->ia_link)
359  {
360  /*
361  * The link type MPLS has no children in the control plane graph, it only
362  * has children in the data-plane graph. The backwalk is up the former.
363  * So we need to walk from its IP cousin.
364  */
365  walk_ai = adj_nbr_find(adj->ia_nh_proto,
367  &adj->sub_type.nbr.next_hop,
368  adj->rewrite_header.sw_if_index);
369  }
370 
371  /*
372  * Don't call the walk re-entrantly
373  */
374  if (ADJ_INDEX_INVALID != walk_ai)
375  {
376  walk_adj = adj_get(walk_ai);
377  if (ADJ_FLAG_SYNC_WALK_ACTIVE & walk_adj->ia_flags)
378  {
379  do_walk = 0;
380  }
381  else
382  {
383  /*
384  * Prevent re-entrant walk of the same adj
385  */
386  walk_adj->ia_flags |= ADJ_FLAG_SYNC_WALK_ACTIVE;
387  do_walk = 1;
388  }
389  }
390  else
391  {
392  do_walk = 0;
393  }
394 
395  /*
396  * lock the adjacencies that are affected by updates this walk will provoke.
397  * Since the aim of the walk is to update children to link to a different
398  * DPO, this adj will no longer be in use and its lock count will drop to 0.
399  * We don't want it to be deleted as part of this endeavour.
400  */
401  adj_lock(ai);
402  adj_lock(walk_ai);
403 
404  /*
405  * Updating a rewrite string is not atomic;
406  * - the rewrite string is too long to write in one instruction
407  * - when swapping from incomplete to complete, we also need to update
408  * the VLIB graph next-index of the adj.
409  * ideally we would only want to suspend forwarding via this adj whilst we
410  * do this, but we do not have that level of granularity - it's suspend all
411  * worker threads or nothing.
412  * The other choices are:
413  * - to mark the adj down and back walk so child load-balances drop this adj
414  * from the set.
415  * - update the next_node index of this adj to point to error-drop
416  * both of which will mean for MAC change we will drop for this adj
417  * which is not acceptable. However, when the adj changes type (from
418  * complete to incomplete and vice-versa) the child DPOs, which have the
419  * VLIB graph next node index, will be sending packets to the wrong graph
420  * node. So from the options above, updating the next_node of the adj to
421  * be drop will work, but it relies on each graph node v4/v6/mpls, rewrite/
422  * arp/midchain always be valid w.r.t. a mis-match of adj type and node type
423  * (i.e. a rewrite adj in the arp node). This is not enforceable. Getting it
424  * wrong will lead to hard to find bugs since its a race condition. So we
425  * choose the more reliable method of updating the children to use the drop,
426  * then switching adj's type, then updating the children again. Did I mention
427  * that this doesn't happen often...
428  * So we need to distinguish between the two cases:
429  * 1 - mac change
430  * 2 - adj type change
431  */
432  if (do_walk &&
433  old_next != adj_next_index &&
434  ADJ_INDEX_INVALID != walk_ai)
435  {
436  /*
437  * the adj is changing type. we need to fix all children so that they
438  * stack momentarily on a drop, while the adj changes. If we don't do
439  * this the children will send packets to a VLIB graph node that does
440  * not correspond to the adj's type - and it goes downhill from there.
441  */
442  fib_node_back_walk_ctx_t bw_ctx = {
444  /*
445  * force this walk to be synchronous. if we don't and a node in the graph
446  * (a heavily shared path-list) chooses to back-ground the walk (make it
447  * async) then it will pause and we will do the adj update below, before
448  * all the children are updated. not good.
449  */
450  .fnbw_flags = FIB_NODE_BW_FLAG_FORCE_SYNC,
451  };
452 
453  fib_walk_sync(FIB_NODE_TYPE_ADJ, walk_ai, &bw_ctx);
454  /*
455  * fib_walk_sync may allocate a new adjacency and potentially cuase a
456  * realloc for adj_pool. When that happens, adj pointer is no longer
457  * valid here. We refresh the adj pointer accordingly.
458  */
459  adj = adj_get (ai);
460  }
461 
462  /*
463  * If we are just updating the MAC string of the adj (which we also can't
464  * do atomically), then we need to stop packets switching through the adj.
465  * We can't do that on a per-adj basis, so it's all the packets.
466  * If we are updating the type, and we walked back to the children above,
467  * then this barrier serves to flush the queues/frames.
468  */
470 
471  adj->lookup_next_index = adj_next_index;
472  adj->ia_node_index = this_node;
473 
474  if (NULL != rewrite)
475  {
476  /*
477  * new rewrite provided.
478  * fill in the adj's rewrite string, and build the VLIB graph arc.
479  */
480  vnet_rewrite_set_data_internal(&adj->rewrite_header,
481  sizeof(adj->rewrite_data),
482  rewrite,
483  vec_len(rewrite));
484  vec_free(rewrite);
485  }
486  else
487  {
488  vnet_rewrite_clear_data_internal(&adj->rewrite_header,
489  sizeof(adj->rewrite_data));
490  }
491  adj->rewrite_header.next_index = vlib_node_add_next(vlib_get_main(),
492  this_node,
493  next_node);
494 
495  /*
496  * done with the rewrite update - let the workers loose.
497  */
499 
500  if (do_walk &&
501  (old_next != adj->lookup_next_index) &&
502  (ADJ_INDEX_INVALID != walk_ai))
503  {
504  /*
505  * backwalk to the children so they can stack on the now updated
506  * adjacency
507  */
508  fib_node_back_walk_ctx_t bw_ctx = {
510  };
511 
512  fib_walk_sync(FIB_NODE_TYPE_ADJ, walk_ai, &bw_ctx);
513  }
514  /*
515  * Prevent re-entrant walk of the same adj
516  */
517  if (do_walk)
518  {
519  walk_adj = adj_get(walk_ai);
520  walk_adj->ia_flags &= ~ADJ_FLAG_SYNC_WALK_ACTIVE;
521  }
522 
524  adj_unlock(ai);
525  adj_unlock(walk_ai);
526 }
527 
528 u32
530 {
532  u32 sw_if_index = 0;
533  u64 count = 0;
534 
535  for (proto = FIB_PROTOCOL_IP4; proto <= FIB_PROTOCOL_IP6; proto++)
536  {
537  vec_foreach_index(sw_if_index, adj_nbr_tables[proto])
538  {
539  if (NULL != adj_nbr_tables[proto][sw_if_index])
540  {
541  count += hash_elts(adj_nbr_tables[proto][sw_if_index]);
542  }
543  }
544  }
545  return (count);
546 }
547 
548 /**
549  * @brief Walk all adjacencies on a link for a given next-hop protocol
550  */
551 void
553  fib_protocol_t adj_nh_proto,
554  adj_walk_cb_t cb,
555  void *ctx)
556 {
557  adj_index_t ai, *ais, *aip;
559 
560  if (!ADJ_NBR_ITF_OK(adj_nh_proto, sw_if_index))
561  return;
562 
563  ais = NULL;
564 
565  /* elements may be removed from the table during the walk, so
566  * collect the set first then process them */
567  hash_foreach_mem (key, ai, adj_nbr_tables[adj_nh_proto][sw_if_index],
568  ({
569  vec_add1(ais, ai);
570  }));
571 
572  vec_foreach(aip, ais)
573  {
574  /* An adj may be deleted during the walk so check first */
575  if (!pool_is_free_index(adj_pool, *aip))
576  cb(*aip, ctx);
577  }
578  vec_free(ais);
579 }
580 
581 /**
582  * @brief Walk adjacencies on a link with a given v4 next-hop.
583  * that is visit the adjacencies with different link types.
584  */
585 void
587  const ip4_address_t *addr,
588  adj_walk_cb_t cb,
589  void *ctx)
590 {
591  if (!ADJ_NBR_ITF_OK(FIB_PROTOCOL_IP4, sw_if_index))
592  return;
593 
594  ip46_address_t nh = {
595  .ip4 = *addr,
596  };
597  vnet_link_t linkt;
598  adj_index_t ai;
599 
600  FOR_EACH_VNET_LINK(linkt)
601  {
602  ai = adj_nbr_find (FIB_PROTOCOL_IP4, linkt, &nh, sw_if_index);
603 
604  if (INDEX_INVALID != ai)
605  cb(ai, ctx);
606  }
607 }
608 
609 /**
610  * @brief Walk adjacencies on a link with a given v6 next-hop.
611  * that is visit the adjacencies with different link types.
612  */
613 void
615  const ip6_address_t *addr,
616  adj_walk_cb_t cb,
617  void *ctx)
618 {
619  if (!ADJ_NBR_ITF_OK(FIB_PROTOCOL_IP6, sw_if_index))
620  return;
621 
622  ip46_address_t nh = {
623  .ip6 = *addr,
624  };
625  vnet_link_t linkt;
626  adj_index_t ai;
627 
628  FOR_EACH_VNET_LINK(linkt)
629  {
630  ai = adj_nbr_find (FIB_PROTOCOL_IP6, linkt, &nh, sw_if_index);
631 
632  if (INDEX_INVALID != ai)
633  cb(ai, ctx);
634  }
635 }
636 
637 /**
638  * @brief Walk adjacencies on a link with a given next-hop.
639  * that is visit the adjacencies with different link types.
640  */
641 void
643  fib_protocol_t adj_nh_proto,
644  const ip46_address_t *nh,
645  adj_walk_cb_t cb,
646  void *ctx)
647 {
648  if (!ADJ_NBR_ITF_OK(adj_nh_proto, sw_if_index))
649  return;
650 
651  switch (adj_nh_proto)
652  {
653  case FIB_PROTOCOL_IP4:
654  adj_nbr_walk_nh4(sw_if_index, &nh->ip4, cb, ctx);
655  break;
656  case FIB_PROTOCOL_IP6:
657  adj_nbr_walk_nh6(sw_if_index, &nh->ip6, cb, ctx);
658  break;
659  case FIB_PROTOCOL_MPLS:
660  ASSERT(0);
661  break;
662  }
663 }
664 
665 /**
666  * Flags associated with the interface state walks
667  */
669 {
672 
673 /**
674  * Context for the state change walk of the DB
675  */
677 {
678  /**
679  * Flags on the interface
680  */
683 
684 static adj_walk_rc_t
686  void *arg)
687 {
688  /*
689  * Back walk the graph to inform the forwarding entries
690  * that this interface state has changed. Do this synchronously
691  * since this is the walk that provides convergence
692  */
694  fib_node_back_walk_ctx_t bw_ctx = {
695  .fnbw_reason = ((ctx->flags & ADJ_NBR_INTERFACE_UP) ?
698  /*
699  * the force sync applies only as far as the first fib_entry.
700  * And it's the fib_entry's we need to converge away from
701  * the adjacencies on the now down link
702  */
703  .fnbw_flags = (!(ctx->flags & ADJ_NBR_INTERFACE_UP) ?
706  };
707  ip_adjacency_t *adj;
708 
709  adj = adj_get(ai);
710 
712  fib_walk_sync(FIB_NODE_TYPE_ADJ, ai, &bw_ctx);
714 
715  return (ADJ_WALK_RC_CONTINUE);
716 }
717 
718 /**
719  * @brief Registered function for SW interface state changes
720  */
721 static clib_error_t *
724  u32 flags)
725 {
727 
728  /*
729  * walk each adj on the interface and trigger a walk from that adj
730  */
731  for (proto = FIB_PROTOCOL_IP4; proto <= FIB_PROTOCOL_IP6; proto++)
732  {
734  .flags = ((flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ?
736  0),
737  };
738 
739  adj_nbr_walk(sw_if_index, proto,
741  &ctx);
742  }
743 
744  return (NULL);
745 }
746 
750 
751 /**
752  * @brief Invoked on each SW interface of a HW interface when the
753  * HW interface state changes
754  */
755 static walk_rc_t
758  void *arg)
759 {
762 
763  /*
764  * walk each adj on the interface and trigger a walk from that adj
765  */
766  for (proto = FIB_PROTOCOL_IP4; proto <= FIB_PROTOCOL_IP6; proto++)
767  {
768  adj_nbr_walk(sw_if_index, proto,
770  ctx);
771  }
772  return (WALK_CONTINUE);
773 }
774 
775 /**
776  * @brief Registered callback for HW interface state changes
777  */
778 static clib_error_t *
780  u32 hw_if_index,
781  u32 flags)
782 {
783  /*
784  * walk SW interface on the HW
785  */
787  .flags = ((flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ?
789  0),
790  };
791 
792  vnet_hw_interface_walk_sw(vnm, hw_if_index,
794  &ctx);
795 
796  return (NULL);
797 }
798 
802 
803 static adj_walk_rc_t
805  void *arg)
806 {
807  /*
808  * Back walk the graph to inform the forwarding entries
809  * that this interface has been deleted.
810  */
811  fib_node_back_walk_ctx_t bw_ctx = {
813  };
814  ip_adjacency_t *adj;
815 
816  adj_lock(ai);
817 
818  adj = adj_get(ai);
819 
821  fib_walk_sync(FIB_NODE_TYPE_ADJ, ai, &bw_ctx);
823 
824  adj_unlock(ai);
825  return (ADJ_WALK_RC_CONTINUE);
826 }
827 
828 /**
829  * adj_nbr_interface_add_del
830  *
831  * Registered to receive interface Add and delete notifications
832  */
833 static clib_error_t *
836  u32 is_add)
837 {
839 
840  if (is_add)
841  {
842  /*
843  * not interested in interface additions. we will not back walk
844  * to resolve paths through newly added interfaces. Why? The control
845  * plane should have the brains to add interfaces first, then routes.
846  * So the case where there are paths with a interface that matches
847  * one just created is the case where the path resolved through an
848  * interface that was deleted, and still has not been removed. The
849  * new interface added, is NO GUARANTEE that the interface being
850  * added now, even though it may have the same sw_if_index, is the
851  * same interface that the path needs. So tough!
852  * If the control plane wants these routes to resolve it needs to
853  * remove and add them again.
854  */
855  return (NULL);
856  }
857 
858  for (proto = FIB_PROTOCOL_IP4; proto <= FIB_PROTOCOL_IP6; proto++)
859  {
860  adj_nbr_walk(sw_if_index, proto,
862  NULL);
863  }
864 
865  return (NULL);
866 
867 }
868 
870 
871 
872 static adj_walk_rc_t
874  void *arg)
875 {
876  vlib_cli_output (arg, "[@%d] %U",
877  ai,
880 
881  return (ADJ_WALK_RC_CONTINUE);
882 }
883 
884 static clib_error_t *
886  unformat_input_t * input,
887  vlib_cli_command_t * cmd)
888 {
890  ip46_address_t nh = ip46_address_initializer;
891  u32 sw_if_index = ~0;
892 
894  {
895  if (unformat (input, "%U",
897  &sw_if_index))
898  ;
899  else if (unformat (input, "%U",
901  ;
902  else if (unformat (input, "%d", &ai))
903  ;
904  else
905  break;
906  }
907 
908  if (ADJ_INDEX_INVALID != ai)
909  {
910  vlib_cli_output (vm, "[@%d] %U",
911  ai,
914  }
915  else if (~0 != sw_if_index)
916  {
918 
919  if (ip46_address_is_zero(&nh))
920  {
921  for (proto = FIB_PROTOCOL_IP4; proto <= FIB_PROTOCOL_IP6; proto++)
922  {
923  adj_nbr_walk(sw_if_index, proto,
925  vm);
926  }
927  }
928  else
929  {
930  proto = (ip46_address_is_ip4(&nh) ?
933  adj_nbr_walk_nh(sw_if_index, proto, &nh,
935  vm);
936  }
937  }
938  else
939  {
941 
942  for (proto = FIB_PROTOCOL_IP4; proto <= FIB_PROTOCOL_IP6; proto++)
943  {
944  vec_foreach_index(sw_if_index, adj_nbr_tables[proto])
945  {
946  adj_nbr_walk(sw_if_index, proto,
948  vm);
949  }
950  }
951  }
952 
953  return 0;
954 }
955 
956 /*?
957  * Show all neighbour adjacencies.
958  * @cliexpar
959  * @cliexstart{sh adj nbr}
960  * [@2] ipv4 via 1.0.0.2 loop0: IP4: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
961  * [@3] mpls via 1.0.0.2 loop0: MPLS_UNICAST: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
962  * [@4] ipv4 via 1.0.0.3 loop0: IP4: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
963  * [@5] mpls via 1.0.0.3 loop0: MPLS_UNICAST: 00:00:22:aa:bb:cc -> 00:00:11:aa:bb:cc
964  * @cliexend
965  ?*/
966 VLIB_CLI_COMMAND (ip4_show_fib_command, static) = {
967  .path = "show adj nbr",
968  .short_help = "show adj nbr [<adj_index>] [interface]",
969  .function = adj_nbr_show,
970 };
971 
972 u8*
973 format_adj_nbr_incomplete (u8* s, va_list *ap)
974 {
975  index_t index = va_arg(*ap, index_t);
976  CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
977  vnet_main_t * vnm = vnet_get_main();
978  ip_adjacency_t * adj = adj_get(index);
979 
980  s = format (s, "arp-%U", format_vnet_link, adj->ia_link);
981  s = format (s, ": via %U",
982  format_ip46_address, &adj->sub_type.nbr.next_hop,
984  s = format (s, " %U",
986  vnm, adj->rewrite_header.sw_if_index);
987 
988  return (s);
989 }
990 
991 u8*
992 format_adj_nbr (u8* s, va_list *ap)
993 {
994  index_t index = va_arg(*ap, index_t);
995  CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
996  ip_adjacency_t * adj = adj_get(index);
997 
998  s = format (s, "%U", format_vnet_link, adj->ia_link);
999  s = format (s, " via %U ",
1000  format_ip46_address, &adj->sub_type.nbr.next_hop,
1002  s = format (s, "%U",
1004  &adj->rewrite_header, sizeof (adj->rewrite_data), 0);
1005 
1006  return (s);
1007 }
1008 
1009 static void
1011 {
1012  adj_lock(dpo->dpoi_index);
1013 }
1014 static void
1016 {
1017  adj_unlock(dpo->dpoi_index);
1018 }
1019 
1020 static void
1022 {
1023  fib_show_memory_usage("Adjacency",
1025  pool_len(adj_pool),
1026  sizeof(ip_adjacency_t));
1027 }
1028 
1029 const static dpo_vft_t adj_nbr_dpo_vft = {
1030  .dv_lock = adj_dpo_lock,
1031  .dv_unlock = adj_dpo_unlock,
1032  .dv_format = format_adj_nbr,
1033  .dv_mem_show = adj_mem_show,
1034  .dv_get_urpf = adj_dpo_get_urpf,
1035 };
1036 const static dpo_vft_t adj_nbr_incompl_dpo_vft = {
1037  .dv_lock = adj_dpo_lock,
1038  .dv_unlock = adj_dpo_unlock,
1039  .dv_format = format_adj_nbr_incomplete,
1040  .dv_get_urpf = adj_dpo_get_urpf,
1041 };
1042 
1043 /**
1044  * @brief The per-protocol VLIB graph nodes that are assigned to an adjacency
1045  * object.
1046  *
1047  * this means that these graph nodes are ones from which a nbr is the
1048  * parent object in the DPO-graph.
1049  */
1050 const static char* const nbr_ip4_nodes[] =
1051 {
1052  "ip4-rewrite",
1053  NULL,
1054 };
1055 const static char* const nbr_ip6_nodes[] =
1056 {
1057  "ip6-rewrite",
1058  NULL,
1059 };
1060 const static char* const nbr_mpls_nodes[] =
1061 {
1062  "mpls-output",
1063  NULL,
1064 };
1065 const static char* const nbr_ethernet_nodes[] =
1066 {
1067  "adj-l2-rewrite",
1068  NULL,
1069 };
1070 const static char* const * const nbr_nodes[DPO_PROTO_NUM] =
1071 {
1076 };
1077 
1078 const static char* const nbr_incomplete_ip4_nodes[] =
1079 {
1080  "ip4-arp",
1081  NULL,
1082 };
1083 const static char* const nbr_incomplete_ip6_nodes[] =
1084 {
1085  "ip6-discover-neighbor",
1086  NULL,
1087 };
1088 const static char* const nbr_incomplete_mpls_nodes[] =
1089 {
1090  "mpls-adj-incomplete",
1091  NULL,
1092 };
1093 
1094 const static char* const * const nbr_incomplete_nodes[DPO_PROTO_NUM] =
1095 {
1099 };
1100 
1101 void
1103 {
1105  &adj_nbr_dpo_vft,
1106  nbr_nodes);
1108  &adj_nbr_incompl_dpo_vft,
1110 }
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:507
u8 count
Definition: dhcp.api:208
dpo_lock_fn_t dv_lock
A reference counting lock function.
Definition: dpo.h:406
void adj_nbr_walk_nh(u32 sw_if_index, fib_protocol_t adj_nh_proto, const ip46_address_t *nh, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given next-hop.
Definition: adj_nbr.c:642
static clib_error_t * adj_nbr_hw_interface_state_change(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Registered callback for HW interface state changes.
Definition: adj_nbr.c:779
#define vec_foreach_index(var, v)
Iterate over vector indices.
adj_flags_t ia_flags
Flags on the adjacency 1-bytes.
Definition: adj.h:348
ip_adjacency_t * adj_pool
The global adjacency pool.
Definition: adj.c:33
#define CLIB_UNUSED(x)
Definition: clib.h:86
A virtual function table regisitered for a DPO type.
Definition: dpo.h:401
enum adj_nbr_interface_flags_t_ adj_nbr_interface_flags_t
Flags associated with the interface state walks.
u8 * format_adj_nbr(u8 *s, va_list *ap)
Format a neigbour (REWRITE) adjacency.
Definition: adj_nbr.c:992
void adj_lock(adj_index_t adj_index)
Take a reference counting lock on the adjacency.
Definition: adj.c:308
An indication that the rewrite is complete, i.e.
Definition: adj_nbr.h:98
vnet_main_t * vnet_get_main(void)
Definition: misc.c:46
static const char *const nbr_ethernet_nodes[]
Definition: adj_nbr.c:1065
static uword ** adj_nbr_tables[FIB_PROTOCOL_IP_MAX]
Definition: adj_nbr.c:26
vl_api_fib_path_nh_t nh
Definition: fib_types.api:126
static const char *const nbr_incomplete_ip6_nodes[]
Definition: adj_nbr.c:1083
unsigned long u64
Definition: types.h:89
void adj_delegate_adj_created(ip_adjacency_t *adj)
Definition: adj_delegate.c:158
static adj_walk_rc_t adj_nbr_interface_state_change_one(adj_index_t ai, void *arg)
Definition: adj_nbr.c:685
void vnet_hw_interface_walk_sw(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_sw_interface_walk_t fn, void *ctx)
Walk the SW interfaces on a HW interface - this is the super interface and any sub-interfaces.
Definition: interface.c:1049
Broadcast Adjacency.
Definition: adj.h:85
IP unicast adjacency.
Definition: adj.h:227
Context for the state change walk of the DB.
Definition: adj_nbr.c:676
#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:58
This packet is to be rewritten and forwarded to the next processing node.
Definition: adj.h:73
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
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:590
ip_lookup_main_t lookup_main
Definition: ip4.h:108
void adj_nbr_walk_nh4(u32 sw_if_index, const ip4_address_t *addr, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given v4 next-hop.
Definition: adj_nbr.c:586
union ip_adjacency_t_::@137 sub_type
u64 ank_linkt
Definition: adj_nbr.c:31
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
unformat_function_t unformat_vnet_sw_interface
u8 * format_adj_nbr_incomplete(u8 *s, va_list *ap)
Format aa incomplete neigbour (ARP) adjacency.
Definition: adj_nbr.c:973
static const char *const nbr_incomplete_mpls_nodes[]
Definition: adj_nbr.c:1088
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
Definition: ip46_address.h:55
u32 adj_dpo_get_urpf(const dpo_id_t *dpo)
Definition: adj.c:298
vhost_vring_addr_t addr
Definition: vhost_user.h:254
adj_index_t adj_nbr_add_or_lock_w_rewrite(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index, u8 *rewrite)
Add (and lock) a new or lock an existing neighbour adjacency.
Definition: adj_nbr.c:263
format_function_t format_vnet_sw_if_index_name
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1092
unsigned char u8
Definition: types.h:56
ip_lookup_next_t
An adjacency is a representation of an attached L3 peer.
Definition: adj.h:50
#define pool_len(p)
Number of elements in pool vector.
Definition: pool.h:140
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:204
vnet_link_t ia_link
link/ether-type 1 bytes
Definition: adj.h:335
#define fm
static void adj_nbr_insert(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index, adj_index_t adj_index)
Definition: adj_nbr.c:45
enum walk_rc_t_ walk_rc_t
Walk return code.
u8 output_feature_arc_index
Definition: lookup.h:169
static clib_error_t * adj_nbr_sw_interface_state_change(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
Registered function for SW interface state changes.
Definition: adj_nbr.c:722
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
vlib_node_registration_t ip6_discover_neighbor_node
(constructor) VLIB_REGISTER_NODE (ip6_discover_neighbor_node)
Definition: ip6_neighbor.c:278
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION_PRIO(adj_nbr_sw_interface_state_change, VNET_ITF_FUNC_PRIORITY_HIGH)
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
vl_api_interface_index_t sw_if_index
Definition: gre.api:53
format_function_t format_ip_adjacency
Definition: format.h:58
void fib_walk_sync(fib_node_type_t parent_type, fib_node_index_t parent_index, fib_node_back_walk_ctx_t *ctx)
Back walk all the children of a FIB node.
Definition: fib_walk.c:745
static void vnet_rewrite_clear_data_internal(vnet_rewrite_header_t *rw, int max_size)
Definition: rewrite.h:129
static const char *const nbr_incomplete_ip4_nodes[]
Definition: adj_nbr.c:1078
enum adj_walk_rc_t_ adj_walk_rc_t
return codes from a adjacency walker callback function
static walk_rc_t adj_nbr_hw_sw_interface_state_change(vnet_main_t *vnm, u32 sw_if_index, void *arg)
Invoked on each SW interface of a HW interface when the HW interface state changes.
Definition: adj_nbr.c:756
static clib_error_t * adj_nbr_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: adj_nbr.c:885
ip46_address_t ank_ip
Definition: adj_nbr.c:30
static const char *const nbr_mpls_nodes[]
Definition: adj_nbr.c:1060
static void adj_dpo_lock(dpo_id_t *dpo)
Definition: adj_nbr.c:1010
void fib_show_memory_usage(const char *name, u32 in_use_elts, u32 allocd_elts, size_t size_elt)
Show the memory usage for a type.
Definition: fib_node.c:220
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
Definition: adj.c:325
void vnet_update_adjacency_for_sw_interface(vnet_main_t *vnm, u32 sw_if_index, u32 ai)
Definition: rewrite.c:179
unsigned int u32
Definition: types.h:88
static const char *const nbr_ip6_nodes[]
Definition: adj_nbr.c:1055
static void adj_nbr_evaluate_feature(adj_index_t ai)
Check and set feature flags if o/p interface has any o/p features.
Definition: adj_nbr.c:133
format_function_t format_vnet_rewrite
Definition: rewrite.h:263
u8 output_feature_arc_index
Definition: mpls.h:57
u32 adj_nbr_db_size(void)
Return the size of the adjacency database.
Definition: adj_nbr.c:529
vlib_node_registration_t ip4_arp_node
(constructor) VLIB_REGISTER_NODE (ip4_arp_node)
Definition: ip4_neighbor.c:261
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
fib_node_bw_reason_flag_t fnbw_reason
The reason/trigger for the backwalk.
Definition: fib_node.h:212
vnet_crypto_main_t * cm
Definition: quic_crypto.c:53
#define hash_create_mem(elts, key_bytes, value_bytes)
Definition: hash.h:661
#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
void adj_nbr_remove(adj_index_t ai, fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Definition: adj_nbr.c:70
vl_api_ip_proto_t proto
Definition: acl_types.api:50
vl_api_address_t nh_addr
Definition: lisp_gpe.api:222
static u8 ip46_address_is_zero(const ip46_address_t *ip46)
Definition: ip46_address.h:87
long ctx[MAX_CONNS]
Definition: main.c:144
static adj_index_t adj_get_index(const ip_adjacency_t *adj)
Get a pointer to an adjacency object from its index.
Definition: adj_internal.h:101
struct _unformat_input_t unformat_input_t
#define hash_free(h)
Definition: hash.h:310
void adj_delegate_adj_modified(ip_adjacency_t *adj)
Definition: adj_delegate.c:128
static clib_error_t * adj_nbr_interface_add_del(vnet_main_t *vnm, u32 sw_if_index, u32 is_add)
adj_nbr_interface_add_del
Definition: adj_nbr.c:834
u32 ia_node_index
The VLIB node in which this adj is used to forward packets.
Definition: adj.h:322
ip6_main_t ip6_main
Definition: ip6_forward.c:2784
void adj_nbr_module_init(void)
Module initialisation.
Definition: adj_nbr.c:1102
#define hash_foreach_mem(key_var, value_var, h, body)
Definition: hash.h:461
vlib_main_t * vm
Definition: in2out_ed.c:1599
static u8 ip46_address_is_equal(const ip46_address_t *ip46_1, const ip46_address_t *ip46_2)
Definition: ip46_address.h:93
format_function_t format_ip46_address
Definition: ip46_address.h:50
#define ADJ_NBR_SET_KEY(_key, _lt, _nh)
Definition: adj_nbr.c:34
This packet matches an "incomplete adjacency" and packets need to be passed to ARP to find rewrite st...
Definition: adj.h:63
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
u32 flags
Definition: vhost_user.h:248
void vnet_rewrite_init(vnet_main_t *vnm, u32 sw_if_index, vnet_link_t linkt, u32 this_node, u32 next_node, vnet_rewrite_header_t *rw)
Definition: rewrite.c:80
mpls_main_t mpls_main
Definition: mpls.c:25
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
static adj_walk_rc_t adj_nbr_show_one(adj_index_t ai, void *arg)
Definition: adj_nbr.c:873
Force the walk to be synchronous.
Definition: fib_node.h:174
u32 vnet_tx_node_index_for_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: rewrite.c:73
static void vnet_rewrite_set_data_internal(vnet_rewrite_header_t *rw, int max_size, void *data, int data_bytes)
Definition: rewrite.h:139
adj_walk_rc_t(* adj_walk_cb_t)(adj_index_t ai, void *ctx)
Call back function when walking adjacencies.
Definition: adj_types.h:50
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:299
u32 adj_index_t
An index for adjacencies.
Definition: adj_types.h:30
static void adj_mem_show(void)
Definition: adj_nbr.c:1021
static ip_adjacency_t * adj_nbr_alloc(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Definition: adj_nbr.c:177
void adj_nbr_walk(u32 sw_if_index, fib_protocol_t adj_nh_proto, adj_walk_cb_t cb, void *ctx)
Walk all adjacencies on a link for a given next-hop protocol.
Definition: adj_nbr.c:552
i16 ** feature_count_by_sw_if_index
feature reference counts by interface
Definition: feature.h:109
#define FOR_EACH_VNET_LINK(_link)
Definition: interface.h:351
Context passed between object during a back walk.
Definition: fib_node.h:208
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:152
VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION_PRIO(adj_nbr_hw_interface_state_change, VNET_ITF_FUNC_PRIORITY_HIGH)
adj_nbr_interface_flags_t flags
Flags on the interface.
Definition: adj_nbr.c:681
#define ASSERT(truth)
static uword hash_elts(void *v)
Definition: hash.h:118
struct ip_adjacency_t_::@137::@138 nbr
IP_LOOKUP_NEXT_ARP/IP_LOOKUP_NEXT_REWRITE.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:689
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.
u32 ia_cfg_index
feature [arc] config index
Definition: adj.h:239
static void hash_unset_mem_free(uword **h, const void *key)
Definition: hash.h:295
struct adj_nbr_key_t_ adj_nbr_key_t
static const char *const nbr_ip4_nodes[]
The per-protocol VLIB graph nodes that are assigned to an adjacency object.
Definition: adj_nbr.c:1050
static const char *const *const nbr_nodes[DPO_PROTO_NUM]
Definition: adj_nbr.c:1070
static u32 adj_get_rewrite_node(vnet_link_t linkt)
Definition: adj_internal.h:46
static u32 adj_get_nd_node(fib_protocol_t proto)
Definition: adj_nbr.c:115
unformat_function_t unformat_ip46_address
Definition: format.h:63
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
#define vec_elt(v, i)
Get vector value at index i.
typedef key
Definition: ipsec_types.api:85
fib_protocol_t ia_nh_proto
The protocol of the neighbor/peer.
Definition: adj.h:342
static const char *const *const nbr_incomplete_nodes[DPO_PROTO_NUM]
Definition: adj_nbr.c:1094
#define DPO_PROTO_NUM
Definition: dpo.h:70
index_t dpoi_index
the index of objects of that type
Definition: dpo.h:186
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
ip_lookup_next_t lookup_next_index
Next hop after ip4-lookup.
Definition: adj.h:329
void adj_nbr_update_rewrite_internal(ip_adjacency_t *adj, ip_lookup_next_t adj_next_index, u32 this_node, u32 next_node, u8 *rewrite)
adj_nbr_update_rewrite_internal
Definition: adj_nbr.c:342
enum adj_nbr_rewrite_flag_t_ adj_nbr_rewrite_flag_t
When adding a rewrite to an adjacency these are flags that apply to that rewrite. ...
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:47
u64 uword
Definition: types.h:112
ip_adjacency_t * adj_alloc(fib_protocol_t proto)
Definition: adj.c:63
static adj_walk_rc_t adj_nbr_interface_delete_one(adj_index_t ai, void *arg)
Definition: adj_nbr.c:804
#define hash_get_mem(h, key)
Definition: hash.h:269
adj_nbr_interface_flags_t_
Flags associated with the interface state walks.
Definition: adj_nbr.c:668
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1540
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1144
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:217
#define vec_foreach(var, vec)
Vector iterator.
vnet_link_t fib_proto_to_link(fib_protocol_t proto)
Convert from a protocol to a link type.
Definition: fib_types.c:358
u8 * format_vnet_link(u8 *s, va_list *ap)
Definition: fib_types.c:41
static void hash_set_mem_alloc(uword **h, const void *key, uword v)
Definition: hash.h:279
VNET_SW_INTERFACE_ADD_DEL_FUNCTION(adj_nbr_interface_add_del)
static void adj_dpo_unlock(dpo_id_t *dpo)
Definition: adj_nbr.c:1015
vnet_feature_config_main_t * feature_config_mains
feature config main objects
Definition: feature.h:100
#define ADJ_NBR_ITF_OK(_proto, _itf)
Definition: adj_nbr.c:40
This adjacency/interface has output features configured.
Definition: rewrite.h:57
void vnet_rewrite_update_mtu(vnet_main_t *vnm, vnet_link_t linkt, vnet_rewrite_header_t *rw)
Definition: rewrite.c:92
vnet_feature_main_t feature_main
Definition: feature.c:19
void adj_nbr_update_rewrite(adj_index_t adj_index, adj_nbr_rewrite_flag_t flags, u8 *rewrite)
adj_nbr_update_rewrite
Definition: adj_nbr.c:300
const ip46_address_t ADJ_BCAST_ADDR
The special broadcast address (to construct a broadcast adjacency.
Definition: adj.c:41
struct adj_nbr_interface_state_change_ctx_t_ adj_nbr_interface_state_change_ctx_t
Context for the state change walk of the DB.
#define ip46_address_initializer
Definition: ip46_address.h:52
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
static ip46_type_t adj_proto_to_46(fib_protocol_t proto)
Definition: adj_internal.h:82
signed short i16
Definition: types.h:46
adj_index_t adj_nbr_find(fib_protocol_t nh_proto, vnet_link_t link_type, const ip46_address_t *nh_addr, u32 sw_if_index)
Lookup neighbor adjancency.
Definition: adj_nbr.c:92
void adj_nbr_walk_nh6(u32 sw_if_index, const ip6_address_t *addr, adj_walk_cb_t cb, void *ctx)
Walk adjacencies on a link with a given v6 next-hop.
Definition: adj_nbr.c:614
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128