FD.io VPP  v19.08.2-294-g37e99c22d
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_msg_enum.h>
41 
42 #define vl_typedefs /* define message structures */
43 #include <gbp/gbp_all_api_h.h>
44 #undef vl_typedefs
45 
46 #define vl_endianfun /* define message structures */
47 #include <gbp/gbp_all_api_h.h>
48 #undef vl_endianfun
49 
50 /* instantiate all the print functions we know about */
51 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
52 #define vl_printfun
53 #include <gbp/gbp_all_api_h.h>
54 #undef vl_printfun
55 
56 /* Get the API version number */
57 #define vl_api_version(n,v) static u32 api_version=(v);
58 #include <gbp/gbp_all_api_h.h>
59 #undef vl_api_version
60 
62 
63 #define foreach_gbp_api_msg \
64  _(GBP_ENDPOINT_ADD, gbp_endpoint_add) \
65  _(GBP_ENDPOINT_DEL, gbp_endpoint_del) \
66  _(GBP_ENDPOINT_DUMP, gbp_endpoint_dump) \
67  _(GBP_SUBNET_ADD_DEL, gbp_subnet_add_del) \
68  _(GBP_SUBNET_DUMP, gbp_subnet_dump) \
69  _(GBP_ENDPOINT_GROUP_ADD, gbp_endpoint_group_add) \
70  _(GBP_ENDPOINT_GROUP_DEL, gbp_endpoint_group_del) \
71  _(GBP_ENDPOINT_GROUP_DUMP, gbp_endpoint_group_dump) \
72  _(GBP_BRIDGE_DOMAIN_ADD, gbp_bridge_domain_add) \
73  _(GBP_BRIDGE_DOMAIN_DEL, gbp_bridge_domain_del) \
74  _(GBP_BRIDGE_DOMAIN_DUMP, gbp_bridge_domain_dump) \
75  _(GBP_ROUTE_DOMAIN_ADD, gbp_route_domain_add) \
76  _(GBP_ROUTE_DOMAIN_DEL, gbp_route_domain_del) \
77  _(GBP_ROUTE_DOMAIN_DUMP, gbp_route_domain_dump) \
78  _(GBP_RECIRC_ADD_DEL, gbp_recirc_add_del) \
79  _(GBP_RECIRC_DUMP, gbp_recirc_dump) \
80  _(GBP_EXT_ITF_ADD_DEL, gbp_ext_itf_add_del) \
81  _(GBP_EXT_ITF_DUMP, gbp_ext_itf_dump) \
82  _(GBP_CONTRACT_ADD_DEL, gbp_contract_add_del) \
83  _(GBP_CONTRACT_DUMP, gbp_contract_dump) \
84  _(GBP_VXLAN_TUNNEL_ADD, gbp_vxlan_tunnel_add) \
85  _(GBP_VXLAN_TUNNEL_DEL, gbp_vxlan_tunnel_del) \
86  _(GBP_VXLAN_TUNNEL_DUMP, gbp_vxlan_tunnel_dump)
87 
89 
91 
92 #define GBP_MSG_BASE msg_id_base
93 
95 gbp_endpoint_flags_decode (vl_api_gbp_endpoint_flags_t v)
96 {
98 
99  v = ntohl (v);
100 
109 
110  return (f);
111 }
112 
113 static vl_api_gbp_endpoint_flags_t
115 {
116  vl_api_gbp_endpoint_flags_t v = 0;
117 
118 
119  if (f & GBP_ENDPOINT_FLAG_BOUNCE)
121  if (f & GBP_ENDPOINT_FLAG_REMOTE)
123  if (f & GBP_ENDPOINT_FLAG_LEARNT)
127 
128  v = htonl (v);
129 
130  return (v);
131 }
132 
133 static void
135 {
138  u32 sw_if_index, handle;
139  ip46_address_t *ips;
141  int rv = 0, ii;
142 
143  handle = INDEX_INVALID;
144 
146 
147  gef = gbp_endpoint_flags_decode (mp->endpoint.flags), ips = NULL;
148  sw_if_index = ntohl (mp->endpoint.sw_if_index);
149 
150  if (mp->endpoint.n_ips)
151  {
152  vec_validate (ips, mp->endpoint.n_ips - 1);
153 
154  vec_foreach_index (ii, ips)
155  {
156  ip_address_decode (&mp->endpoint.ips[ii], &ips[ii]);
157  }
158  }
159  mac_address_decode (mp->endpoint.mac, &mac);
160 
161  if (GBP_ENDPOINT_FLAG_REMOTE & gef)
162  {
163  ip46_address_t tun_src, tun_dst;
164 
165  ip_address_decode (&mp->endpoint.tun.src, &tun_src);
166  ip_address_decode (&mp->endpoint.tun.dst, &tun_dst);
167 
168  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
169  sw_if_index, ips, &mac,
171  ntohs (mp->endpoint.sclass),
172  gef, &tun_src, &tun_dst, &handle);
173  }
174  else
175  {
176  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
177  sw_if_index, ips, &mac,
179  ntohs (mp->endpoint.sclass),
180  gef, NULL, NULL, &handle);
181  }
182  vec_free (ips);
184 
185  /* *INDENT-OFF* */
186  REPLY_MACRO2 (VL_API_GBP_ENDPOINT_ADD_REPLY + GBP_MSG_BASE,
187  ({
188  rmp->handle = htonl (handle);
189  }));
190  /* *INDENT-ON* */
191 }
192 
193 static void
195 {
196  vl_api_gbp_endpoint_del_reply_t *rmp;
197  int rv = 0;
198 
199  gbp_endpoint_unlock (GBP_ENDPOINT_SRC_CP, ntohl (mp->handle));
200 
201  REPLY_MACRO (VL_API_GBP_ENDPOINT_DEL_REPLY + GBP_MSG_BASE);
202 }
203 
204 typedef struct gbp_walk_ctx_t_
205 {
209 
210 static walk_rc_t
212 {
214  gbp_endpoint_loc_t *gel;
215  gbp_endpoint_fwd_t *gef;
218  u8 n_ips, ii;
219 
220  ctx = args;
221  ge = gbp_endpoint_get (gei);
222 
223  n_ips = vec_len (ge->ge_key.gek_ips);
224  mp = vl_msg_api_alloc (sizeof (*mp) + (sizeof (*mp->endpoint.ips) * n_ips));
225  if (!mp)
226  return 1;
227 
228  clib_memset (mp, 0, sizeof (*mp));
229  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_DETAILS + GBP_MSG_BASE);
230  mp->context = ctx->context;
231 
232  gel = &ge->ge_locs[0];
233  gef = &ge->ge_fwd;
234 
235  if (gbp_endpoint_is_remote (ge))
236  {
237  mp->endpoint.sw_if_index = ntohl (gel->tun.gel_parent_sw_if_index);
239  &mp->endpoint.tun.src);
241  &mp->endpoint.tun.dst);
242  }
243  else
244  {
245  mp->endpoint.sw_if_index =
246  ntohl (gbp_itf_get_sw_if_index (gef->gef_itf));
247  }
248  mp->endpoint.sclass = ntohs (ge->ge_fwd.gef_sclass);
249  mp->endpoint.n_ips = n_ips;
250  mp->endpoint.flags = gbp_endpoint_flags_encode (gef->gef_flags);
251  mp->handle = htonl (gei);
252  mp->age =
254  ge->ge_last_time);
255  mac_address_encode (&ge->ge_key.gek_mac, mp->endpoint.mac);
256 
258  {
260  IP46_TYPE_ANY, &mp->endpoint.ips[ii]);
261  }
262 
263  vl_api_send_msg (ctx->reg, (u8 *) mp);
264 
265  return (WALK_CONTINUE);
266 }
267 
268 static void
270 {
272 
274  if (!reg)
275  return;
276 
277  gbp_walk_ctx_t ctx = {
278  .reg = reg,
279  .context = mp->context,
280  };
281 
283 }
284 
285 static void
286 gbp_retention_decode (const vl_api_gbp_endpoint_retention_t * in,
288 {
289  out->remote_ep_timeout = ntohl (in->remote_ep_timeout);
290 }
291 
292 static void
295 {
296  vl_api_gbp_endpoint_group_add_reply_t *rmp;
297  gbp_endpoint_retention_t retention;
298  int rv = 0;
299 
300  gbp_retention_decode (&mp->epg.retention, &retention);
301 
302  rv = gbp_endpoint_group_add_and_lock (ntohl (mp->epg.vnid),
303  ntohs (mp->epg.sclass),
304  ntohl (mp->epg.bd_id),
305  ntohl (mp->epg.rd_id),
306  ntohl (mp->epg.uplink_sw_if_index),
307  &retention);
308 
309  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_ADD_REPLY + GBP_MSG_BASE);
310 }
311 
312 static void
315 {
316  vl_api_gbp_endpoint_group_del_reply_t *rmp;
317  int rv = 0;
318 
319  rv = gbp_endpoint_group_delete (ntohs (mp->sclass));
320 
321  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_DEL_REPLY + GBP_MSG_BASE);
322 }
323 
325 gbp_bridge_domain_flags_from_api (vl_api_gbp_bridge_domain_flags_t a)
326 {
328 
329  g = GBP_BD_FLAG_NONE;
330  a = clib_net_to_host_u32 (a);
331 
340 
341  return (g);
342 }
343 
344 static void
346 {
347  vl_api_gbp_bridge_domain_add_reply_t *rmp;
348  int rv = 0;
349 
350  rv = gbp_bridge_domain_add_and_lock (ntohl (mp->bd.bd_id),
351  ntohl (mp->bd.rd_id),
353  (mp->bd.flags),
354  ntohl (mp->bd.bvi_sw_if_index),
355  ntohl (mp->bd.uu_fwd_sw_if_index),
356  ntohl (mp->bd.bm_flood_sw_if_index));
357 
358  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
359 }
360 
361 static void
363 {
364  vl_api_gbp_bridge_domain_del_reply_t *rmp;
365  int rv = 0;
366 
367  rv = gbp_bridge_domain_delete (ntohl (mp->bd_id));
368 
369  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
370 }
371 
372 static void
374 {
375  vl_api_gbp_route_domain_add_reply_t *rmp;
376  int rv = 0;
377 
378  rv = gbp_route_domain_add_and_lock (ntohl (mp->rd.rd_id),
379  ntohs (mp->rd.scope),
380  ntohl (mp->rd.ip4_table_id),
381  ntohl (mp->rd.ip6_table_id),
382  ntohl (mp->rd.ip4_uu_sw_if_index),
383  ntohl (mp->rd.ip6_uu_sw_if_index));
384 
385  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
386 }
387 
388 static void
390 {
391  vl_api_gbp_route_domain_del_reply_t *rmp;
392  int rv = 0;
393 
394  rv = gbp_route_domain_delete (ntohl (mp->rd_id));
395 
396  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
397 }
398 
399 static int
400 gub_subnet_type_from_api (vl_api_gbp_subnet_type_t a, gbp_subnet_type_t * t)
401 {
402  a = clib_net_to_host_u32 (a);
403 
404  switch (a)
405  {
408  return (0);
410  *t = GBP_SUBNET_L3_OUT;
411  return (0);
414  return (0);
417  return (0);
420  return (0);
421  }
422 
423  return (-1);
424 }
425 
426 static void
428 {
429  vl_api_gbp_subnet_add_del_reply_t *rmp;
431  fib_prefix_t pfx;
432  int rv = 0;
433 
434  ip_prefix_decode (&mp->subnet.prefix, &pfx);
435 
436  rv = gub_subnet_type_from_api (mp->subnet.type, &type);
437 
438  if (0 != rv)
439  goto out;
440 
441  if (mp->is_add)
442  rv = gbp_subnet_add (ntohl (mp->subnet.rd_id),
443  &pfx, type,
444  ntohl (mp->subnet.sw_if_index),
445  ntohs (mp->subnet.sclass));
446  else
447  rv = gbp_subnet_del (ntohl (mp->subnet.rd_id), &pfx);
448 
449 out:
450  REPLY_MACRO (VL_API_GBP_SUBNET_ADD_DEL_REPLY + GBP_MSG_BASE);
451 }
452 
453 static vl_api_gbp_subnet_type_t
455 {
456  vl_api_gbp_subnet_type_t a = 0;
457 
458  switch (t)
459  {
462  break;
465  break;
468  break;
469  case GBP_SUBNET_L3_OUT:
471  break;
474  break;
475  }
476 
477  a = clib_host_to_net_u32 (a);
478 
479  return (a);
480 }
481 
482 static walk_rc_t
484  const fib_prefix_t * pfx,
486  u32 sw_if_index, sclass_t sclass, void *args)
487 {
490 
491  ctx = args;
492  mp = vl_msg_api_alloc (sizeof (*mp));
493  if (!mp)
494  return 1;
495 
496  clib_memset (mp, 0, sizeof (*mp));
497  mp->_vl_msg_id = ntohs (VL_API_GBP_SUBNET_DETAILS + GBP_MSG_BASE);
498  mp->context = ctx->context;
499 
500  mp->subnet.type = gub_subnet_type_to_api (type);
501  mp->subnet.sw_if_index = ntohl (sw_if_index);
502  mp->subnet.sclass = ntohs (sclass);
503  mp->subnet.rd_id = ntohl (rd_id);
504  ip_prefix_encode (pfx, &mp->subnet.prefix);
505 
506  vl_api_send_msg (ctx->reg, (u8 *) mp);
507 
508  return (WALK_CONTINUE);
509 }
510 
511 static void
513 {
515 
517  if (!reg)
518  return;
519 
520  gbp_walk_ctx_t ctx = {
521  .reg = reg,
522  .context = mp->context,
523  };
524 
526 }
527 
528 static int
530 {
533 
534  ctx = args;
535  mp = vl_msg_api_alloc (sizeof (*mp));
536  if (!mp)
537  return 1;
538 
539  clib_memset (mp, 0, sizeof (*mp));
540  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_GROUP_DETAILS + GBP_MSG_BASE);
541  mp->context = ctx->context;
542 
543  mp->epg.uplink_sw_if_index = ntohl (gg->gg_uplink_sw_if_index);
544  mp->epg.vnid = ntohl (gg->gg_vnid);
545  mp->epg.sclass = ntohs (gg->gg_sclass);
546  mp->epg.bd_id = ntohl (gbp_endpoint_group_get_bd_id (gg));
547  mp->epg.rd_id = ntohl (gbp_route_domain_get_rd_id (gg->gg_rd));
548 
549  vl_api_send_msg (ctx->reg, (u8 *) mp);
550 
551  return (1);
552 }
553 
554 static void
556  mp)
557 {
559 
561  if (!reg)
562  return;
563 
564  gbp_walk_ctx_t ctx = {
565  .reg = reg,
566  .context = mp->context,
567  };
568 
570 }
571 
572 static int
574 {
576  gbp_route_domain_t *gr;
578 
579  ctx = args;
580  mp = vl_msg_api_alloc (sizeof (*mp));
581  if (!mp)
582  return 1;
583 
584  memset (mp, 0, sizeof (*mp));
585  mp->_vl_msg_id = ntohs (VL_API_GBP_BRIDGE_DOMAIN_DETAILS + GBP_MSG_BASE);
586  mp->context = ctx->context;
587 
588  gr = gbp_route_domain_get (gb->gb_rdi);
589 
590  mp->bd.bd_id = ntohl (gb->gb_bd_id);
591  mp->bd.rd_id = ntohl (gr->grd_id);
592  mp->bd.bvi_sw_if_index = ntohl (gb->gb_bvi_sw_if_index);
593  mp->bd.uu_fwd_sw_if_index = ntohl (gb->gb_uu_fwd_sw_if_index);
594  mp->bd.bm_flood_sw_if_index =
596 
597  vl_api_send_msg (ctx->reg, (u8 *) mp);
598 
599  return (1);
600 }
601 
602 static void
604 {
606 
608  if (!reg)
609  return;
610 
611  gbp_walk_ctx_t ctx = {
612  .reg = reg,
613  .context = mp->context,
614  };
615 
617 }
618 
619 static int
621 {
624 
625  ctx = args;
626  mp = vl_msg_api_alloc (sizeof (*mp));
627  if (!mp)
628  return 1;
629 
630  memset (mp, 0, sizeof (*mp));
631  mp->_vl_msg_id = ntohs (VL_API_GBP_ROUTE_DOMAIN_DETAILS + GBP_MSG_BASE);
632  mp->context = ctx->context;
633 
634  mp->rd.rd_id = ntohl (grd->grd_id);
635  mp->rd.ip4_uu_sw_if_index =
636  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP4]);
637  mp->rd.ip6_uu_sw_if_index =
638  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP6]);
639 
640  vl_api_send_msg (ctx->reg, (u8 *) mp);
641 
642  return (1);
643 }
644 
645 static void
647 {
649 
651  if (!reg)
652  return;
653 
654  gbp_walk_ctx_t ctx = {
655  .reg = reg,
656  .context = mp->context,
657  };
658 
660 }
661 
662 static void
664 {
665  vl_api_gbp_recirc_add_del_reply_t *rmp;
667  int rv = 0;
668 
669  sw_if_index = ntohl (mp->recirc.sw_if_index);
670  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
671  goto bad_sw_if_index;
672 
673  if (mp->is_add)
674  rv = gbp_recirc_add (sw_if_index,
675  ntohs (mp->recirc.sclass), mp->recirc.is_ext);
676  else
677  rv = gbp_recirc_delete (sw_if_index);
678 
680 
681  REPLY_MACRO (VL_API_GBP_RECIRC_ADD_DEL_REPLY + GBP_MSG_BASE);
682 }
683 
684 static walk_rc_t
686 {
689 
690  ctx = args;
691  mp = vl_msg_api_alloc (sizeof (*mp));
692  if (!mp)
693  return (WALK_STOP);
694 
695  clib_memset (mp, 0, sizeof (*mp));
696  mp->_vl_msg_id = ntohs (VL_API_GBP_RECIRC_DETAILS + GBP_MSG_BASE);
697  mp->context = ctx->context;
698 
699  mp->recirc.sclass = ntohs (gr->gr_sclass);
700  mp->recirc.sw_if_index = ntohl (gr->gr_sw_if_index);
701  mp->recirc.is_ext = gr->gr_is_ext;
702 
703  vl_api_send_msg (ctx->reg, (u8 *) mp);
704 
705  return (WALK_CONTINUE);
706 }
707 
708 static void
710 {
712 
714  if (!reg)
715  return;
716 
717  gbp_walk_ctx_t ctx = {
718  .reg = reg,
719  .context = mp->context,
720  };
721 
723 }
724 
725 static void
727 {
728  vl_api_gbp_ext_itf_add_del_reply_t *rmp;
729  u32 sw_if_index = ~0;
730  vl_api_gbp_ext_itf_t *ext_itf;
731  int rv = 0;
732 
733  ext_itf = &mp->ext_itf;
734  if (ext_itf)
735  sw_if_index = ntohl (ext_itf->sw_if_index);
736 
737  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
738  goto bad_sw_if_index;
739 
740  if (mp->is_add)
741  rv = gbp_ext_itf_add (sw_if_index,
742  ntohl (ext_itf->bd_id), ntohl (ext_itf->rd_id),
743  ntohl (ext_itf->flags));
744  else
745  rv = gbp_ext_itf_delete (sw_if_index);
746 
748 
749  REPLY_MACRO (VL_API_GBP_EXT_ITF_ADD_DEL_REPLY + GBP_MSG_BASE);
750 }
751 
752 static walk_rc_t
754 {
757 
758  ctx = args;
759  mp = vl_msg_api_alloc (sizeof (*mp));
760  if (!mp)
761  return (WALK_STOP);
762 
763  clib_memset (mp, 0, sizeof (*mp));
764  mp->_vl_msg_id = ntohs (VL_API_GBP_EXT_ITF_DETAILS + GBP_MSG_BASE);
765  mp->context = ctx->context;
766 
767  mp->ext_itf.flags = ntohl (gx->gx_flags);
768  mp->ext_itf.bd_id = ntohl (gbp_bridge_domain_get_bd_id (gx->gx_bd));
769  mp->ext_itf.rd_id = ntohl (gbp_route_domain_get_rd_id (gx->gx_rd));
771 
772  vl_api_send_msg (ctx->reg, (u8 *) mp);
773 
774  return (WALK_CONTINUE);
775 }
776 
777 static void
779 {
781 
783  if (!reg)
784  return;
785 
786  gbp_walk_ctx_t ctx = {
787  .reg = reg,
788  .context = mp->context,
789  };
790 
792 }
793 
794 static int
795 gbp_contract_rule_action_deocde (vl_api_gbp_rule_action_t in,
796  gbp_rule_action_t * out)
797 {
798  in = clib_net_to_host_u32 (in);
799 
800  switch (in)
801  {
802  case GBP_API_RULE_PERMIT:
803  *out = GBP_RULE_PERMIT;
804  return (0);
805  case GBP_API_RULE_DENY:
806  *out = GBP_RULE_DENY;
807  return (0);
809  *out = GBP_RULE_REDIRECT;
810  return (0);
811  }
812 
813  return (-1);
814 }
815 
816 static int
817 gbp_hash_mode_decode (vl_api_gbp_hash_mode_t in, gbp_hash_mode_t * out)
818 {
819  in = clib_net_to_host_u32 (in);
820 
821  switch (in)
822  {
824  *out = GBP_HASH_MODE_SRC_IP;
825  return (0);
827  *out = GBP_HASH_MODE_DST_IP;
828  return (0);
830  *out = GBP_HASH_MODE_SYMMETRIC;
831  return (0);
832  }
833 
834  return (-2);
835 }
836 
837 static int
838 gbp_next_hop_decode (const vl_api_gbp_next_hop_t * in, index_t * gnhi)
839 {
840  ip46_address_t ip;
842  index_t grd, gbd;
843 
844  gbd = gbp_bridge_domain_find_and_lock (ntohl (in->bd_id));
845 
846  if (INDEX_INVALID == gbd)
847  return (VNET_API_ERROR_BD_NOT_MODIFIABLE);
848 
849  grd = gbp_route_domain_find_and_lock (ntohl (in->rd_id));
850 
851  if (INDEX_INVALID == grd)
852  return (VNET_API_ERROR_NO_SUCH_FIB);
853 
854  ip_address_decode (&in->ip, &ip);
855  mac_address_decode (in->mac, &mac);
856 
857  *gnhi = gbp_next_hop_alloc (&ip, grd, &mac, gbd);
858 
859  return (0);
860 }
861 
862 static int
863 gbp_next_hop_set_decode (const vl_api_gbp_next_hop_set_t * in,
864  gbp_hash_mode_t * hash_mode, index_t ** out)
865 {
866 
867  index_t *gnhis = NULL;
868  int rv;
869  u8 ii;
870 
871  rv = gbp_hash_mode_decode (in->hash_mode, hash_mode);
872 
873  if (0 != rv)
874  return rv;
875 
876  vec_validate (gnhis, in->n_nhs - 1);
877 
878  for (ii = 0; ii < in->n_nhs; ii++)
879  {
880  rv = gbp_next_hop_decode (&in->nhs[ii], &gnhis[ii]);
881 
882  if (0 != rv)
883  {
884  vec_free (gnhis);
885  break;
886  }
887  }
888 
889  *out = gnhis;
890  return (rv);
891 }
892 
893 static int
894 gbp_contract_rule_decode (const vl_api_gbp_rule_t * in, index_t * gui)
895 {
896  gbp_hash_mode_t hash_mode;
897  gbp_rule_action_t action;
898  index_t *nhs = NULL;
899  int rv;
900 
901  rv = gbp_contract_rule_action_deocde (in->action, &action);
902 
903  if (0 != rv)
904  return rv;
905 
906  if (GBP_RULE_REDIRECT == action)
907  {
908  rv = gbp_next_hop_set_decode (&in->nh_set, &hash_mode, &nhs);
909 
910  if (0 != rv)
911  return (rv);
912  }
913  else
914  {
915  hash_mode = GBP_HASH_MODE_SRC_IP;
916  }
917 
918  *gui = gbp_rule_alloc (action, hash_mode, nhs);
919 
920  return (rv);
921 }
922 
923 static int
925  const vl_api_gbp_rule_t * rules, index_t ** out)
926 {
927  index_t *guis = NULL;
928  int rv;
929  u8 ii;
930 
931  if (0 == n_rules)
932  {
933  *out = NULL;
934  return (0);
935  }
936 
937  vec_validate (guis, n_rules - 1);
938 
939  for (ii = 0; ii < n_rules; ii++)
940  {
941  rv = gbp_contract_rule_decode (&rules[ii], &guis[ii]);
942 
943  if (0 != rv)
944  {
945  index_t *gui;
946  vec_foreach (gui, guis) gbp_rule_free (*gui);
947  vec_free (guis);
948  return (rv);
949  }
950  }
951 
952  *out = guis;
953  return (rv);
954 }
955 
956 static void
958 {
961  u32 stats_index = ~0;
962  index_t *rules;
963  int ii, rv = 0;
964  u8 n_et;
965 
966  if (mp->is_add)
967  {
968  rv = gbp_contract_rules_decode (mp->contract.n_rules,
969  mp->contract.rules, &rules);
970  if (0 != rv)
971  goto out;
972 
973  allowed_ethertypes = NULL;
974 
975  /*
976  * allowed ether types
977  */
978  n_et = mp->contract.n_ether_types;
979  vec_validate (allowed_ethertypes, n_et - 1);
980 
981  for (ii = 0; ii < n_et; ii++)
982  {
983  /* leave the ether types in network order */
984  allowed_ethertypes[ii] = mp->contract.allowed_ethertypes[ii];
985  }
986 
987  rv = gbp_contract_update (ntohs (mp->contract.scope),
988  ntohs (mp->contract.sclass),
989  ntohs (mp->contract.dclass),
990  ntohl (mp->contract.acl_index),
991  rules, allowed_ethertypes, &stats_index);
992  }
993  else
994  rv = gbp_contract_delete (ntohs (mp->contract.scope),
995  ntohs (mp->contract.sclass),
996  ntohs (mp->contract.dclass));
997 
998 out:
999  /* *INDENT-OFF* */
1000  REPLY_MACRO2 (VL_API_GBP_CONTRACT_ADD_DEL_REPLY + GBP_MSG_BASE,
1001  ({
1002  rmp->stats_index = htonl (stats_index);
1003  }));
1004  /* *INDENT-ON* */
1005 }
1006 
1007 static int
1009 {
1012 
1013  ctx = args;
1014  mp = vl_msg_api_alloc (sizeof (*mp));
1015  if (!mp)
1016  return 1;
1017 
1018  clib_memset (mp, 0, sizeof (*mp));
1019  mp->_vl_msg_id = ntohs (VL_API_GBP_CONTRACT_DETAILS + GBP_MSG_BASE);
1020  mp->context = ctx->context;
1021 
1022  mp->contract.sclass = ntohs (gbpc->gc_key.gck_src);
1023  mp->contract.dclass = ntohs (gbpc->gc_key.gck_dst);
1024  mp->contract.acl_index = ntohl (gbpc->gc_acl_index);
1025  mp->contract.scope = ntohs (gbpc->gc_key.gck_scope);
1026 
1027  vl_api_send_msg (ctx->reg, (u8 *) mp);
1028 
1029  return (1);
1030 }
1031 
1032 static void
1034 {
1036 
1038  if (!reg)
1039  return;
1040 
1041  gbp_walk_ctx_t ctx = {
1042  .reg = reg,
1043  .context = mp->context,
1044  };
1045 
1047 }
1048 
1049 static int
1050 gbp_vxlan_tunnel_mode_2_layer (vl_api_gbp_vxlan_tunnel_mode_t mode,
1052 {
1053  mode = clib_net_to_host_u32 (mode);
1054 
1055  switch (mode)
1056  {
1058  *l = GBP_VXLAN_TUN_L2;
1059  return (0);
1061  *l = GBP_VXLAN_TUN_L3;
1062  return (0);
1063  }
1064  return (-1);
1065 }
1066 
1067 static void
1069 {
1073  u32 sw_if_index;
1074  int rv = 0;
1075 
1076  ip4_address_decode (mp->tunnel.src, &src);
1077  rv = gbp_vxlan_tunnel_mode_2_layer (mp->tunnel.mode, &layer);
1078 
1079  if (0 != rv)
1080  goto out;
1081 
1082  rv = gbp_vxlan_tunnel_add (ntohl (mp->tunnel.vni),
1083  layer,
1084  ntohl (mp->tunnel.bd_rd_id), &src, &sw_if_index);
1085 
1086 out:
1087  /* *INDENT-OFF* */
1088  REPLY_MACRO2 (VL_API_GBP_VXLAN_TUNNEL_ADD_REPLY + GBP_MSG_BASE,
1089  ({
1090  rmp->sw_if_index = htonl (sw_if_index);
1091  }));
1092  /* *INDENT-ON* */
1093 }
1094 
1095 static void
1097 {
1098  vl_api_gbp_vxlan_tunnel_del_reply_t *rmp;
1099  int rv = 0;
1100 
1101  rv = gbp_vxlan_tunnel_del (ntohl (mp->tunnel.vni));
1102 
1103  REPLY_MACRO (VL_API_GBP_VXLAN_TUNNEL_DEL_REPLY + GBP_MSG_BASE);
1104 }
1105 
1106 static vl_api_gbp_vxlan_tunnel_mode_t
1108 {
1109  vl_api_gbp_vxlan_tunnel_mode_t mode = GBP_VXLAN_TUNNEL_MODE_L2;
1110 
1111  switch (layer)
1112  {
1113  case GBP_VXLAN_TUN_L2:
1114  mode = GBP_VXLAN_TUNNEL_MODE_L2;
1115  break;
1116  case GBP_VXLAN_TUN_L3:
1117  mode = GBP_VXLAN_TUNNEL_MODE_L3;
1118  break;
1119  }
1120  mode = clib_host_to_net_u32 (mode);
1121 
1122  return (mode);
1123 }
1124 
1125 static walk_rc_t
1127 {
1130 
1131  ctx = args;
1132  mp = vl_msg_api_alloc (sizeof (*mp));
1133  if (!mp)
1134  return 1;
1135 
1136  memset (mp, 0, sizeof (*mp));
1137  mp->_vl_msg_id = htons (VL_API_GBP_VXLAN_TUNNEL_DETAILS + GBP_MSG_BASE);
1138  mp->context = ctx->context;
1139 
1140  mp->tunnel.vni = htonl (gt->gt_vni);
1142  mp->tunnel.bd_rd_id = htonl (gt->gt_bd_rd_id);
1143 
1144  vl_api_send_msg (ctx->reg, (u8 *) mp);
1145 
1146  return (1);
1147 }
1148 
1149 static void
1151 {
1153 
1155  if (!reg)
1156  return;
1157 
1158  gbp_walk_ctx_t ctx = {
1159  .reg = reg,
1160  .context = mp->context,
1161  };
1162 
1164 }
1165 
1166 /*
1167  * gbp_api_hookup
1168  * Add vpe's API message handlers to the table.
1169  * vlib has already mapped shared memory and
1170  * added the client registration handlers.
1171  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1172  */
1173 #define vl_msg_name_crc_list
1174 #include <gbp/gbp_all_api_h.h>
1175 #undef vl_msg_name_crc_list
1176 
1177 static void
1179 {
1180 #define _(id,n,crc) \
1181  vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + GBP_MSG_BASE);
1182  foreach_vl_msg_name_crc_gbp;
1183 #undef _
1184 }
1185 
1186 static void
1188 {
1189 #define _(N,n) \
1190  vl_msg_api_set_handlers(VL_API_##N + GBP_MSG_BASE, \
1191  #n, \
1192  vl_api_##n##_t_handler, \
1193  vl_noop_handler, \
1194  vl_api_##n##_t_endian, \
1195  vl_api_##n##_t_print, \
1196  sizeof(vl_api_##n##_t), 1);
1198 #undef _
1199 }
1200 
1201 static clib_error_t *
1203 {
1204  api_main_t *am = &api_main;
1205  gbp_main_t *gbpm = &gbp_main;
1206  u8 *name = format (0, "gbp_%08x%c", api_version, 0);
1207 
1208  gbpm->gbp_acl_user_id = ~0;
1209 
1210  /* Ask for a correctly-sized block of API message decode slots */
1211  msg_id_base = vl_msg_api_get_msg_ids ((char *) name,
1213  gbp_api_hookup (vm);
1214 
1215  /* Add our API messages to the global name_crc hash table */
1217 
1218  vec_free (name);
1219  return (NULL);
1220 }
1221 
1223 
1224 /* *INDENT-OFF* */
1225 VLIB_PLUGIN_REGISTER () = {
1226  .version = VPP_BUILD_VER,
1227  .description = "Group Based Policy (GBP)",
1228 };
1229 /* *INDENT-ON* */
1230 
1231 
1232 /*
1233  * fd.io coding-style-patch-verification: ON
1234  *
1235  * Local Variables:
1236  * eval: (c-set-style "gnu")
1237  * End:
1238  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
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:1150
void gbp_subnet_walk(gbp_subnet_cb_t cb, void *ctx)
Definition: gbp_subnet.c:414
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:1008
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:924
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:134
vl_api_gbp_endpoint_group_t epg
Definition: gbp.api:184
gbp_contract_key_t gc_key
source and destination EPGs
Definition: gbp_contract.h:139
vl_api_gbp_endpoint_t endpoint
Definition: gbp.api:134
vl_api_mac_address_t mac
Definition: l2.api:490
static gbp_endpoint_flags_t gbp_endpoint_flags_decode(vl_api_gbp_endpoint_flags_t v)
Definition: gbp_api.c:95
static gbp_bridge_domain_flags_t gbp_bridge_domain_flags_from_api(vl_api_gbp_bridge_domain_flags_t a)
Definition: gbp_api.c:325
gbp_main_t gbp_main
Definition: gbp_api.c:88
vl_api_gbp_subnet_t subnet
Definition: gbp.api:267
a
Definition: bitmap.h:538
void gbp_endpoint_unlock(gbp_endpoint_src_t src, index_t gei)
Definition: gbp_endpoint.c:918
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:200
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
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:279
static void vl_api_gbp_recirc_dump_t_handler(vl_api_gbp_recirc_dump_t *mp)
Definition: gbp_api.c:709
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:286
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:313
vl_api_address_t src
Definition: gre.api:51
vl_api_gbp_vxlan_tunnel_t tunnel
Definition: gbp.api:393
static void vl_api_gbp_vxlan_tunnel_del_t_handler(vl_api_gbp_vxlan_tunnel_add_t *mp)
Definition: gbp_api.c:1096
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:367
u32 rd_id
Definition: gbp.api:34
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
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:427
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:529
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:957
int gbp_subnet_del(u32 rd_id, const fib_prefix_t *pfx)
Definition: gbp_subnet.c:228
unsigned char u8
Definition: types.h:56
static u16 msg_id_base
Definition: gbp_api.c:90
static void vl_api_gbp_bridge_domain_add_t_handler(vl_api_gbp_bridge_domain_add_t *mp)
Definition: gbp_api.c:345
vl_api_gbp_endpoint_retention_t retention
Definition: gbp.api:177
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:795
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:1068
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:61
enum gbp_bridge_domain_flags_t_ gbp_bridge_domain_flags_t
Bridge Domain Flags.
vl_api_interface_index_t sw_if_index
Definition: gre.api:50
static int gbp_route_domain_send_details(gbp_route_domain_t *grd, void *args)
Definition: gbp_api.c:620
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:253
static vl_api_gbp_subnet_type_t gub_subnet_type_to_api(gbp_subnet_type_t t)
Definition: gbp_api.c:454
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:389
static void setup_message_id_table(api_main_t *am)
Definition: gbp_api.c:1178
u8 n_ips
Definition: gbp.api:126
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:114
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Definition: ip_types_api.c:161
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:211
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:483
static void vl_api_gbp_endpoint_group_add_t_handler(vl_api_gbp_endpoint_group_add_t *mp)
Definition: gbp_api.c:294
static void vl_api_gbp_contract_dump_t_handler(vl_api_gbp_contract_dump_t *mp)
Definition: gbp_api.c:1033
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:122
static vl_api_gbp_vxlan_tunnel_mode_t gbp_vxlan_tunnel_layer_2_mode(gbp_vxlan_tunnel_layer_t layer)
Definition: gbp_api.c:1107
#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:289
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
u8 name[64]
Definition: memclnt.api:152
mac_address_t gek_mac
MAC address of the endpoint.
Definition: gbp_endpoint.h:99
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:822
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.
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:203
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:45
static void vl_api_gbp_recirc_add_del_t_handler(vl_api_gbp_recirc_add_del_t *mp)
Definition: gbp_api.c:663
An API client registration, only in vpp/vlib.
Definition: api_common.h:46
#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:603
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
vlib_main_t * vm
Definition: buffer.c:323
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:341
vl_api_prefix_t prefix
Definition: gbp.api:247
static void vl_api_gbp_ext_itf_add_del_t_handler(vl_api_gbp_ext_itf_add_del_t *mp)
Definition: gbp_api.c:726
static walk_rc_t gbp_vxlan_tunnel_send_details(gbp_vxlan_tunnel_t *gt, void *args)
Definition: gbp_api.c:1126
static void vl_api_gbp_subnet_add_del_t_handler(vl_api_gbp_subnet_add_del_t *mp)
Definition: gbp_api.c:427
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:57
vl_api_gbp_endpoint_group_t epg
Definition: gbp.api:202
static void vl_api_gbp_route_domain_dump_t_handler(vl_api_gbp_route_domain_dump_t *mp)
Definition: gbp_api.c:646
vl_api_gbp_subnet_t subnet
Definition: gbp.api:255
vl_api_vxlan_gbp_api_tunnel_mode_t mode
Definition: vxlan_gbp.api:44
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:314
static void vl_api_gbp_endpoint_dump_t_handler(vl_api_gbp_endpoint_dump_t *mp)
Definition: gbp_api.c:269
vl_api_gbp_contract_t contract
Definition: gbp.api:322
enum gbp_endpoint_flags_t_ gbp_endpoint_flags_t
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:555
u32 gb_bvi_sw_if_index
The BD&#39;s BVI interface (obligatory)
vl_api_gbp_recirc_t recirc
Definition: gbp.api:217
static clib_error_t * gbp_init(vlib_main_t *vm)
Definition: gbp_api.c:1202
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 void gbp_api_hookup(vlib_main_t *vm)
Definition: gbp_api.c:1187
static f64 clib_host_to_net_f64(f64 x)
Definition: byte_order.h:216
static void vl_api_gbp_ext_itf_dump_t_handler(vl_api_gbp_ext_itf_dump_t *mp)
Definition: gbp_api.c:778
static void vl_api_gbp_subnet_dump_t_handler(vl_api_gbp_subnet_dump_t *mp)
Definition: gbp_api.c:512
int gbp_bridge_domain_delete(u32 bd_id)
vl_api_gbp_contract_t contract
Definition: gbp.api:340
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_gbp_subnet_type_t type
Definition: gbp.api:246
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
Definition: ip_types_api.c:217
static void vl_api_gbp_endpoint_del_t_handler(vl_api_gbp_endpoint_del_t *mp)
Definition: gbp_api.c:194
static void vl_api_gbp_route_domain_add_t_handler(vl_api_gbp_route_domain_add_t *mp)
Definition: gbp_api.c:373
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:863
vl_api_address_t ip
Definition: l2.api:489
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_gbp_endpoint_t endpoint
Definition: gbp.api:162
static walk_rc_t gbp_recirc_send_details(gbp_recirc_t *gr, void *args)
Definition: gbp_api.c:685
#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:838
#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:206
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:573
static walk_rc_t gbp_ext_itf_send_details(gbp_ext_itf_t *gx, void *args)
Definition: gbp_api.c:753
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:178
struct gbp_endpoint_loc_t_::@462 tun
Tunnel info for remote endpoints.
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:415
vl_api_gbp_route_domain_t rd
Definition: gbp.api:96
vl_api_address_t ips[n_ips]
Definition: gbp.api:127
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:362
#define GBP_MSG_BASE
Definition: gbp_api.c:92
static void vl_api_gbp_endpoint_group_del_t_handler(vl_api_gbp_endpoint_group_del_t *mp)
Definition: gbp_api.c:314
u16 allowed_ethertypes[16]
Definition: gbp.api:312
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:135
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:80
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:894
u32 gbp_bridge_domain_get_bd_id(index_t gbdi)
api_main_t api_main
Definition: api_shared.c:35
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:817
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:1050
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:229
index_t gbp_route_domain_find_and_lock(u32 rd_id)
vl_api_gbp_ext_itf_flags_t flags
Definition: gbp.api:407
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
u16 vl_msg_api_get_msg_ids(const char *name, int n)
Definition: api_shared.c:957
void gbp_endpoint_group_walk(gbp_endpoint_group_cb_t cb, void *ctx)
#define foreach_gbp_api_msg
Definition: gbp_api.c:63
static int gub_subnet_type_from_api(vl_api_gbp_subnet_type_t a, gbp_subnet_type_t *t)
Definition: gbp_api.c:400