FD.io VPP  v19.01.3-6-g70449b9b9
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 
35 #include <vlibapi/api.h>
36 #include <vlibmemory/api.h>
37 
38 /* define message IDs */
39 #include <gbp/gbp_msg_enum.h>
40 
41 #define vl_typedefs /* define message structures */
42 #include <gbp/gbp_all_api_h.h>
43 #undef vl_typedefs
44 
45 #define vl_endianfun /* define message structures */
46 #include <gbp/gbp_all_api_h.h>
47 #undef vl_endianfun
48 
49 /* instantiate all the print functions we know about */
50 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
51 #define vl_printfun
52 #include <gbp/gbp_all_api_h.h>
53 #undef vl_printfun
54 
55 /* Get the API version number */
56 #define vl_api_version(n,v) static u32 api_version=(v);
57 #include <gbp/gbp_all_api_h.h>
58 #undef vl_api_version
59 
61 
62 #define foreach_gbp_api_msg \
63  _(GBP_ENDPOINT_ADD, gbp_endpoint_add) \
64  _(GBP_ENDPOINT_DEL, gbp_endpoint_del) \
65  _(GBP_ENDPOINT_DUMP, gbp_endpoint_dump) \
66  _(GBP_SUBNET_ADD_DEL, gbp_subnet_add_del) \
67  _(GBP_SUBNET_DUMP, gbp_subnet_dump) \
68  _(GBP_ENDPOINT_GROUP_ADD, gbp_endpoint_group_add) \
69  _(GBP_ENDPOINT_GROUP_DEL, gbp_endpoint_group_del) \
70  _(GBP_ENDPOINT_GROUP_DUMP, gbp_endpoint_group_dump) \
71  _(GBP_BRIDGE_DOMAIN_ADD, gbp_bridge_domain_add) \
72  _(GBP_BRIDGE_DOMAIN_DEL, gbp_bridge_domain_del) \
73  _(GBP_BRIDGE_DOMAIN_DUMP, gbp_bridge_domain_dump) \
74  _(GBP_ROUTE_DOMAIN_ADD, gbp_route_domain_add) \
75  _(GBP_ROUTE_DOMAIN_DEL, gbp_route_domain_del) \
76  _(GBP_ROUTE_DOMAIN_DUMP, gbp_route_domain_dump) \
77  _(GBP_RECIRC_ADD_DEL, gbp_recirc_add_del) \
78  _(GBP_RECIRC_DUMP, gbp_recirc_dump) \
79  _(GBP_EXT_ITF_ADD_DEL, gbp_ext_itf_add_del) \
80  _(GBP_EXT_ITF_DUMP, gbp_ext_itf_dump) \
81  _(GBP_CONTRACT_ADD_DEL, gbp_contract_add_del) \
82  _(GBP_CONTRACT_DUMP, gbp_contract_dump) \
83  _(GBP_ENDPOINT_LEARN_SET_INACTIVE_THRESHOLD, gbp_endpoint_learn_set_inactive_threshold) \
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 
144 
145  gef = gbp_endpoint_flags_decode (mp->endpoint.flags), ips = NULL;
146  sw_if_index = ntohl (mp->endpoint.sw_if_index);
147 
148  if (mp->endpoint.n_ips)
149  {
150  vec_validate (ips, mp->endpoint.n_ips - 1);
151 
152  vec_foreach_index (ii, ips)
153  {
154  ip_address_decode (&mp->endpoint.ips[ii], &ips[ii]);
155  }
156  }
157  mac_address_decode (mp->endpoint.mac, &mac);
158 
159  if (GBP_ENDPOINT_FLAG_REMOTE & gef)
160  {
161  ip46_address_t tun_src, tun_dst;
162 
163  ip_address_decode (&mp->endpoint.tun.src, &tun_src);
164  ip_address_decode (&mp->endpoint.tun.dst, &tun_dst);
165 
166  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
167  sw_if_index, ips, &mac,
169  ntohs (mp->endpoint.epg_id),
170  gef, &tun_src, &tun_dst, &handle);
171  }
172  else
173  {
174  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
175  sw_if_index, ips, &mac,
177  ntohs (mp->endpoint.epg_id),
178  gef, NULL, NULL, &handle);
179  }
180  vec_free (ips);
182 
183  /* *INDENT-OFF* */
184  REPLY_MACRO2 (VL_API_GBP_ENDPOINT_ADD_REPLY + GBP_MSG_BASE,
185  ({
186  rmp->handle = htonl (handle);
187  }));
188  /* *INDENT-ON* */
189 }
190 
191 static void
193 {
194  vl_api_gbp_endpoint_del_reply_t *rmp;
195  int rv = 0;
196 
197  gbp_endpoint_unlock (GBP_ENDPOINT_SRC_CP, ntohl (mp->handle));
198 
199  REPLY_MACRO (VL_API_GBP_ENDPOINT_DEL_REPLY + GBP_MSG_BASE);
200 }
201 
202 static void
205 {
206  vl_api_gbp_endpoint_learn_set_inactive_threshold_reply_t *rmp;
207  int rv = 0;
208 
210 
211  REPLY_MACRO (VL_API_GBP_ENDPOINT_LEARN_SET_INACTIVE_THRESHOLD_REPLY +
212  GBP_MSG_BASE);
213 }
214 
215 typedef struct gbp_walk_ctx_t_
216 {
220 
221 static walk_rc_t
223 {
225  gbp_endpoint_loc_t *gel;
226  gbp_endpoint_fwd_t *gef;
227  gbp_endpoint_t *ge;
229  u8 n_ips, ii;
230 
231  ctx = args;
232  ge = gbp_endpoint_get (gei);
233 
234  n_ips = vec_len (ge->ge_key.gek_ips);
235  mp = vl_msg_api_alloc (sizeof (*mp) + (sizeof (*mp->endpoint.ips) * n_ips));
236  if (!mp)
237  return 1;
238 
239  clib_memset (mp, 0, sizeof (*mp));
240  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_DETAILS + GBP_MSG_BASE);
241  mp->context = ctx->context;
242 
243  gel = &ge->ge_locs[0];
244  gef = &ge->ge_fwd;
245 
246  if (gbp_endpoint_is_remote (ge))
247  {
248  mp->endpoint.sw_if_index = ntohl (gel->tun.gel_parent_sw_if_index);
250  &mp->endpoint.tun.src);
252  &mp->endpoint.tun.dst);
253  }
254  else
255  {
256  mp->endpoint.sw_if_index = ntohl (gef->gef_itf);
257  }
258  mp->endpoint.epg_id = ntohs (ge->ge_fwd.gef_epg_id);
259  mp->endpoint.n_ips = n_ips;
260  mp->endpoint.flags = gbp_endpoint_flags_encode (gef->gef_flags);
261  mp->handle = htonl (gei);
262  mp->age = vlib_time_now (vlib_get_main ()) - ge->ge_last_time;
263  mac_address_encode (&ge->ge_key.gek_mac, mp->endpoint.mac);
264 
266  {
268  IP46_TYPE_ANY, &mp->endpoint.ips[ii]);
269  }
270 
271  vl_api_send_msg (ctx->reg, (u8 *) mp);
272 
273  return (WALK_CONTINUE);
274 }
275 
276 static void
278 {
280 
282  if (!reg)
283  return;
284 
285  gbp_walk_ctx_t ctx = {
286  .reg = reg,
287  .context = mp->context,
288  };
289 
291 }
292 
293 static void
296 {
297  vl_api_gbp_endpoint_group_add_reply_t *rmp;
298  int rv = 0;
299 
300  rv = gbp_endpoint_group_add_and_lock (ntohs (mp->epg.epg_id),
301  ntohl (mp->epg.bd_id),
302  ntohl (mp->epg.rd_id),
303  ntohl (mp->epg.uplink_sw_if_index));
304 
305  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_ADD_REPLY + GBP_MSG_BASE);
306 }
307 
308 static void
311 {
312  vl_api_gbp_endpoint_group_del_reply_t *rmp;
313  int rv = 0;
314 
315  rv = gbp_endpoint_group_delete (ntohs (mp->epg_id));
316 
317  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_DEL_REPLY + GBP_MSG_BASE);
318 }
319 
321 gbp_bridge_domain_flags_from_api (vl_api_gbp_bridge_domain_flags_t a)
322 {
324 
325  g = GBP_BD_FLAG_NONE;
326  a = clib_net_to_host_u32 (a);
327 
330 
331  return (g);
332 }
333 
334 static void
336 {
337  vl_api_gbp_bridge_domain_add_reply_t *rmp;
338  int rv = 0;
339 
340  rv = gbp_bridge_domain_add_and_lock (ntohl (mp->bd.bd_id),
342  (mp->bd.flags),
343  ntohl (mp->bd.bvi_sw_if_index),
344  ntohl (mp->bd.uu_fwd_sw_if_index));
345 
346  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
347 }
348 
349 static void
351 {
352  vl_api_gbp_bridge_domain_del_reply_t *rmp;
353  int rv = 0;
354 
355  rv = gbp_bridge_domain_delete (ntohl (mp->bd_id));
356 
357  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
358 }
359 
360 static void
362 {
363  vl_api_gbp_route_domain_add_reply_t *rmp;
364  int rv = 0;
365 
366  rv = gbp_route_domain_add_and_lock (ntohl (mp->rd.rd_id),
367  ntohl (mp->rd.ip4_table_id),
368  ntohl (mp->rd.ip6_table_id),
369  ntohl (mp->rd.ip4_uu_sw_if_index),
370  ntohl (mp->rd.ip6_uu_sw_if_index));
371 
372  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
373 }
374 
375 static void
377 {
378  vl_api_gbp_route_domain_del_reply_t *rmp;
379  int rv = 0;
380 
381  rv = gbp_route_domain_delete (ntohl (mp->rd_id));
382 
383  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
384 }
385 
386 static int
387 gub_subnet_type_from_api (vl_api_gbp_subnet_type_t a, gbp_subnet_type_t * t)
388 {
389  a = clib_net_to_host_u32 (a);
390 
391  switch (a)
392  {
395  return (0);
397  *t = GBP_SUBNET_L3_OUT;
398  return (0);
401  return (0);
404  return (0);
405  }
406 
407  return (-1);
408 }
409 
410 static void
412 {
413  vl_api_gbp_subnet_add_del_reply_t *rmp;
414  gbp_subnet_type_t type;
415  fib_prefix_t pfx;
416  int rv = 0;
417 
418  ip_prefix_decode (&mp->subnet.prefix, &pfx);
419 
420  rv = gub_subnet_type_from_api (mp->subnet.type, &type);
421 
422  if (0 != rv)
423  goto out;
424 
425  if (mp->is_add)
426  rv = gbp_subnet_add (ntohl (mp->subnet.rd_id),
427  &pfx, type,
428  ntohl (mp->subnet.sw_if_index),
429  ntohs (mp->subnet.epg_id));
430  else
431  rv = gbp_subnet_del (ntohl (mp->subnet.rd_id), &pfx);
432 
433 out:
434  REPLY_MACRO (VL_API_GBP_SUBNET_ADD_DEL_REPLY + GBP_MSG_BASE);
435 }
436 
437 static vl_api_gbp_subnet_type_t
439 {
440  vl_api_gbp_subnet_type_t a = 0;
441 
442  switch (t)
443  {
446  break;
449  break;
452  break;
453  case GBP_SUBNET_L3_OUT:
455  break;
456  }
457 
458  a = clib_host_to_net_u32 (a);
459 
460  return (a);
461 }
462 
463 static walk_rc_t
465  const fib_prefix_t * pfx,
466  gbp_subnet_type_t type,
467  u32 sw_if_index, epg_id_t epg, void *args)
468 {
471 
472  ctx = args;
473  mp = vl_msg_api_alloc (sizeof (*mp));
474  if (!mp)
475  return 1;
476 
477  clib_memset (mp, 0, sizeof (*mp));
478  mp->_vl_msg_id = ntohs (VL_API_GBP_SUBNET_DETAILS + GBP_MSG_BASE);
479  mp->context = ctx->context;
480 
481  mp->subnet.type = gub_subnet_type_to_api (type);
482  mp->subnet.sw_if_index = ntohl (sw_if_index);
483  mp->subnet.epg_id = ntohs (epg);
484  mp->subnet.rd_id = ntohl (rd_id);
485  ip_prefix_encode (pfx, &mp->subnet.prefix);
486 
487  vl_api_send_msg (ctx->reg, (u8 *) mp);
488 
489  return (WALK_CONTINUE);
490 }
491 
492 static void
494 {
496 
498  if (!reg)
499  return;
500 
501  gbp_walk_ctx_t ctx = {
502  .reg = reg,
503  .context = mp->context,
504  };
505 
507 }
508 
509 static int
511 {
514 
515  ctx = args;
516  mp = vl_msg_api_alloc (sizeof (*mp));
517  if (!mp)
518  return 1;
519 
520  clib_memset (mp, 0, sizeof (*mp));
521  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_GROUP_DETAILS + GBP_MSG_BASE);
522  mp->context = ctx->context;
523 
524  mp->epg.uplink_sw_if_index = ntohl (gg->gg_uplink_sw_if_index);
525  mp->epg.epg_id = ntohs (gg->gg_id);
526  mp->epg.bd_id = ntohl (gbp_endpoint_group_get_bd_id (gg));
527  mp->epg.rd_id = ntohl (gbp_route_domain_get_rd_id (gg->gg_rd));
528 
529  vl_api_send_msg (ctx->reg, (u8 *) mp);
530 
531  return (1);
532 }
533 
534 static void
536  mp)
537 {
539 
541  if (!reg)
542  return;
543 
544  gbp_walk_ctx_t ctx = {
545  .reg = reg,
546  .context = mp->context,
547  };
548 
550 }
551 
552 static int
554 {
557 
558  ctx = args;
559  mp = vl_msg_api_alloc (sizeof (*mp));
560  if (!mp)
561  return 1;
562 
563  memset (mp, 0, sizeof (*mp));
564  mp->_vl_msg_id = ntohs (VL_API_GBP_BRIDGE_DOMAIN_DETAILS + GBP_MSG_BASE);
565  mp->context = ctx->context;
566 
567  mp->bd.bd_id = ntohl (gb->gb_bd_id);
568  mp->bd.bvi_sw_if_index = ntohl (gb->gb_bvi_sw_if_index);
569  mp->bd.uu_fwd_sw_if_index = ntohl (gb->gb_uu_fwd_sw_if_index);
570 
571  vl_api_send_msg (ctx->reg, (u8 *) mp);
572 
573  return (1);
574 }
575 
576 static void
578 {
580 
582  if (!reg)
583  return;
584 
585  gbp_walk_ctx_t ctx = {
586  .reg = reg,
587  .context = mp->context,
588  };
589 
591 }
592 
593 static int
595 {
598 
599  ctx = args;
600  mp = vl_msg_api_alloc (sizeof (*mp));
601  if (!mp)
602  return 1;
603 
604  memset (mp, 0, sizeof (*mp));
605  mp->_vl_msg_id = ntohs (VL_API_GBP_ROUTE_DOMAIN_DETAILS + GBP_MSG_BASE);
606  mp->context = ctx->context;
607 
608  mp->rd.rd_id = ntohl (grd->grd_id);
609  mp->rd.ip4_uu_sw_if_index =
610  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP4]);
611  mp->rd.ip6_uu_sw_if_index =
612  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP6]);
613 
614  vl_api_send_msg (ctx->reg, (u8 *) mp);
615 
616  return (1);
617 }
618 
619 static void
621 {
623 
625  if (!reg)
626  return;
627 
628  gbp_walk_ctx_t ctx = {
629  .reg = reg,
630  .context = mp->context,
631  };
632 
634 }
635 
636 static void
638 {
639  vl_api_gbp_recirc_add_del_reply_t *rmp;
641  int rv = 0;
642 
643  sw_if_index = ntohl (mp->recirc.sw_if_index);
644  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
645  goto bad_sw_if_index;
646 
647  if (mp->is_add)
648  rv = gbp_recirc_add (sw_if_index,
649  ntohs (mp->recirc.epg_id), mp->recirc.is_ext);
650  else
651  rv = gbp_recirc_delete (sw_if_index);
652 
654 
655  REPLY_MACRO (VL_API_GBP_RECIRC_ADD_DEL_REPLY + GBP_MSG_BASE);
656 }
657 
658 static walk_rc_t
660 {
663 
664  ctx = args;
665  mp = vl_msg_api_alloc (sizeof (*mp));
666  if (!mp)
667  return (WALK_STOP);
668 
669  clib_memset (mp, 0, sizeof (*mp));
670  mp->_vl_msg_id = ntohs (VL_API_GBP_RECIRC_DETAILS + GBP_MSG_BASE);
671  mp->context = ctx->context;
672 
673  mp->recirc.epg_id = ntohs (gr->gr_epg);
674  mp->recirc.sw_if_index = ntohl (gr->gr_sw_if_index);
675  mp->recirc.is_ext = gr->gr_is_ext;
676 
677  vl_api_send_msg (ctx->reg, (u8 *) mp);
678 
679  return (WALK_CONTINUE);
680 }
681 
682 static void
684 {
686 
688  if (!reg)
689  return;
690 
691  gbp_walk_ctx_t ctx = {
692  .reg = reg,
693  .context = mp->context,
694  };
695 
697 }
698 
699 static void
701 {
702  vl_api_gbp_ext_itf_add_del_reply_t *rmp;
703  u32 sw_if_index = ~0;
704  vl_api_gbp_ext_itf_t *ext_itf;
705  int rv = 0;
706 
707  ext_itf = &mp->ext_itf;
708  if (ext_itf)
709  sw_if_index = ntohl (ext_itf->sw_if_index);
710 
711  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
712  goto bad_sw_if_index;
713 
714  if (mp->is_add)
715  rv = gbp_ext_itf_add (sw_if_index,
716  ntohl (ext_itf->bd_id), ntohl (ext_itf->rd_id));
717  else
718  rv = gbp_ext_itf_delete (sw_if_index);
719 
721 
722  REPLY_MACRO (VL_API_GBP_EXT_ITF_ADD_DEL_REPLY + GBP_MSG_BASE);
723 }
724 
725 static walk_rc_t
727 {
730 
731  ctx = args;
732  mp = vl_msg_api_alloc (sizeof (*mp));
733  if (!mp)
734  return (WALK_STOP);
735 
736  clib_memset (mp, 0, sizeof (*mp));
737  mp->_vl_msg_id = ntohs (VL_API_GBP_EXT_ITF_DETAILS + GBP_MSG_BASE);
738  mp->context = ctx->context;
739 
740  mp->ext_itf.bd_id = ntohl (gbp_bridge_domain_get_bd_id (gx->gx_bd));
741  mp->ext_itf.rd_id = ntohl (gbp_route_domain_get_rd_id (gx->gx_rd));
742  mp->ext_itf.sw_if_index = ntohl (gx->gx_itf);
743 
744  vl_api_send_msg (ctx->reg, (u8 *) mp);
745 
746  return (WALK_CONTINUE);
747 }
748 
749 static void
751 {
753 
755  if (!reg)
756  return;
757 
758  gbp_walk_ctx_t ctx = {
759  .reg = reg,
760  .context = mp->context,
761  };
762 
764 }
765 
766 static int
767 gbp_contract_rule_action_deocde (vl_api_gbp_rule_action_t in,
768  gbp_rule_action_t * out)
769 {
770  in = clib_net_to_host_u32 (in);
771 
772  switch (in)
773  {
774  case GBP_API_RULE_PERMIT:
775  *out = GBP_RULE_PERMIT;
776  return (0);
777  case GBP_API_RULE_DENY:
778  *out = GBP_RULE_DENY;
779  return (0);
781  *out = GBP_RULE_REDIRECT;
782  return (0);
783  }
784 
785  return (-1);
786 }
787 
788 static int
789 gbp_hash_mode_decode (vl_api_gbp_hash_mode_t in, gbp_hash_mode_t * out)
790 {
791  in = clib_net_to_host_u32 (in);
792 
793  switch (in)
794  {
796  *out = GBP_HASH_MODE_SRC_IP;
797  return (0);
799  *out = GBP_HASH_MODE_DST_IP;
800  return (0);
802  *out = GBP_HASH_MODE_SYMMETRIC;
803  return (0);
804  }
805 
806  return (-2);
807 }
808 
809 static int
810 gbp_next_hop_decode (const vl_api_gbp_next_hop_t * in, index_t * gnhi)
811 {
812  ip46_address_t ip;
814  index_t grd, gbd;
815 
816  gbd = gbp_bridge_domain_find_and_lock (ntohl (in->bd_id));
817 
818  if (INDEX_INVALID == gbd)
819  return (VNET_API_ERROR_BD_NOT_MODIFIABLE);
820 
821  grd = gbp_route_domain_find_and_lock (ntohl (in->rd_id));
822 
823  if (INDEX_INVALID == grd)
824  return (VNET_API_ERROR_NO_SUCH_FIB);
825 
826  ip_address_decode (&in->ip, &ip);
827  mac_address_decode (in->mac, &mac);
828 
829  *gnhi = gbp_next_hop_alloc (&ip, grd, &mac, gbd);
830 
831  return (0);
832 }
833 
834 static int
835 gbp_next_hop_set_decode (const vl_api_gbp_next_hop_set_t * in,
836  gbp_hash_mode_t * hash_mode, index_t ** out)
837 {
838 
839  index_t *gnhis = NULL;
840  int rv;
841  u8 ii;
842 
843  rv = gbp_hash_mode_decode (in->hash_mode, hash_mode);
844 
845  if (0 != rv)
846  return rv;
847 
848  vec_validate (gnhis, in->n_nhs - 1);
849 
850  for (ii = 0; ii < in->n_nhs; ii++)
851  {
852  rv = gbp_next_hop_decode (&in->nhs[ii], &gnhis[ii]);
853 
854  if (0 != rv)
855  {
856  vec_free (gnhis);
857  break;
858  }
859  }
860 
861  *out = gnhis;
862  return (rv);
863 }
864 
865 static int
866 gbp_contract_rule_decode (const vl_api_gbp_rule_t * in, index_t * gui)
867 {
868  gbp_hash_mode_t hash_mode;
869  gbp_rule_action_t action;
870  index_t *nhs = NULL;
871  int rv;
872 
873  rv = gbp_contract_rule_action_deocde (in->action, &action);
874 
875  if (0 != rv)
876  return rv;
877 
878  if (GBP_RULE_REDIRECT == action)
879  {
880  rv = gbp_next_hop_set_decode (&in->nh_set, &hash_mode, &nhs);
881 
882  if (0 != rv)
883  return (rv);
884  }
885  else
886  {
887  hash_mode = GBP_HASH_MODE_SRC_IP;
888  }
889 
890  *gui = gbp_rule_alloc (action, hash_mode, nhs);
891 
892  return (rv);
893 }
894 
895 static int
897  const vl_api_gbp_rule_t * rules, index_t ** out)
898 {
899  index_t *guis = NULL;
900  int rv;
901  u8 ii;
902 
903  if (0 == n_rules)
904  {
905  *out = NULL;
906  return (0);
907  }
908 
909  vec_validate (guis, n_rules - 1);
910 
911  for (ii = 0; ii < n_rules; ii++)
912  {
913  rv = gbp_contract_rule_decode (&rules[ii], &guis[ii]);
914 
915  if (0 != rv)
916  {
917  vec_free (guis);
918  return (rv);
919  }
920  }
921 
922  *out = guis;
923  return (rv);
924 }
925 
926 static void
928 {
929  vl_api_gbp_contract_add_del_reply_t *rmp;
931  index_t *rules;
932  int ii, rv = 0;
933  u8 *data, n_et;
934  u16 *et;
935 
936  if (mp->is_add)
937  {
938  rv = gbp_contract_rules_decode (mp->contract.n_rules,
939  mp->contract.rules, &rules);
940  if (0 != rv)
941  goto out;
942 
943  allowed_ethertypes = NULL;
944 
945  /*
946  * move past the variable legnth array of rules to get to the
947  * allowed ether types
948  */
949  data = (((u8 *) & mp->contract.n_ether_types) +
950  (sizeof (mp->contract.rules[0]) * mp->contract.n_rules));
951  n_et = *data;
952  et = (u16 *) (++data);
953  vec_validate (allowed_ethertypes, n_et - 1);
954 
955  for (ii = 0; ii < n_et; ii++)
956  {
957  /* leave the ether types in network order */
958  allowed_ethertypes[ii] = et[ii];
959  }
960 
961  rv = gbp_contract_update (ntohs (mp->contract.src_epg),
962  ntohs (mp->contract.dst_epg),
963  ntohl (mp->contract.acl_index),
964  rules, allowed_ethertypes);
965  }
966  else
967  rv = gbp_contract_delete (ntohs (mp->contract.src_epg),
968  ntohs (mp->contract.dst_epg));
969 
970 out:
971  REPLY_MACRO (VL_API_GBP_CONTRACT_ADD_DEL_REPLY + GBP_MSG_BASE);
972 }
973 
974 static int
976 {
979 
980  ctx = args;
981  mp = vl_msg_api_alloc (sizeof (*mp));
982  if (!mp)
983  return 1;
984 
985  clib_memset (mp, 0, sizeof (*mp));
986  mp->_vl_msg_id = ntohs (VL_API_GBP_CONTRACT_DETAILS + GBP_MSG_BASE);
987  mp->context = ctx->context;
988 
989  mp->contract.src_epg = ntohs (gbpc->gc_key.gck_src);
990  mp->contract.dst_epg = ntohs (gbpc->gc_key.gck_dst);
991  // mp->contract.acl_index = ntohl (gbpc->gc_value.gc_acl_index);
992 
993  vl_api_send_msg (ctx->reg, (u8 *) mp);
994 
995  return (1);
996 }
997 
998 static void
1000 {
1002 
1004  if (!reg)
1005  return;
1006 
1007  gbp_walk_ctx_t ctx = {
1008  .reg = reg,
1009  .context = mp->context,
1010  };
1011 
1013 }
1014 
1015 static int
1016 gbp_vxlan_tunnel_mode_2_layer (vl_api_gbp_vxlan_tunnel_mode_t mode,
1018 {
1019  mode = clib_net_to_host_u32 (mode);
1020 
1021  switch (mode)
1022  {
1024  *l = GBP_VXLAN_TUN_L2;
1025  return (0);
1027  *l = GBP_VXLAN_TUN_L3;
1028  return (0);
1029  }
1030  return (-1);
1031 }
1032 
1033 static void
1035 {
1038  u32 sw_if_index;
1039  int rv = 0;
1040 
1041  rv = gbp_vxlan_tunnel_mode_2_layer (mp->tunnel.mode, &layer);
1042 
1043  if (0 != rv)
1044  goto out;
1045 
1046  rv = gbp_vxlan_tunnel_add (ntohl (mp->tunnel.vni),
1047  layer,
1048  ntohl (mp->tunnel.bd_rd_id), &sw_if_index);
1049 
1050 out:
1051  /* *INDENT-OFF* */
1052  REPLY_MACRO2 (VL_API_GBP_VXLAN_TUNNEL_ADD_REPLY + GBP_MSG_BASE,
1053  ({
1054  rmp->sw_if_index = htonl (sw_if_index);
1055  }));
1056  /* *INDENT-ON* */
1057 }
1058 
1059 static void
1061 {
1062  vl_api_gbp_vxlan_tunnel_del_reply_t *rmp;
1063  int rv = 0;
1064 
1065  rv = gbp_vxlan_tunnel_del (ntohl (mp->tunnel.vni));
1066 
1067  REPLY_MACRO (VL_API_GBP_VXLAN_TUNNEL_DEL_REPLY + GBP_MSG_BASE);
1068 }
1069 
1070 static vl_api_gbp_vxlan_tunnel_mode_t
1072 {
1073  vl_api_gbp_vxlan_tunnel_mode_t mode = GBP_VXLAN_TUNNEL_MODE_L2;
1074 
1075  switch (layer)
1076  {
1077  case GBP_VXLAN_TUN_L2:
1078  mode = GBP_VXLAN_TUNNEL_MODE_L2;
1079  break;
1080  case GBP_VXLAN_TUN_L3:
1081  mode = GBP_VXLAN_TUNNEL_MODE_L3;
1082  break;
1083  }
1084  mode = clib_host_to_net_u32 (mode);
1085 
1086  return (mode);
1087 }
1088 
1089 static walk_rc_t
1091 {
1094 
1095  ctx = args;
1096  mp = vl_msg_api_alloc (sizeof (*mp));
1097  if (!mp)
1098  return 1;
1099 
1100  memset (mp, 0, sizeof (*mp));
1101  mp->_vl_msg_id = htons (VL_API_GBP_VXLAN_TUNNEL_DETAILS + GBP_MSG_BASE);
1102  mp->context = ctx->context;
1103 
1104  mp->tunnel.vni = htonl (gt->gt_vni);
1106  mp->tunnel.bd_rd_id = htonl (gt->gt_bd_rd_id);
1107 
1108  vl_api_send_msg (ctx->reg, (u8 *) mp);
1109 
1110  return (1);
1111 }
1112 
1113 static void
1115 {
1117 
1119  if (!reg)
1120  return;
1121 
1122  gbp_walk_ctx_t ctx = {
1123  .reg = reg,
1124  .context = mp->context,
1125  };
1126 
1128 }
1129 
1130 /*
1131  * gbp_api_hookup
1132  * Add vpe's API message handlers to the table.
1133  * vlib has already mapped shared memory and
1134  * added the client registration handlers.
1135  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1136  */
1137 #define vl_msg_name_crc_list
1138 #include <gbp/gbp_all_api_h.h>
1139 #undef vl_msg_name_crc_list
1140 
1141 static void
1143 {
1144 #define _(id,n,crc) \
1145  vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + GBP_MSG_BASE);
1146  foreach_vl_msg_name_crc_gbp;
1147 #undef _
1148 }
1149 
1150 static void
1152 {
1153 #define _(N,n) \
1154  vl_msg_api_set_handlers(VL_API_##N + GBP_MSG_BASE, \
1155  #n, \
1156  vl_api_##n##_t_handler, \
1157  vl_noop_handler, \
1158  vl_api_##n##_t_endian, \
1159  vl_api_##n##_t_print, \
1160  sizeof(vl_api_##n##_t), 1);
1162 #undef _
1163 }
1164 
1165 static clib_error_t *
1167 {
1168  api_main_t *am = &api_main;
1169  gbp_main_t *gbpm = &gbp_main;
1170  u8 *name = format (0, "gbp_%08x%c", api_version, 0);
1171 
1172  gbpm->gbp_acl_user_id = ~0;
1173 
1174  /* Ask for a correctly-sized block of API message decode slots */
1175  msg_id_base = vl_msg_api_get_msg_ids ((char *) name,
1177  gbp_api_hookup (vm);
1178 
1179  /* Add our API messages to the global name_crc hash table */
1181 
1182  vec_free (name);
1183  return (NULL);
1184 }
1185 
1187 
1188 /* *INDENT-OFF* */
1189 VLIB_PLUGIN_REGISTER () = {
1190  .version = VPP_BUILD_VER,
1191  .description = "Group Based Policy (GBP)",
1192 };
1193 /* *INDENT-ON* */
1194 
1195 
1196 /*
1197  * fd.io coding-style-patch-verification: ON
1198  *
1199  * Local Variables:
1200  * eval: (c-set-style "gnu")
1201  * End:
1202  */
#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)
static void vl_api_gbp_endpoint_learn_set_inactive_threshold_t_handler(vl_api_gbp_endpoint_learn_set_inactive_threshold_t *mp)
Definition: gbp_api.c:204
VLIB_PLUGIN_REGISTER()
#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:1114
void gbp_subnet_walk(gbp_subnet_cb_t cb, void *ctx)
Definition: gbp_subnet.c:287
u16 epg_id_t
Definition: gbp_types.h:21
int gbp_endpoint_is_remote(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:93
u32 gx_itf
The interface.
Definition: gbp_ext_itf.h:32
static gbp_endpoint_t * gbp_endpoint_get(index_t gbpei)
Get the endpoint from a port/interface.
Definition: gbp_endpoint.h:258
f64 ge_last_time
The last time a packet from seen from this end point.
Definition: gbp_endpoint.h:205
static int gbp_contract_send_details(gbp_contract_t *gbpc, void *args)
Definition: gbp_api.c:975
A Group Based Policy Endpoint.
Definition: gbp_endpoint.h:182
static int gbp_contract_rules_decode(u8 n_rules, const vl_api_gbp_rule_t *rules, index_t **out)
Definition: gbp_api.c:896
fib_prefix_t * gek_ips
A vector of ip addresses that belong to the endpoint.
Definition: gbp_endpoint.h:90
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:171
gbp_contract_key_t gc_key
source and destination EPGs
Definition: gbp_contract.h:114
vl_api_gbp_endpoint_t endpoint
Definition: gbp.api:128
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:321
gbp_main_t gbp_main
Definition: gbp_api.c:88
vl_api_gbp_subnet_t subnet
Definition: gbp.api:253
a
Definition: bitmap.h:538
void gbp_endpoint_unlock(gbp_endpoint_src_t src, index_t gei)
Definition: gbp_endpoint.c:898
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:98
Information about the location of the endpoint provided by a source of endpoints. ...
Definition: gbp_endpoint.h:113
gbp_endpoint_fwd_t ge_fwd
Definition: gbp_endpoint.h:200
gbp_endpoint_key_t ge_key
The key/ID of this EP.
Definition: gbp_endpoint.h:192
void mac_address_encode(const mac_address_t *in, u8 *out)
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:58
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
gbp_endpoint_flags_t gef_flags
Definition: gbp_endpoint.h:171
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:232
static void vl_api_gbp_recirc_dump_t_handler(vl_api_gbp_recirc_dump_t *mp)
Definition: gbp_api.c:683
int gbp_route_domain_add_and_lock(u32 rd_id, u32 ip4_table_id, u32 ip6_table_id, u32 ip4_uu_sw_if_index, u32 ip6_uu_sw_if_index)
index_t gef_itf
The interface on which the EP is connected.
Definition: gbp_endpoint.h:159
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
Definition: api.h:34
u32 gbp_acl_user_id
Definition: gbp.h:45
A bridge Domain Representation.
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:296
vl_api_gbp_vxlan_tunnel_t tunnel
Definition: gbp.api:383
static void vl_api_gbp_vxlan_tunnel_del_t_handler(vl_api_gbp_vxlan_tunnel_add_t *mp)
Definition: gbp_api.c:1060
void gbp_vxlan_walk(gbp_vxlan_cb_t cb, void *ctx)
Definition: gbp_vxlan.c:502
vl_api_gbp_vxlan_tunnel_t tunnel
Definition: gbp.api:357
u32 rd_id
Definition: gbp.api:261
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
int gbp_bridge_domain_add_and_lock(u32 bd_id, gbp_bridge_domain_flags_t flags, u32 bvi_sw_if_index, u32 uu_fwd_sw_if_index)
index_t gg_rd
route-domain/IP-table ID the EPG is in
vl_api_gbp_ext_itf_t ext_itf
Definition: gbp.api:410
int gbp_endpoint_group_add_and_lock(epg_id_t epg_id, u32 bd_id, u32 rd_id, u32 uplink_sw_if_index)
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:510
gbp_endpoint_src_t gel_src
The source providing this location information.
Definition: gbp_endpoint.h:118
static void vl_api_gbp_contract_add_del_t_handler(vl_api_gbp_contract_add_del_t *mp)
Definition: gbp_api.c:927
int gbp_subnet_del(u32 rd_id, const fib_prefix_t *pfx)
Definition: gbp_subnet.c:200
unsigned char u8
Definition: types.h:56
static u16 msg_id_base
Definition: gbp_api.c:90
epg_id_t gef_epg_id
Endpoint Group&#39;s ID.
Definition: gbp_endpoint.h:169
static void vl_api_gbp_bridge_domain_add_t_handler(vl_api_gbp_bridge_domain_add_t *mp)
Definition: gbp_api.c:335
struct gbp_endpoint_loc_t_::@427 tun
Tunnel info for remote endpoints.
int gbp_subnet_add(u32 rd_id, const fib_prefix_t *pfx, gbp_subnet_type_t type, u32 sw_if_index, epg_id_t epg)
Definition: gbp_subnet.c:236
static int gbp_contract_rule_action_deocde(vl_api_gbp_rule_action_t in, gbp_rule_action_t *out)
Definition: gbp_api.c:767
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:1034
void gbp_learn_set_inactive_threshold(u32 threshold)
u8 gr_is_ext
Is the interface for packets post-NAT translation (i.e.
Definition: gbp_recirc.h:49
vl_api_gbp_bridge_domain_t bd
Definition: gbp.api:56
enum gbp_bridge_domain_flags_t_ gbp_bridge_domain_flags_t
Bridge Domain Flags.
u32 sw_if_index
Definition: vxlan_gbp.api:37
static int gbp_route_domain_send_details(gbp_route_domain_t *grd, void *args)
Definition: gbp_api.c:594
static vl_api_gbp_subnet_type_t gub_subnet_type_to_api(gbp_subnet_type_t t)
Definition: gbp_api.c:438
void gbp_route_domain_walk(gbp_route_domain_cb_t cb, void *ctx)
Aggregrate 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:376
static void setup_message_id_table(api_main_t *am)
Definition: gbp_api.c:1142
u8 n_ips
Definition: gbp.api:120
A GBP recirculation interface representation Thes interfaces join Bridge domains that are internal to...
Definition: gbp_recirc.h:28
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:37
u16 allowed_ethertypes[n_ether_types]
Definition: gbp.api:299
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:59
Set the time throeshold after which an endpoint is considered inative and is aged/reaped by the scann...
Definition: gbp.api:327
static walk_rc_t gbp_endpoint_send_details(index_t gei, void *args)
Definition: gbp_api.c:222
epg_id_t gr_epg
EPG ID that packets will classify to when they arrive on this recirc.
Definition: gbp_recirc.h:33
int gbp_ext_itf_delete(u32 sw_if_index)
Definition: gbp_ext_itf.c:111
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, epg_id_t epg_id, gbp_endpoint_flags_t flags, const ip46_address_t *tun_src, const ip46_address_t *tun_dst, u32 *handle)
Definition: gbp_endpoint.c:804
int gbp_endpoint_group_delete(epg_id_t epg_id)
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 void vl_api_gbp_endpoint_group_add_t_handler(vl_api_gbp_endpoint_group_add_t *mp)
Definition: gbp_api.c:295
static void vl_api_gbp_contract_dump_t_handler(vl_api_gbp_contract_dump_t *mp)
Definition: gbp_api.c:999
int gbp_route_domain_delete(u32 rd_id)
long ctx[MAX_CONNS]
Definition: main.c:144
unsigned short u16
Definition: types.h:57
static vl_api_gbp_vxlan_tunnel_mode_t gbp_vxlan_tunnel_layer_2_mode(gbp_vxlan_tunnel_layer_t layer)
Definition: gbp_api.c:1071
int gbp_ext_itf_add(u32 sw_if_index, u32 bd_id, u32 rd_id)
Definition: gbp_ext_itf.c:52
#define REPLY_MACRO(t)
u32 grd_uu_sw_if_index[FIB_PROTOCOL_IP_MAX]
The interfaces on which to send packets to unnknown EPs.
vl_api_gbp_next_hop_t nhs[8]
Definition: gbp.api:275
u32 gb_bd_id
Bridge-domain ID.
u8 name[64]
Definition: memclnt.api:152
mac_address_t gek_mac
MAC address of the endpoint.
Definition: gbp_endpoint.h:96
int gbp_contract_delete(epg_id_t src_epg, epg_id_t dst_epg)
Definition: gbp_contract.c:496
enum gbp_hash_mode_t_ gbp_hash_mode_t
An external interface maps directly to an oflex L3ExternalInterface.
Definition: gbp_ext_itf.h:27
An Endpoint Group representation.
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:202
vl_api_gbp_bridge_domain_t bd
Definition: gbp.api:40
static void vl_api_gbp_recirc_add_del_t_handler(vl_api_gbp_recirc_add_del_t *mp)
Definition: gbp_api.c:637
An API client registration, only in vpp/vlib.
Definition: api_common.h:45
#define BAD_SW_IF_INDEX_LABEL
int gbp_vxlan_tunnel_add(u32 vni, gbp_vxlan_tunnel_layer_t layer, u32 bd_rd_id, u32 *sw_if_indexp)
Definition: gbp_vxlan.c:640
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:577
vlib_main_t * vm
Definition: buffer.c:301
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:233
static void vl_api_gbp_ext_itf_add_del_t_handler(vl_api_gbp_ext_itf_add_del_t *mp)
Definition: gbp_api.c:700
static walk_rc_t gbp_vxlan_tunnel_send_details(gbp_vxlan_tunnel_t *gt, void *args)
Definition: gbp_api.c:1090
static void vl_api_gbp_subnet_add_del_t_handler(vl_api_gbp_subnet_add_del_t *mp)
Definition: gbp_api.c:411
int gbp_vxlan_tunnel_del(u32 vni)
Definition: gbp_vxlan.c:765
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:56
epg_id_t gck_src
source and destination EPGs for which the ACL applies
Definition: gbp_contract.h:33
vl_api_gbp_endpoint_group_t epg
Definition: gbp.api:189
static void vl_api_gbp_route_domain_dump_t_handler(vl_api_gbp_route_domain_dump_t *mp)
Definition: gbp_api.c:620
vl_api_gbp_subnet_t subnet
Definition: gbp.api:241
index_t gx_rd
The RD this external interface is a member of.
Definition: gbp_ext_itf.h:42
index_t gbp_bridge_domain_find_and_lock(u32 bd_id)
u32 gr_sw_if_index
Definition: gbp_recirc.h:53
vl_api_gbp_rule_t rules[n_rules]
Definition: gbp.api:297
static void vl_api_gbp_endpoint_dump_t_handler(vl_api_gbp_endpoint_dump_t *mp)
Definition: gbp_api.c:277
vl_api_gbp_contract_t contract
Definition: gbp.api:307
enum gbp_endpoint_flags_t_ gbp_endpoint_flags_t
gbp_vxlan_tunnel_layer_t gt_layer
Definition: gbp_vxlan.h:48
static void vl_api_gbp_endpoint_group_dump_t_handler(vl_api_gbp_endpoint_group_dump_t *mp)
Definition: gbp_api.c:535
u32 gb_bvi_sw_if_index
The BD&#39;s BVI interface (obligatory)
vl_api_gbp_recirc_t recirc
Definition: gbp.api:204
static clib_error_t * gbp_init(vlib_main_t *vm)
Definition: gbp_api.c:1166
index_t gbp_rule_alloc(gbp_rule_action_t action, gbp_hash_mode_t hash_mode, index_t *nhs)
Definition: gbp_contract.c:44
static void gbp_api_hookup(vlib_main_t *vm)
Definition: gbp_api.c:1151
static void vl_api_gbp_ext_itf_dump_t_handler(vl_api_gbp_ext_itf_dump_t *mp)
Definition: gbp_api.c:750
static void vl_api_gbp_subnet_dump_t_handler(vl_api_gbp_subnet_dump_t *mp)
Definition: gbp_api.c:493
int gbp_bridge_domain_delete(u32 bd_id)
vl_api_gbp_contract_t contract
Definition: gbp.api:319
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
int gbp_contract_update(epg_id_t src_epg, epg_id_t dst_epg, u32 acl_index, index_t *rules, u16 *allowed_ethertypes)
Definition: gbp_contract.c:436
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:232
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
Definition: ip_types_api.c:115
static void vl_api_gbp_endpoint_del_t_handler(vl_api_gbp_endpoint_del_t *mp)
Definition: gbp_api.c:192
static void vl_api_gbp_route_domain_add_t_handler(vl_api_gbp_route_domain_add_t *mp)
Definition: gbp_api.c:361
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:835
And endpoints current forwarding state.
Definition: gbp_endpoint.h:154
vl_api_gbp_endpoint_t endpoint
Definition: gbp.api:156
static walk_rc_t gbp_recirc_send_details(gbp_recirc_t *gr, void *args)
Definition: gbp_api.c:659
#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:810
#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)
vl_api_registration_t * reg
Definition: gbp_api.c:217
void gbp_ext_itf_walk(gbp_ext_itf_cb_t cb, void *ctx)
Definition: gbp_ext_itf.c:144
static int gbp_bridge_domain_send_details(gbp_bridge_domain_t *gb, void *args)
Definition: gbp_api.c:553
static walk_rc_t gbp_ext_itf_send_details(gbp_ext_itf_t *gx, void *args)
Definition: gbp_api.c:726
Group Base Policy (GBP) defines:
Definition: gbp.h:43
void ip_address_encode(const ip46_address_t *in, ip46_type_t type, vl_api_address_t *out)
Definition: ip_types_api.c:76
int gbp_recirc_delete(u32 sw_if_index)
Definition: gbp_recirc.c:175
int gbp_recirc_add(u32 sw_if_index, epg_id_t epg_id, u8 is_ext)
Definition: gbp_recirc.c:62
GBP VXLAN (template) tunnel.
Definition: gbp_vxlan.h:38
u32 grd_id
Route-domain ID.
vl_api_gbp_ext_itf_t ext_itf
Definition: gbp.api:398
vl_api_gbp_vxlan_tunnel_mode_t mode
Definition: gbp.api:349
vl_api_gbp_route_domain_t rd
Definition: gbp.api:88
vl_api_address_t ips[n_ips]
Definition: gbp.api:121
u32 gbp_endpoint_group_get_bd_id(const gbp_endpoint_group_t *gg)
static void vl_api_gbp_bridge_domain_del_t_handler(vl_api_gbp_bridge_domain_del_t *mp)
Definition: gbp_api.c:350
#define GBP_MSG_BASE
Definition: gbp_api.c:92
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, epg_id_t epg, void *args)
Definition: gbp_api.c:464
static void vl_api_gbp_endpoint_group_del_t_handler(vl_api_gbp_endpoint_group_del_t *mp)
Definition: gbp_api.c:310
u32 gt_bd_rd_id
The BD or RD value (depending on the layer) that the tunnel is bound to.
Definition: gbp_vxlan.h:47
VLIB_API_INIT_FUNCTION(gbp_init)
gbp_endpoint_loc_t * ge_locs
Location information provided by the various sources.
Definition: gbp_endpoint.h:198
vl_api_gbp_route_domain_t rd
Definition: gbp.api:72
void gbp_contract_walk(gbp_contract_cb_t cb, void *ctx)
Definition: gbp_contract.c:524
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:866
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:147
vl_api_mac_address_t mac
Definition: gbp.api:118
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:789
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:1016
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:59
vl_api_gbp_recirc_t recirc
Definition: gbp.api:216
index_t gbp_route_domain_find_and_lock(u32 rd_id)
A Group Based Policy Contract.
Definition: gbp_contract.h:109
#define VALIDATE_SW_IF_INDEX(mp)
u16 vl_msg_api_get_msg_ids(const char *name, int n)
Definition: api_shared.c:865
void gbp_endpoint_group_walk(gbp_endpoint_group_cb_t cb, void *ctx)
#define foreach_gbp_api_msg
Definition: gbp_api.c:62
static int gub_subnet_type_from_api(vl_api_gbp_subnet_type_t a, gbp_subnet_type_t *t)
Definition: gbp_api.c:387