FD.io VPP  v19.04.1-1-ge4a0f9f
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_VXLAN_TUNNEL_ADD, gbp_vxlan_tunnel_add) \
84  _(GBP_VXLAN_TUNNEL_DEL, gbp_vxlan_tunnel_del) \
85  _(GBP_VXLAN_TUNNEL_DUMP, gbp_vxlan_tunnel_dump)
86 
88 
90 
91 #define GBP_MSG_BASE msg_id_base
92 
94 gbp_endpoint_flags_decode (vl_api_gbp_endpoint_flags_t v)
95 {
97 
98  v = ntohl (v);
99 
108 
109  return (f);
110 }
111 
112 static vl_api_gbp_endpoint_flags_t
114 {
115  vl_api_gbp_endpoint_flags_t v = 0;
116 
117 
118  if (f & GBP_ENDPOINT_FLAG_BOUNCE)
120  if (f & GBP_ENDPOINT_FLAG_REMOTE)
122  if (f & GBP_ENDPOINT_FLAG_LEARNT)
126 
127  v = htonl (v);
128 
129  return (v);
130 }
131 
132 static void
134 {
137  u32 sw_if_index, handle;
138  ip46_address_t *ips;
140  int rv = 0, ii;
141 
143 
144  gef = gbp_endpoint_flags_decode (mp->endpoint.flags), ips = NULL;
145  sw_if_index = ntohl (mp->endpoint.sw_if_index);
146 
147  if (mp->endpoint.n_ips)
148  {
149  vec_validate (ips, mp->endpoint.n_ips - 1);
150 
151  vec_foreach_index (ii, ips)
152  {
153  ip_address_decode (&mp->endpoint.ips[ii], &ips[ii]);
154  }
155  }
156  mac_address_decode (mp->endpoint.mac, &mac);
157 
158  if (GBP_ENDPOINT_FLAG_REMOTE & gef)
159  {
160  ip46_address_t tun_src, tun_dst;
161 
162  ip_address_decode (&mp->endpoint.tun.src, &tun_src);
163  ip_address_decode (&mp->endpoint.tun.dst, &tun_dst);
164 
165  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
166  sw_if_index, ips, &mac,
168  ntohs (mp->endpoint.sclass),
169  gef, &tun_src, &tun_dst, &handle);
170  }
171  else
172  {
173  rv = gbp_endpoint_update_and_lock (GBP_ENDPOINT_SRC_CP,
174  sw_if_index, ips, &mac,
176  ntohs (mp->endpoint.sclass),
177  gef, NULL, NULL, &handle);
178  }
179  vec_free (ips);
181 
182  /* *INDENT-OFF* */
183  REPLY_MACRO2 (VL_API_GBP_ENDPOINT_ADD_REPLY + GBP_MSG_BASE,
184  ({
185  rmp->handle = htonl (handle);
186  }));
187  /* *INDENT-ON* */
188 }
189 
190 static void
192 {
193  vl_api_gbp_endpoint_del_reply_t *rmp;
194  int rv = 0;
195 
196  gbp_endpoint_unlock (GBP_ENDPOINT_SRC_CP, ntohl (mp->handle));
197 
198  REPLY_MACRO (VL_API_GBP_ENDPOINT_DEL_REPLY + GBP_MSG_BASE);
199 }
200 
201 typedef struct gbp_walk_ctx_t_
202 {
206 
207 static walk_rc_t
209 {
211  gbp_endpoint_loc_t *gel;
212  gbp_endpoint_fwd_t *gef;
213  gbp_endpoint_t *ge;
215  u8 n_ips, ii;
216 
217  ctx = args;
218  ge = gbp_endpoint_get (gei);
219 
220  n_ips = vec_len (ge->ge_key.gek_ips);
221  mp = vl_msg_api_alloc (sizeof (*mp) + (sizeof (*mp->endpoint.ips) * n_ips));
222  if (!mp)
223  return 1;
224 
225  clib_memset (mp, 0, sizeof (*mp));
226  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_DETAILS + GBP_MSG_BASE);
227  mp->context = ctx->context;
228 
229  gel = &ge->ge_locs[0];
230  gef = &ge->ge_fwd;
231 
232  if (gbp_endpoint_is_remote (ge))
233  {
234  mp->endpoint.sw_if_index = ntohl (gel->tun.gel_parent_sw_if_index);
236  &mp->endpoint.tun.src);
238  &mp->endpoint.tun.dst);
239  }
240  else
241  {
242  mp->endpoint.sw_if_index = ntohl (gef->gef_itf);
243  }
244  mp->endpoint.sclass = ntohs (ge->ge_fwd.gef_sclass);
245  mp->endpoint.n_ips = n_ips;
246  mp->endpoint.flags = gbp_endpoint_flags_encode (gef->gef_flags);
247  mp->handle = htonl (gei);
248  mp->age = vlib_time_now (vlib_get_main ()) - ge->ge_last_time;
249  mac_address_encode (&ge->ge_key.gek_mac, mp->endpoint.mac);
250 
252  {
254  IP46_TYPE_ANY, &mp->endpoint.ips[ii]);
255  }
256 
257  vl_api_send_msg (ctx->reg, (u8 *) mp);
258 
259  return (WALK_CONTINUE);
260 }
261 
262 static void
264 {
266 
268  if (!reg)
269  return;
270 
271  gbp_walk_ctx_t ctx = {
272  .reg = reg,
273  .context = mp->context,
274  };
275 
277 }
278 
279 static void
280 gbp_retention_decode (const vl_api_gbp_endpoint_retention_t * in,
282 {
283  out->remote_ep_timeout = ntohl (in->remote_ep_timeout);
284 }
285 
286 static void
289 {
290  vl_api_gbp_endpoint_group_add_reply_t *rmp;
291  gbp_endpoint_retention_t retention;
292  int rv = 0;
293 
294  gbp_retention_decode (&mp->epg.retention, &retention);
295 
296  rv = gbp_endpoint_group_add_and_lock (ntohl (mp->epg.vnid),
297  ntohs (mp->epg.sclass),
298  ntohl (mp->epg.bd_id),
299  ntohl (mp->epg.rd_id),
300  ntohl (mp->epg.uplink_sw_if_index),
301  &retention);
302 
303  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_ADD_REPLY + GBP_MSG_BASE);
304 }
305 
306 static void
309 {
310  vl_api_gbp_endpoint_group_del_reply_t *rmp;
311  int rv = 0;
312 
313  rv = gbp_endpoint_group_delete (ntohs (mp->sclass));
314 
315  REPLY_MACRO (VL_API_GBP_ENDPOINT_GROUP_DEL_REPLY + GBP_MSG_BASE);
316 }
317 
319 gbp_bridge_domain_flags_from_api (vl_api_gbp_bridge_domain_flags_t a)
320 {
322 
323  g = GBP_BD_FLAG_NONE;
324  a = clib_net_to_host_u32 (a);
325 
334 
335  return (g);
336 }
337 
338 static void
340 {
341  vl_api_gbp_bridge_domain_add_reply_t *rmp;
342  int rv = 0;
343 
344  rv = gbp_bridge_domain_add_and_lock (ntohl (mp->bd.bd_id),
346  (mp->bd.flags),
347  ntohl (mp->bd.bvi_sw_if_index),
348  ntohl (mp->bd.uu_fwd_sw_if_index),
349  ntohl (mp->bd.bm_flood_sw_if_index));
350 
351  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
352 }
353 
354 static void
356 {
357  vl_api_gbp_bridge_domain_del_reply_t *rmp;
358  int rv = 0;
359 
360  rv = gbp_bridge_domain_delete (ntohl (mp->bd_id));
361 
362  REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
363 }
364 
365 static void
367 {
368  vl_api_gbp_route_domain_add_reply_t *rmp;
369  int rv = 0;
370 
371  rv = gbp_route_domain_add_and_lock (ntohl (mp->rd.rd_id),
372  ntohl (mp->rd.ip4_table_id),
373  ntohl (mp->rd.ip6_table_id),
374  ntohl (mp->rd.ip4_uu_sw_if_index),
375  ntohl (mp->rd.ip6_uu_sw_if_index));
376 
377  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_ADD_REPLY + GBP_MSG_BASE);
378 }
379 
380 static void
382 {
383  vl_api_gbp_route_domain_del_reply_t *rmp;
384  int rv = 0;
385 
386  rv = gbp_route_domain_delete (ntohl (mp->rd_id));
387 
388  REPLY_MACRO (VL_API_GBP_ROUTE_DOMAIN_DEL_REPLY + GBP_MSG_BASE);
389 }
390 
391 static int
392 gub_subnet_type_from_api (vl_api_gbp_subnet_type_t a, gbp_subnet_type_t * t)
393 {
394  a = clib_net_to_host_u32 (a);
395 
396  switch (a)
397  {
400  return (0);
402  *t = GBP_SUBNET_L3_OUT;
403  return (0);
406  return (0);
409  return (0);
410  }
411 
412  return (-1);
413 }
414 
415 static void
417 {
418  vl_api_gbp_subnet_add_del_reply_t *rmp;
419  gbp_subnet_type_t type;
420  fib_prefix_t pfx;
421  int rv = 0;
422 
423  ip_prefix_decode (&mp->subnet.prefix, &pfx);
424 
425  rv = gub_subnet_type_from_api (mp->subnet.type, &type);
426 
427  if (0 != rv)
428  goto out;
429 
430  if (mp->is_add)
431  rv = gbp_subnet_add (ntohl (mp->subnet.rd_id),
432  &pfx, type,
433  ntohl (mp->subnet.sw_if_index),
434  ntohs (mp->subnet.sclass));
435  else
436  rv = gbp_subnet_del (ntohl (mp->subnet.rd_id), &pfx);
437 
438 out:
439  REPLY_MACRO (VL_API_GBP_SUBNET_ADD_DEL_REPLY + GBP_MSG_BASE);
440 }
441 
442 static vl_api_gbp_subnet_type_t
444 {
445  vl_api_gbp_subnet_type_t a = 0;
446 
447  switch (t)
448  {
451  break;
454  break;
457  break;
458  case GBP_SUBNET_L3_OUT:
460  break;
461  }
462 
463  a = clib_host_to_net_u32 (a);
464 
465  return (a);
466 }
467 
468 static walk_rc_t
470  const fib_prefix_t * pfx,
471  gbp_subnet_type_t type,
472  u32 sw_if_index, sclass_t sclass, void *args)
473 {
476 
477  ctx = args;
478  mp = vl_msg_api_alloc (sizeof (*mp));
479  if (!mp)
480  return 1;
481 
482  clib_memset (mp, 0, sizeof (*mp));
483  mp->_vl_msg_id = ntohs (VL_API_GBP_SUBNET_DETAILS + GBP_MSG_BASE);
484  mp->context = ctx->context;
485 
486  mp->subnet.type = gub_subnet_type_to_api (type);
487  mp->subnet.sw_if_index = ntohl (sw_if_index);
488  mp->subnet.sclass = ntohs (sclass);
489  mp->subnet.rd_id = ntohl (rd_id);
490  ip_prefix_encode (pfx, &mp->subnet.prefix);
491 
492  vl_api_send_msg (ctx->reg, (u8 *) mp);
493 
494  return (WALK_CONTINUE);
495 }
496 
497 static void
499 {
501 
503  if (!reg)
504  return;
505 
506  gbp_walk_ctx_t ctx = {
507  .reg = reg,
508  .context = mp->context,
509  };
510 
512 }
513 
514 static int
516 {
519 
520  ctx = args;
521  mp = vl_msg_api_alloc (sizeof (*mp));
522  if (!mp)
523  return 1;
524 
525  clib_memset (mp, 0, sizeof (*mp));
526  mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_GROUP_DETAILS + GBP_MSG_BASE);
527  mp->context = ctx->context;
528 
529  mp->epg.uplink_sw_if_index = ntohl (gg->gg_uplink_sw_if_index);
530  mp->epg.vnid = ntohl (gg->gg_vnid);
531  mp->epg.sclass = ntohs (gg->gg_sclass);
532  mp->epg.bd_id = ntohl (gbp_endpoint_group_get_bd_id (gg));
533  mp->epg.rd_id = ntohl (gbp_route_domain_get_rd_id (gg->gg_rd));
534 
535  vl_api_send_msg (ctx->reg, (u8 *) mp);
536 
537  return (1);
538 }
539 
540 static void
542  mp)
543 {
545 
547  if (!reg)
548  return;
549 
550  gbp_walk_ctx_t ctx = {
551  .reg = reg,
552  .context = mp->context,
553  };
554 
556 }
557 
558 static int
560 {
563 
564  ctx = args;
565  mp = vl_msg_api_alloc (sizeof (*mp));
566  if (!mp)
567  return 1;
568 
569  memset (mp, 0, sizeof (*mp));
570  mp->_vl_msg_id = ntohs (VL_API_GBP_BRIDGE_DOMAIN_DETAILS + GBP_MSG_BASE);
571  mp->context = ctx->context;
572 
573  mp->bd.bd_id = ntohl (gb->gb_bd_id);
574  mp->bd.bvi_sw_if_index = ntohl (gb->gb_bvi_sw_if_index);
575  mp->bd.uu_fwd_sw_if_index = ntohl (gb->gb_uu_fwd_sw_if_index);
576  mp->bd.bm_flood_sw_if_index = ntohl (gb->gb_bm_flood_sw_if_index);
577 
578  vl_api_send_msg (ctx->reg, (u8 *) mp);
579 
580  return (1);
581 }
582 
583 static void
585 {
587 
589  if (!reg)
590  return;
591 
592  gbp_walk_ctx_t ctx = {
593  .reg = reg,
594  .context = mp->context,
595  };
596 
598 }
599 
600 static int
602 {
605 
606  ctx = args;
607  mp = vl_msg_api_alloc (sizeof (*mp));
608  if (!mp)
609  return 1;
610 
611  memset (mp, 0, sizeof (*mp));
612  mp->_vl_msg_id = ntohs (VL_API_GBP_ROUTE_DOMAIN_DETAILS + GBP_MSG_BASE);
613  mp->context = ctx->context;
614 
615  mp->rd.rd_id = ntohl (grd->grd_id);
616  mp->rd.ip4_uu_sw_if_index =
617  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP4]);
618  mp->rd.ip6_uu_sw_if_index =
619  ntohl (grd->grd_uu_sw_if_index[FIB_PROTOCOL_IP6]);
620 
621  vl_api_send_msg (ctx->reg, (u8 *) mp);
622 
623  return (1);
624 }
625 
626 static void
628 {
630 
632  if (!reg)
633  return;
634 
635  gbp_walk_ctx_t ctx = {
636  .reg = reg,
637  .context = mp->context,
638  };
639 
641 }
642 
643 static void
645 {
646  vl_api_gbp_recirc_add_del_reply_t *rmp;
648  int rv = 0;
649 
650  sw_if_index = ntohl (mp->recirc.sw_if_index);
651  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
652  goto bad_sw_if_index;
653 
654  if (mp->is_add)
655  rv = gbp_recirc_add (sw_if_index,
656  ntohs (mp->recirc.sclass), mp->recirc.is_ext);
657  else
658  rv = gbp_recirc_delete (sw_if_index);
659 
661 
662  REPLY_MACRO (VL_API_GBP_RECIRC_ADD_DEL_REPLY + GBP_MSG_BASE);
663 }
664 
665 static walk_rc_t
667 {
670 
671  ctx = args;
672  mp = vl_msg_api_alloc (sizeof (*mp));
673  if (!mp)
674  return (WALK_STOP);
675 
676  clib_memset (mp, 0, sizeof (*mp));
677  mp->_vl_msg_id = ntohs (VL_API_GBP_RECIRC_DETAILS + GBP_MSG_BASE);
678  mp->context = ctx->context;
679 
680  mp->recirc.sclass = ntohs (gr->gr_sclass);
681  mp->recirc.sw_if_index = ntohl (gr->gr_sw_if_index);
682  mp->recirc.is_ext = gr->gr_is_ext;
683 
684  vl_api_send_msg (ctx->reg, (u8 *) mp);
685 
686  return (WALK_CONTINUE);
687 }
688 
689 static void
691 {
693 
695  if (!reg)
696  return;
697 
698  gbp_walk_ctx_t ctx = {
699  .reg = reg,
700  .context = mp->context,
701  };
702 
704 }
705 
706 static void
708 {
709  vl_api_gbp_ext_itf_add_del_reply_t *rmp;
710  u32 sw_if_index = ~0;
711  vl_api_gbp_ext_itf_t *ext_itf;
712  int rv = 0;
713 
714  ext_itf = &mp->ext_itf;
715  if (ext_itf)
716  sw_if_index = ntohl (ext_itf->sw_if_index);
717 
718  if (!vnet_sw_if_index_is_api_valid (sw_if_index))
719  goto bad_sw_if_index;
720 
721  if (mp->is_add)
722  rv = gbp_ext_itf_add (sw_if_index,
723  ntohl (ext_itf->bd_id), ntohl (ext_itf->rd_id));
724  else
725  rv = gbp_ext_itf_delete (sw_if_index);
726 
728 
729  REPLY_MACRO (VL_API_GBP_EXT_ITF_ADD_DEL_REPLY + GBP_MSG_BASE);
730 }
731 
732 static walk_rc_t
734 {
737 
738  ctx = args;
739  mp = vl_msg_api_alloc (sizeof (*mp));
740  if (!mp)
741  return (WALK_STOP);
742 
743  clib_memset (mp, 0, sizeof (*mp));
744  mp->_vl_msg_id = ntohs (VL_API_GBP_EXT_ITF_DETAILS + GBP_MSG_BASE);
745  mp->context = ctx->context;
746 
747  mp->ext_itf.bd_id = ntohl (gbp_bridge_domain_get_bd_id (gx->gx_bd));
748  mp->ext_itf.rd_id = ntohl (gbp_route_domain_get_rd_id (gx->gx_rd));
749  mp->ext_itf.sw_if_index = ntohl (gx->gx_itf);
750 
751  vl_api_send_msg (ctx->reg, (u8 *) mp);
752 
753  return (WALK_CONTINUE);
754 }
755 
756 static void
758 {
760 
762  if (!reg)
763  return;
764 
765  gbp_walk_ctx_t ctx = {
766  .reg = reg,
767  .context = mp->context,
768  };
769 
771 }
772 
773 static int
774 gbp_contract_rule_action_deocde (vl_api_gbp_rule_action_t in,
775  gbp_rule_action_t * out)
776 {
777  in = clib_net_to_host_u32 (in);
778 
779  switch (in)
780  {
781  case GBP_API_RULE_PERMIT:
782  *out = GBP_RULE_PERMIT;
783  return (0);
784  case GBP_API_RULE_DENY:
785  *out = GBP_RULE_DENY;
786  return (0);
788  *out = GBP_RULE_REDIRECT;
789  return (0);
790  }
791 
792  return (-1);
793 }
794 
795 static int
796 gbp_hash_mode_decode (vl_api_gbp_hash_mode_t in, gbp_hash_mode_t * out)
797 {
798  in = clib_net_to_host_u32 (in);
799 
800  switch (in)
801  {
803  *out = GBP_HASH_MODE_SRC_IP;
804  return (0);
806  *out = GBP_HASH_MODE_DST_IP;
807  return (0);
809  *out = GBP_HASH_MODE_SYMMETRIC;
810  return (0);
811  }
812 
813  return (-2);
814 }
815 
816 static int
817 gbp_next_hop_decode (const vl_api_gbp_next_hop_t * in, index_t * gnhi)
818 {
819  ip46_address_t ip;
821  index_t grd, gbd;
822 
823  gbd = gbp_bridge_domain_find_and_lock (ntohl (in->bd_id));
824 
825  if (INDEX_INVALID == gbd)
826  return (VNET_API_ERROR_BD_NOT_MODIFIABLE);
827 
828  grd = gbp_route_domain_find_and_lock (ntohl (in->rd_id));
829 
830  if (INDEX_INVALID == grd)
831  return (VNET_API_ERROR_NO_SUCH_FIB);
832 
833  ip_address_decode (&in->ip, &ip);
834  mac_address_decode (in->mac, &mac);
835 
836  *gnhi = gbp_next_hop_alloc (&ip, grd, &mac, gbd);
837 
838  return (0);
839 }
840 
841 static int
842 gbp_next_hop_set_decode (const vl_api_gbp_next_hop_set_t * in,
843  gbp_hash_mode_t * hash_mode, index_t ** out)
844 {
845 
846  index_t *gnhis = NULL;
847  int rv;
848  u8 ii;
849 
850  rv = gbp_hash_mode_decode (in->hash_mode, hash_mode);
851 
852  if (0 != rv)
853  return rv;
854 
855  vec_validate (gnhis, in->n_nhs - 1);
856 
857  for (ii = 0; ii < in->n_nhs; ii++)
858  {
859  rv = gbp_next_hop_decode (&in->nhs[ii], &gnhis[ii]);
860 
861  if (0 != rv)
862  {
863  vec_free (gnhis);
864  break;
865  }
866  }
867 
868  *out = gnhis;
869  return (rv);
870 }
871 
872 static int
873 gbp_contract_rule_decode (const vl_api_gbp_rule_t * in, index_t * gui)
874 {
875  gbp_hash_mode_t hash_mode;
876  gbp_rule_action_t action;
877  index_t *nhs = NULL;
878  int rv;
879 
880  rv = gbp_contract_rule_action_deocde (in->action, &action);
881 
882  if (0 != rv)
883  return rv;
884 
885  if (GBP_RULE_REDIRECT == action)
886  {
887  rv = gbp_next_hop_set_decode (&in->nh_set, &hash_mode, &nhs);
888 
889  if (0 != rv)
890  return (rv);
891  }
892  else
893  {
894  hash_mode = GBP_HASH_MODE_SRC_IP;
895  }
896 
897  *gui = gbp_rule_alloc (action, hash_mode, nhs);
898 
899  return (rv);
900 }
901 
902 static int
904  const vl_api_gbp_rule_t * rules, index_t ** out)
905 {
906  index_t *guis = NULL;
907  int rv;
908  u8 ii;
909 
910  if (0 == n_rules)
911  {
912  *out = NULL;
913  return (0);
914  }
915 
916  vec_validate (guis, n_rules - 1);
917 
918  for (ii = 0; ii < n_rules; ii++)
919  {
920  rv = gbp_contract_rule_decode (&rules[ii], &guis[ii]);
921 
922  if (0 != rv)
923  {
924  vec_free (guis);
925  return (rv);
926  }
927  }
928 
929  *out = guis;
930  return (rv);
931 }
932 
933 static void
935 {
938  u32 stats_index = ~0;
939  index_t *rules;
940  int ii, rv = 0;
941  u8 n_et;
942 
943  if (mp->is_add)
944  {
945  rv = gbp_contract_rules_decode (mp->contract.n_rules,
946  mp->contract.rules, &rules);
947  if (0 != rv)
948  goto out;
949 
950  allowed_ethertypes = NULL;
951 
952  /*
953  * allowed ether types
954  */
955  n_et = mp->contract.n_ether_types;
956  vec_validate (allowed_ethertypes, n_et - 1);
957 
958  for (ii = 0; ii < n_et; ii++)
959  {
960  /* leave the ether types in network order */
961  allowed_ethertypes[ii] = mp->contract.allowed_ethertypes[ii];
962  }
963 
964  rv = gbp_contract_update (ntohs (mp->contract.sclass),
965  ntohs (mp->contract.dclass),
966  ntohl (mp->contract.acl_index),
967  rules, allowed_ethertypes, &stats_index);
968  }
969  else
970  rv = gbp_contract_delete (ntohs (mp->contract.sclass),
971  ntohs (mp->contract.dclass));
972 
973 out:
974  /* *INDENT-OFF* */
975  REPLY_MACRO2 (VL_API_GBP_CONTRACT_ADD_DEL_REPLY + GBP_MSG_BASE,
976  ({
977  rmp->stats_index = htonl (stats_index);
978  }));
979  /* *INDENT-ON* */
980 }
981 
982 static int
984 {
987 
988  ctx = args;
989  mp = vl_msg_api_alloc (sizeof (*mp));
990  if (!mp)
991  return 1;
992 
993  clib_memset (mp, 0, sizeof (*mp));
994  mp->_vl_msg_id = ntohs (VL_API_GBP_CONTRACT_DETAILS + GBP_MSG_BASE);
995  mp->context = ctx->context;
996 
997  mp->contract.sclass = ntohs (gbpc->gc_key.gck_src);
998  mp->contract.dclass = ntohs (gbpc->gc_key.gck_dst);
999  mp->contract.acl_index = ntohl (gbpc->gc_acl_index);
1000 
1001  vl_api_send_msg (ctx->reg, (u8 *) mp);
1002 
1003  return (1);
1004 }
1005 
1006 static void
1008 {
1010 
1012  if (!reg)
1013  return;
1014 
1015  gbp_walk_ctx_t ctx = {
1016  .reg = reg,
1017  .context = mp->context,
1018  };
1019 
1021 }
1022 
1023 static int
1024 gbp_vxlan_tunnel_mode_2_layer (vl_api_gbp_vxlan_tunnel_mode_t mode,
1026 {
1027  mode = clib_net_to_host_u32 (mode);
1028 
1029  switch (mode)
1030  {
1032  *l = GBP_VXLAN_TUN_L2;
1033  return (0);
1035  *l = GBP_VXLAN_TUN_L3;
1036  return (0);
1037  }
1038  return (-1);
1039 }
1040 
1041 static void
1043 {
1047  u32 sw_if_index;
1048  int rv = 0;
1049 
1050  ip4_address_decode (mp->tunnel.src, &src);
1051  rv = gbp_vxlan_tunnel_mode_2_layer (mp->tunnel.mode, &layer);
1052 
1053  if (0 != rv)
1054  goto out;
1055 
1056  rv = gbp_vxlan_tunnel_add (ntohl (mp->tunnel.vni),
1057  layer,
1058  ntohl (mp->tunnel.bd_rd_id), &src, &sw_if_index);
1059 
1060 out:
1061  /* *INDENT-OFF* */
1062  REPLY_MACRO2 (VL_API_GBP_VXLAN_TUNNEL_ADD_REPLY + GBP_MSG_BASE,
1063  ({
1064  rmp->sw_if_index = htonl (sw_if_index);
1065  }));
1066  /* *INDENT-ON* */
1067 }
1068 
1069 static void
1071 {
1072  vl_api_gbp_vxlan_tunnel_del_reply_t *rmp;
1073  int rv = 0;
1074 
1075  rv = gbp_vxlan_tunnel_del (ntohl (mp->tunnel.vni));
1076 
1077  REPLY_MACRO (VL_API_GBP_VXLAN_TUNNEL_DEL_REPLY + GBP_MSG_BASE);
1078 }
1079 
1080 static vl_api_gbp_vxlan_tunnel_mode_t
1082 {
1083  vl_api_gbp_vxlan_tunnel_mode_t mode = GBP_VXLAN_TUNNEL_MODE_L2;
1084 
1085  switch (layer)
1086  {
1087  case GBP_VXLAN_TUN_L2:
1088  mode = GBP_VXLAN_TUNNEL_MODE_L2;
1089  break;
1090  case GBP_VXLAN_TUN_L3:
1091  mode = GBP_VXLAN_TUNNEL_MODE_L3;
1092  break;
1093  }
1094  mode = clib_host_to_net_u32 (mode);
1095 
1096  return (mode);
1097 }
1098 
1099 static walk_rc_t
1101 {
1104 
1105  ctx = args;
1106  mp = vl_msg_api_alloc (sizeof (*mp));
1107  if (!mp)
1108  return 1;
1109 
1110  memset (mp, 0, sizeof (*mp));
1111  mp->_vl_msg_id = htons (VL_API_GBP_VXLAN_TUNNEL_DETAILS + GBP_MSG_BASE);
1112  mp->context = ctx->context;
1113 
1114  mp->tunnel.vni = htonl (gt->gt_vni);
1116  mp->tunnel.bd_rd_id = htonl (gt->gt_bd_rd_id);
1117 
1118  vl_api_send_msg (ctx->reg, (u8 *) mp);
1119 
1120  return (1);
1121 }
1122 
1123 static void
1125 {
1127 
1129  if (!reg)
1130  return;
1131 
1132  gbp_walk_ctx_t ctx = {
1133  .reg = reg,
1134  .context = mp->context,
1135  };
1136 
1138 }
1139 
1140 /*
1141  * gbp_api_hookup
1142  * Add vpe's API message handlers to the table.
1143  * vlib has already mapped shared memory and
1144  * added the client registration handlers.
1145  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1146  */
1147 #define vl_msg_name_crc_list
1148 #include <gbp/gbp_all_api_h.h>
1149 #undef vl_msg_name_crc_list
1150 
1151 static void
1153 {
1154 #define _(id,n,crc) \
1155  vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + GBP_MSG_BASE);
1156  foreach_vl_msg_name_crc_gbp;
1157 #undef _
1158 }
1159 
1160 static void
1162 {
1163 #define _(N,n) \
1164  vl_msg_api_set_handlers(VL_API_##N + GBP_MSG_BASE, \
1165  #n, \
1166  vl_api_##n##_t_handler, \
1167  vl_noop_handler, \
1168  vl_api_##n##_t_endian, \
1169  vl_api_##n##_t_print, \
1170  sizeof(vl_api_##n##_t), 1);
1172 #undef _
1173 }
1174 
1175 static clib_error_t *
1177 {
1178  api_main_t *am = &api_main;
1179  gbp_main_t *gbpm = &gbp_main;
1180  u8 *name = format (0, "gbp_%08x%c", api_version, 0);
1181 
1182  gbpm->gbp_acl_user_id = ~0;
1183 
1184  /* Ask for a correctly-sized block of API message decode slots */
1185  msg_id_base = vl_msg_api_get_msg_ids ((char *) name,
1187  gbp_api_hookup (vm);
1188 
1189  /* Add our API messages to the global name_crc hash table */
1191 
1192  vec_free (name);
1193  return (NULL);
1194 }
1195 
1197 
1198 /* *INDENT-OFF* */
1199 VLIB_PLUGIN_REGISTER () = {
1200  .version = VPP_BUILD_VER,
1201  .description = "Group Based Policy (GBP)",
1202 };
1203 /* *INDENT-ON* */
1204 
1205 
1206 /*
1207  * fd.io coding-style-patch-verification: ON
1208  *
1209  * Local Variables:
1210  * eval: (c-set-style "gnu")
1211  * End:
1212  */
#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)
u32 sw_if_index
Definition: ipsec_gre.api:37
VLIB_PLUGIN_REGISTER()
sclass_t gr_sclass
EPG ID that packets will classify to when they arrive on this recirc.
Definition: gbp_recirc.h:33
#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:1124
void gbp_subnet_walk(gbp_subnet_cb_t cb, void *ctx)
Definition: gbp_subnet.c:300
int gbp_endpoint_is_remote(const gbp_endpoint_t *ge)
Definition: gbp_endpoint.c:87
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:262
f64 ge_last_time
The last time a packet from seen from this end point.
Definition: gbp_endpoint.h:210
static int gbp_contract_send_details(gbp_contract_t *gbpc, void *args)
Definition: gbp_api.c:983
u16 sclass_t
Definition: gbp_types.h:24
A Group Based Policy Endpoint.
Definition: gbp_endpoint.h:187
static int gbp_contract_rules_decode(u8 n_rules, const vl_api_gbp_rule_t *rules, index_t **out)
Definition: gbp_api.c:903
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:133
vl_api_gbp_endpoint_group_t epg
Definition: gbp.api:180
gbp_contract_key_t gc_key
source and destination EPGs
Definition: gbp_contract.h:124
vl_api_gbp_endpoint_t endpoint
Definition: gbp.api:130
static gbp_endpoint_flags_t gbp_endpoint_flags_decode(vl_api_gbp_endpoint_flags_t v)
Definition: gbp_api.c:94
static gbp_bridge_domain_flags_t gbp_bridge_domain_flags_from_api(vl_api_gbp_bridge_domain_flags_t a)
Definition: gbp_api.c:319
gbp_main_t gbp_main
Definition: gbp_api.c:87
vl_api_gbp_subnet_t subnet
Definition: gbp.api:262
a
Definition: bitmap.h:538
void gbp_endpoint_unlock(gbp_endpoint_src_t src, index_t gei)
Definition: gbp_endpoint.c:920
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
Definition: ip_types_api.c:122
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:205
gbp_endpoint_key_t ge_key
The key/ID of this EP.
Definition: gbp_endpoint.h:197
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)
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:58
gbp_endpoint_flags_t gef_flags
Definition: gbp_endpoint.h:176
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:255
static void vl_api_gbp_recirc_dump_t_handler(vl_api_gbp_recirc_dump_t *mp)
Definition: gbp_api.c:690
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
static void gbp_retention_decode(const vl_api_gbp_endpoint_retention_t *in, gbp_endpoint_retention_t *out)
Definition: gbp_api.c:280
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:468
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:307
vl_api_gbp_vxlan_tunnel_t tunnel
Definition: gbp.api:387
static void vl_api_gbp_vxlan_tunnel_del_t_handler(vl_api_gbp_vxlan_tunnel_add_t *mp)
Definition: gbp_api.c:1070
void gbp_vxlan_walk(gbp_vxlan_cb_t cb, void *ctx)
Definition: gbp_vxlan.c:330
vl_api_gbp_vxlan_tunnel_t tunnel
Definition: gbp.api:361
u32 rd_id
Definition: gbp.api:270
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
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.
vl_api_gbp_ext_itf_t ext_itf
Definition: gbp.api:414
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:515
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:934
int gbp_subnet_del(u32 rd_id, const fib_prefix_t *pfx)
Definition: gbp_subnet.c:221
unsigned char u8
Definition: types.h:56
static u16 msg_id_base
Definition: gbp_api.c:89
static void vl_api_gbp_bridge_domain_add_t_handler(vl_api_gbp_bridge_domain_add_t *mp)
Definition: gbp_api.c:339
vl_api_gbp_endpoint_retention_t retention
Definition: gbp.api:173
static int gbp_contract_rule_action_deocde(vl_api_gbp_rule_action_t in, gbp_rule_action_t *out)
Definition: gbp_api.c:774
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:1042
int gbp_contract_update(sclass_t sclass, sclass_t dclass, u32 acl_index, index_t *rules, u16 *allowed_ethertypes, u32 *stats_index)
Definition: gbp_contract.c:447
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:60
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:601
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:246
static vl_api_gbp_subnet_type_t gub_subnet_type_to_api(gbp_subnet_type_t t)
Definition: gbp_api.c:443
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:381
static void setup_message_id_table(api_main_t *am)
Definition: gbp_api.c:1152
u8 n_ips
Definition: gbp.api:122
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
static vl_api_gbp_endpoint_flags_t gbp_endpoint_flags_encode(gbp_endpoint_flags_t f)
Definition: gbp_api.c:113
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
Definition: ip_types_api.c:83
static walk_rc_t gbp_endpoint_send_details(index_t gei, void *args)
Definition: gbp_api.c:208
int gbp_ext_itf_delete(u32 sw_if_index)
Definition: gbp_ext_itf.c:106
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, u32 bm_flood_sw_if_index)
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:469
static void vl_api_gbp_endpoint_group_add_t_handler(vl_api_gbp_endpoint_group_add_t *mp)
Definition: gbp_api.c:288
static void vl_api_gbp_contract_dump_t_handler(vl_api_gbp_contract_dump_t *mp)
Definition: gbp_api.c:1007
int gbp_route_domain_delete(u32 rd_id)
long ctx[MAX_CONNS]
Definition: main.c:144
unsigned short u16
Definition: types.h:57
sclass_t gck_src
source and destination EPGs for which the ACL applies
Definition: gbp_contract.h:43
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:118
static vl_api_gbp_vxlan_tunnel_mode_t gbp_vxlan_tunnel_layer_2_mode(gbp_vxlan_tunnel_layer_t layer)
Definition: gbp_api.c:1081
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.
u32 remote_ep_timeout
Aging timeout for remote endpoints.
vl_api_gbp_next_hop_t nhs[8]
Definition: gbp.api:284
vl_api_ip4_address_t src
Definition: ipsec_gre.api:38
u32 gb_bd_id
Bridge-domain ID.
sclass_t gef_sclass
Endpoint Group&#39;s sclass.
Definition: gbp_endpoint.h:169
u8 name[64]
Definition: memclnt.api:152
mac_address_t gek_mac
MAC address of the endpoint.
Definition: gbp_endpoint.h:96
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:824
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:44
static void vl_api_gbp_recirc_add_del_t_handler(vl_api_gbp_recirc_add_del_t *mp)
Definition: gbp_api.c:644
An API client registration, only in vpp/vlib.
Definition: api_common.h:45
#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
u32 gb_bm_flood_sw_if_index
The BD&#39;s interface to sned Broadcast and multicast packets.
static void vl_api_gbp_bridge_domain_dump_t_handler(vl_api_gbp_bridge_domain_dump_t *mp)
Definition: gbp_api.c:584
int gbp_contract_delete(sclass_t sclass, sclass_t dclass)
Definition: gbp_contract.c:516
vlib_main_t * vm
Definition: buffer.c:312
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:242
static void vl_api_gbp_ext_itf_add_del_t_handler(vl_api_gbp_ext_itf_add_del_t *mp)
Definition: gbp_api.c:707
static walk_rc_t gbp_vxlan_tunnel_send_details(gbp_vxlan_tunnel_t *gt, void *args)
Definition: gbp_api.c:1100
static void vl_api_gbp_subnet_add_del_t_handler(vl_api_gbp_subnet_add_del_t *mp)
Definition: gbp_api.c:416
int gbp_vxlan_tunnel_del(u32 vni)
Definition: gbp_vxlan.c:596
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
Definition: api.h:56
vl_api_gbp_endpoint_group_t epg
Definition: gbp.api:198
static void vl_api_gbp_route_domain_dump_t_handler(vl_api_gbp_route_domain_dump_t *mp)
Definition: gbp_api.c:627
vl_api_gbp_subnet_t subnet
Definition: gbp.api:250
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: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:308
static void vl_api_gbp_endpoint_dump_t_handler(vl_api_gbp_endpoint_dump_t *mp)
Definition: gbp_api.c:263
vl_api_gbp_contract_t contract
Definition: gbp.api:316
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:541
u32 gb_bvi_sw_if_index
The BD&#39;s BVI interface (obligatory)
vl_api_gbp_recirc_t recirc
Definition: gbp.api:213
static clib_error_t * gbp_init(vlib_main_t *vm)
Definition: gbp_api.c:1176
index_t gbp_rule_alloc(gbp_rule_action_t action, gbp_hash_mode_t hash_mode, index_t *nhs)
Definition: gbp_contract.c:55
static void gbp_api_hookup(vlib_main_t *vm)
Definition: gbp_api.c:1161
static void vl_api_gbp_ext_itf_dump_t_handler(vl_api_gbp_ext_itf_dump_t *mp)
Definition: gbp_api.c:757
static void vl_api_gbp_subnet_dump_t_handler(vl_api_gbp_subnet_dump_t *mp)
Definition: gbp_api.c:498
int gbp_bridge_domain_delete(u32 bd_id)
vl_api_gbp_contract_t contract
Definition: gbp.api:334
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:241
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
Definition: ip_types_api.c:139
static void vl_api_gbp_endpoint_del_t_handler(vl_api_gbp_endpoint_del_t *mp)
Definition: gbp_api.c:191
static void vl_api_gbp_route_domain_add_t_handler(vl_api_gbp_route_domain_add_t *mp)
Definition: gbp_api.c:366
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:842
And endpoints current forwarding state.
Definition: gbp_endpoint.h:154
vl_api_gbp_endpoint_t endpoint
Definition: gbp.api:158
static walk_rc_t gbp_recirc_send_details(gbp_recirc_t *gr, void *args)
Definition: gbp_api.c:666
#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:817
#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)
struct gbp_endpoint_loc_t_::@436 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:51
vl_api_registration_t * reg
Definition: gbp_api.c:203
void gbp_ext_itf_walk(gbp_ext_itf_cb_t cb, void *ctx)
Definition: gbp_ext_itf.c:134
static int gbp_bridge_domain_send_details(gbp_bridge_domain_t *gb, void *args)
Definition: gbp_api.c:559
static walk_rc_t gbp_ext_itf_send_details(gbp_ext_itf_t *gx, void *args)
Definition: gbp_api.c:733
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:100
int gbp_recirc_delete(u32 sw_if_index)
Definition: gbp_recirc.c:175
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:402
vl_api_gbp_route_domain_t rd
Definition: gbp.api:92
vl_api_address_t ips[n_ips]
Definition: gbp.api:123
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:355
#define GBP_MSG_BASE
Definition: gbp_api.c:91
static void vl_api_gbp_endpoint_group_del_t_handler(vl_api_gbp_endpoint_group_del_t *mp)
Definition: gbp_api.c:308
u16 allowed_ethertypes[16]
Definition: gbp.api:306
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:203
vl_api_gbp_route_domain_t rd
Definition: gbp.api:76
void gbp_contract_walk(gbp_contract_cb_t cb, void *ctx)
Definition: gbp_contract.c:544
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:873
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:120
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:796
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:1024
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:70
vl_api_gbp_recirc_t recirc
Definition: gbp.api:225
index_t gbp_route_domain_find_and_lock(u32 rd_id)
A Group Based Policy Contract.
Definition: gbp_contract.h:119
#define VALIDATE_SW_IF_INDEX(mp)
u16 vl_msg_api_get_msg_ids(const char *name, int n)
Definition: api_shared.c:880
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:392