25 #include <vpp/app/version.h> 44 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 50 #define vl_api_version(n,v) static u32 api_version=(v); 56 #define foreach_gbp_api_msg \ 57 _(GBP_ENDPOINT_ADD, gbp_endpoint_add) \ 58 _(GBP_ENDPOINT_DEL, gbp_endpoint_del) \ 59 _(GBP_ENDPOINT_DUMP, gbp_endpoint_dump) \ 60 _(GBP_SUBNET_ADD_DEL, gbp_subnet_add_del) \ 61 _(GBP_SUBNET_DUMP, gbp_subnet_dump) \ 62 _(GBP_ENDPOINT_GROUP_ADD_DEL, gbp_endpoint_group_add_del) \ 63 _(GBP_ENDPOINT_GROUP_DUMP, gbp_endpoint_group_dump) \ 64 _(GBP_RECIRC_ADD_DEL, gbp_recirc_add_del) \ 65 _(GBP_RECIRC_DUMP, gbp_recirc_dump) \ 66 _(GBP_CONTRACT_ADD_DEL, gbp_contract_add_del) \ 67 _(GBP_CONTRACT_DUMP, gbp_contract_dump) 73 #define GBP_MSG_BASE msg_id_base 86 sw_if_index = ntohl (mp->
endpoint.sw_if_index);
102 ntohs (mp->
endpoint.epg_id), &handle);
111 rmp->
handle = htonl (handle);
119 vl_api_gbp_endpoint_del_reply_t *rmp;
146 memset (mp, 0,
sizeof (*mp));
147 mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_DETAILS +
GBP_MSG_BASE);
187 vl_api_gbp_endpoint_group_add_del_reply_t *rmp;
188 u32 uplink_sw_if_index;
193 goto bad_sw_if_index;
216 vl_api_gbp_subnet_add_del_reply_t *rmp;
245 memset (mp, 0,
sizeof (*mp));
246 mp->_vl_msg_id = ntohs (VL_API_GBP_SUBNET_DETAILS +
GBP_MSG_BASE);
288 memset (mp, 0,
sizeof (*mp));
289 mp->_vl_msg_id = ntohs (VL_API_GBP_ENDPOINT_GROUP_DETAILS +
GBP_MSG_BASE);
324 vl_api_gbp_recirc_add_del_reply_t *rmp;
330 goto bad_sw_if_index;
354 memset (mp, 0,
sizeof (*mp));
355 mp->_vl_msg_id = ntohs (VL_API_GBP_RECIRC_DETAILS +
GBP_MSG_BASE);
387 vl_api_gbp_contract_add_del_reply_t *rmp;
412 memset (mp, 0,
sizeof (*mp));
413 mp->_vl_msg_id = ntohs (VL_API_GBP_CONTRACT_DETAILS +
GBP_MSG_BASE);
449 #define vl_msg_name_crc_list 451 #undef vl_msg_name_crc_list 456 #define _(id,n,crc) \ 457 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + GBP_MSG_BASE); 458 foreach_vl_msg_name_crc_gbp;
466 vl_msg_api_set_handlers(VL_API_##N + GBP_MSG_BASE, \ 468 vl_api_##n##_t_handler, \ 470 vl_api_##n##_t_endian, \ 471 vl_api_##n##_t_print, \ 472 sizeof(vl_api_##n##_t), 1); 502 .version = VPP_BUILD_VER,
503 .description =
"Group Based Policy",
u32 ge_sw_if_index
The interface on which the EP is connected.
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
#define vec_foreach_index(var, v)
Iterate over vector indices.
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.
static void vl_api_gbp_endpoint_add_t_handler(vl_api_gbp_endpoint_add_t *mp)
gbp_contract_key_t gc_key
source and destination EPGs
vl_api_gbp_endpoint_t endpoint
vl_api_gbp_subnet_t subnet
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
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)
#define REPLY_MACRO2(t, body)
void gbp_endpoint_delete(u32 handle)
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)
mac_address_t ge_mac
MAC address of the endpoint.
static int gbp_recirc_send_details(gbp_recirc_t *gr, void *args)
void * vl_msg_api_alloc(int nbytes)
void mac_address_decode(const vl_api_mac_address_t *in, mac_address_t *out)
static void vl_api_gbp_contract_add_del_t_handler(vl_api_gbp_contract_add_del_t *mp)
enum walk_rc_t_ walk_rc_t
Walk return code.
memset(h->entries, 0, sizeof(h->entries[0])*entries)
u8 gr_is_ext
Is the interface for packets post-NAT translation (i.e.
void mac_address_encode(const mac_address_t *in, vl_api_mac_address_t *out)
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.
ip46_type_t ip_address_decode(const vl_api_address_t *in, ip46_address_t *out)
gbp_contract_value_t gc_value
The ACL to apply for packets from the source to the destination EPG.
epg_id_t gr_epg
EPG ID that packets will classify to when they arrive on this recirc.
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)
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)
void gbp_endpoint_walk(gbp_endpoint_cb_t cb, void *ctx)
#define vec_free(V)
Free vector's memory (no header).
ip46_address_t * ge_ips
A vector of ip addresses that below to the endpoint.
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)
int gbp_endpoint_update(u32 sw_if_index, const ip46_address_t *ips, const mac_address_t *mac, epg_id_t epg_id, u32 *handle)
static void vl_api_gbp_subnet_add_del_t_handler(vl_api_gbp_subnet_add_del_t *mp)
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)
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
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 walk_rc_t gbp_endpoint_send_details(gbp_endpoint_t *gbpe, void *args)
static void vl_api_gbp_subnet_dump_t_handler(vl_api_gbp_subnet_dump_t *mp)
vl_api_gbp_contract_t contract
void gbp_recirc_walk(gbp_recirc_cb_t cb, void *ctx)
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
static void vl_api_gbp_endpoint_del_t_handler(vl_api_gbp_endpoint_del_t *mp)
void gbp_recirc_delete(u32 sw_if_index)
vl_api_gbp_endpoint_t endpoint
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
epg_id_t ge_epg_id
The endpoint's designated EPG.
vl_api_registration_t * reg
Group Base Policy (GBP) defines:
void ip_address_encode(const ip46_address_t *in, ip46_type_t type, vl_api_address_t *out)
int gbp_recirc_add(u32 sw_if_index, epg_id_t epg_id, u8 is_ext)
vl_api_address_t ips[n_ips]
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.
#define VALIDATE_SW_IF_INDEX(mp)
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