FD.io VPP  v21.01.1
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 
47 
49 
50 #define GBP_MSG_BASE msg_id_base
51 
53 gbp_endpoint_flags_decode (vl_api_gbp_endpoint_flags_t v)
54 {
56 
57  v = ntohl (v);
58 
67 
68  return (f);
69 }
70 
71 static vl_api_gbp_endpoint_flags_t
73 {
74  vl_api_gbp_endpoint_flags_t v = 0;
75 
76 
85 
86  v = htonl (v);
87 
88  return (v);
89 }
90 
91 static void
93 {
96  u32 sw_if_index, handle;
97  ip46_address_t *ips;
99  int rv = 0, ii;
100 
101  handle = INDEX_INVALID;
102 
104 
105  gef = gbp_endpoint_flags_decode (mp->endpoint.flags), ips = NULL;
106  sw_if_index = ntohl (mp->endpoint.sw_if_index);
107 
108  if (mp->endpoint.n_ips)
109  {
110  vec_validate (ips, mp->endpoint.n_ips - 1);
111 
112  vec_foreach_index (ii, ips)
113  {
114  ip_address_decode (&mp->endpoint.ips[ii], &ips[ii]);
115  }
116  }
117  mac_address_decode (mp->endpoint.mac, &mac);
118 
119  if (GBP_ENDPOINT_FLAG_REMOTE & gef)
120  {
121  ip46_address_t tun_src, tun_dst;
122 
123  ip_address_decode (&mp->endpoint.tun.src, &tun_src);
124  ip_address_decode (&mp->endpoint.tun.dst, &tun_dst);
125 
126  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
127  sw_if_index, ips, &mac,
129  ntohs (mp->endpoint.sclass),
130  gef, &tun_src, &tun_dst, &handle);
131  }
132  else
133  {
134  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
135  sw_if_index, ips, &mac,
137  ntohs (mp->endpoint.sclass),
138  gef, NULL, NULL, &handle);
139  }
140  vec_free (ips);
142 
143  /* *INDENT-OFF* */
144  REPLY_MACRO2 (VL_API_GBP_ENDPOINT_ADD_REPLY + GBP_MSG_BASE,
145  ({
146  rmp->handle = htonl (handle);
147  }));
148  /* *INDENT-ON* */
149 }
150 
151 static void
153 {
154  vl_api_gbp_endpoint_del_reply_t *rmp;
155  int rv = 0;
156 
157  gbp_endpoint_unlock (GBP_ENDPOINT_SRC_CP, ntohl (mp->handle));
158 
159  REPLY_MACRO (VL_API_GBP_ENDPOINT_DEL_REPLY + GBP_MSG_BASE);
160 }
161 
162 typedef struct gbp_walk_ctx_t_
163 {
167 
168 static walk_rc_t
170 {
172  gbp_endpoint_loc_t *gel;
173  gbp_endpoint_fwd_t *gef;
176  u8 n_ips, ii;
177 
178  ctx = args;
179  ge = gbp_endpoint_get (gei);
180 
181  n_ips = vec_len (ge->ge_key.gek_ips);
182  mp = vl_msg_api_alloc (sizeof (*mp) + (sizeof (*mp->endpoint.ips) * n_ips));
183  if (!mp)
184  return 1;
185 
186  clib_memset (mp, 0, sizeof (*mp));
187  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_DETAILS + GBP_MSG_BASE);
188  mp->context = ctx->context;
189 
190  gel = &ge->ge_locs[0];
191  gef = &ge->ge_fwd;
192 
193  if (gbp_endpoint_is_remote (ge))
194  {
195  mp->endpoint.sw_if_index = ntohl (gel->tun.gel_parent_sw_if_index);
197  &mp->endpoint.tun.src);
199  &mp->endpoint.tun.dst);
200  }
201  else
202  {
203  mp->endpoint.sw_if_index =
204  ntohl (gbp_itf_get_sw_if_index (gef->gef_itf));
205  }
206  mp->endpoint.sclass = ntohs (ge->ge_fwd.gef_sclass);
207  mp->endpoint.n_ips = n_ips;
208  mp->endpoint.flags = gbp_endpoint_flags_encode (gef->gef_flags);
209  mp->handle = htonl (gei);
210  mp->age =
212  ge->ge_last_time);
213  mac_address_encode (&ge->ge_key.gek_mac, mp->endpoint.mac);
214 
216  {
218  IP46_TYPE_ANY, &mp->endpoint.ips[ii]);
219  }
220 
221  vl_api_send_msg (ctx->reg, (u8 *) mp);
222 
223  return (WALK_CONTINUE);
224 }
225 
226 static void
228 {
230 
232  if (!reg)
233  return;
234 
235  gbp_walk_ctx_t ctx = {
236  .reg = reg,
237  .context = mp->context,
238  };
239 
241 }
242 
243 static void
244 gbp_retention_decode (const vl_api_gbp_endpoint_retention_t * in,
246 {
247  out->remote_ep_timeout = ntohl (in->remote_ep_timeout);
248 }
249 
250 static void
253 {
254  vl_api_gbp_endpoint_group_add_reply_t *rmp;
256  int rv = 0;
257 
258  gbp_retention_decode (&mp->epg.retention, &retention);
259 
260  rv = gbp_endpoint_group_add_and_lock (ntohl (mp->epg.vnid),
261  ntohs (mp->epg.sclass),
262  ntohl (mp->epg.bd_id),
263  ntohl (mp->epg.rd_id),
264  ntohl (mp->epg.uplink_sw_if_index),
265  &retention);
266 
267  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_ADD_REPLY + GBP_MSG_BASE);
268 }
269 
270 static void
273 {
274  vl_api_gbp_endpoint_group_del_reply_t *rmp;
275  int rv = 0;
276 
278 
279  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_DEL_REPLY + GBP_MSG_BASE);
280 }
281 
283 gbp_bridge_domain_flags_from_api (vl_api_gbp_bridge_domain_flags_t a)
284 {
286 
287  g = GBP_BD_FLAG_NONE;
288  a = clib_net_to_host_u32 (a);
289 
298 
299  return (g);
300 }
301 
302 static void
304 {
305  vl_api_gbp_bridge_domain_add_reply_t *rmp;
306  int rv = 0;
307 
308  rv = gbp_bridge_domain_add_and_lock (ntohl (mp->bd.bd_id),
309  ntohl (mp->bd.rd_id),
311  (mp->bd.flags),
312  ntohl (mp->bd.bvi_sw_if_index),
313  ntohl (mp->bd.uu_fwd_sw_if_index),
314  ntohl (mp->bd.bm_flood_sw_if_index));
315 
316  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
317 }
318 
319 static void
321 {
322  vl_api_gbp_bridge_domain_del_reply_t *rmp;
323  int rv = 0;
324 
325  rv = gbp_bridge_domain_delete (ntohl (mp->bd_id));
326 
327  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
328 }
329 
330 static void
332 {
333  vl_api_gbp_route_domain_add_reply_t *rmp;
334  int rv = 0;
335 
336  rv = gbp_route_domain_add_and_lock (ntohl (mp->rd.rd_id),
337  ntohs (mp->rd.scope),
338  ntohl (mp->rd.ip4_table_id),
339  ntohl (mp->rd.ip6_table_id),
340  ntohl (mp->rd.ip4_uu_sw_if_index),
341  ntohl (mp->rd.ip6_uu_sw_if_index));
342 
343  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
344 }
345 
346 static void
348 {
349  vl_api_gbp_route_domain_del_reply_t *rmp;
350  int rv = 0;
351 
352  rv = gbp_route_domain_delete (ntohl (mp->rd_id));
353 
354  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
355 }
356 
357 static int
358 gub_subnet_type_from_api (vl_api_gbp_subnet_type_t a, gbp_subnet_type_t * t)
359 {
360  a = clib_net_to_host_u32 (a);
361 
362  switch (a)
363  {
366  return (0);
368  *t = GBP_SUBNET_L3_OUT;
369  return (0);
372  return (0);
375  return (0);
378  return (0);
379  }
380 
381  return (-1);
382 }
383 
384 static void
386 {
387  vl_api_gbp_subnet_add_del_reply_t *rmp;
389  fib_prefix_t pfx;
390  int rv = 0;
391 
392  ip_prefix_decode (&mp->subnet.prefix, &pfx);
393 
394  rv = gub_subnet_type_from_api (mp->subnet.type, &type);
395 
396  if (0 != rv)
397  goto out;
398 
399  if (mp->is_add)
400  rv = gbp_subnet_add (ntohl (mp->subnet.rd_id),
401  &pfx, type,
402  ntohl (mp->subnet.sw_if_index),
403  ntohs (mp->subnet.sclass));
404  else
405  rv = gbp_subnet_del (ntohl (mp->subnet.rd_id), &pfx);
406 
407 out:
408  REPLY_MACRO (VL_API_GBP_SUBNET_ADD_DEL_REPLY + GBP_MSG_BASE);
409 }
410 
411 static vl_api_gbp_subnet_type_t
413 {
414  vl_api_gbp_subnet_type_t a = 0;
415 
416  switch (t)
417  {
420  break;
423  break;
426  break;
427  case GBP_SUBNET_L3_OUT:
429  break;
432  break;
433  }
434 
435  a = clib_host_to_net_u32 (a);
436 
437  return (a);
438 }
439 
440 static walk_rc_t
442  const fib_prefix_t * pfx,
444  u32 sw_if_index, sclass_t sclass, void *args)
445 {
448 
449  ctx = args;
450  mp = vl_msg_api_alloc (sizeof (*mp));
451  if (!mp)
452  return 1;
453 
454  clib_memset (mp, 0, sizeof (*mp));
455  mp->_vl_msg_id = ntohs (VL_API_GBP_SUBNET_DETAILS + GBP_MSG_BASE);
456  mp->context = ctx->context;
457 
458  mp->subnet.type = gub_subnet_type_to_api (type);
459  mp->subnet.sw_if_index = ntohl (sw_if_index);
460  mp->subnet.sclass = ntohs (sclass);
461  mp->subnet.rd_id = ntohl (rd_id);
462  ip_prefix_encode (pfx, &mp->subnet.prefix);
463 
464  vl_api_send_msg (ctx->reg, (u8 *) mp);
465 
466  return (WALK_CONTINUE);
467 }
468 
469 static void
471 {
473 
475  if (!reg)
476  return;
477 
478  gbp_walk_ctx_t ctx = {
479  .reg = reg,
480  .context = mp->context,
481  };
482 
484 }
485 
486 static int
488 {
491 
492  ctx = args;
493  mp = vl_msg_api_alloc (sizeof (*mp));
494  if (!mp)
495  return 1;
496 
497  clib_memset (mp, 0, sizeof (*mp));
498  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_GROUP_DETAILS + GBP_MSG_BASE);
499  mp->context = ctx->context;
500 
501  mp->epg.uplink_sw_if_index = ntohl (gg->gg_uplink_sw_if_index);
502  mp->epg.vnid = ntohl (gg->gg_vnid);
503  mp->epg.sclass = ntohs (gg->gg_sclass);
504  mp->epg.bd_id = ntohl (gbp_endpoint_group_get_bd_id (gg));
505  mp->epg.rd_id = ntohl (gbp_route_domain_get_rd_id (gg->gg_rd));
506 
507  vl_api_send_msg (ctx->reg, (u8 *) mp);
508 
509  return (1);
510 }
511 
512 static void
514  mp)
515 {
517 
519  if (!reg)
520  return;
521 
522  gbp_walk_ctx_t ctx = {
523  .reg = reg,
524  .context = mp->context,
525  };
526 
528 }
529 
530 static int
532 {
534  gbp_route_domain_t *gr;
536 
537  ctx = args;
538  mp = vl_msg_api_alloc (sizeof (*mp));
539  if (!mp)
540  return 1;
541 
542  memset (mp, 0, sizeof (*mp));
543  mp->_vl_msg_id = ntohs (VL_API_GBP_BRIDGE_DOMAIN_DETAILS + GBP_MSG_BASE);
544  mp->context = ctx->context;
545 
546  gr = gbp_route_domain_get (gb->gb_rdi);
547 
548  mp->bd.bd_id = ntohl (gb->gb_bd_id);
549  mp->bd.rd_id = ntohl (gr->grd_id);
550  mp->bd.bvi_sw_if_index = ntohl (gb->gb_bvi_sw_if_index);
551  mp->bd.uu_fwd_sw_if_index = ntohl (gb->gb_uu_fwd_sw_if_index);
552  mp->bd.bm_flood_sw_if_index =
554 
555  vl_api_send_msg (ctx->reg, (u8 *) mp);
556 
557  return (1);
558 }
559 
560 static void
562 {
564 
566  if (!reg)
567  return;
568 
569  gbp_walk_ctx_t ctx = {
570  .reg = reg,
571  .context = mp->context,
572  };
573 
575 }
576 
577 static int
579 {
582 
583  ctx = args;
584  mp = vl_msg_api_alloc (sizeof (*mp));
585  if (!mp)
586  return 1;
587 
588  memset (mp, 0, sizeof (*mp));
589  mp->_vl_msg_id = ntohs (VL_API_GBP_ROUTE_DOMAIN_DETAILS + GBP_MSG_BASE);
590  mp->context = ctx->context;
591 
592  mp->rd.rd_id = ntohl (grd->grd_id);
593  mp->rd.ip4_uu_sw_if_index =
594  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP4]);
595  mp->rd.ip6_uu_sw_if_index =
596  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP6]);
597 
598  vl_api_send_msg (ctx->reg, (u8 *) mp);
599 
600  return (1);
601 }
602 
603 static void
605 {
607 
609  if (!reg)
610  return;
611 
612  gbp_walk_ctx_t ctx = {
613  .reg = reg,
614  .context = mp->context,
615  };
616 
618 }
619 
620 static void
622 {
623  vl_api_gbp_recirc_add_del_reply_t *rmp;
625  int rv = 0;
626 
627  sw_if_index = ntohl (mp->recirc.sw_if_index);
628  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
629  goto bad_sw_if_index;
630 
631  if (mp->is_add)
632  rv = gbp_recirc_add (sw_if_index,
633  ntohs (mp->recirc.sclass), mp->recirc.is_ext);
634  else
635  rv = gbp_recirc_delete (sw_if_index);
636 
638 
639  REPLY_MACRO (VL_API_GBP_RECIRC_ADD_DEL_REPLY + GBP_MSG_BASE);
640 }
641 
642 static walk_rc_t
644 {
647 
648  ctx = args;
649  mp = vl_msg_api_alloc (sizeof (*mp));
650  if (!mp)
651  return (WALK_STOP);
652 
653  clib_memset (mp, 0, sizeof (*mp));
654  mp->_vl_msg_id = ntohs (VL_API_GBP_RECIRC_DETAILS + GBP_MSG_BASE);
655  mp->context = ctx->context;
656 
657  mp->recirc.sclass = ntohs (gr->gr_sclass);
658  mp->recirc.sw_if_index = ntohl (gr->gr_sw_if_index);
659  mp->recirc.is_ext = gr->gr_is_ext;
660 
661  vl_api_send_msg (ctx->reg, (u8 *) mp);
662 
663  return (WALK_CONTINUE);
664 }
665 
666 static void
668 {
670 
672  if (!reg)
673  return;
674 
675  gbp_walk_ctx_t ctx = {
676  .reg = reg,
677  .context = mp->context,
678  };
679 
681 }
682 
683 static void
685 {
686  vl_api_gbp_ext_itf_add_del_reply_t *rmp;
687  u32 sw_if_index = ~0;
688  vl_api_gbp_ext_itf_t *ext_itf;
689  int rv = 0;
690 
691  ext_itf = &mp->ext_itf;
692  if (ext_itf)
693  sw_if_index = ntohl (ext_itf->sw_if_index);
694 
695  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
696  goto bad_sw_if_index;
697 
698  if (mp->is_add)
699  rv = gbp_ext_itf_add (sw_if_index,
700  ntohl (ext_itf->bd_id), ntohl (ext_itf->rd_id),
701  ntohl (ext_itf->flags));
702  else
703  rv = gbp_ext_itf_delete (sw_if_index);
704 
706 
707  REPLY_MACRO (VL_API_GBP_EXT_ITF_ADD_DEL_REPLY + GBP_MSG_BASE);
708 }
709 
710 static walk_rc_t
712 {
715 
716  ctx = args;
717  mp = vl_msg_api_alloc (sizeof (*mp));
718  if (!mp)
719  return (WALK_STOP);
720 
721  clib_memset (mp, 0, sizeof (*mp));
722  mp->_vl_msg_id = ntohs (VL_API_GBP_EXT_ITF_DETAILS + GBP_MSG_BASE);
723  mp->context = ctx->context;
724 
725  mp->ext_itf.flags = ntohl (gx->gx_flags);
726  mp->ext_itf.bd_id = ntohl (gbp_bridge_domain_get_bd_id (gx->gx_bd));
727  mp->ext_itf.rd_id = ntohl (gbp_route_domain_get_rd_id (gx->gx_rd));
728  mp->ext_itf.sw_if_index = ntohl (gbp_itf_get_sw_if_index (gx->gx_itf));
729 
730  vl_api_send_msg (ctx->reg, (u8 *) mp);
731 
732  return (WALK_CONTINUE);
733 }
734 
735 static void
737 {
739 
741  if (!reg)
742  return;
743 
744  gbp_walk_ctx_t ctx = {
745  .reg = reg,
746  .context = mp->context,
747  };
748 
750 }
751 
752 static int
753 gbp_contract_rule_action_deocde (vl_api_gbp_rule_action_t in,
754  gbp_rule_action_t * out)
755 {
756  in = clib_net_to_host_u32 (in);
757 
758  switch (in)
759  {
760  case GBP_API_RULE_PERMIT:
761  *out = GBP_RULE_PERMIT;
762  return (0);
763  case GBP_API_RULE_DENY:
764  *out = GBP_RULE_DENY;
765  return (0);
767  *out = GBP_RULE_REDIRECT;
768  return (0);
769  }
770 
771  return (-1);
772 }
773 
774 static int
775 gbp_hash_mode_decode (vl_api_gbp_hash_mode_t in, gbp_hash_mode_t * out)
776 {
777  in = clib_net_to_host_u32 (in);
778 
779  switch (in)
780  {
782  *out = GBP_HASH_MODE_SRC_IP;
783  return (0);
785  *out = GBP_HASH_MODE_DST_IP;
786  return (0);
788  *out = GBP_HASH_MODE_SYMMETRIC;
789  return (0);
790  }
791 
792  return (-2);
793 }
794 
795 static int
796 gbp_next_hop_decode (const vl_api_gbp_next_hop_t * in, index_t * gnhi)
797 {
798  ip46_address_t ip;
800  index_t grd, gbd;
801 
802  gbd = gbp_bridge_domain_find_and_lock (ntohl (in->bd_id));
803 
804  if (INDEX_INVALID == gbd)
805  return (VNET_API_ERROR_BD_NOT_MODIFIABLE);
806 
807  grd = gbp_route_domain_find_and_lock (ntohl (in->rd_id));
808 
809  if (INDEX_INVALID == grd)
810  return (VNET_API_ERROR_NO_SUCH_FIB);
811 
812  ip_address_decode (&in->ip, &ip);
813  mac_address_decode (in->mac, &mac);
814 
815  *gnhi = gbp_next_hop_alloc (&ip, grd, &mac, gbd);
816 
817  return (0);
818 }
819 
820 static int
821 gbp_next_hop_set_decode (const vl_api_gbp_next_hop_set_t * in,
822  gbp_hash_mode_t * hash_mode, index_t ** out)
823 {
824 
825  index_t *gnhis = NULL;
826  int rv;
827  u8 ii;
828 
829  rv = gbp_hash_mode_decode (in->hash_mode, hash_mode);
830 
831  if (0 != rv)
832  return rv;
833 
834  vec_validate (gnhis, in->n_nhs - 1);
835 
836  for (ii = 0; ii < in->n_nhs; ii++)
837  {
838  rv = gbp_next_hop_decode (&in->nhs[ii], &gnhis[ii]);
839 
840  if (0 != rv)
841  {
842  vec_free (gnhis);
843  break;
844  }
845  }
846 
847  *out = gnhis;
848  return (rv);
849 }
850 
851 static int
852 gbp_contract_rule_decode (const vl_api_gbp_rule_t * in, index_t * gui)
853 {
854  gbp_hash_mode_t hash_mode;
856  index_t *nhs = NULL;
857  int rv;
858 
859  rv = gbp_contract_rule_action_deocde (in->action, &action);
860 
861  if (0 != rv)
862  return rv;
863 
864  if (GBP_RULE_REDIRECT == action)
865  {
866  rv = gbp_next_hop_set_decode (&in->nh_set, &hash_mode, &nhs);
867 
868  if (0 != rv)
869  return (rv);
870  }
871  else
872  {
873  hash_mode = GBP_HASH_MODE_SRC_IP;
874  }
875 
876  *gui = gbp_rule_alloc (action, hash_mode, nhs);
877 
878  return (rv);
879 }
880 
881 static int
883  const vl_api_gbp_rule_t * rules, index_t ** out)
884 {
885  index_t *guis = NULL;
886  int rv;
887  u8 ii;
888 
889  if (0 == n_rules)
890  {
891  *out = NULL;
892  return (0);
893  }
894 
895  vec_validate (guis, n_rules - 1);
896 
897  for (ii = 0; ii < n_rules; ii++)
898  {
899  rv = gbp_contract_rule_decode (&rules[ii], &guis[ii]);
900 
901  if (0 != rv)
902  {
903  index_t *gui;
904  vec_foreach (gui, guis) gbp_rule_free (*gui);
905  vec_free (guis);
906  return (rv);
907  }
908  }
909 
910  *out = guis;
911  return (rv);
912 }
913 
914 static void
916 {
919  u32 stats_index = ~0;
920  index_t *rules;
921  int ii, rv = 0;
922  u8 n_et;
923 
924  if (mp->is_add)
925  {
926  rv = gbp_contract_rules_decode (mp->contract.n_rules,
927  mp->contract.rules, &rules);
928  if (0 != rv)
929  goto out;
930 
931  allowed_ethertypes = NULL;
932 
933  /*
934  * allowed ether types
935  */
936  n_et = mp->contract.n_ether_types;
937  vec_validate (allowed_ethertypes, n_et - 1);
938 
939  for (ii = 0; ii < n_et; ii++)
940  {
941  /* leave the ether types in network order */
942  allowed_ethertypes[ii] = mp->contract.allowed_ethertypes[ii];
943  }
944 
945  rv = gbp_contract_update (ntohs (mp->contract.scope),
946  ntohs (mp->contract.sclass),
947  ntohs (mp->contract.dclass),
948  ntohl (mp->contract.acl_index),
949  rules, allowed_ethertypes, &stats_index);
950  }
951  else
952  rv = gbp_contract_delete (ntohs (mp->contract.scope),
953  ntohs (mp->contract.sclass),
954  ntohs (mp->contract.dclass));
955 
956 out:
957  /* *INDENT-OFF* */
958  REPLY_MACRO2 (VL_API_GBP_CONTRACT_ADD_DEL_REPLY + GBP_MSG_BASE,
959  ({
960  rmp->stats_index = htonl (stats_index);
961  }));
962  /* *INDENT-ON* */
963 }
964 
965 static int
967 {
970 
971  ctx = args;
972  mp = vl_msg_api_alloc (sizeof (*mp));
973  if (!mp)
974  return 1;
975 
976  clib_memset (mp, 0, sizeof (*mp));
977  mp->_vl_msg_id = ntohs (VL_API_GBP_CONTRACT_DETAILS + GBP_MSG_BASE);
978  mp->context = ctx->context;
979 
980  mp->contract.sclass = ntohs (gbpc->gc_key.gck_src);
981  mp->contract.dclass = ntohs (gbpc->gc_key.gck_dst);
982  mp->contract.acl_index = ntohl (gbpc->gc_acl_index);
983  mp->contract.scope = ntohs (gbpc->gc_key.gck_scope);
984 
985  vl_api_send_msg (ctx->reg, (u8 *) mp);
986 
987  return (1);
988 }
989 
990 static void
992 {
994 
996  if (!reg)
997  return;
998 
999  gbp_walk_ctx_t ctx = {
1000  .reg = reg,
1001  .context = mp->context,
1002  };
1003 
1005 }
1006 
1007 static int
1008 gbp_vxlan_tunnel_mode_2_layer (vl_api_gbp_vxlan_tunnel_mode_t mode,
1010 {
1011  mode = clib_net_to_host_u32 (mode);
1012 
1013  switch (mode)
1014  {
1016  *l = GBP_VXLAN_TUN_L2;
1017  return (0);
1019  *l = GBP_VXLAN_TUN_L3;
1020  return (0);
1021  }
1022  return (-1);
1023 }
1024 
1025 static void
1027 {
1031  u32 sw_if_index;
1032  int rv = 0;
1033 
1034  ip4_address_decode (mp->tunnel.src, &src);
1035  rv = gbp_vxlan_tunnel_mode_2_layer (mp->tunnel.mode, &layer);
1036 
1037  if (0 != rv)
1038  goto out;
1039 
1040  rv = gbp_vxlan_tunnel_add (ntohl (mp->tunnel.vni),
1041  layer,
1042  ntohl (mp->tunnel.bd_rd_id), &src, &sw_if_index);
1043 
1044 out:
1045  /* *INDENT-OFF* */
1046  REPLY_MACRO2 (VL_API_GBP_VXLAN_TUNNEL_ADD_REPLY + GBP_MSG_BASE,
1047  ({
1048  rmp->sw_if_index = htonl (sw_if_index);
1049  }));
1050  /* *INDENT-ON* */
1051 }
1052 
1053 static void
1055 {
1056  vl_api_gbp_vxlan_tunnel_del_reply_t *rmp;
1057  int rv = 0;
1058 
1059  rv = gbp_vxlan_tunnel_del (ntohl (mp->tunnel.vni));
1060 
1061  REPLY_MACRO (VL_API_GBP_VXLAN_TUNNEL_DEL_REPLY + GBP_MSG_BASE);
1062 }
1063 
1064 static vl_api_gbp_vxlan_tunnel_mode_t
1066 {
1067  vl_api_gbp_vxlan_tunnel_mode_t mode = GBP_VXLAN_TUNNEL_MODE_L2;
1068 
1069  switch (layer)
1070  {
1071  case GBP_VXLAN_TUN_L2:
1072  mode = GBP_VXLAN_TUNNEL_MODE_L2;
1073  break;
1074  case GBP_VXLAN_TUN_L3:
1075  mode = GBP_VXLAN_TUNNEL_MODE_L3;
1076  break;
1077  }
1078  mode = clib_host_to_net_u32 (mode);
1079 
1080  return (mode);
1081 }
1082 
1083 static walk_rc_t
1085 {
1088 
1089  ctx = args;
1090  mp = vl_msg_api_alloc (sizeof (*mp));
1091  if (!mp)
1092  return 1;
1093 
1094  memset (mp, 0, sizeof (*mp));
1095  mp->_vl_msg_id = htons (VL_API_GBP_VXLAN_TUNNEL_DETAILS + GBP_MSG_BASE);
1096  mp->context = ctx->context;
1097 
1098  mp->tunnel.vni = htonl (gt->gt_vni);
1100  mp->tunnel.bd_rd_id = htonl (gt->gt_bd_rd_id);
1101 
1102  vl_api_send_msg (ctx->reg, (u8 *) mp);
1103 
1104  return (1);
1105 }
1106 
1107 static void
1109 {
1111 
1113  if (!reg)
1114  return;
1115 
1116  gbp_walk_ctx_t ctx = {
1117  .reg = reg,
1118  .context = mp->context,
1119  };
1120 
1122 }
1123 
1124 #include <gbp/gbp.api.c>
1125 static clib_error_t *
1127 {
1128  gbp_main_t *gbpm = &gbp_main;
1129 
1130  gbpm->gbp_acl_user_id = ~0;
1131 
1132  /* Ask for a correctly-sized block of API message decode slots */
1133  msg_id_base = setup_message_id_table ();
1134 
1135  return (NULL);
1136 }
1137 
1139 
1140 /* *INDENT-OFF* */
1141 VLIB_PLUGIN_REGISTER () = {
1142  .version = VPP_BUILD_VER,
1143  .description = "Group Based Policy (GBP)",
1144 };
1145 /* *INDENT-ON* */
1146 
1147 
1148 /*
1149  * fd.io coding-style-patch-verification: ON
1150  *
1151  * Local Variables:
1152  * eval: (c-set-style "gnu")
1153  * End:
1154  */
#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:1108
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:89
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:966
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:882
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:92
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:53
static gbp_bridge_domain_flags_t gbp_bridge_domain_flags_from_api(vl_api_gbp_bridge_domain_flags_t a)
Definition: gbp_api.c:283
gbp_main_t gbp_main
Definition: gbp_api.c:46
vl_api_gbp_subnet_t subnet
Definition: gbp.api:291
a
Definition: bitmap.h:544
void gbp_endpoint_unlock(gbp_endpoint_src_t src, index_t gei)
Definition: gbp_endpoint.c:916
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:259
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:334
static void vl_api_gbp_recirc_dump_t_handler(vl_api_gbp_recirc_dump_t *mp)
Definition: gbp_api.c:667
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:244
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:1054
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:1580
index_t gg_rd
route-domain/IP-table ID the EPG is in
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:487
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:915
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:48
static void vl_api_gbp_bridge_domain_add_t_handler(vl_api_gbp_bridge_domain_add_t *mp)
Definition: gbp_api.c:303
u32 gbp_itf_get_sw_if_index(gbp_itf_hdl_t hdl)
Definition: gbp_itf.c:150
static int gbp_contract_rule_action_deocde(vl_api_gbp_rule_action_t in, gbp_rule_action_t *out)
Definition: gbp_api.c:753
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:1026
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:578
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:412
void gbp_route_domain_walk(gbp_route_domain_cb_t cb, void *ctx)
Aggregate type for a prefix.
Definition: fib_types.h:202
static void vl_api_gbp_route_domain_del_t_handler(vl_api_gbp_route_domain_del_t *mp)
Definition: gbp_api.c:347
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:72
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:186
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:169
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:225
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:441
static void vl_api_gbp_endpoint_group_add_t_handler(vl_api_gbp_endpoint_group_add_t *mp)
Definition: gbp_api.c:252
static void vl_api_gbp_contract_dump_t_handler(vl_api_gbp_contract_dump_t *mp)
Definition: gbp_api.c:991
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:1065
#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:820
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:621
An API client registration, only in vpp/vlib.
Definition: api_common.h:47
static void setup_message_id_table(api_main_t *am)
Definition: bfd_api.c:409
#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:561
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:684
static walk_rc_t gbp_vxlan_tunnel_send_details(gbp_vxlan_tunnel_t *gt, void *args)
Definition: gbp_api.c:1084
static void vl_api_gbp_subnet_add_del_t_handler(vl_api_gbp_subnet_add_del_t *mp)
Definition: gbp_api.c:385
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:604
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:227
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:513
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:1126
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:736
static void vl_api_gbp_subnet_dump_t_handler(vl_api_gbp_subnet_dump_t *mp)
Definition: gbp_api.c:470
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:287
static void vl_api_gbp_endpoint_del_t_handler(vl_api_gbp_endpoint_del_t *mp)
Definition: gbp_api.c:152
static void vl_api_gbp_route_domain_add_t_handler(vl_api_gbp_route_domain_add_t *mp)
Definition: gbp_api.c:331
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:821
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:643
#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:796
#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
struct gbp_endpoint_loc_t_::@643 tun
Tunnel info for remote endpoints.
void ip4_address_decode(const vl_api_ip4_address_t in, ip4_address_t *out)
Definition: ip_types_api.c:155
vl_api_registration_t * reg
Definition: gbp_api.c:164
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:531
static walk_rc_t gbp_ext_itf_send_details(gbp_ext_itf_t *gx, void *args)
Definition: gbp_api.c:711
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:220
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 vl_api_gbp_bridge_domain_del_t_handler(vl_api_gbp_bridge_domain_del_t *mp)
Definition: gbp_api.c:320
#define GBP_MSG_BASE
Definition: gbp_api.c:50
static void vl_api_gbp_endpoint_group_del_t_handler(vl_api_gbp_endpoint_group_del_t *mp)
Definition: gbp_api.c:272
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:160
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:852
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:775
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:1008
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:34
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:358