FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
gbp_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2018 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #include <vnet/vnet.h>
19 #include <vnet/plugin/plugin.h>
20 
21 #include <vnet/interface.h>
22 #include <vnet/api_errno.h>
23 #include <vnet/ip/ip_types_api.h>
25 #include <vpp/app/version.h>
26 
27 #include <gbp/gbp.h>
28 #include <gbp/gbp_learn.h>
29 #include <gbp/gbp_itf.h>
30 #include <gbp/gbp_vxlan.h>
31 #include <gbp/gbp_bridge_domain.h>
32 #include <gbp/gbp_route_domain.h>
33 #include <gbp/gbp_ext_itf.h>
34 #include <gbp/gbp_contract.h>
35 
36 #include <vlibapi/api.h>
37 #include <vlibmemory/api.h>
38 
39 /* define message IDs */
40 #include <gbp/gbp.api_enum.h>
41 #include <gbp/gbp.api_types.h>
42 #include <vnet/format_fns.h>
44 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
45 #include "gbp_api_print.h"
46 
48 
50 
51 #define GBP_MSG_BASE msg_id_base
52 
54 gbp_endpoint_flags_decode (vl_api_gbp_endpoint_flags_t v)
55 {
57 
58  v = ntohl (v);
59 
68 
69  return (f);
70 }
71 
72 static vl_api_gbp_endpoint_flags_t
74 {
75  vl_api_gbp_endpoint_flags_t v = 0;
76 
77 
86 
87  v = htonl (v);
88 
89  return (v);
90 }
91 
92 static void
94 {
97  u32 sw_if_index, handle;
98  ip46_address_t *ips;
100  int rv = 0, ii;
101 
102  handle = INDEX_INVALID;
103 
105 
106  gef = gbp_endpoint_flags_decode (mp->endpoint.flags), ips = NULL;
107  sw_if_index = ntohl (mp->endpoint.sw_if_index);
108 
109  if (mp->endpoint.n_ips)
110  {
111  vec_validate (ips, mp->endpoint.n_ips - 1);
112 
113  vec_foreach_index (ii, ips)
114  {
115  ip_address_decode (&mp->endpoint.ips[ii], &ips[ii]);
116  }
117  }
118  mac_address_decode (mp->endpoint.mac, &mac);
119 
120  if (GBP_ENDPOINT_FLAG_REMOTE & gef)
121  {
122  ip46_address_t tun_src, tun_dst;
123 
124  ip_address_decode (&mp->endpoint.tun.src, &tun_src);
125  ip_address_decode (&mp->endpoint.tun.dst, &tun_dst);
126 
127  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
128  sw_if_index, ips, &mac,
130  ntohs (mp->endpoint.sclass),
131  gef, &tun_src, &tun_dst, &handle);
132  }
133  else
134  {
135  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
136  sw_if_index, ips, &mac,
138  ntohs (mp->endpoint.sclass),
139  gef, NULL, NULL, &handle);
140  }
141  vec_free (ips);
143 
144  /* *INDENT-OFF* */
145  REPLY_MACRO2 (VL_API_GBP_ENDPOINT_ADD_REPLY + GBP_MSG_BASE,
146  ({
147  rmp->handle = htonl (handle);
148  }));
149  /* *INDENT-ON* */
150 }
151 
152 static void
154 {
155  vl_api_gbp_endpoint_del_reply_t *rmp;
156  int rv = 0;
157 
158  gbp_endpoint_unlock (GBP_ENDPOINT_SRC_CP, ntohl (mp->handle));
159 
160  REPLY_MACRO (VL_API_GBP_ENDPOINT_DEL_REPLY + GBP_MSG_BASE);
161 }
162 
163 typedef struct gbp_walk_ctx_t_
164 {
168 
169 static walk_rc_t
171 {
173  gbp_endpoint_loc_t *gel;
174  gbp_endpoint_fwd_t *gef;
177  u8 n_ips, ii;
178 
179  ctx = args;
180  ge = gbp_endpoint_get (gei);
181 
182  n_ips = vec_len (ge->ge_key.gek_ips);
183  mp = vl_msg_api_alloc (sizeof (*mp) + (sizeof (*mp->endpoint.ips) * n_ips));
184  if (!mp)
185  return 1;
186 
187  clib_memset (mp, 0, sizeof (*mp));
188  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_DETAILS + GBP_MSG_BASE);
189  mp->context = ctx->context;
190 
191  gel = &ge->ge_locs[0];
192  gef = &ge->ge_fwd;
193 
194  if (gbp_endpoint_is_remote (ge))
195  {
196  mp->endpoint.sw_if_index = ntohl (gel->tun.gel_parent_sw_if_index);
198  &mp->endpoint.tun.src);
200  &mp->endpoint.tun.dst);
201  }
202  else
203  {
204  mp->endpoint.sw_if_index =
205  ntohl (gbp_itf_get_sw_if_index (gef->gef_itf));
206  }
207  mp->endpoint.sclass = ntohs (ge->ge_fwd.gef_sclass);
208  mp->endpoint.n_ips = n_ips;
209  mp->endpoint.flags = gbp_endpoint_flags_encode (gef->gef_flags);
210  mp->handle = htonl (gei);
211  mp->age =
213  ge->ge_last_time);
214  mac_address_encode (&ge->ge_key.gek_mac, mp->endpoint.mac);
215 
217  {
219  IP46_TYPE_ANY, &mp->endpoint.ips[ii]);
220  }
221 
222  vl_api_send_msg (ctx->reg, (u8 *) mp);
223 
224  return (WALK_CONTINUE);
225 }
226 
227 static void
229 {
231 
233  if (!reg)
234  return;
235 
236  gbp_walk_ctx_t ctx = {
237  .reg = reg,
238  .context = mp->context,
239  };
240 
242 }
243 
244 static void
245 gbp_retention_decode (const vl_api_gbp_endpoint_retention_t * in,
247 {
248  out->remote_ep_timeout = ntohl (in->remote_ep_timeout);
249 }
250 
251 static void
254 {
255  vl_api_gbp_endpoint_group_add_reply_t *rmp;
257  int rv = 0;
258 
259  gbp_retention_decode (&mp->epg.retention, &retention);
260 
261  rv = gbp_endpoint_group_add_and_lock (ntohl (mp->epg.vnid),
262  ntohs (mp->epg.sclass),
263  ntohl (mp->epg.bd_id),
264  ntohl (mp->epg.rd_id),
265  ntohl (mp->epg.uplink_sw_if_index),
266  &retention);
267 
268  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_ADD_REPLY + GBP_MSG_BASE);
269 }
270 
271 static void
274 {
275  vl_api_gbp_endpoint_group_del_reply_t *rmp;
276  int rv = 0;
277 
279 
280  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_DEL_REPLY + GBP_MSG_BASE);
281 }
282 
284 gbp_bridge_domain_flags_from_api (vl_api_gbp_bridge_domain_flags_t a)
285 {
287 
288  g = GBP_BD_FLAG_NONE;
289  a = clib_net_to_host_u32 (a);
290 
299 
300  return (g);
301 }
302 
303 static void
305 {
306  vl_api_gbp_bridge_domain_add_reply_t *rmp;
307  int rv = 0;
308 
309  rv = gbp_bridge_domain_add_and_lock (ntohl (mp->bd.bd_id),
310  ntohl (mp->bd.rd_id),
312  (mp->bd.flags),
313  ntohl (mp->bd.bvi_sw_if_index),
314  ntohl (mp->bd.uu_fwd_sw_if_index),
315  ntohl (mp->bd.bm_flood_sw_if_index));
316 
317  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
318 }
319 
320 static void
322 {
323  vl_api_gbp_bridge_domain_del_reply_t *rmp;
324  int rv = 0;
325 
326  rv = gbp_bridge_domain_delete (ntohl (mp->bd_id));
327 
328  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
329 }
330 
331 static void
333 {
334  vl_api_gbp_route_domain_add_reply_t *rmp;
335  int rv = 0;
336 
337  rv = gbp_route_domain_add_and_lock (ntohl (mp->rd.rd_id),
338  ntohs (mp->rd.scope),
339  ntohl (mp->rd.ip4_table_id),
340  ntohl (mp->rd.ip6_table_id),
341  ntohl (mp->rd.ip4_uu_sw_if_index),
342  ntohl (mp->rd.ip6_uu_sw_if_index));
343 
344  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
345 }
346 
347 static void
349 {
350  vl_api_gbp_route_domain_del_reply_t *rmp;
351  int rv = 0;
352 
353  rv = gbp_route_domain_delete (ntohl (mp->rd_id));
354 
355  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
356 }
357 
358 static int
359 gub_subnet_type_from_api (vl_api_gbp_subnet_type_t a, gbp_subnet_type_t * t)
360 {
361  a = clib_net_to_host_u32 (a);
362 
363  switch (a)
364  {
367  return (0);
369  *t = GBP_SUBNET_L3_OUT;
370  return (0);
373  return (0);
376  return (0);
379  return (0);
380  }
381 
382  return (-1);
383 }
384 
385 static void
387 {
388  vl_api_gbp_subnet_add_del_reply_t *rmp;
390  fib_prefix_t pfx;
391  int rv = 0;
392 
393  ip_prefix_decode (&mp->subnet.prefix, &pfx);
394 
395  rv = gub_subnet_type_from_api (mp->subnet.type, &type);
396 
397  if (0 != rv)
398  goto out;
399 
400  if (mp->is_add)
401  rv = gbp_subnet_add (ntohl (mp->subnet.rd_id),
402  &pfx, type,
403  ntohl (mp->subnet.sw_if_index),
404  ntohs (mp->subnet.sclass));
405  else
406  rv = gbp_subnet_del (ntohl (mp->subnet.rd_id), &pfx);
407 
408 out:
409  REPLY_MACRO (VL_API_GBP_SUBNET_ADD_DEL_REPLY + GBP_MSG_BASE);
410 }
411 
412 static vl_api_gbp_subnet_type_t
414 {
415  vl_api_gbp_subnet_type_t a = 0;
416 
417  switch (t)
418  {
421  break;
424  break;
427  break;
428  case GBP_SUBNET_L3_OUT:
430  break;
433  break;
434  }
435 
436  a = clib_host_to_net_u32 (a);
437 
438  return (a);
439 }
440 
441 static walk_rc_t
443  const fib_prefix_t * pfx,
445  u32 sw_if_index, sclass_t sclass, void *args)
446 {
449 
450  ctx = args;
451  mp = vl_msg_api_alloc (sizeof (*mp));
452  if (!mp)
453  return 1;
454 
455  clib_memset (mp, 0, sizeof (*mp));
456  mp->_vl_msg_id = ntohs (VL_API_GBP_SUBNET_DETAILS + GBP_MSG_BASE);
457  mp->context = ctx->context;
458 
459  mp->subnet.type = gub_subnet_type_to_api (type);
460  mp->subnet.sw_if_index = ntohl (sw_if_index);
461  mp->subnet.sclass = ntohs (sclass);
462  mp->subnet.rd_id = ntohl (rd_id);
463  ip_prefix_encode (pfx, &mp->subnet.prefix);
464 
465  vl_api_send_msg (ctx->reg, (u8 *) mp);
466 
467  return (WALK_CONTINUE);
468 }
469 
470 static void
472 {
474 
476  if (!reg)
477  return;
478 
479  gbp_walk_ctx_t ctx = {
480  .reg = reg,
481  .context = mp->context,
482  };
483 
485 }
486 
487 static int
489 {
492 
493  ctx = args;
494  mp = vl_msg_api_alloc (sizeof (*mp));
495  if (!mp)
496  return 1;
497 
498  clib_memset (mp, 0, sizeof (*mp));
499  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_GROUP_DETAILS + GBP_MSG_BASE);
500  mp->context = ctx->context;
501 
502  mp->epg.uplink_sw_if_index = ntohl (gg->gg_uplink_sw_if_index);
503  mp->epg.vnid = ntohl (gg->gg_vnid);
504  mp->epg.sclass = ntohs (gg->gg_sclass);
505  mp->epg.bd_id = ntohl (gbp_endpoint_group_get_bd_id (gg));
506  mp->epg.rd_id = ntohl (gbp_route_domain_get_rd_id (gg->gg_rd));
507 
508  vl_api_send_msg (ctx->reg, (u8 *) mp);
509 
510  return (1);
511 }
512 
513 static void
515  mp)
516 {
518 
520  if (!reg)
521  return;
522 
523  gbp_walk_ctx_t ctx = {
524  .reg = reg,
525  .context = mp->context,
526  };
527 
529 }
530 
531 static int
533 {
535  gbp_route_domain_t *gr;
537 
538  ctx = args;
539  mp = vl_msg_api_alloc (sizeof (*mp));
540  if (!mp)
541  return 1;
542 
543  memset (mp, 0, sizeof (*mp));
544  mp->_vl_msg_id = ntohs (VL_API_GBP_BRIDGE_DOMAIN_DETAILS + GBP_MSG_BASE);
545  mp->context = ctx->context;
546 
547  gr = gbp_route_domain_get (gb->gb_rdi);
548 
549  mp->bd.bd_id = ntohl (gb->gb_bd_id);
550  mp->bd.rd_id = ntohl (gr->grd_id);
551  mp->bd.bvi_sw_if_index = ntohl (gb->gb_bvi_sw_if_index);
552  mp->bd.uu_fwd_sw_if_index = ntohl (gb->gb_uu_fwd_sw_if_index);
553  mp->bd.bm_flood_sw_if_index =
555 
556  vl_api_send_msg (ctx->reg, (u8 *) mp);
557 
558  return (1);
559 }
560 
561 static void
563 {
565 
567  if (!reg)
568  return;
569 
570  gbp_walk_ctx_t ctx = {
571  .reg = reg,
572  .context = mp->context,
573  };
574 
576 }
577 
578 static int
580 {
583 
584  ctx = args;
585  mp = vl_msg_api_alloc (sizeof (*mp));
586  if (!mp)
587  return 1;
588 
589  memset (mp, 0, sizeof (*mp));
590  mp->_vl_msg_id = ntohs (VL_API_GBP_ROUTE_DOMAIN_DETAILS + GBP_MSG_BASE);
591  mp->context = ctx->context;
592 
593  mp->rd.rd_id = ntohl (grd->grd_id);
594  mp->rd.ip4_uu_sw_if_index =
595  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP4]);
596  mp->rd.ip6_uu_sw_if_index =
597  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP6]);
598 
599  vl_api_send_msg (ctx->reg, (u8 *) mp);
600 
601  return (1);
602 }
603 
604 static void
606 {
608 
610  if (!reg)
611  return;
612 
613  gbp_walk_ctx_t ctx = {
614  .reg = reg,
615  .context = mp->context,
616  };
617 
619 }
620 
621 static void
623 {
624  vl_api_gbp_recirc_add_del_reply_t *rmp;
626  int rv = 0;
627 
628  sw_if_index = ntohl (mp->recirc.sw_if_index);
629  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
630  goto bad_sw_if_index;
631 
632  if (mp->is_add)
633  rv = gbp_recirc_add (sw_if_index,
634  ntohs (mp->recirc.sclass), mp->recirc.is_ext);
635  else
636  rv = gbp_recirc_delete (sw_if_index);
637 
639 
640  REPLY_MACRO (VL_API_GBP_RECIRC_ADD_DEL_REPLY + GBP_MSG_BASE);
641 }
642 
643 static walk_rc_t
645 {
648 
649  ctx = args;
650  mp = vl_msg_api_alloc (sizeof (*mp));
651  if (!mp)
652  return (WALK_STOP);
653 
654  clib_memset (mp, 0, sizeof (*mp));
655  mp->_vl_msg_id = ntohs (VL_API_GBP_RECIRC_DETAILS + GBP_MSG_BASE);
656  mp->context = ctx->context;
657 
658  mp->recirc.sclass = ntohs (gr->gr_sclass);
659  mp->recirc.sw_if_index = ntohl (gr->gr_sw_if_index);
660  mp->recirc.is_ext = gr->gr_is_ext;
661 
662  vl_api_send_msg (ctx->reg, (u8 *) mp);
663 
664  return (WALK_CONTINUE);
665 }
666 
667 static void
669 {
671 
673  if (!reg)
674  return;
675 
676  gbp_walk_ctx_t ctx = {
677  .reg = reg,
678  .context = mp->context,
679  };
680 
682 }
683 
684 static void
686 {
687  vl_api_gbp_ext_itf_add_del_reply_t *rmp;
688  u32 sw_if_index = ~0;
689  vl_api_gbp_ext_itf_t *ext_itf;
690  int rv = 0;
691 
692  ext_itf = &mp->ext_itf;
693  if (ext_itf)
694  sw_if_index = ntohl (ext_itf->sw_if_index);
695 
696  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
697  goto bad_sw_if_index;
698 
699  if (mp->is_add)
700  rv = gbp_ext_itf_add (sw_if_index,
701  ntohl (ext_itf->bd_id), ntohl (ext_itf->rd_id),
702  ntohl (ext_itf->flags));
703  else
704  rv = gbp_ext_itf_delete (sw_if_index);
705 
707 
708  REPLY_MACRO (VL_API_GBP_EXT_ITF_ADD_DEL_REPLY + GBP_MSG_BASE);
709 }
710 
711 static walk_rc_t
713 {
716 
717  ctx = args;
718  mp = vl_msg_api_alloc (sizeof (*mp));
719  if (!mp)
720  return (WALK_STOP);
721 
722  clib_memset (mp, 0, sizeof (*mp));
723  mp->_vl_msg_id = ntohs (VL_API_GBP_EXT_ITF_DETAILS + GBP_MSG_BASE);
724  mp->context = ctx->context;
725 
726  mp->ext_itf.flags = ntohl (gx->gx_flags);
727  mp->ext_itf.bd_id = ntohl (gbp_bridge_domain_get_bd_id (gx->gx_bd));
728  mp->ext_itf.rd_id = ntohl (gbp_route_domain_get_rd_id (gx->gx_rd));
729  mp->ext_itf.sw_if_index = ntohl (gbp_itf_get_sw_if_index (gx->gx_itf));
730 
731  vl_api_send_msg (ctx->reg, (u8 *) mp);
732 
733  return (WALK_CONTINUE);
734 }
735 
736 static void
738 {
740 
742  if (!reg)
743  return;
744 
745  gbp_walk_ctx_t ctx = {
746  .reg = reg,
747  .context = mp->context,
748  };
749 
751 }
752 
753 static int
754 gbp_contract_rule_action_deocde (vl_api_gbp_rule_action_t in,
755  gbp_rule_action_t * out)
756 {
757  in = clib_net_to_host_u32 (in);
758 
759  switch (in)
760  {
761  case GBP_API_RULE_PERMIT:
762  *out = GBP_RULE_PERMIT;
763  return (0);
764  case GBP_API_RULE_DENY:
765  *out = GBP_RULE_DENY;
766  return (0);
768  *out = GBP_RULE_REDIRECT;
769  return (0);
770  }
771 
772  return (-1);
773 }
774 
775 static int
776 gbp_hash_mode_decode (vl_api_gbp_hash_mode_t in, gbp_hash_mode_t * out)
777 {
778  in = clib_net_to_host_u32 (in);
779 
780  switch (in)
781  {
783  *out = GBP_HASH_MODE_SRC_IP;
784  return (0);
786  *out = GBP_HASH_MODE_DST_IP;
787  return (0);
789  *out = GBP_HASH_MODE_SYMMETRIC;
790  return (0);
791  }
792 
793  return (-2);
794 }
795 
796 static int
797 gbp_next_hop_decode (const vl_api_gbp_next_hop_t * in, index_t * gnhi)
798 {
799  ip46_address_t ip;
801  index_t grd, gbd;
802 
803  gbd = gbp_bridge_domain_find_and_lock (ntohl (in->bd_id));
804 
805  if (INDEX_INVALID == gbd)
806  return (VNET_API_ERROR_BD_NOT_MODIFIABLE);
807 
808  grd = gbp_route_domain_find_and_lock (ntohl (in->rd_id));
809 
810  if (INDEX_INVALID == grd)
811  return (VNET_API_ERROR_NO_SUCH_FIB);
812 
813  ip_address_decode (&in->ip, &ip);
814  mac_address_decode (in->mac, &mac);
815 
816  *gnhi = gbp_next_hop_alloc (&ip, grd, &mac, gbd);
817 
818  return (0);
819 }
820 
821 static int
822 gbp_next_hop_set_decode (const vl_api_gbp_next_hop_set_t * in,
823  gbp_hash_mode_t * hash_mode, index_t ** out)
824 {
825 
826  index_t *gnhis = NULL;
827  int rv;
828  u8 ii;
829 
830  rv = gbp_hash_mode_decode (in->hash_mode, hash_mode);
831 
832  if (0 != rv)
833  return rv;
834 
835  vec_validate (gnhis, in->n_nhs - 1);
836 
837  for (ii = 0; ii < in->n_nhs; ii++)
838  {
839  rv = gbp_next_hop_decode (&in->nhs[ii], &gnhis[ii]);
840 
841  if (0 != rv)
842  {
843  vec_free (gnhis);
844  break;
845  }
846  }
847 
848  *out = gnhis;
849  return (rv);
850 }
851 
852 static int
853 gbp_contract_rule_decode (const vl_api_gbp_rule_t * in, index_t * gui)
854 {
855  gbp_hash_mode_t hash_mode;
857  index_t *nhs = NULL;
858  int rv;
859 
860  rv = gbp_contract_rule_action_deocde (in->action, &action);
861 
862  if (0 != rv)
863  return rv;
864 
865  if (GBP_RULE_REDIRECT == action)
866  {
867  rv = gbp_next_hop_set_decode (&in->nh_set, &hash_mode, &nhs);
868 
869  if (0 != rv)
870  return (rv);
871  }
872  else
873  {
874  hash_mode = GBP_HASH_MODE_SRC_IP;
875  }
876 
877  *gui = gbp_rule_alloc (action, hash_mode, nhs);
878 
879  return (rv);
880 }
881 
882 static int
884  const vl_api_gbp_rule_t * rules, index_t ** out)
885 {
886  index_t *guis = NULL;
887  int rv;
888  u8 ii;
889 
890  if (0 == n_rules)
891  {
892  *out = NULL;
893  return (0);
894  }
895 
896  vec_validate (guis, n_rules - 1);
897 
898  for (ii = 0; ii < n_rules; ii++)
899  {
900  rv = gbp_contract_rule_decode (&rules[ii], &guis[ii]);
901 
902  if (0 != rv)
903  {
904  index_t *gui;
905  vec_foreach (gui, guis) gbp_rule_free (*gui);
906  vec_free (guis);
907  return (rv);
908  }
909  }
910 
911  *out = guis;
912  return (rv);
913 }
914 
915 static void
917 {
920  u32 stats_index = ~0;
921  index_t *rules;
922  int ii, rv = 0;
923  u8 n_et;
924 
925  if (mp->is_add)
926  {
927  rv = gbp_contract_rules_decode (mp->contract.n_rules,
928  mp->contract.rules, &rules);
929  if (0 != rv)
930  goto out;
931 
932  allowed_ethertypes = NULL;
933 
934  /*
935  * allowed ether types
936  */
937  n_et = mp->contract.n_ether_types;
938  vec_validate (allowed_ethertypes, n_et - 1);
939 
940  for (ii = 0; ii < n_et; ii++)
941  {
942  /* leave the ether types in network order */
943  allowed_ethertypes[ii] = mp->contract.allowed_ethertypes[ii];
944  }
945 
946  rv = gbp_contract_update (ntohs (mp->contract.scope),
947  ntohs (mp->contract.sclass),
948  ntohs (mp->contract.dclass),
949  ntohl (mp->contract.acl_index),
950  rules, allowed_ethertypes, &stats_index);
951  }
952  else
953  rv = gbp_contract_delete (ntohs (mp->contract.scope),
954  ntohs (mp->contract.sclass),
955  ntohs (mp->contract.dclass));
956 
957 out:
958  /* *INDENT-OFF* */
959  REPLY_MACRO2 (VL_API_GBP_CONTRACT_ADD_DEL_REPLY + GBP_MSG_BASE,
960  ({
961  rmp->stats_index = htonl (stats_index);
962  }));
963  /* *INDENT-ON* */
964 }
965 
966 static int
968 {
971 
972  ctx = args;
973  mp = vl_msg_api_alloc (sizeof (*mp));
974  if (!mp)
975  return 1;
976 
977  clib_memset (mp, 0, sizeof (*mp));
978  mp->_vl_msg_id = ntohs (VL_API_GBP_CONTRACT_DETAILS + GBP_MSG_BASE);
979  mp->context = ctx->context;
980 
981  mp->contract.sclass = ntohs (gbpc->gc_key.gck_src);
982  mp->contract.dclass = ntohs (gbpc->gc_key.gck_dst);
983  mp->contract.acl_index = ntohl (gbpc->gc_acl_index);
984  mp->contract.scope = ntohs (gbpc->gc_key.gck_scope);
985 
986  vl_api_send_msg (ctx->reg, (u8 *) mp);
987 
988  return (1);
989 }
990 
991 static void
993 {
995 
997  if (!reg)
998  return;
999 
1000  gbp_walk_ctx_t ctx = {
1001  .reg = reg,
1002  .context = mp->context,
1003  };
1004 
1006 }
1007 
1008 static int
1009 gbp_vxlan_tunnel_mode_2_layer (vl_api_gbp_vxlan_tunnel_mode_t mode,
1011 {
1012  mode = clib_net_to_host_u32 (mode);
1013 
1014  switch (mode)
1015  {
1017  *l = GBP_VXLAN_TUN_L2;
1018  return (0);
1020  *l = GBP_VXLAN_TUN_L3;
1021  return (0);
1022  }
1023  return (-1);
1024 }
1025 
1026 static void
1028 {
1032  u32 sw_if_index;
1033  int rv = 0;
1034 
1035  ip4_address_decode (mp->tunnel.src, &src);
1036  rv = gbp_vxlan_tunnel_mode_2_layer (mp->tunnel.mode, &layer);
1037 
1038  if (0 != rv)
1039  goto out;
1040 
1041  rv = gbp_vxlan_tunnel_add (ntohl (mp->tunnel.vni),
1042  layer,
1043  ntohl (mp->tunnel.bd_rd_id), &src, &sw_if_index);
1044 
1045 out:
1046  /* *INDENT-OFF* */
1047  REPLY_MACRO2 (VL_API_GBP_VXLAN_TUNNEL_ADD_REPLY + GBP_MSG_BASE,
1048  ({
1049  rmp->sw_if_index = htonl (sw_if_index);
1050  }));
1051  /* *INDENT-ON* */
1052 }
1053 
1054 static void
1056 {
1057  vl_api_gbp_vxlan_tunnel_del_reply_t *rmp;
1058  int rv = 0;
1059 
1060  rv = gbp_vxlan_tunnel_del (ntohl (mp->tunnel.vni));
1061 
1062  REPLY_MACRO (VL_API_GBP_VXLAN_TUNNEL_DEL_REPLY + GBP_MSG_BASE);
1063 }
1064 
1065 static vl_api_gbp_vxlan_tunnel_mode_t
1067 {
1068  vl_api_gbp_vxlan_tunnel_mode_t mode = GBP_VXLAN_TUNNEL_MODE_L2;
1069 
1070  switch (layer)
1071  {
1072  case GBP_VXLAN_TUN_L2:
1073  mode = GBP_VXLAN_TUNNEL_MODE_L2;
1074  break;
1075  case GBP_VXLAN_TUN_L3:
1076  mode = GBP_VXLAN_TUNNEL_MODE_L3;
1077  break;
1078  }
1079  mode = clib_host_to_net_u32 (mode);
1080 
1081  return (mode);
1082 }
1083 
1084 static walk_rc_t
1086 {
1089 
1090  ctx = args;
1091  mp = vl_msg_api_alloc (sizeof (*mp));
1092  if (!mp)
1093  return 1;
1094 
1095  memset (mp, 0, sizeof (*mp));
1096  mp->_vl_msg_id = htons (VL_API_GBP_VXLAN_TUNNEL_DETAILS + GBP_MSG_BASE);
1097  mp->context = ctx->context;
1098 
1099  mp->tunnel.vni = htonl (gt->gt_vni);
1101  mp->tunnel.bd_rd_id = htonl (gt->gt_bd_rd_id);
1102 
1103  vl_api_send_msg (ctx->reg, (u8 *) mp);
1104 
1105  return (1);
1106 }
1107 
1108 static void
1110 {
1112 
1114  if (!reg)
1115  return;
1116 
1117  gbp_walk_ctx_t ctx = {
1118  .reg = reg,
1119  .context = mp->context,
1120  };
1121 
1123 }
1124 
1125 #include <gbp/gbp.api.c>
1126 static clib_error_t *
1128 {
1129  gbp_main_t *gbpm = &gbp_main;
1130 
1131  gbpm->gbp_acl_user_id = ~0;
1132 
1133  /* Ask for a correctly-sized block of API message decode slots */
1134  msg_id_base = setup_message_id_table ();
1135 
1136  return (NULL);
1137 }
1138 
1140 
1141 /* *INDENT-OFF* */
1142 VLIB_PLUGIN_REGISTER () = {
1143  .version = VPP_BUILD_VER,
1144  .description = "Group Based Policy (GBP)",
1145 };
1146 /* *INDENT-ON* */
1147 
1148 
1149 /*
1150  * fd.io coding-style-patch-verification: ON
1151  *
1152  * Local Variables:
1153  * eval: (c-set-style "gnu")
1154  * End:
1155  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:509
void gbp_bridge_domain_walk(gbp_bridge_domain_cb_t cb, void *ctx)
VLIB_PLUGIN_REGISTER()
sclass_t gr_sclass
EPG ID that packets will classify to when they arrive on this recirc.
Definition: gbp_recirc.h:34
#define vec_foreach_index(var, v)
Iterate over vector indices.
u32 gb_uu_fwd_sw_if_index
The BD&#39;s MAC spine-proxy interface (optional)
static void vl_api_gbp_vxlan_tunnel_dump_t_handler(vl_api_gbp_vxlan_tunnel_dump_t *mp)
Definition: gbp_api.c:1109
void gbp_subnet_walk(gbp_subnet_cb_t cb, void *ctx)
Definition: gbp_subnet.c:416
int gbp_endpoint_is_remote(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:87
static gbp_endpoint_t * gbp_endpoint_get(index_t gbpei)
Get the endpoint from a port/interface.
Definition: gbp_endpoint.h:265
f64 ge_last_time
The last time a packet from seen from this end point.
Definition: gbp_endpoint.h:213
static int gbp_contract_send_details(gbp_contract_t *gbpc, void *args)
Definition: gbp_api.c:967
u16 sclass_t
Definition: gbp_types.h:25
A Group Based Policy Endpoint.
Definition: gbp_endpoint.h:190
static int gbp_contract_rules_decode(u8 n_rules, const vl_api_gbp_rule_t *rules, index_t **out)
Definition: gbp_api.c:883
fib_prefix_t * gek_ips
A vector of ip addresses that belong to the endpoint.
Definition: gbp_endpoint.h:93
static void vl_api_gbp_endpoint_add_t_handler(vl_api_gbp_endpoint_add_t *mp)
Definition: gbp_api.c:93
vl_api_gbp_endpoint_group_t epg
Definition: gbp.api:199
gbp_contract_key_t gc_key
source and destination EPGs
Definition: gbp_contract.h:139
vl_api_gbp_endpoint_t endpoint
Definition: gbp.api:144
vl_api_mac_address_t mac
Definition: l2.api:502
static gbp_endpoint_flags_t gbp_endpoint_flags_decode(vl_api_gbp_endpoint_flags_t v)
Definition: gbp_api.c:54
static gbp_bridge_domain_flags_t gbp_bridge_domain_flags_from_api(vl_api_gbp_bridge_domain_flags_t a)
Definition: gbp_api.c:284
gbp_main_t gbp_main
Definition: gbp_api.c:47
vl_api_gbp_subnet_t subnet
Definition: gbp.api:291
a
Definition: bitmap.h:538
void gbp_endpoint_unlock(gbp_endpoint_src_t src, index_t gei)
Definition: gbp_endpoint.c:909
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:233
Information about the location of the endpoint provided by a source of endpoints. ...
Definition: gbp_endpoint.h:116
gbp_endpoint_fwd_t ge_fwd
Definition: gbp_endpoint.h:208
#define ntohs(x)
Definition: af_xdp.bpf.c:29
gbp_endpoint_key_t ge_key
The key/ID of this EP.
Definition: gbp_endpoint.h:200
int gbp_recirc_add(u32 sw_if_index, sclass_t sclass, u8 is_ext)
Definition: gbp_recirc.c:62
void mac_address_encode(const mac_address_t *in, u8 *out)
int gbp_bridge_domain_add_and_lock(u32 bd_id, u32 rd_id, gbp_bridge_domain_flags_t flags, u32 bvi_sw_if_index, u32 uu_fwd_sw_if_index, u32 bm_flood_sw_if_index)
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
gbp_endpoint_flags_t gef_flags
Definition: gbp_endpoint.h:179
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:333
static void vl_api_gbp_recirc_dump_t_handler(vl_api_gbp_recirc_dump_t *mp)
Definition: gbp_api.c:668
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:35
u32 gbp_acl_user_id
Definition: gbp.h:44
static void gbp_retention_decode(const vl_api_gbp_endpoint_retention_t *in, gbp_endpoint_retention_t *out)
Definition: gbp_api.c:245
A bridge Domain Representation.
int gbp_vxlan_tunnel_add(u32 vni, gbp_vxlan_tunnel_layer_t layer, u32 bd_rd_id, const ip4_address_t *src, u32 *sw_if_indexp)
Definition: gbp_vxlan.c:439
int gbp_endpoint_group_delete(sclass_t sclass)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
Definition: dpo.h:41
u8 n_rules
Definition: gbp.api:337
vl_api_address_t src
Definition: gre.api:54
vl_api_gbp_vxlan_tunnel_t tunnel
Definition: gbp.api:426
static void vl_api_gbp_vxlan_tunnel_del_t_handler(vl_api_gbp_vxlan_tunnel_add_t *mp)
Definition: gbp_api.c:1055
void gbp_vxlan_walk(gbp_vxlan_cb_t cb, void *ctx)
Definition: gbp_vxlan.c:304
vl_api_gbp_vxlan_tunnel_t tunnel
Definition: gbp.api:396
u32 rd_id
Definition: gbp.api:35
vlib_main_t * vm
Definition: in2out_ed.c:1582
index_t gg_rd
route-domain/IP-table ID the EPG is in
struct gbp_endpoint_loc_t_::@645 tun
Tunnel info for remote endpoints.
Endpoint Retnetion Policy.
gbp_itf_hdl_t gx_itf
The interface.
Definition: gbp_ext_itf.h:38
vl_api_gbp_ext_itf_t ext_itf
Definition: gbp.api:463
void * vl_msg_api_alloc(int nbytes)
static int gbp_endpoint_group_send_details(gbp_endpoint_group_t *gg, void *args)
Definition: gbp_api.c:488
gbp_endpoint_src_t gel_src
The source providing this location information.
Definition: gbp_endpoint.h:121
static void vl_api_gbp_contract_add_del_t_handler(vl_api_gbp_contract_add_del_t *mp)
Definition: gbp_api.c:916
int gbp_subnet_del(u32 rd_id, const fib_prefix_t *pfx)
Definition: gbp_subnet.c:230
unsigned char u8
Definition: types.h:56
static u16 msg_id_base
Definition: gbp_api.c:49
static void vl_api_gbp_bridge_domain_add_t_handler(vl_api_gbp_bridge_domain_add_t *mp)
Definition: gbp_api.c:304
u32 gbp_itf_get_sw_if_index(gbp_itf_hdl_t hdl)
Definition: gbp_itf.c:148
static int gbp_contract_rule_action_deocde(vl_api_gbp_rule_action_t in, gbp_rule_action_t *out)
Definition: gbp_api.c:754
enum walk_rc_t_ walk_rc_t
Walk return code.
static void vl_api_gbp_vxlan_tunnel_add_t_handler(vl_api_gbp_vxlan_tunnel_add_t *mp)
Definition: gbp_api.c:1027
u8 gr_is_ext
Is the interface for packets post-NAT translation (i.e.
Definition: gbp_recirc.h:50
vl_api_gbp_bridge_domain_t bd
Definition: gbp.api:66
enum gbp_bridge_domain_flags_t_ gbp_bridge_domain_flags_t
Bridge Domain Flags.
static int gbp_route_domain_send_details(gbp_route_domain_t *grd, void *args)
Definition: gbp_api.c:579
int gbp_subnet_add(u32 rd_id, const fib_prefix_t *pfx, gbp_subnet_type_t type, u32 sw_if_index, sclass_t sclass)
Definition: gbp_subnet.c:255
static vl_api_gbp_subnet_type_t gub_subnet_type_to_api(gbp_subnet_type_t t)
Definition: gbp_api.c:413
void gbp_route_domain_walk(gbp_route_domain_cb_t cb, void *ctx)
Aggregate type for a prefix.
Definition: fib_types.h:203
static void vl_api_gbp_route_domain_del_t_handler(vl_api_gbp_route_domain_del_t *mp)
Definition: gbp_api.c:348
u8 n_ips
Definition: gbp.api:135
A GBP recirculation interface representation Thes interfaces join Bridge domains that are internal to...
Definition: gbp_recirc.h:29
unsigned int u32
Definition: types.h:88
index_t gx_bd
The BD this external interface is a member of.
Definition: gbp_ext_itf.h:43
static vl_api_gbp_endpoint_flags_t gbp_endpoint_flags_encode(gbp_endpoint_flags_t f)
Definition: gbp_api.c:73
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Decode/Encode for struct/union types.
Definition: ip_types_api.c:160
vl_api_fib_path_type_t type
Definition: fib_types.api:123
static walk_rc_t gbp_endpoint_send_details(index_t gei, void *args)
Definition: gbp_api.c:170
int gbp_ext_itf_delete(u32 sw_if_index)
Definition: gbp_ext_itf.c:122
enum gbp_subnet_type_t_ gbp_subnet_type_t
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:226
static walk_rc_t gbp_subnet_send_details(u32 rd_id, const fib_prefix_t *pfx, gbp_subnet_type_t type, u32 sw_if_index, sclass_t sclass, void *args)
Definition: gbp_api.c:442
static void vl_api_gbp_endpoint_group_add_t_handler(vl_api_gbp_endpoint_group_add_t *mp)
Definition: gbp_api.c:253
static void vl_api_gbp_contract_dump_t_handler(vl_api_gbp_contract_dump_t *mp)
Definition: gbp_api.c:992
int gbp_route_domain_delete(u32 rd_id)
long ctx[MAX_CONNS]
Definition: main.c:144
int gbp_contract_delete(gbp_scope_t scope, sclass_t sclass, sclass_t dclass)
Definition: gbp_contract.c:536
unsigned short u16
Definition: types.h:57
sclass_t gck_src
source and destination EPGs for which the ACL applies
Definition: gbp_contract.h:58
int gbp_endpoint_group_add_and_lock(vnid_t vnid, u16 sclass, u32 bd_id, u32 rd_id, u32 uplink_sw_if_index, const gbp_endpoint_retention_t *retention)
u16 sclass
Definition: gbp.api:131
static vl_api_gbp_vxlan_tunnel_mode_t gbp_vxlan_tunnel_layer_2_mode(gbp_vxlan_tunnel_layer_t layer)
Definition: gbp_api.c:1066
#define REPLY_MACRO(t)
u32 grd_uu_sw_if_index[FIB_PROTOCOL_IP_MAX]
The interfaces on which to send packets to unnknown EPs.
u32 remote_ep_timeout
Aging timeout for remote endpoints.
vl_api_gbp_next_hop_t nhs[8]
Definition: gbp.api:313
u32 gb_bd_id
Bridge-domain ID.
u32 gb_rdi
Index of the Route-domain this BD is associated with.
sclass_t gef_sclass
Endpoint Group&#39;s sclass.
Definition: gbp_endpoint.h:172
mac_address_t gek_mac
MAC address of the endpoint.
Definition: gbp_endpoint.h:99
vl_api_tunnel_mode_t mode
Definition: gre.api:48
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:813
enum gbp_hash_mode_t_ gbp_hash_mode_t
An external interface maps directly to an oflex L3ExternalInterface.
Definition: gbp_ext_itf.h:33
An Endpoint Group representation.
int gbp_route_domain_add_and_lock(u32 rd_id, gbp_scope_t scope, u32 ip4_table_id, u32 ip6_table_id, u32 ip4_uu_sw_if_index, u32 ip6_uu_sw_if_index)
vl_api_gbp_bridge_domain_t bd
Definition: gbp.api:47
static void vl_api_gbp_recirc_add_del_t_handler(vl_api_gbp_recirc_add_del_t *mp)
Definition: gbp_api.c:622
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
#define BAD_SW_IF_INDEX_LABEL
static uword vnet_sw_if_index_is_api_valid(u32 sw_if_index)
enum gbp_vxlan_tunnel_layer_t_ gbp_vxlan_tunnel_layer_t
static void vl_api_gbp_bridge_domain_dump_t_handler(vl_api_gbp_bridge_domain_dump_t *mp)
Definition: gbp_api.c:562
int gbp_contract_update(gbp_scope_t scope, sclass_t sclass, sclass_t dclass, u32 acl_index, index_t *rules, u16 *allowed_ethertypes, u32 *stats_index)
Definition: gbp_contract.c:465
void gbp_endpoint_walk(gbp_endpoint_cb_t cb, void *ctx)
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:380
vl_api_gbp_endpoint_retention_t retention
Definition: gbp.api:191
static void vl_api_gbp_ext_itf_add_del_t_handler(vl_api_gbp_ext_itf_add_del_t *mp)
Definition: gbp_api.c:685
static walk_rc_t gbp_vxlan_tunnel_send_details(gbp_vxlan_tunnel_t *gt, void *args)
Definition: gbp_api.c:1085
static void vl_api_gbp_subnet_add_del_t_handler(vl_api_gbp_subnet_add_del_t *mp)
Definition: gbp_api.c:386
int gbp_vxlan_tunnel_del(u32 vni)
Definition: gbp_vxlan.c:550
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:79
vl_api_gbp_endpoint_group_t epg
Definition: gbp.api:220
static void vl_api_gbp_route_domain_dump_t_handler(vl_api_gbp_route_domain_dump_t *mp)
Definition: gbp_api.c:605
vl_api_gbp_subnet_t subnet
Definition: gbp.api:277
index_t gx_rd
The RD this external interface is a member of.
Definition: gbp_ext_itf.h:48
index_t gbp_bridge_domain_find_and_lock(u32 bd_id)
u32 gr_sw_if_index
Definition: gbp_recirc.h:54
vl_api_gbp_rule_t rules[n_rules]
Definition: gbp.api:338
static void vl_api_gbp_endpoint_dump_t_handler(vl_api_gbp_endpoint_dump_t *mp)
Definition: gbp_api.c:228
vl_api_gbp_contract_t contract
Definition: gbp.api:347
enum gbp_endpoint_flags_t_ gbp_endpoint_flags_t
u32 stats_index
Definition: ip.api:143
gbp_vxlan_tunnel_layer_t gt_layer
Definition: gbp_vxlan.h:49
gbp_route_domain_t * gbp_route_domain_get(index_t i)
static void vl_api_gbp_endpoint_group_dump_t_handler(vl_api_gbp_endpoint_group_dump_t *mp)
Definition: gbp_api.c:514
u32 gb_bvi_sw_if_index
The BD&#39;s BVI interface (obligatory)
vl_api_gbp_recirc_t recirc
Definition: gbp.api:236
static clib_error_t * gbp_init(vlib_main_t *vm)
Definition: gbp_api.c:1127
index_t gbp_rule_alloc(gbp_rule_action_t action, gbp_hash_mode_t hash_mode, index_t *nhs)
Definition: gbp_contract.c:62
static f64 clib_host_to_net_f64(f64 x)
Definition: byte_order.h:178
static void vl_api_gbp_ext_itf_dump_t_handler(vl_api_gbp_ext_itf_dump_t *mp)
Definition: gbp_api.c:737
static void vl_api_gbp_subnet_dump_t_handler(vl_api_gbp_subnet_dump_t *mp)
Definition: gbp_api.c:471
int gbp_bridge_domain_delete(u32 bd_id)
vl_api_gbp_contract_t contract
Definition: gbp.api:368
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
enum gbp_rule_action_t_ gbp_rule_action_t
void gbp_recirc_walk(gbp_recirc_cb_t cb, void *ctx)
Definition: gbp_recirc.c:225
vl_api_interface_index_t sw_if_index
Definition: gbp.api:404
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
Definition: ip_types_api.c:261
static void vl_api_gbp_endpoint_del_t_handler(vl_api_gbp_endpoint_del_t *mp)
Definition: gbp_api.c:153
static void vl_api_gbp_route_domain_add_t_handler(vl_api_gbp_route_domain_add_t *mp)
Definition: gbp_api.c:332
gbp_itf_hdl_t gef_itf
The interface on which the EP is connected.
Definition: gbp_endpoint.h:162
static int gbp_next_hop_set_decode(const vl_api_gbp_next_hop_set_t *in, gbp_hash_mode_t *hash_mode, index_t **out)
Definition: gbp_api.c:822
vl_api_address_t ip
Definition: l2.api:501
And endpoints current forwarding state.
Definition: gbp_endpoint.h:157
gbp_itf_hdl_t gb_bm_flood_itf
The BD&#39;s interface to sned Broadcast and multicast packets.
vl_api_mac_event_action_t action
Definition: l2.api:181
vl_api_gbp_endpoint_t endpoint
Definition: gbp.api:176
static walk_rc_t gbp_recirc_send_details(gbp_recirc_t *gr, void *args)
Definition: gbp_api.c:644
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
A route Domain Representation.
u32 gg_uplink_sw_if_index
the uplink interface dedicated to the EPG
static int gbp_next_hop_decode(const vl_api_gbp_next_hop_t *in, index_t *gnhi)
Definition: gbp_api.c:797
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
Definition: dpo.h:47
u32 gbp_route_domain_get_rd_id(index_t grdi)
gbp_scope_t gck_scope
Definition: gbp_contract.h:54
void ip4_address_decode(const vl_api_ip4_address_t in, ip4_address_t *out)
Definition: ip_types_api.c:129
vl_api_registration_t * reg
Definition: gbp_api.c:165
u32 gx_flags
The associated flags.
Definition: gbp_ext_itf.h:58
void gbp_ext_itf_walk(gbp_ext_itf_cb_t cb, void *ctx)
Definition: gbp_ext_itf.c:231
static int gbp_bridge_domain_send_details(gbp_bridge_domain_t *gb, void *args)
Definition: gbp_api.c:532
static walk_rc_t gbp_ext_itf_send_details(gbp_ext_itf_t *gx, void *args)
Definition: gbp_api.c:712
Group Base Policy (GBP) defines:
Definition: gbp.h:42
void ip_address_encode(const ip46_address_t *in, ip46_type_t type, vl_api_address_t *out)
Definition: ip_types_api.c:194
int gbp_recirc_delete(u32 sw_if_index)
Definition: gbp_recirc.c:175
GBP VXLAN (template) tunnel.
Definition: gbp_vxlan.h:39
u32 grd_id
Route-domain ID.
vl_api_gbp_ext_itf_t ext_itf
Definition: gbp.api:449
vl_api_gbp_route_domain_t rd
Definition: gbp.api:105
vl_api_address_t ips[n_ips]
Definition: gbp.api:136
u32 gbp_endpoint_group_get_bd_id(const gbp_endpoint_group_t *gg)
#define vec_foreach(var, vec)
Vector iterator.
static void setup_message_id_table(snat_main_t *sm, api_main_t *am)
Definition: nat_api.c:2804
static void vl_api_gbp_bridge_domain_del_t_handler(vl_api_gbp_bridge_domain_del_t *mp)
Definition: gbp_api.c:321
#define GBP_MSG_BASE
Definition: gbp_api.c:51
static void vl_api_gbp_endpoint_group_del_t_handler(vl_api_gbp_endpoint_group_del_t *mp)
Definition: gbp_api.c:273
u16 allowed_ethertypes[16]
Definition: gbp.api:336
u32 gt_bd_rd_id
The BD or RD value (depending on the layer) that the tunnel is bound to.
Definition: gbp_vxlan.h:48
u8 ge
Definition: ip_types.api:149
VLIB_API_INIT_FUNCTION(gbp_init)
gbp_endpoint_loc_t * ge_locs
Location information provided by the various sources.
Definition: gbp_endpoint.h:206
vl_api_gbp_route_domain_t rd
Definition: gbp.api:86
void gbp_contract_walk(gbp_contract_cb_t cb, void *ctx)
Definition: gbp_contract.c:565
struct gbp_walk_ctx_t_ gbp_walk_ctx_t
static int gbp_contract_rule_decode(const vl_api_gbp_rule_t *in, index_t *gui)
Definition: gbp_api.c:853
u32 gbp_bridge_domain_get_bd_id(index_t gbdi)
ip46_address_t gel_dst
Definition: gbp_endpoint.h:150
int gbp_ext_itf_add(u32 sw_if_index, u32 bd_id, u32 rd_id, u32 flags)
Definition: gbp_ext_itf.c:53
void mac_address_decode(const u8 *in, mac_address_t *out)
Conversion functions to/from (decode/encode) API types to VPP internal types.
static int gbp_hash_mode_decode(vl_api_gbp_hash_mode_t in, gbp_hash_mode_t *out)
Definition: gbp_api.c:776
static int gbp_vxlan_tunnel_mode_2_layer(vl_api_gbp_vxlan_tunnel_mode_t mode, gbp_vxlan_tunnel_layer_t *l)
Definition: gbp_api.c:1009
index_t gbp_next_hop_alloc(const ip46_address_t *ip, index_t grd, const mac_address_t *mac, index_t gbd)
Definition: gbp_contract.c:83
vl_api_gbp_recirc_t recirc
Definition: gbp.api:250
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:33
index_t gbp_route_domain_find_and_lock(u32 rd_id)
A Group Based Policy Contract.
Definition: gbp_contract.h:134
#define VALIDATE_SW_IF_INDEX(mp)
void gbp_rule_free(index_t gui)
Definition: gbp_contract.c:77
void gbp_endpoint_group_walk(gbp_endpoint_group_cb_t cb, void *ctx)
static int gub_subnet_type_from_api(vl_api_gbp_subnet_type_t a, gbp_subnet_type_t *t)
Definition: gbp_api.c:359