FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
gbp_endpoint.c
Go to the documentation of this file.
1 /*
2  * gbp.h : Group Based Policy
3  *
4  * Copyright (c) 2018 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
20 #include <plugins/gbp/gbp_itf.h>
25 #include <plugins/gbp/gbp_vxlan.h>
26 
27 #include <vnet/l2/l2_input.h>
28 #include <vnet/l2/l2_output.h>
29 #include <vnet/l2/feat_bitmap.h>
30 #include <vnet/l2/l2_fib.h>
31 #include <vnet/fib/fib_table.h>
35 #include <vnet/fib/fib_walk.h>
37 
39 
40 /**
41  * EP DBs
42  */
44 
49 
50 #define GBP_ENDPOINT_DBG(...) \
51  vlib_log_debug (gbp_ep_logger, __VA_ARGS__);
52 
53 #define GBP_ENDPOINT_INFO(...) \
54  vlib_log_notice (gbp_ep_logger, __VA_ARGS__);
55 
56 /**
57  * Pool of GBP endpoints
58  */
60 
61 /**
62  * A count of the number of dynamic entries
63  */
65 
66 #define FOR_EACH_GBP_ENDPOINT_ATTR(_item) \
67  for (_item = GBP_ENDPOINT_ATTR_FIRST; \
68  _item < GBP_ENDPOINT_ATTR_LAST; \
69  _item++)
70 
71 u8 *
72 format_gbp_endpoint_flags (u8 * s, va_list * args)
73 {
76 
78  {
79  if ((1 << attr) & flags)
80  {
81  s = format (s, "%s,", gbp_endpoint_attr_names[attr]);
82  }
83  }
84 
85  return (s);
86 }
87 
88 int
90 {
91  return (! !(ge->ge_fwd.gef_flags & GBP_ENDPOINT_FLAG_REMOTE));
92 }
93 
94 int
96 {
97  return (!(ge->ge_fwd.gef_flags & GBP_ENDPOINT_FLAG_REMOTE));
98 }
99 
100 int
102 {
103  return (! !(ge->ge_fwd.gef_flags & GBP_ENDPOINT_FLAG_EXTERNAL));
104 }
105 
106 int
108 {
109  if (0 == vec_len (ge->ge_locs))
110  return 0;
111 
112  /* DP is the highest source so if present it will be first */
113  return (ge->ge_locs[0].gel_src == GBP_ENDPOINT_SRC_DP);
114 }
115 
116 static void
119 {
120  mac_address_from_u64 (mac, key->key[0]);
121  *sw_if_index = key->key[1];
122 }
123 
124 static void
126  ip46_address_t * ip, u32 * sw_if_index)
127 {
128  ip->as_u64[0] = key->key[0];
129  ip->as_u64[1] = key->key[1];
130  *sw_if_index = key->key[2];
131 }
132 
134 gbp_endpoint_find_ip (const ip46_address_t * ip, u32 fib_index)
135 {
137  int rv;
138 
139  gbp_endpoint_mk_key_ip (ip, fib_index, &key);
140 
141  rv = clib_bihash_search_24_8 (&gbp_ep_db.ged_by_ip_rd, &key, &value);
142 
143  if (0 != rv)
144  return NULL;
145 
146  return (gbp_endpoint_get (value.value));
147 }
148 
149 static void
151 {
153 
155 }
156 
157 static bool
159 {
161  int rv;
162 
163  gbp_endpoint_mk_key_mac (mac->bytes, bd_index, &key);
164  key.value = gei;
165 
166  rv = clib_bihash_add_del_16_8 (&gbp_ep_db.ged_by_mac_bd, &key, 1);
167 
168 
169  return (0 == rv);
170 }
171 
172 static bool
173 gbp_endpoint_add_ip (const ip46_address_t * ip, u32 fib_index, index_t gei)
174 {
176  int rv;
177 
178  gbp_endpoint_mk_key_ip (ip, fib_index, &key);
179  key.value = gei;
180 
181  rv = clib_bihash_add_del_24_8 (&gbp_ep_db.ged_by_ip_rd, &key, 1);
182 
183  return (0 == rv);
184 }
185 
186 static void
188 {
190 
191  gbp_endpoint_mk_key_mac (mac->bytes, bd_index, &key);
192 
193  clib_bihash_add_del_16_8 (&gbp_ep_db.ged_by_mac_bd, &key, 0);
194 }
195 
196 static void
197 gbp_endpoint_del_ip (const ip46_address_t * ip, u32 fib_index)
198 {
200 
201  gbp_endpoint_mk_key_ip (ip, fib_index, &key);
202 
203  clib_bihash_add_del_24_8 (&gbp_ep_db.ged_by_ip_rd, &key, 0);
204 }
205 
206 static index_t
208 {
209  return (ge - gbp_endpoint_pool);
210 }
211 
212 static int
213 gbp_endpoint_ip_is_equal (const fib_prefix_t * fp, const ip46_address_t * ip)
214 {
215  return (ip46_address_is_equal (ip, &fp->fp_addr));
216 }
217 
218 static void
220  const ip46_address_t * ips,
221  const gbp_route_domain_t * grd)
222 {
223  const ip46_address_t *ip;
224  index_t gei, grdi;
225 
226  gei = gbp_endpoint_index (ge);
227  grdi = gbp_route_domain_index (grd);
228 
229  ASSERT ((ge->ge_key.gek_grd == INDEX_INVALID) ||
230  (ge->ge_key.gek_grd == grdi));
231 
232  vec_foreach (ip, ips)
233  {
234  if (~0 == vec_search_with_function (ge->ge_key.gek_ips, ip,
236  {
237  fib_prefix_t *pfx;
238 
239  vec_add2 (ge->ge_key.gek_ips, pfx, 1);
241 
243  grd->grd_fib_index[pfx->fp_proto], gei);
244  }
245  ge->ge_key.gek_grd = grdi;
246  }
247 }
248 
249 static gbp_endpoint_t *
250 gbp_endpoint_alloc (const ip46_address_t * ips,
251  const gbp_route_domain_t * grd,
252  const mac_address_t * mac,
253  const gbp_bridge_domain_t * gbd)
254 {
256  index_t gei;
257 
259 
261  gei = gbp_endpoint_index (ge);
262  ge->ge_key.gek_gbd =
263  ge->ge_key.gek_grd = ge->ge_fwd.gef_fib_index = INDEX_INVALID;
264  gbp_itf_hdl_reset (&ge->ge_fwd.gef_itf);
265  ge->ge_last_time = vlib_time_now (vlib_get_main ());
266  ge->ge_key.gek_gbd = gbp_bridge_domain_index (gbd);
267 
268  if (NULL != mac)
269  {
270  mac_address_copy (&ge->ge_key.gek_mac, mac);
271  gbp_endpoint_add_mac (mac, gbd->gb_bd_index, gei);
272  }
274 
275  return (ge);
276 }
277 
278 static int
280 {
281  return (a->gel_src == b->gel_src);
282 }
283 
284 static int
286 {
287  return (a->gel_src - b->gel_src);
288 }
289 
290 static gbp_endpoint_loc_t *
292 {
293  gbp_endpoint_loc_t gel = {
294  .gel_src = src,
295  };
296  u32 pos;
297 
298  pos = vec_search_with_function (ge->ge_locs, &gel,
300 
301  if (~0 != pos)
302  return (&ge->ge_locs[pos]);
303 
304  return NULL;
305 }
306 
307 static int
309 {
310  u32 pos;
311 
312  gel->gel_locks--;
313 
314  if (0 == gel->gel_locks)
315  {
316  pos = gel - ge->ge_locs;
317 
318  vec_del1 (ge->ge_locs, pos);
319  if (vec_len (ge->ge_locs) > 1)
321 
322  /* This could be the last lock, so don't access the EP from
323  * this point on */
324  fib_node_unlock (&ge->ge_node);
325 
326  return (1);
327  }
328  return (0);
329 }
330 
331 static void
333 {
335  gbp_itf_unlock (&gel->gel_itf);
336 }
337 
338 static gbp_endpoint_loc_t *
340 {
341  gbp_endpoint_loc_t gel = {
342  .gel_src = src,
343  .gel_epg = INDEX_INVALID,
344  .gel_itf = GBP_ITF_HDL_INVALID,
345  .gel_locks = 0,
346  };
347  u32 pos;
348 
349  pos = vec_search_with_function (ge->ge_locs, &gel,
351 
352  if (~0 == pos)
353  {
354  vec_add1 (ge->ge_locs, gel);
355 
356  if (vec_len (ge->ge_locs) > 1)
357  {
359 
360  pos = vec_search_with_function (ge->ge_locs, &gel,
362  }
363  else
364  pos = 0;
365 
366  /*
367  * it's the sources and children that lock the endpoints
368  */
369  fib_node_lock (&ge->ge_node);
370  }
371 
372  return (&ge->ge_locs[pos]);
373 }
374 
375 /**
376  * Find an EP inthe DBs and check that if we find it in the L2 DB
377  * it has the same IPs as this update
378  */
379 static int
380 gbp_endpoint_find_for_update (const ip46_address_t * ips,
381  const gbp_route_domain_t * grd,
382  const mac_address_t * mac,
383  const gbp_bridge_domain_t * gbd,
384  gbp_endpoint_t ** ge)
385 {
386  gbp_endpoint_t *l2_ge, *l3_ge, *tmp;
387 
388  l2_ge = l3_ge = NULL;
389 
390  if (NULL != mac && !mac_address_is_zero (mac))
391  {
392  ASSERT (gbd);
393  l2_ge = gbp_endpoint_find_mac (mac->bytes, gbd->gb_bd_index);
394  }
395  if (NULL != ips && !ip46_address_is_zero (ips))
396  {
397  const ip46_address_t *ip;
398  fib_protocol_t fproto;
399 
400  ASSERT (grd);
401  vec_foreach (ip, ips)
402  {
404 
405  tmp = gbp_endpoint_find_ip (ip, grd->grd_fib_index[fproto]);
406 
407  if (NULL == tmp)
408  /* not found */
409  continue;
410  else if (NULL == l3_ge)
411  /* first match against an IP address */
412  l3_ge = tmp;
413  else if (tmp == l3_ge)
414  /* another match against IP address that is the same endpoint */
415  continue;
416  else
417  {
418  /*
419  * a match agains a different endpoint.
420  * this means the KEY of the EP is changing which is not allowed
421  */
422  return (-1);
423  }
424  }
425  }
426 
427  if (NULL == l2_ge && NULL == l3_ge)
428  /* not found */
429  *ge = NULL;
430  else if (NULL == l2_ge)
431  /* found at L3 */
432  *ge = l3_ge;
433  else if (NULL == l3_ge)
434  /* found at L2 */
435  *ge = l2_ge;
436  else
437  {
438  /* found both L3 and L2 - they must be the same else the KEY
439  * is changing
440  */
441  if (l2_ge == l3_ge)
442  *ge = l2_ge;
443  else
444  return (-1);
445  }
446 
447  return (0);
448 }
449 
450 static gbp_endpoint_src_t
452 {
453  if (0 == vec_len (ge->ge_locs))
454  return (GBP_ENDPOINT_SRC_MAX);
455 
456  return (ge->ge_locs[0].gel_src);
457 }
458 
459 static void
461 {
463 
464  if (n > 0 && 1 == gbp_n_learnt_endpoints)
465  {
467  gbp_scanner_node.index,
469  }
470  if (n < 0 && 0 == gbp_n_learnt_endpoints)
471  {
473  gbp_scanner_node.index,
475  }
476 }
477 
478 static void
480  gbp_endpoint_loc_t * gel,
481  const gbp_bridge_domain_t * gb,
483  index_t ggi,
485  const ip46_address_t * tun_src,
486  const ip46_address_t * tun_dst)
487 {
488  int was_learnt, is_learnt;
489 
490  gel->gel_locks++;
491  was_learnt = ! !(gel->gel_flags & GBP_ENDPOINT_FLAG_REMOTE);
492  gel->gel_flags = flags;
493  is_learnt = ! !(gel->gel_flags & GBP_ENDPOINT_FLAG_REMOTE);
494 
495  gbp_endpoint_n_learned (is_learnt - was_learnt);
496 
497  /*
498  * update the EPG
499  */
502  gel->gel_epg = ggi;
503 
505  {
506  if (NULL != tun_src)
507  ip46_address_copy (&gel->tun.gel_src, tun_src);
508  if (NULL != tun_dst)
509  ip46_address_copy (&gel->tun.gel_dst, tun_dst);
510 
512  {
513  /*
514  * we learnt the EP from the multicast tunnel.
515  * Create a unicast TEP from the packet's source
516  * and the fixed address of the BD's parent tunnel
517  */
518  const gbp_vxlan_tunnel_t *gt;
519 
520  gt = gbp_vxlan_tunnel_get (gb->gb_vni);
521 
522  if (NULL != gt)
523  {
524  ip46_address_copy (&gel->tun.gel_src, &gt->gt_src);
526  }
527  }
528 
529  /*
530  * the input interface may be the parent GBP-vxlan interface,
531  * create a child vlxan-gbp tunnel and use that as the endpoint's
532  * interface.
533  */
534  gbp_itf_hdl_t old = gel->gel_itf;
535 
537  {
541  &gel->tun.gel_src,
542  &gel->tun.gel_dst);
543  break;
544  case VXLAN_GBP_TUNNEL:
548  break;
549  }
550 
551  gbp_itf_unlock (&old);
552  }
553  else
554  {
556  ge->ge_key.gek_gbd);
557  }
558 }
559 
560 static void
562 {
563  const gbp_route_domain_t *grd;
564  const gbp_bridge_domain_t *gbd;
565  gbp_endpoint_fwd_t *gef;
566  const fib_prefix_t *pfx;
567  index_t *ai;
568 
569  gbd = gbp_bridge_domain_get (ge->ge_key.gek_gbd);
570  gef = &ge->ge_fwd;
571 
572  vec_foreach (pfx, ge->ge_key.gek_ips)
573  {
574  u32 fib_index;
575 
576  grd = gbp_route_domain_get (ge->ge_key.gek_grd);
577  fib_index = grd->grd_fib_index[pfx->fp_proto];
578 
580  &pfx->fp_addr, &ge->ge_key.gek_mac, 0);
581 
582  /*
583  * remove a host route
584  */
586  {
588  }
589 
590  fib_table_entry_delete (fib_index, pfx, gbp_fib_source_low);
591  }
592  vec_foreach (ai, gef->gef_adjs)
593  {
594  adj_unlock (*ai);
595  }
596 
597  if (gbp_itf_hdl_is_valid (gef->gef_itf))
598  {
599  l2fib_del_entry (ge->ge_key.gek_mac.bytes,
600  gbd->gb_bd_index,
602  }
603 
604  gbp_itf_unlock (&gef->gef_itf);
605  vec_free (gef->gef_adjs);
606 }
607 
608 static void
610 {
611  const gbp_bridge_domain_t *gbd;
612  const gbp_endpoint_group_t *gg;
613  const gbp_route_domain_t *grd;
614  gbp_endpoint_loc_t *gel;
615  gbp_endpoint_fwd_t *gef;
616  const fib_prefix_t *pfx;
617  index_t gei;
618 
619  /*
620  * locations are sort in source priority order
621  */
622  gei = gbp_endpoint_index (ge);
623  gel = &ge->ge_locs[0];
624  gef = &ge->ge_fwd;
625  gbd = gbp_bridge_domain_get (ge->ge_key.gek_gbd);
626 
627  gef->gef_flags = gel->gel_flags;
628 
629  if (INDEX_INVALID != gel->gel_epg)
630  {
631  gg = gbp_endpoint_group_get (gel->gel_epg);
632  gef->gef_sclass = gg->gg_sclass;
633  }
634  else
635  {
636  gg = NULL;
637  }
638 
639  gef->gef_itf = gbp_itf_clone_and_lock (gel->gel_itf);
640 
641  if (!mac_address_is_zero (&ge->ge_key.gek_mac))
642  {
643  gbp_itf_l2_set_input_feature (gef->gef_itf, L2INPUT_FEAT_GBP_FWD);
644 
646  {
647  /*
648  * bridged packets to external endpoints should be classifed
649  * based on the EP's/BD's EPG
650  */
652  L2OUTPUT_FEAT_GBP_POLICY_MAC);
653  }
654  else
655  {
658  L2OUTPUT_FEAT_GBP_POLICY_PORT);
659  }
660  l2fib_add_entry (ge->ge_key.gek_mac.bytes,
661  gbd->gb_bd_index,
663  L2FIB_ENTRY_RESULT_FLAG_STATIC);
664  }
665 
666  vec_foreach (pfx, ge->ge_key.gek_ips)
667  {
668  ethernet_header_t *eth;
669  u32 ip_sw_if_index;
670  u32 fib_index;
671  u8 *rewrite;
672  index_t ai;
673 
674  rewrite = NULL;
675  grd = gbp_route_domain_get (ge->ge_key.gek_grd);
676  fib_index = grd->grd_fib_index[pfx->fp_proto];
677  gef->gef_fib_index = fib_index;
678 
680  &pfx->fp_addr, &ge->ge_key.gek_mac, 1);
681 
682  /*
683  * add a host route via the EPG's BVI we need this because the
684  * adj fib does not install, due to cover refinement check, since
685  * the BVI's prefix is /32
686  */
687  vec_validate (rewrite, sizeof (*eth) - 1);
688  eth = (ethernet_header_t *) rewrite;
689 
690  eth->type = clib_host_to_net_u16 ((pfx->fp_proto == FIB_PROTOCOL_IP4 ?
691  ETHERNET_TYPE_IP4 :
692  ETHERNET_TYPE_IP6));
693 
695  {
696  /*
697  * for dynamic EPs we must add the IP adjacency via the learned
698  * tunnel since the BD will not contain the EP's MAC since it was
699  * L3 learned. The dst MAC address used is the 'BD's MAC'.
700  */
701  ip_sw_if_index = gbp_itf_get_sw_if_index (gef->gef_itf);
702 
704  eth->src_address);
706  eth->dst_address);
707  }
708  else
709  {
710  /*
711  * for the static EPs we add the IP adjacency via the BVI
712  * knowing that the BD has the MAC address to route to and
713  * that policy will be applied on egress to the EP's port
714  */
715  ip_sw_if_index = gbd->gb_bvi_sw_if_index;
716 
717  clib_memcpy (eth->src_address,
719  ip_sw_if_index),
720  sizeof (eth->src_address));
721  mac_address_to_bytes (&ge->ge_key.gek_mac, eth->dst_address);
722  }
723 
724  fib_table_entry_path_add (fib_index, pfx,
727  fib_proto_to_dpo (pfx->fp_proto),
728  &pfx->fp_addr, ip_sw_if_index,
729  ~0, 1, NULL, FIB_ROUTE_PATH_FLAG_NONE);
730 
733  &pfx->fp_addr,
734  ip_sw_if_index, rewrite);
735  vec_add1 (gef->gef_adjs, ai);
736 
737  /*
738  * if the endpoint is external then routed packet to it must be
739  * classifed to the BD's EPG. but this will happen anyway with
740  * the GBP_MAC classification.
741  */
742 
743  if (NULL != gg)
744  {
746  {
747  dpo_id_t policy_dpo = DPO_INVALID;
748 
749  /*
750  * interpose a policy DPO from the endpoint so that policy
751  * is applied
752  */
754  grd->grd_scope,
755  gg->gg_sclass, ~0, &policy_dpo);
756 
757  fib_table_entry_special_dpo_add (fib_index, pfx,
760  &policy_dpo);
761  dpo_reset (&policy_dpo);
762  }
763 
764  /*
765  * send a gratuitous ARP on the EPG's uplink. this is done so
766  * that if this EP has moved from some other place in the
767  * 'fabric', upstream devices are informed
768  */
770  {
772  gei);
773  if (FIB_PROTOCOL_IP4 == pfx->fp_proto)
775  vnet_get_main (),
777  &pfx->fp_addr.ip4);
778  else
780  vnet_get_main (),
782  &pfx->fp_addr.ip6);
783  }
784  }
785  }
786 
788  {
790  L2INPUT_FEAT_GBP_LPM_CLASSIFY);
791  }
792  else if (gbp_endpoint_is_local (ge))
793  {
794  /*
795  * non-remote endpoints (i.e. those not arriving on iVXLAN
796  * tunnels) need to be classifed based on the the input interface.
797  * We enable the GBP-FWD feature only if the group has an uplink
798  * interface (on which the GBP-FWD feature would send UU traffic).
799  * External endpoints get classified based on an LPM match
800  */
801  l2input_feat_masks_t feats = L2INPUT_FEAT_GBP_SRC_CLASSIFY;
802 
803  if (NULL != gg && ~0 != gg->gg_uplink_sw_if_index)
804  feats |= L2INPUT_FEAT_GBP_FWD;
806  }
807 
808  /*
809  * update children with the new forwarding info
810  */
811  fib_node_back_walk_ctx_t bw_ctx = {
813  .fnbw_flags = FIB_NODE_BW_FLAG_FORCE_SYNC,
814  };
815 
816  fib_walk_sync (gbp_endpoint_fib_type, gei, &bw_ctx);
817 }
818 
819 int
822  const ip46_address_t * ips,
823  const mac_address_t * mac,
824  index_t gbdi, index_t grdi,
827  const ip46_address_t * tun_src,
828  const ip46_address_t * tun_dst, u32 * handle)
829 {
830  gbp_bridge_domain_t *gbd;
832  gbp_endpoint_src_t best;
833  gbp_route_domain_t *grd;
834  gbp_endpoint_loc_t *gel;
836  index_t ggi, gei;
837  int rv;
838 
839  if (~0 == sw_if_index)
840  return (VNET_API_ERROR_INVALID_SW_IF_INDEX);
841 
842  ge = NULL;
843  gg = NULL;
844 
845  /*
846  * we need to determine the bridge-domain, either from the EPG or
847  * the BD passed
848  */
849  if (SCLASS_INVALID != sclass)
850  {
852 
853  if (INDEX_INVALID == ggi)
854  return (VNET_API_ERROR_NO_SUCH_ENTRY);
855 
856  gg = gbp_endpoint_group_get (ggi);
857  gbdi = gg->gg_gbd;
858  grdi = gg->gg_rd;
859  }
860  else
861  {
862  if (INDEX_INVALID == gbdi)
863  return (VNET_API_ERROR_NO_SUCH_ENTRY);
864  if (INDEX_INVALID == grdi)
865  return (VNET_API_ERROR_NO_SUCH_FIB);
866  ggi = INDEX_INVALID;
867  }
868 
869  gbd = gbp_bridge_domain_get (gbdi);
870  grd = gbp_route_domain_get (grdi);
871  rv = gbp_endpoint_find_for_update (ips, grd, mac, gbd, &ge);
872 
873  if (0 != rv)
874  return (rv);
875 
876  if (NULL == ge)
877  {
878  ge = gbp_endpoint_alloc (ips, grd, mac, gbd);
879  }
880  else
881  {
883  }
884 
885  best = gbp_endpoint_get_best_src (ge);
886  gei = gbp_endpoint_index (ge);
888 
889  gbp_endpoint_loc_update (ge, gel, gbd, sw_if_index, ggi, flags,
890  tun_src, tun_dst);
891 
892  if (src <= best)
893  {
894  /*
895  * either the best source has been updated or we have a new best source
896  */
899  }
900  else
901  {
902  /*
903  * an update to a lower priority source, so we need do nothing
904  */
905  }
906 
907  if (handle)
908  *handle = gei;
909 
910  GBP_ENDPOINT_INFO ("update: %U", format_gbp_endpoint, gei);
911 
912  return (0);
913 }
914 
915 void
917 {
918  gbp_endpoint_loc_t *gel, gel_copy;
919  gbp_endpoint_src_t best;
921  int removed;
922 
924  return;
925 
926  GBP_ENDPOINT_INFO ("delete: %U", format_gbp_endpoint, gei);
927 
928  ge = gbp_endpoint_get (gei);
929 
930  gel = gbp_endpoint_loc_find (ge, src);
931 
932  if (NULL == gel)
933  return;
934 
935  /*
936  * lock the EP so we can control when it is deleted
937  */
938  fib_node_lock (&ge->ge_node);
939  best = gbp_endpoint_get_best_src (ge);
940 
941  /*
942  * copy the location info since we'll lose it when it's removed from
943  * the vector
944  */
945  clib_memcpy (&gel_copy, gel, sizeof (gel_copy));
946 
947  /*
948  * remove the source we no longer need
949  */
950  removed = gbp_endpoint_loc_unlock (ge, gel);
951 
952  if (src == best)
953  {
954  /*
955  * we have removed the old best source => recalculate fwding
956  */
957  if (0 == vec_len (ge->ge_locs))
958  {
959  /*
960  * if there are no more sources left, then we need only release
961  * the fwding resources held and then this EP is gawn.
962  */
964  }
965  else
966  {
967  /*
968  * else there are more sources. release the old and get new
969  * fwding objects
970  */
973  }
974  }
975  /*
976  * else
977  * we removed a lower priority source so we need to do nothing
978  */
979 
980  /*
981  * clear up any resources held by the source
982  */
983  if (removed)
984  gbp_endpoint_loc_destroy (&gel_copy);
985 
986  /*
987  * remove the lock taken above
988  */
989  fib_node_unlock (&ge->ge_node);
990  /*
991  * We may have removed the last source and so this EP is now TOAST
992  * DO NOTHING BELOW HERE
993  */
994 }
995 
996 u32
999 {
1001 }
1002 
1003 void
1005 {
1006  return (fib_node_child_remove (gbp_endpoint_fib_type, gei, sibling));
1007 }
1008 
1010 {
1015 
1016 static walk_rc_t
1018 {
1019  gbp_endpoint_flush_ctx_t *ctx = args;
1020  gbp_endpoint_loc_t *gel;
1021  gbp_endpoint_t *ge;
1022 
1023  ge = gbp_endpoint_get (gei);
1024  gel = gbp_endpoint_loc_find (ge, ctx->src);
1025 
1026  if ((NULL != gel) && ctx->sw_if_index == gel->tun.gel_parent_sw_if_index)
1027  {
1028  vec_add1 (ctx->geis, gei);
1029  }
1030 
1031  return (WALK_CONTINUE);
1032 }
1033 
1034 /**
1035  * remove all learnt endpoints using the interface
1036  */
1037 void
1039 {
1041  .sw_if_index = sw_if_index,
1042  .src = src,
1043  };
1044  index_t *gei;
1045 
1046  GBP_ENDPOINT_INFO ("flush: %U %U",
1049  sw_if_index);
1051 
1052  vec_foreach (gei, ctx.geis)
1053  {
1054  gbp_endpoint_unlock (src, *gei);
1055  }
1056 
1057  vec_free (ctx.geis);
1058 }
1059 
1060 void
1062 {
1063  u32 index;
1064 
1065  /* *INDENT-OFF* */
1067  {
1068  if (!cb(index, ctx))
1069  break;
1070  }
1071  /* *INDENT-ON* */
1072 }
1073 
1074 static clib_error_t *
1076  unformat_input_t * input, vlib_cli_command_t * cmd)
1077 {
1078  ip46_address_t ip = ip46_address_initializer, *ips = NULL;
1080  vnet_main_t *vnm = vnet_get_main ();
1082  u32 handle = INDEX_INVALID;
1083  u32 sw_if_index = ~0;
1085  u8 add = 1;
1086  int rv;
1087 
1088  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1089  {
1091 
1092  if (unformat (input, "%U", unformat_vnet_sw_interface,
1093  vnm, &sw_if_index))
1094  ;
1095  else if (unformat (input, "add"))
1096  add = 1;
1097  else if (unformat (input, "del"))
1098  add = 0;
1099  else if (unformat (input, "sclass %d", &sclass))
1100  ;
1101  else if (unformat (input, "handle %d", &handle))
1102  ;
1103  else if (unformat (input, "ip %U", unformat_ip4_address, &ip.ip4))
1104  vec_add1 (ips, ip);
1105  else if (unformat (input, "ip %U", unformat_ip6_address, &ip.ip6))
1106  vec_add1 (ips, ip);
1107  else if (unformat (input, "mac %U", unformat_mac_address, &mac))
1108  ;
1109  else if (unformat (input, "flags 0x%x", &flags))
1110  ;
1111  else
1112  break;
1113  }
1114 
1115  if (add)
1116  {
1117  if (~0 == sw_if_index)
1118  return clib_error_return (0, "interface must be specified");
1119  if (SCLASS_INVALID == sclass)
1120  return clib_error_return (0, "SCLASS must be specified");
1121 
1122  rv =
1123  gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
1124  sw_if_index, ips, &mac,
1126  sclass, flags, NULL, NULL, &handle);
1127 
1128  if (rv)
1129  return clib_error_return (0, "GBP Endpoint update returned %d", rv);
1130  else
1131  vlib_cli_output (vm, "handle %d\n", handle);
1132  }
1133  else
1134  {
1135  if (INDEX_INVALID == handle)
1136  return clib_error_return (0, "handle must be specified");
1137 
1138  gbp_endpoint_unlock (GBP_ENDPOINT_SRC_CP, handle);
1139  }
1140 
1141  vec_free (ips);
1142 
1143  return (NULL);
1144 }
1145 
1146 /*?
1147  * Configure a GBP Endpoint
1148  *
1149  * @cliexpar
1150  * @cliexstart{gbp endpoint del <handle> | [add] <interface> sclass <SCLASS> ip <IP> mac <MAC> [flags <flags>]}
1151  * @cliexend
1152  ?*/
1153 /* *INDENT-OFF* */
1155  .path = "gbp endpoint",
1156  .short_help = "gbp endpoint del <handle> | [add] <interface> sclass <SCLASS> ip <IP> mac <MAC> [flags <flags>]",
1157  .function = gbp_endpoint_cli,
1158 };
1159 /* *INDENT-ON* */
1160 
1161 u8 *
1162 format_gbp_endpoint_src (u8 * s, va_list * args)
1163 {
1164  gbp_endpoint_src_t action = va_arg (*args, gbp_endpoint_src_t);
1165 
1166  switch (action)
1167  {
1168 #define _(v,a) case GBP_ENDPOINT_SRC_##v: return (format (s, "%s", a));
1170 #undef _
1171  }
1172 
1173  return (format (s, "unknown"));
1174 }
1175 
1176 static u8 *
1177 format_gbp_endpoint_fwd (u8 * s, va_list * args)
1178 {
1179  gbp_endpoint_fwd_t *gef = va_arg (*args, gbp_endpoint_fwd_t *);
1180 
1181  s = format (s, "fwd:");
1182  s = format (s, "\n itf:[%U]", format_gbp_itf_hdl, gef->gef_itf);
1183  if (GBP_ENDPOINT_FLAG_NONE != gef->gef_flags)
1184  {
1185  s = format (s, " flags:%U", format_gbp_endpoint_flags, gef->gef_flags);
1186  }
1187 
1188  return (s);
1189 }
1190 
1191 static u8 *
1192 format_gbp_endpoint_key (u8 * s, va_list * args)
1193 {
1194  gbp_endpoint_key_t *gek = va_arg (*args, gbp_endpoint_key_t *);
1195  const fib_prefix_t *pfx;
1196 
1197  s = format (s, "ips:[");
1198 
1199  vec_foreach (pfx, gek->gek_ips)
1200  {
1201  s = format (s, "%U, ", format_fib_prefix, pfx);
1202  }
1203  s = format (s, "]");
1204 
1205  s = format (s, " mac:%U", format_mac_address_t, &gek->gek_mac);
1206 
1207  return (s);
1208 }
1209 
1210 static u8 *
1211 format_gbp_endpoint_loc (u8 * s, va_list * args)
1212 {
1213  gbp_endpoint_loc_t *gel = va_arg (*args, gbp_endpoint_loc_t *);
1214 
1215  s = format (s, "%U", format_gbp_endpoint_src, gel->gel_src);
1216  s = format (s, "\n EPG:%d [%U]", gel->gel_epg,
1217  format_gbp_itf_hdl, gel->gel_itf);
1218 
1219  if (GBP_ENDPOINT_FLAG_NONE != gel->gel_flags)
1220  {
1221  s = format (s, " flags:%U", format_gbp_endpoint_flags, gel->gel_flags);
1222  }
1224  {
1225  s = format (s, " tun:[");
1226  s = format (s, "parent:%U", format_vnet_sw_if_index_name,
1228  s = format (s, " {%U,%U}]",
1231  }
1232 
1233  return (s);
1234 }
1235 
1236 u8 *
1237 format_gbp_endpoint (u8 * s, va_list * args)
1238 {
1239  index_t gei = va_arg (*args, index_t);
1240  gbp_endpoint_loc_t *gel;
1241  gbp_endpoint_t *ge;
1242 
1243  ge = gbp_endpoint_get (gei);
1244 
1245  s = format (s, "[@%d] %U", gei, format_gbp_endpoint_key, &ge->ge_key);
1246  s = format (s, " last-time:[%f]", ge->ge_last_time);
1247 
1248  vec_foreach (gel, ge->ge_locs)
1249  {
1250  s = format (s, "\n %U", format_gbp_endpoint_loc, gel);
1251  }
1252  s = format (s, "\n %U", format_gbp_endpoint_fwd, &ge->ge_fwd);
1253 
1254  return s;
1255 }
1256 
1257 static walk_rc_t
1259 {
1260  vlib_main_t *vm;
1261 
1262  vm = ctx;
1263  vlib_cli_output (vm, " %U", format_gbp_endpoint, gei);
1264 
1265  return (WALK_CONTINUE);
1266 }
1267 
1268 static int
1270 {
1271  ip46_address_t ip;
1272  vlib_main_t *vm;
1273  u32 sw_if_index;
1274 
1275  vm = arg;
1276 
1278 
1279  vlib_cli_output (vm, " {%U, %U} -> %d",
1282  sw_if_index, kvp->value);
1283  return (BIHASH_WALK_CONTINUE);
1284 }
1285 
1286 static int
1288 {
1290  vlib_main_t *vm;
1291  u32 sw_if_index;
1292 
1293  vm = arg;
1294 
1296 
1297  vlib_cli_output (vm, " {%U, %U} -> %d",
1300  sw_if_index, kvp->value);
1301  return (BIHASH_WALK_CONTINUE);
1302 }
1303 
1304 static clib_error_t *
1306  unformat_input_t * input, vlib_cli_command_t * cmd)
1307 {
1308  u32 show_dbs, handle;
1309 
1310  handle = INDEX_INVALID;
1311  show_dbs = 0;
1312 
1313  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1314  {
1315  if (unformat (input, "%d", &handle))
1316  ;
1317  else if (unformat (input, "db"))
1318  show_dbs = 1;
1319  else
1320  break;
1321  }
1322 
1323  if (INDEX_INVALID != handle)
1324  {
1325  vlib_cli_output (vm, "%U", format_gbp_endpoint, handle);
1326  }
1327  else if (show_dbs)
1328  {
1329  vlib_cli_output (vm, "\nDatabases:");
1330  clib_bihash_foreach_key_value_pair_24_8 (&gbp_ep_db.ged_by_ip_rd,
1332  clib_bihash_foreach_key_value_pair_16_8
1334  }
1335  else
1336  {
1337  vlib_cli_output (vm, "Endpoints:");
1339  }
1340 
1341  return (NULL);
1342 }
1343 
1344 /*?
1345  * Show Group Based Policy Endpoints and derived information
1346  *
1347  * @cliexpar
1348  * @cliexstart{show gbp endpoint}
1349  * @cliexend
1350  ?*/
1351 /* *INDENT-OFF* */
1353  .path = "show gbp endpoint",
1354  .short_help = "show gbp endpoint\n",
1355  .function = gbp_endpoint_show,
1356 };
1357 /* *INDENT-ON* */
1358 
1359 static void
1360 gbp_endpoint_check (index_t gei, f64 start_time)
1361 {
1363  gbp_endpoint_loc_t *gel;
1364  gbp_endpoint_t *ge;
1365 
1366  ge = gbp_endpoint_get (gei);
1367  gel = gbp_endpoint_loc_find (ge, GBP_ENDPOINT_SRC_DP);
1368 
1369  if (NULL != gel)
1370  {
1371  gg = gbp_endpoint_group_get (gel->gel_epg);
1372 
1373  if ((start_time - ge->ge_last_time) >
1375  {
1376  gbp_endpoint_unlock (GBP_ENDPOINT_SRC_DP, gei);
1377  }
1378  }
1379 }
1380 
1381 static void
1383 {
1384  clib_bihash_16_8_t *gte_table = &gbp_ep_db.ged_by_mac_bd;
1385  f64 last_start, start_time, delta_t;
1386  int i, j, k;
1387 
1388  if (!gte_table->instantiated)
1389  return;
1390 
1391  delta_t = 0;
1392  last_start = start_time = vlib_time_now (vm);
1393 
1394  for (i = 0; i < gte_table->nbuckets; i++)
1395  {
1396  clib_bihash_bucket_16_8_t *b;
1397  clib_bihash_value_16_8_t *v;
1398 
1399  /* allow no more than 20us without a pause */
1400  delta_t = vlib_time_now (vm) - last_start;
1401  if (delta_t > 20e-6)
1402  {
1403  /* suspend for 100 us */
1404  vlib_process_suspend (vm, 100e-6);
1405  last_start = vlib_time_now (vm);
1406  }
1407 
1408  b = clib_bihash_get_bucket_16_8 (gte_table, i);
1409  if (clib_bihash_bucket_is_empty_16_8 (b))
1410  continue;
1411  v = clib_bihash_get_value_16_8 (gte_table, b->offset);
1412 
1413  for (j = 0; j < (1 << b->log2_pages); j++)
1414  {
1415  for (k = 0; k < BIHASH_KVP_PER_PAGE; k++)
1416  {
1417  if (clib_bihash_is_free_16_8 (&v->kvp[k]))
1418  continue;
1419 
1420  gbp_endpoint_check (v->kvp[k].value, start_time);
1421 
1422  /*
1423  * Note: we may have just freed the bucket's backing
1424  * storage, so check right here...
1425  */
1426  if (clib_bihash_bucket_is_empty_16_8 (b))
1427  goto doublebreak;
1428  }
1429  v++;
1430  }
1431  doublebreak:
1432  ;
1433  }
1434 }
1435 
1436 static void
1438 {
1439  clib_bihash_24_8_t *gte_table = &gbp_ep_db.ged_by_ip_rd;
1440  f64 last_start, start_time, delta_t;
1441  int i, j, k;
1442 
1443  if (!gte_table->instantiated)
1444  return;
1445 
1446  delta_t = 0;
1447  last_start = start_time = vlib_time_now (vm);
1448 
1449  for (i = 0; i < gte_table->nbuckets; i++)
1450  {
1451  clib_bihash_bucket_24_8_t *b;
1452  clib_bihash_value_24_8_t *v;
1453 
1454  /* allow no more than 20us without a pause */
1455  delta_t = vlib_time_now (vm) - last_start;
1456  if (delta_t > 20e-6)
1457  {
1458  /* suspend for 100 us */
1459  vlib_process_suspend (vm, 100e-6);
1460  last_start = vlib_time_now (vm);
1461  }
1462 
1463  b = clib_bihash_get_bucket_24_8 (gte_table, i);
1464  if (clib_bihash_bucket_is_empty_24_8 (b))
1465  continue;
1466  v = clib_bihash_get_value_24_8 (gte_table, b->offset);
1467 
1468  for (j = 0; j < (1 << b->log2_pages); j++)
1469  {
1470  for (k = 0; k < BIHASH_KVP_PER_PAGE; k++)
1471  {
1472  if (clib_bihash_is_free_24_8 (&v->kvp[k]))
1473  continue;
1474 
1475  gbp_endpoint_check (v->kvp[k].value, start_time);
1476 
1477  /*
1478  * Note: we may have just freed the bucket's backing
1479  * storage, so check right here...
1480  */
1481  if (clib_bihash_bucket_is_empty_24_8 (b))
1482  goto doublebreak;
1483  }
1484  v++;
1485  }
1486  doublebreak:
1487  ;
1488  }
1489 }
1490 
1491 void
1493 {
1496 }
1497 
1498 static fib_node_t *
1500 {
1501  gbp_endpoint_t *ge;
1502 
1504 
1505  return (&ge->ge_node);
1506 }
1507 
1508 static gbp_endpoint_t *
1510 {
1511  ASSERT (gbp_endpoint_fib_type == node->fn_type);
1512  return ((gbp_endpoint_t *) node);
1513 }
1514 
1515 static void
1517 {
1518  const gbp_bridge_domain_t *gbd;
1519  const gbp_route_domain_t *grd;
1520  const fib_prefix_t *pfx;
1521  gbp_endpoint_t *ge;
1522 
1524 
1525  ASSERT (0 == vec_len (ge->ge_locs));
1526 
1527  gbd = gbp_bridge_domain_get (ge->ge_key.gek_gbd);
1528 
1529  /*
1530  * we have removed the last source. this EP is toast
1531  */
1532  if (INDEX_INVALID != ge->ge_key.gek_gbd)
1533  {
1534  gbp_endpoint_del_mac (&ge->ge_key.gek_mac, gbd->gb_bd_index);
1535  }
1536  vec_foreach (pfx, ge->ge_key.gek_ips)
1537  {
1538  grd = gbp_route_domain_get (ge->ge_key.gek_grd);
1539  gbp_endpoint_del_ip (&pfx->fp_addr, grd->grd_fib_index[pfx->fp_proto]);
1540  }
1542 }
1543 
1547 {
1548  ASSERT (0);
1549 
1550  return (FIB_NODE_BACK_WALK_CONTINUE);
1551 }
1552 
1553 /*
1554  * The FIB path's graph node virtual function table
1555  */
1558  .fnv_last_lock = gbp_endpoint_last_lock_gone,
1559  .fnv_back_walk = gbp_endpoint_back_walk_notify,
1560  // .fnv_mem_show = fib_path_memory_show,
1561 };
1562 
1563 static clib_error_t *
1565 {
1566 #define GBP_EP_HASH_NUM_BUCKETS (2 * 1024)
1567 #define GBP_EP_HASH_MEMORY_SIZE (1 << 20)
1568 
1569  clib_bihash_init_24_8 (&gbp_ep_db.ged_by_ip_rd,
1570  "GBP Endpoints - IP/RD",
1572 
1573  clib_bihash_init_16_8 (&gbp_ep_db.ged_by_mac_bd,
1574  "GBP Endpoints - MAC/BD",
1576 
1577  gbp_ep_logger = vlib_log_register_class ("gbp", "ep");
1579  gbp_fib_source_hi = fib_source_allocate ("gbp-endpoint-hi",
1582  gbp_fib_source_low = fib_source_allocate ("gbp-endpoint-low",
1585 
1586  return (NULL);
1587 }
1588 
1590 
1591 /*
1592  * fd.io coding-style-patch-verification: ON
1593  *
1594  * Local Variables:
1595  * eval: (c-set-style "gnu")
1596  * End:
1597  */
gbp_itf_l2_set_input_feature
void gbp_itf_l2_set_input_feature(gbp_itf_hdl_t gh, l2input_feat_masks_t feats)
Definition: gbp_itf.c:384
tmp
u32 * tmp
Definition: interface_output.c:1078
fib_proto_from_ip46
fib_protocol_t fib_proto_from_ip46(ip46_type_t iproto)
Convert from ip46_type to fib_protocol.
Definition: fib_types.c:409
GBP_ENDPOINT_SCAN_STOP
@ GBP_ENDPOINT_SCAN_STOP
Definition: gbp_scanner.h:24
fib_table_entry_path_add
fib_node_index_t fib_table_entry_path_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Add one path to an entry (aka route) in the FIB.
Definition: fib_table.c:558
gbp_endpoint_index
static index_t gbp_endpoint_index(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:207
GBP_EP_HASH_NUM_BUCKETS
#define GBP_EP_HASH_NUM_BUCKETS
gbp_endpoint_group_find
index_t gbp_endpoint_group_find(sclass_t sclass)
Definition: gbp_endpoint_group.c:67
gbp_policy_dpo.h
DPO_INVALID
#define DPO_INVALID
An initialiser for DPOs declared on the stack.
Definition: dpo.h:204
clib_bihash_kv_16_8_t::value
u64 value
Definition: bihash_16_8.h:43
mac
vl_api_mac_address_t mac
Definition: l2.api:559
gbp_endpoint_src_t
enum gbp_endpoint_src_t_ gbp_endpoint_src_t
fib_table_entry_special_dpo_add
fib_node_index_t fib_table_entry_special_dpo_add(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, const dpo_id_t *dpo)
Add a 'special' entry to the FIB that links to the DPO passed A special entry is an entry that the FI...
Definition: fib_table.c:324
gbp_endpoint_scan_l3
static void gbp_endpoint_scan_l3(vlib_main_t *vm)
Definition: gbp_endpoint.c:1437
gbp_bridge_domain_t_::gb_bd_index
u32 gb_bd_index
Definition: gbp_bridge_domain.h:48
WALK_CONTINUE
@ WALK_CONTINUE
Definition: interface_funcs.h:174
gbp_endpoint_walk_ip_itf
static int gbp_endpoint_walk_ip_itf(clib_bihash_kv_24_8_t *kvp, void *arg)
Definition: gbp_endpoint.c:1269
gbp_endpoint_show_one
static walk_rc_t gbp_endpoint_show_one(index_t gei, void *ctx)
Definition: gbp_endpoint.c:1258
fib_node_back_walk_rc_t
enum fib_node_back_walk_rc_t_ fib_node_back_walk_rc_t
Return code from a back walk function.
GBP_ENDPOINT_SRC_MAX
#define GBP_ENDPOINT_SRC_MAX
Definition: gbp_endpoint.h:78
ip4_neighbor.h
GBP_ENDPOINT_FLAG_REMOTE
@ GBP_ENDPOINT_FLAG_REMOTE
Definition: gbp_endpoint.h:46
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
gbp_endpoint_fwd_t_::gef_sclass
sclass_t gef_sclass
Endpoint Group's sclass.
Definition: gbp_endpoint.h:172
fib_table_entry_delete
void fib_table_entry_delete(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Delete a FIB entry.
Definition: fib_table.c:895
BIHASH_KVP_PER_PAGE
#define BIHASH_KVP_PER_PAGE
Definition: bihash_16_8.h:25
SCLASS_INVALID
#define SCLASS_INVALID
Definition: gbp_types.h:26
gpb_route_domain_t_::grd_fib_index
u32 grd_fib_index[FIB_PROTOCOL_IP_MAX]
Definition: gbp_route_domain.h:36
ip46_address_is_multicast
static uword ip46_address_is_multicast(const ip46_address_t *a)
Definition: ip46_address.h:154
gbp_route_domain_index
index_t gbp_route_domain_index(const gbp_route_domain_t *grd)
Definition: gbp_route_domain.c:66
gbp_vxlan_tunnel_clone_and_lock
gbp_itf_hdl_t gbp_vxlan_tunnel_clone_and_lock(u32 sw_if_index, const ip46_address_t *src, const ip46_address_t *dst)
Definition: gbp_vxlan.c:271
ip46_address_initializer
#define ip46_address_initializer
Definition: ip46_address.h:52
gbp_endpoint_child_remove
void gbp_endpoint_child_remove(index_t gei, u32 sibling)
Definition: gbp_endpoint.c:1004
gbp_ep_by_ip_itf_db_t_::ged_by_ip_rd
clib_bihash_24_8_t ged_by_ip_rd
Definition: gbp_endpoint.h:224
gbp_endpoint_unlock
void gbp_endpoint_unlock(gbp_endpoint_src_t src, index_t gei)
Definition: gbp_endpoint.c:916
vlib_log_class_t
u32 vlib_log_class_t
Definition: vlib.h:52
ip46_address_reset
static void ip46_address_reset(ip46_address_t *ip46)
Definition: ip46_address.h:74
ethernet_header_t::dst_address
u8 dst_address[6]
Definition: packet.h:55
gbp_itf_hdl_t_
Definition: gbp_itf.h:45
gbp_bridge_domain_t_::gb_vni
u32 gb_vni
The index of the BD's VNI interface on which packets from unkown endpoints arrive.
Definition: gbp_bridge_domain.h:80
ethernet_header_t::src_address
u8 src_address[6]
Definition: packet.h:56
vlib_log_register_class
vlib_log_class_t vlib_log_register_class(char *class, char *subclass)
Definition: log.c:339
gpb_endpoint_group_t_::gg_gbd
index_t gg_gbd
Bridge-domain ID the EPG is in.
Definition: gbp_endpoint_group.h:51
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
fib_node_vft_t_
A FIB graph nodes virtual function table.
Definition: fib_node.h:288
gbp_endpoint_loc_update
static void gbp_endpoint_loc_update(const gbp_endpoint_t *ge, gbp_endpoint_loc_t *gel, const gbp_bridge_domain_t *gb, u32 sw_if_index, index_t ggi, gbp_endpoint_flags_t flags, const ip46_address_t *tun_src, const ip46_address_t *tun_dst)
Definition: gbp_endpoint.c:479
gpb_endpoint_group_t_::gg_sclass
u16 gg_sclass
Sclass.
Definition: gbp_endpoint_group.h:46
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
gbp_scanner_node
vlib_node_registration_t gbp_scanner_node
(constructor) VLIB_REGISTER_NODE (gbp_scanner_node)
Definition: gbp_scanner.c:89
gbp_endpoint_del_ip
static void gbp_endpoint_del_ip(const ip46_address_t *ip, u32 fib_index)
Definition: gbp_endpoint.c:197
clib_bihash_is_free_16_8
static int clib_bihash_is_free_16_8(clib_bihash_kv_16_8_t *v)
Definition: bihash_16_8.h:47
vlib_cli_command_t::path
char * path
Definition: cli.h:96
gbp_endpoint_loc_t_::gel_itf
gbp_itf_hdl_t gel_itf
The interface on which the EP is connected.
Definition: gbp_endpoint.h:126
clib_bihash_kv_24_8_t
Definition: bihash_24_8.h:40
format_gbp_endpoint_flags
u8 * format_gbp_endpoint_flags(u8 *s, va_list *args)
Definition: gbp_endpoint.c:72
gbp_endpoint_get_best_src
static gbp_endpoint_src_t gbp_endpoint_get_best_src(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:451
adj_unlock
void adj_unlock(adj_index_t adj_index)
Release a reference counting lock on the adjacency.
Definition: adj.c:358
fib_table.h
gbp_endpoint_loc_find_or_add
static gbp_endpoint_loc_t * gbp_endpoint_loc_find_or_add(gbp_endpoint_t *ge, gbp_endpoint_src_t src)
Definition: gbp_endpoint.c:339
vxlan_gbp_tunnel_get_parent
u32 vxlan_gbp_tunnel_get_parent(u32 sw_if_index)
Definition: gbp_vxlan.c:222
gbp_endpoint_is_remote
int gbp_endpoint_is_remote(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:89
gbp_endpoint_show_node
static vlib_cli_command_t gbp_endpoint_show_node
(constructor) VLIB_CLI_COMMAND (gbp_endpoint_show_node)
Definition: gbp_endpoint.c:1352
gbp_ep_by_ip_itf_db_t_::ged_by_sw_if_index
index_t * ged_by_sw_if_index
Definition: gbp_endpoint.h:223
gbp_endpoint_get
static gbp_endpoint_t * gbp_endpoint_get(index_t gbpei)
Get the endpoint from a port/interface.
Definition: gbp_endpoint.h:265
gpb_endpoint_group_t_::gg_uplink_sw_if_index
u32 gg_uplink_sw_if_index
the uplink interface dedicated to the EPG
Definition: gbp_endpoint_group.h:66
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
gpb_route_domain_t_
A route Domain Representation.
Definition: gbp_route_domain.h:29
ethernet_header_t::type
u16 type
Definition: packet.h:59
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
ZERO_MAC_ADDRESS
const mac_address_t ZERO_MAC_ADDRESS
Definition: mac_address.c:19
gbp_vxlan_tunnel_get_type
gbp_vxlan_tunnel_type_t gbp_vxlan_tunnel_get_type(u32 sw_if_index)
Definition: gbp_vxlan.c:253
gbp_endpoint_fwd_t_::gef_flags
gbp_endpoint_flags_t gef_flags
Definition: gbp_endpoint.h:179
gbp_endpoint_flush_ctx_t_::geis
index_t * geis
Definition: gbp_endpoint.c:1013
fib_prefix_from_ip46_addr
void fib_prefix_from_ip46_addr(const ip46_address_t *addr, fib_prefix_t *pfx)
Host prefix from ip.
Definition: fib_types.c:81
gbp_n_learnt_endpoints
static u32 gbp_n_learnt_endpoints
A count of the number of dynamic entries.
Definition: gbp_endpoint.c:64
gbp_endpoint_fwd_t_
And endpoints current forwarding state.
Definition: gbp_endpoint.h:157
gbp_bridge_domain_get
static gbp_bridge_domain_t * gbp_bridge_domain_get(index_t i)
Definition: gbp_bridge_domain.h:128
gbp_endpoint_loc_unlock
static int gbp_endpoint_loc_unlock(gbp_endpoint_t *ge, gbp_endpoint_loc_t *gel)
Definition: gbp_endpoint.c:308
gbp_vxlan_tunnel_t_::gt_src
ip46_address_t gt_src
The source address to use for child tunnels.
Definition: gbp_vxlan.h:82
ip46_address_get_type
static ip46_type_t ip46_address_get_type(const ip46_address_t *ip)
Definition: ip46_address.h:148
unformat_input_t
struct _unformat_input_t unformat_input_t
gbp_bridge_domain_t_::gb_bvi_sw_if_index
u32 gb_bvi_sw_if_index
The BD's BVI interface (obligatory)
Definition: gbp_bridge_domain.h:64
GBP_ENDPOINT_FLAG_NONE
@ GBP_ENDPOINT_FLAG_NONE
Definition: gbp_endpoint.h:44
FIB_ENTRY_FLAG_INTERPOSE
@ FIB_ENTRY_FLAG_INTERPOSE
Definition: fib_entry.h:123
vlib_process_signal_event
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:1019
fib_node_type_t
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
gbp_ep_by_ip_itf_db_t_::ged_by_mac_bd
clib_bihash_16_8_t ged_by_mac_bd
Definition: gbp_endpoint.h:225
gbp_ep_by_ip_itf_db_t_
GBP Endpoint Databases.
Definition: gbp_endpoint.h:221
gbp_endpoint_loc_t_::gel_src
gbp_endpoint_src_t gel_src
The source providing this location information.
Definition: gbp_endpoint.h:121
gbp_endpoint_loc_find
static gbp_endpoint_loc_t * gbp_endpoint_loc_find(gbp_endpoint_t *ge, gbp_endpoint_src_t src)
Definition: gbp_endpoint.c:291
gbp_endpoint_attr_t
enum gbp_endpoint_attr_t_ gbp_endpoint_attr_t
Flags for each endpoint.
l2fib_add_entry
void l2fib_add_entry(const u8 *mac, u32 bd_index, u32 sw_if_index, l2fib_entry_result_flags_t flags)
Add an entry to the l2fib.
Definition: l2_fib.c:445
vec_search_with_function
#define vec_search_with_function(v, E, fn)
Search a vector for the index of the entry that matches.
Definition: vec.h:1075
l2_fib.h
gbp_endpoint_flags_t
enum gbp_endpoint_flags_t_ gbp_endpoint_flags_t
key
typedef key
Definition: ipsec_types.api:88
gbp_fib_source_low
static fib_source_t gbp_fib_source_low
Definition: gbp_endpoint.c:46
gbp_endpoint_loc_destroy
static void gbp_endpoint_loc_destroy(gbp_endpoint_loc_t *gel)
Definition: gbp_endpoint.c:332
gbp_itf_l2_set_output_feature
void gbp_itf_l2_set_output_feature(gbp_itf_hdl_t gh, l2output_feat_masks_t feats)
Definition: gbp_itf.c:430
vxlan_gbp_tunnel_lock_itf
gbp_itf_hdl_t vxlan_gbp_tunnel_lock_itf(u32 sw_if_index)
Definition: gbp_vxlan.c:237
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
GBP_VXLAN_TEMPLATE_TUNNEL
@ GBP_VXLAN_TEMPLATE_TUNNEL
This is the object type defined above.
Definition: gbp_vxlan.h:95
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
FIB_NODE_BW_REASON_FLAG_EVALUATE
@ FIB_NODE_BW_REASON_FLAG_EVALUATE
Definition: fib_node.h:157
ips
vl_api_address_t ips[n_ips]
Definition: gbp.api:136
gbp_endpoint_scan_l2
static void gbp_endpoint_scan_l2(vlib_main_t *vm)
Definition: gbp_endpoint.c:1382
fib_table_entry_special_remove
void fib_table_entry_special_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source)
Remove a 'special' entry from the FIB.
Definition: fib_table.c:424
bd_add_del_ip_mac
u32 bd_add_del_ip_mac(u32 bd_index, ip46_type_t type, const ip46_address_t *ip, const mac_address_t *mac, u8 is_add)
Add/delete IP address to MAC address mapping.
Definition: l2_bd.c:945
mac_address_copy
static_always_inline void mac_address_copy(mac_address_t *dst, const mac_address_t *src)
Definition: mac_address.h:128
GBP_ENDPOINT_ATTR_NAMES
#define GBP_ENDPOINT_ATTR_NAMES
Definition: gbp_endpoint.h:51
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
gbp_endpoint_child_add
u32 gbp_endpoint_child_add(index_t gei, fib_node_type_t type, fib_node_index_t index)
Definition: gbp_endpoint.c:997
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
ip6_neighbor.h
clib_bihash_is_free_24_8
static int clib_bihash_is_free_24_8(const clib_bihash_kv_24_8_t *v)
Definition: bihash_24_8.h:47
gbp_itf_hdl_reset
void gbp_itf_hdl_reset(gbp_itf_hdl_t *gh)
Definition: gbp_itf.c:110
format_gbp_endpoint_loc
static u8 * format_gbp_endpoint_loc(u8 *s, va_list *args)
Definition: gbp_endpoint.c:1211
gbp_itf_hdl_is_valid
bool gbp_itf_hdl_is_valid(gbp_itf_hdl_t gh)
Definition: gbp_itf.c:116
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
gbb_endpoint_fwd_reset
static void gbb_endpoint_fwd_reset(gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:561
gbp_endpoint_from_fib_node
static gbp_endpoint_t * gbp_endpoint_from_fib_node(fib_node_t *node)
Definition: gbp_endpoint.c:1509
gbp_endpoint_key_t_::gek_ips
fib_prefix_t * gek_ips
A vector of ip addresses that belong to the endpoint.
Definition: gbp_endpoint.h:93
gbp_endpoint_find_mac
static_always_inline gbp_endpoint_t * gbp_endpoint_find_mac(const u8 *mac, u32 bd_index)
Definition: gbp_endpoint.h:279
gbp_vxlan.h
l2_output.h
fib_walk.h
gbp_endpoint_ip_is_equal
static int gbp_endpoint_ip_is_equal(const fib_prefix_t *fp, const ip46_address_t *ip)
Definition: gbp_endpoint.c:213
gbp_endpoint_loc_t_::gel_flags
gbp_endpoint_flags_t gel_flags
Endpoint flags.
Definition: gbp_endpoint.h:131
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
gbp_endpoint_loc_t_::gel_dst
ip46_address_t gel_dst
Definition: gbp_endpoint.h:150
gbp_endpoint_scan
void gbp_endpoint_scan(vlib_main_t *vm)
Definition: gbp_endpoint.c:1492
gbp_endpoint_add_ip
static bool gbp_endpoint_add_ip(const ip46_address_t *ip, u32 fib_index, index_t gei)
Definition: gbp_endpoint.c:173
ip6_neighbor_advertise
void ip6_neighbor_advertise(vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index, const ip6_address_t *addr)
Definition: ip6_neighbor.c:43
gbp_endpoint_back_walk_notify
static fib_node_back_walk_rc_t gbp_endpoint_back_walk_notify(fib_node_t *node, fib_node_back_walk_ctx_t *ctx)
Definition: gbp_endpoint.c:1545
gbp_endpoint_pool
gbp_endpoint_t * gbp_endpoint_pool
Pool of GBP endpoints.
Definition: gbp_endpoint.c:59
gbp_endpoint_loc_t_
Information about the location of the endpoint provided by a source of endpoints.
Definition: gbp_endpoint.h:116
gbp_fib_source_hi
static fib_source_t gbp_fib_source_hi
Definition: gbp_endpoint.c:45
format_mac_address_t
u8 * format_mac_address_t(u8 *s, va_list *args)
Definition: mac_address.c:27
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
gbp_endpoint_get_node
static fib_node_t * gbp_endpoint_get_node(fib_node_index_t index)
Definition: gbp_endpoint.c:1499
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
FIB_ENTRY_FLAG_NONE
@ FIB_ENTRY_FLAG_NONE
Definition: fib_entry.h:112
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
gbp_endpoint_check
static void gbp_endpoint_check(index_t gei, f64 start_time)
Definition: gbp_endpoint.c:1360
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
mac_address_is_zero
static_always_inline int mac_address_is_zero(const mac_address_t *mac)
Definition: mac_address.h:106
mac_address_to_bytes
static_always_inline void mac_address_to_bytes(const mac_address_t *mac, u8 *bytes)
Definition: mac_address.h:99
gbp_itf_get_sw_if_index
u32 gbp_itf_get_sw_if_index(gbp_itf_hdl_t hdl)
Definition: gbp_itf.c:150
ethernet_header_t
Definition: packet.h:52
vnet_sw_interface_get_hw_address
static const u8 * vnet_sw_interface_get_hw_address(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:292
gpb_endpoint_group_t_
An Endpoint Group representation.
Definition: gbp_endpoint_group.h:36
format_gbp_itf_hdl
u8 * format_gbp_itf_hdl(u8 *s, va_list *args)
Definition: gbp_itf.c:522
clib_bihash_kv_24_8_t::value
u64 value
Definition: bihash_24_8.h:43
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
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
f64
double f64
Definition: types.h:142
gbp_itf.h
GBP_ENDPOINT_FLAG_EXTERNAL
@ GBP_ENDPOINT_FLAG_EXTERNAL
Definition: gbp_endpoint.h:48
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
gbp_endpoint_fwd_t_::gef_itf
gbp_itf_hdl_t gef_itf
The interface on which the EP is connected.
Definition: gbp_endpoint.h:162
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
gbp_endpoint_extract_key_ip_itf
static void gbp_endpoint_extract_key_ip_itf(const clib_bihash_kv_24_8_t *key, ip46_address_t *ip, u32 *sw_if_index)
Definition: gbp_endpoint.c:125
src
vl_api_address_t src
Definition: gre.api:54
gbp_endpoint_group.h
ge
u8 ge
Definition: ip_types.api:160
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
gbp_endpoint_loc_t_::gel_locks
u32 gel_locks
number of times this source has locked this
Definition: gbp_endpoint.h:141
sclass
u16 sclass
Definition: gbp.api:131
gbp_vxlan_tunnel_t_::gt_sw_if_index
u32 gt_sw_if_index
Definition: gbp_vxlan.h:42
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
ip4_neighbor_advertise
void ip4_neighbor_advertise(vlib_main_t *vm, vnet_main_t *vnm, u32 sw_if_index, const ip4_address_t *addr)
Definition: ip4_neighbor.c:71
gbp_bridge_domain.h
FIB_NODE_BACK_WALK_CONTINUE
@ FIB_NODE_BACK_WALK_CONTINUE
Definition: fib_node.h:259
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
fib_source_allocate
fib_source_t fib_source_allocate(const char *name, fib_source_priority_t prio, fib_source_behaviour_t bh)
Definition: fib_source.c:118
fib_proto_to_dpo
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:343
ip46_address_copy
static_always_inline void ip46_address_copy(ip46_address_t *dst, const ip46_address_t *src)
Definition: ip46_address.h:123
fib_prefix_t_::fp_addr
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:225
gbp_endpoint_group_get
gbp_endpoint_group_t * gbp_endpoint_group_get(index_t i)
Definition: gbp_endpoint_group.c:49
gbp_endpoint_alloc
static gbp_endpoint_t * gbp_endpoint_alloc(const ip46_address_t *ips, const gbp_route_domain_t *grd, const mac_address_t *mac, const gbp_bridge_domain_t *gbd)
Definition: gbp_endpoint.c:250
gbp_endpoint_loc_t_::gel_epg
index_t gel_epg
Endpoint Group.
Definition: gbp_endpoint.h:136
l2_input.h
gbp_endpoint_ips_update
static void gbp_endpoint_ips_update(gbp_endpoint_t *ge, const ip46_address_t *ips, const gbp_route_domain_t *grd)
Definition: gbp_endpoint.c:219
ip46_address_is_zero
static u8 ip46_address_is_zero(const ip46_address_t *ip46)
Definition: ip46_address.h:87
format_gbp_endpoint_key
static u8 * format_gbp_endpoint_key(u8 *s, va_list *args)
Definition: gbp_endpoint.c:1192
gbp_endpoint_flush
void gbp_endpoint_flush(gbp_endpoint_src_t src, u32 sw_if_index)
remove all learnt endpoints using the interface
Definition: gbp_endpoint.c:1038
FIB_SOURCE_PRIORITY_HI
#define FIB_SOURCE_PRIORITY_HI
Some priority values that plugins might use when they are not to concerned where in the list they'll ...
Definition: fib_source.h:284
gbp_vxlan_tunnel_t_
GBP VXLAN (template) tunnel.
Definition: gbp_vxlan.h:39
gbp_endpoint_key_t_
This is the identity of an endpoint, as such it is information about an endpoint that is idempotent.
Definition: gbp_endpoint.h:87
gbp_endpoint_is_learnt
int gbp_endpoint_is_learnt(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:107
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
gbp_endpoint_loc_t_::gel_parent_sw_if_index
u32 gel_parent_sw_if_index
Definition: gbp_endpoint.h:148
gbp_endpoint_walk_mac_itf
static int gbp_endpoint_walk_mac_itf(clib_bihash_kv_16_8_t *kvp, void *arg)
Definition: gbp_endpoint.c:1287
GBP_ITF_HDL_INVALID
const static gbp_itf_hdl_t GBP_ITF_HDL_INVALID
Definition: gbp_itf.h:58
format_gbp_endpoint_fwd
static u8 * format_gbp_endpoint_fwd(u8 *s, va_list *args)
Definition: gbp_endpoint.c:1177
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
format_gbp_endpoint
u8 * format_gbp_endpoint(u8 *s, va_list *args)
Definition: gbp_endpoint.c:1237
GBP_ENDPOINT_SCAN_START
@ GBP_ENDPOINT_SCAN_START
Definition: gbp_scanner.h:23
index
u32 index
Definition: flow_types.api:221
gbp_endpoint_flush_ctx_t_
Definition: gbp_endpoint.c:1009
gbp_ep_logger
static vlib_log_class_t gbp_ep_logger
Definition: gbp_endpoint.c:48
FOR_EACH_GBP_ENDPOINT_ATTR
#define FOR_EACH_GBP_ENDPOINT_ATTR(_item)
Definition: gbp_endpoint.c:66
gbp_endpoint_key_t_::gek_mac
mac_address_t gek_mac
MAC address of the endpoint.
Definition: gbp_endpoint.h:99
ip_neighbor.h
sclass_t
u16 sclass_t
Definition: gbp_types.h:25
pool_foreach_index
#define pool_foreach_index(i, v)
Definition: pool.h:576
clib_bihash_kv_16_8_t
Definition: bihash_16_8.h:40
mac_address_from_u64
static_always_inline void mac_address_from_u64(mac_address_t *mac, u64 u)
Definition: mac_address.h:122
gbp_endpoint_update_and_lock
int gbp_endpoint_update_and_lock(gbp_endpoint_src_t src, u32 sw_if_index, const ip46_address_t *ips, const mac_address_t *mac, index_t gbdi, index_t grdi, sclass_t sclass, gbp_endpoint_flags_t flags, const ip46_address_t *tun_src, const ip46_address_t *tun_dst, u32 *handle)
Definition: gbp_endpoint.c:820
gbb_endpoint_fwd_recalc
static void gbb_endpoint_fwd_recalc(gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:609
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
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vec_validate_init_empty
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header,...
Definition: vec.h:570
gbp_policy_dpo_add_or_lock
void gbp_policy_dpo_add_or_lock(dpo_proto_t dproto, gbp_scope_t scope, sclass_t sclass, u32 sw_if_index, dpo_id_t *dpo)
Definition: gbp_policy_dpo.c:97
format_ip46_address
format_function_t format_ip46_address
Definition: ip46_address.h:50
vlib_process_suspend
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
Definition: node_funcs.h:486
FIB_ROUTE_PATH_FLAG_NONE
@ FIB_ROUTE_PATH_FLAG_NONE
Definition: fib_types.h:332
gbp_endpoint_del_mac
static void gbp_endpoint_del_mac(const mac_address_t *mac, u32 bd_index)
Definition: gbp_endpoint.c:187
gbp_endpoint_find_ip
gbp_endpoint_t * gbp_endpoint_find_ip(const ip46_address_t *ip, u32 fib_index)
Definition: gbp_endpoint.c:134
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
gpb_endpoint_group_t_::gg_retention
gbp_endpoint_retention_t gg_retention
EP retention policy.
Definition: gbp_endpoint_group.h:82
gbp_endpoint_group_lock
void gbp_endpoint_group_lock(index_t ggi)
Definition: gbp_endpoint_group.c:55
gbp_endpoint_mk_key_mac
static_always_inline void gbp_endpoint_mk_key_mac(const u8 *mac, u32 bd_index, clib_bihash_kv_16_8_t *key)
Definition: gbp_endpoint.h:271
l2fib_del_entry
u32 l2fib_del_entry(const u8 *mac, u32 bd_index, u32 sw_if_index)
Delete an entry from the l2fib.
Definition: l2_fib.c:746
gbp_endpoint_add_mac
static bool gbp_endpoint_add_mac(const mac_address_t *mac, u32 bd_index, index_t gei)
Definition: gbp_endpoint.c:158
ctx
long ctx[MAX_CONNS]
Definition: main.c:144
gbp_endpoint_add_itf
static void gbp_endpoint_add_itf(u32 sw_if_index, index_t gei)
Definition: gbp_endpoint.c:150
format_fib_prefix
u8 * format_fib_prefix(u8 *s, va_list *args)
Definition: fib_types.c:283
gbp_endpoint_flush_ctx_t
struct gbp_endpoint_flush_ctx_t_ gbp_endpoint_flush_ctx_t
gbp_endpoint_find_for_update
static int gbp_endpoint_find_for_update(const ip46_address_t *ips, const gbp_route_domain_t *grd, const mac_address_t *mac, const gbp_bridge_domain_t *gbd, gbp_endpoint_t **ge)
Find an EP inthe DBs and check that if we find it in the L2 DB it has the same IPs as this update.
Definition: gbp_endpoint.c:380
gpb_route_domain_t_::grd_scope
gbp_scope_t grd_scope
Definition: gbp_route_domain.h:35
gbp_endpoint_walk
void gbp_endpoint_walk(gbp_endpoint_cb_t cb, void *ctx)
Definition: gbp_endpoint.c:1061
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
gbp_itf_l2_add_and_lock
gbp_itf_hdl_t gbp_itf_l2_add_and_lock(u32 sw_if_index, index_t gbi)
Definition: gbp_itf.c:198
fib_node_lock
void fib_node_lock(fib_node_t *node)
Definition: fib_node.c:203
gbp_route_domain_get
gbp_route_domain_t * gbp_route_domain_get(index_t i)
Definition: gbp_route_domain.c:72
gbp_endpoint_extract_key_mac_itf
static void gbp_endpoint_extract_key_mac_itf(const clib_bihash_kv_16_8_t *key, mac_address_t *mac, u32 *sw_if_index)
Definition: gbp_endpoint.c:117
value
u8 value
Definition: qos.api:54
fib_prefix_t_::fp_proto
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:211
gbp_endpoint_loc_t_::tun
struct gbp_endpoint_loc_t_::@659 tun
Tunnel info for remote endpoints.
gbp_bridge_domain_t_
A bridge Domain Representation.
Definition: gbp_bridge_domain.h:42
gbp_endpoint_n_learned
static void gbp_endpoint_n_learned(int n)
Definition: gbp_endpoint.c:460
GBP_ENDPOINT_INFO
#define GBP_ENDPOINT_INFO(...)
Definition: gbp_endpoint.c:53
gbp_endpoint.h
gbp_scanner.h
mac_address_t_
Definition: mac_address.h:21
gbp_endpoint_attr_names
static const char * gbp_endpoint_attr_names[]
Definition: gbp_endpoint.c:38
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
vec_sort_with_function
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
Definition: vec.h:1097
gbp_endpoint_init
static clib_error_t * gbp_endpoint_init(vlib_main_t *vm)
Definition: gbp_endpoint.c:1564
gbp_endpoint_show
static clib_error_t * gbp_endpoint_show(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: gbp_endpoint.c:1305
gbp_endpoint_fwd_t_::gef_fib_index
u32 gef_fib_index
FIB index the EP is in.
Definition: gbp_endpoint.h:177
vlib_main_t
Definition: main.h:102
fib_node_init
void fib_node_init(fib_node_t *node, fib_node_type_t type)
Definition: fib_node.c:185
gbp_endpoint_fwd_t_::gef_adjs
index_t * gef_adjs
The L3 adj, if created.
Definition: gbp_endpoint.h:167
gbp_ep_db
gbp_ep_db_t gbp_ep_db
EP DBs.
Definition: gbp_endpoint.c:43
gbp_endpoint_flush_ctx_t_::src
gbp_endpoint_src_t src
Definition: gbp_endpoint.c:1012
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
pool_get_zero
#define pool_get_zero(P, E)
Allocate an object E from a pool P and zero it.
Definition: pool.h:258
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
fib_node_unlock
void fib_node_unlock(fib_node_t *node)
Definition: fib_node.c:209
a
a
Definition: bitmap.h:544
gpb_endpoint_group_t_::gg_rd
index_t gg_rd
route-domain/IP-table ID the EPG is in
Definition: gbp_endpoint_group.h:56
feat_bitmap.h
gbp_endpoint_group_unlock
void gbp_endpoint_group_unlock(index_t ggi)
Definition: gbp_endpoint_group.c:164
ip
vl_api_address_t ip
Definition: l2.api:558
gbp_endpoint_flush_cb
static walk_rc_t gbp_endpoint_flush_cb(index_t gei, void *args)
Definition: gbp_endpoint.c:1017
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
gbp_endpoint_mk_key_ip
static_always_inline void gbp_endpoint_mk_key_ip(const ip46_address_t *ip, u32 fib_index, clib_bihash_kv_24_8_t *key)
Definition: gbp_endpoint.h:295
gbp_endpoint_cb_t
walk_rc_t(* gbp_endpoint_cb_t)(index_t gbpei, void *ctx)
Definition: gbp_endpoint.h:244
FIB_SOURCE_BH_SIMPLE
@ FIB_SOURCE_BH_SIMPLE
add paths without path extensions
Definition: fib_source.h:210
fib_node_back_walk_ctx_t_
Context passed between object during a back walk.
Definition: fib_node.h:214
fib_node_vft_t_::fnv_get
fib_node_get_t fnv_get
Definition: fib_node.h:289
FIB_SOURCE_PRIORITY_LOW
#define FIB_SOURCE_PRIORITY_LOW
Definition: fib_source.h:285
fib_node_child_remove
void fib_node_child_remove(fib_node_type_t parent_type, fib_node_index_t parent_index, fib_node_index_t sibling_index)
Definition: fib_node.c:123
gbp_endpoint_flush_ctx_t_::sw_if_index
u32 sw_if_index
Definition: gbp_endpoint.c:1011
FIB_NODE_BW_FLAG_FORCE_SYNC
@ FIB_NODE_BW_FLAG_FORCE_SYNC
Force the walk to be synchronous.
Definition: fib_node.h:180
VXLAN_GBP_TUNNEL
@ VXLAN_GBP_TUNNEL
A real VXLAN-GBP tunnel (from vnet/vxlan-gbp/...)
Definition: gbp_vxlan.h:100
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
fib_source_t
enum fib_source_t_ fib_source_t
The different sources that can create a route.
unformat_ip6_address
unformat_function_t unformat_ip6_address
Definition: format.h:89
rv
int __clib_unused rv
Definition: application.c:491
gbp_route_domain.h
IP46_TYPE_ANY
@ IP46_TYPE_ANY
Definition: ip46_address.h:24
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
gbp_endpoint_t_
A Group Based Policy Endpoint.
Definition: gbp_endpoint.h:190
gbp_bridge_domain_index
index_t gbp_bridge_domain_index(const gbp_bridge_domain_t *gbd)
Definition: gbp_bridge_domain.c:53
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:325
l2input_feat_masks_t
l2input_feat_masks_t
Definition: l2_input.h:169
foreach_gbp_endpoint_src
@ foreach_gbp_endpoint_src
Definition: gbp_endpoint.h:74
gbp_endpoint_retention_t_::remote_ep_timeout
u32 remote_ep_timeout
Aging timeout for remote endpoints.
Definition: gbp_endpoint_group.h:30
vlib_cli_command_t
Definition: cli.h:92
GBP_EP_HASH_MEMORY_SIZE
#define GBP_EP_HASH_MEMORY_SIZE
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
action
vl_api_mac_event_action_t action
Definition: l2.api:211
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
rewrite
rewrite
Definition: pnat.api:158
gbp_route_domain_get_remote_mac
const mac_address_t * gbp_route_domain_get_remote_mac(void)
Definition: gbp_route_domain.c:282
gbp_endpoint_cli
static clib_error_t * gbp_endpoint_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: gbp_endpoint.c:1075
gbp_endpoint_cli_node
static vlib_cli_command_t gbp_endpoint_cli_node
(constructor) VLIB_CLI_COMMAND (gbp_endpoint_cli_node)
Definition: gbp_endpoint.c:1154
format_gbp_endpoint_src
u8 * format_gbp_endpoint_src(u8 *s, va_list *args)
Definition: gbp_endpoint.c:1162
gbp_endpoint_loc_cmp_for_sort
static int gbp_endpoint_loc_cmp_for_sort(gbp_endpoint_loc_t *a, gbp_endpoint_loc_t *b)
Definition: gbp_endpoint.c:285
unformat_mac_address
uword unformat_mac_address(unformat_input_t *input, va_list *args)
Definition: format.c:241
walk_rc_t
enum walk_rc_t_ walk_rc_t
Walk return code.
dpo_reset
void dpo_reset(dpo_id_t *dpo)
reset a DPO ID The DPO will be unlocked.
Definition: dpo.c:234
fib_node_register_new_type
fib_node_type_t fib_node_register_new_type(const fib_node_vft_t *vft)
Create a new FIB node type and Register the function table for it.
Definition: fib_node.c:80
fib_proto_to_ip46
ip46_type_t fib_proto_to_ip46(fib_protocol_t fproto)
Convert from fib_protocol to ip46_type.
Definition: fib_types.c:393
gbp_vxlan_tunnel_get
gbp_vxlan_tunnel_t * gbp_vxlan_tunnel_get(index_t gti)
Definition: gbp_vxlan.c:84
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
fib_node_child_add
u32 fib_node_child_add(fib_node_type_t parent_type, fib_node_index_t parent_index, fib_node_type_t type, fib_node_index_t index)
Definition: fib_node.c:98
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
vec_del1
#define vec_del1(v, i)
Delete the element at index I.
Definition: vec.h:896
gbp_endpoint_vft
static const fib_node_vft_t gbp_endpoint_vft
Definition: gbp_endpoint.c:1556
vxlan_gbp.h
gbp_endpoint_is_external
int gbp_endpoint_is_external(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:101
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
gbp_endpoint_loc_is_equal
static int gbp_endpoint_loc_is_equal(gbp_endpoint_loc_t *a, gbp_endpoint_loc_t *b)
Definition: gbp_endpoint.c:279
gbp_endpoint_is_local
int gbp_endpoint_is_local(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:95
gbp_itf_clone_and_lock
gbp_itf_hdl_t gbp_itf_clone_and_lock(gbp_itf_hdl_t gh)
Definition: gbp_itf.c:273
gbp_endpoint_fib_type
static fib_node_type_t gbp_endpoint_fib_type
Definition: gbp_endpoint.c:47
gbp_itf_unlock
void gbp_itf_unlock(gbp_itf_hdl_t *gh)
Definition: gbp_itf.c:288
gbp_route_domain_get_local_mac
const mac_address_t * gbp_route_domain_get_local_mac(void)
Definition: gbp_route_domain.c:276
gbp_endpoint_last_lock_gone
static void gbp_endpoint_last_lock_gone(fib_node_t *node)
Definition: gbp_endpoint.c:1516
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105