23 #include <vpp/app/version.h> 42 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 48 #define vl_api_version(n,v) static u32 api_version=(v); 54 #define foreach_gbp_api_msg \ 55 _(GBP_ENDPOINT_ADD_DEL, gbp_endpoint_add_del) \ 56 _(GBP_ENDPOINT_DUMP, gbp_endpoint_dump) \ 57 _(GBP_SUBNET_ADD_DEL, gbp_subnet_add_del) \ 58 _(GBP_SUBNET_DUMP, gbp_subnet_dump) \ 59 _(GBP_ENDPOINT_GROUP_ADD_DEL, gbp_endpoint_group_add_del) \ 60 _(GBP_ENDPOINT_GROUP_DUMP, gbp_endpoint_group_dump) \ 61 _(GBP_RECIRC_ADD_DEL, gbp_recirc_add_del) \ 62 _(GBP_RECIRC_DUMP, gbp_recirc_dump) \ 63 _(GBP_CONTRACT_ADD_DEL, gbp_contract_add_del) \ 64 _(GBP_CONTRACT_DUMP, gbp_contract_dump) 76 #define GBP_MSG_BASE gbp_main.msg_id_base 81 vl_api_gbp_endpoint_add_del_reply_t *rmp;
82 ip46_address_t ip = { };
131 memset (mp, 0,
sizeof (*mp));
132 mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_DETAILS +
GBP_MSG_BASE);
174 vl_api_gbp_endpoint_group_add_del_reply_t *rmp;
175 u32 uplink_sw_if_index;
180 goto bad_sw_if_index;
203 vl_api_gbp_subnet_add_del_reply_t *rmp;
240 memset (mp, 0,
sizeof (*mp));
241 mp->_vl_msg_id = ntohs (VL_API_GBP_SUBNET_DETAILS +
GBP_MSG_BASE);
291 memset (mp, 0,
sizeof (*mp));
292 mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_GROUP_DETAILS +
GBP_MSG_BASE);
327 vl_api_gbp_recirc_add_del_reply_t *rmp;
333 goto bad_sw_if_index;
357 memset (mp, 0,
sizeof (*mp));
358 mp->_vl_msg_id = ntohs (VL_API_GBP_RECIRC_DETAILS +
GBP_MSG_BASE);
390 vl_api_gbp_contract_add_del_reply_t *rmp;
415 memset (mp, 0,
sizeof (*mp));
416 mp->_vl_msg_id = ntohs (VL_API_GBP_CONTRACT_DETAILS +
GBP_MSG_BASE);
452 #define vl_msg_name_crc_list 454 #undef vl_msg_name_crc_list 459 #define _(id,n,crc) \ 460 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + GBP_MSG_BASE); 461 foreach_vl_msg_name_crc_gbp;
469 vl_msg_api_set_handlers(VL_API_##N + GBP_MSG_BASE, \ 471 vl_api_##n##_t_handler, \ 473 vl_api_##n##_t_endian, \ 474 vl_api_##n##_t_print, \ 475 sizeof(vl_api_##n##_t), 1); 485 u8 *name =
format (0,
"gbp_%08x%c", api_version, 0);
504 .version = VPP_BUILD_VER,
505 .description =
"Group Based Policy",
fib_protocol_t fp_proto
protocol type
void gbp_subnet_walk(gbp_subnet_cb_t cb, void *ctx)
static int gbp_contract_send_details(gbp_contract_t *gbpc, void *args)
A Group Based Policy Endpoint.
gbp_contract_key_t gc_key
source and destination EPGs
static gbp_main_t gbp_main
vl_api_gbp_subnet_t subnet
static int gbp_subnet_send_details(u32 table_id, const fib_prefix_t *pfx, u32 sw_if_index, epg_id_t epg, u8 is_internal, void *args)
u32 gepg_bd
Bridge-domain ID the EPG is in.
static void vl_api_gbp_recirc_dump_t_handler(vl_api_gbp_recirc_dump_t *mp)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
gbp_endpoint_key_t * ge_key
The endpoint's interface and IP address.
static int gbp_recirc_send_details(gbp_recirc_t *gr, void *args)
void * vl_msg_api_alloc(int nbytes)
static void vl_api_gbp_contract_add_del_t_handler(vl_api_gbp_contract_add_del_t *mp)
u8 gr_is_ext
Is the interface for packets post-NAT translatoin (i.e.
u32 gek_sw_if_index
The interface on which the EP is connected.
int gbp_subnet_add_del(u32 table_id, const fib_prefix_t *pfx, u32 sw_if_index, epg_id_t epg, u8 is_add, u8 is_internal)
Aggregrate type for a prefix.
static void setup_message_id_table(api_main_t *am)
An Endpoint Group representation.
u16 fp_len
The mask length.
int gbp_endpoint_update(u32 sw_if_index, const ip46_address_t *ip, epg_id_t epg_id)
epg_id_t gr_epg
EPG ID that packets will classify to when they arrive on this recirc.
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
static void vl_api_gbp_contract_dump_t_handler(vl_api_gbp_contract_dump_t *mp)
void gbp_endpoint_group_delete(epg_id_t epg_id)
vl_api_gbp_endpoint_group_t epg
An Endpoint Group representation.
void gbp_contract_delete(epg_id_t src_epg, epg_id_t dst_epg)
API main structure, used by both vpp and binary API clients.
static void vl_api_gbp_recirc_add_del_t_handler(vl_api_gbp_recirc_add_del_t *mp)
#define ip46_address_is_ip4(ip46)
struct gbp_main_t_ gbp_main_t
L2 Emulation Main.
An API client registration, only in vpp/vlib.
#define BAD_SW_IF_INDEX_LABEL
static uword vnet_sw_if_index_is_api_valid(u32 sw_if_index)
static int gbp_endpoint_group_send_details(gbp_endpoint_group_t *gepg, void *args)
ip46_address_t gek_ip
The IP[46] address of the endpoint.
void gbp_endpoint_walk(gbp_endpoint_cb_t cb, void *ctx)
#define vec_free(V)
Free vector's memory (no header).
int gbp_endpoint_group_add(epg_id_t epg_id, u32 bd_id, u32 ip4_table_id, u32 ip6_table_id, u32 uplink_sw_if_index)
static void vl_api_gbp_subnet_add_del_t_handler(vl_api_gbp_subnet_add_del_t *mp)
#define clib_memcpy(a, b, c)
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
epg_id_t gck_src
source and destination EPGs for which the ACL applies
vl_api_gbp_endpoint_group_t epg
vl_api_gbp_subnet_t subnet
static void vl_api_gbp_endpoint_dump_t_handler(vl_api_gbp_endpoint_dump_t *mp)
vl_api_gbp_contract_t contract
static void vl_api_gbp_endpoint_group_dump_t_handler(vl_api_gbp_endpoint_group_dump_t *mp)
vl_api_gbp_endpoint_t endpoint
static void vl_api_gbp_endpoint_group_add_del_t_handler(vl_api_gbp_endpoint_group_add_del_t *mp)
vl_api_gbp_recirc_t recirc
void gbp_endpoint_delete(u32 sw_if_index, const ip46_address_t *ip)
static clib_error_t * gbp_init(vlib_main_t *vm)
static void gbp_api_hookup(vlib_main_t *vm)
u32 gepg_uplink_sw_if_index
the uplink interface dedicated to the EPG
void gbp_contract_update(epg_id_t src_epg, epg_id_t dst_epg, u32 acl_index)
static void vl_api_gbp_endpoint_add_del_t_handler(vl_api_gbp_endpoint_add_del_t *mp)
static void vl_api_gbp_subnet_dump_t_handler(vl_api_gbp_subnet_dump_t *mp)
static int gbp_endpoint_send_details(gbp_endpoint_t *gbpe, void *args)
vl_api_gbp_contract_t contract
void gbp_recirc_walk(gbp_recirc_cb_t cb, void *ctx)
void gbp_recirc_delete(u32 sw_if_index)
vl_api_gbp_endpoint_t endpoint
epg_id_t ge_epg_id
The endpoint's designated EPG.
vl_api_registration_t * reg
int gbp_recirc_add(u32 sw_if_index, epg_id_t epg_id, u8 is_ext)
u32 gc_acl_index
The ACL to apply for packets from the source to the destination EPG.
VLIB_API_INIT_FUNCTION(gbp_init)
void gbp_contract_walk(gbp_contract_cb_t cb, void *ctx)
struct gbp_walk_ctx_t_ gbp_walk_ctx_t
vl_api_gbp_recirc_t recirc
u32 gepg_rd[FIB_PROTOCOL_IP_MAX]
route-domain/IP-table ID the EPG is in
A Group Based Policy Contract.
u16 vl_msg_api_get_msg_ids(const char *name, int n)
void gbp_endpoint_group_walk(gbp_endpoint_group_cb_t cb, void *ctx)
#define foreach_gbp_api_msg