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