X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fgbp%2Fgbp_api.c;h=665d97ea0b137d1a7e7a0a36e869f34d318fe20a;hb=879d11c25;hp=4402ec15b8cf5db297e0289556edab6295554e0f;hpb=33b81da54acf1236cddf0716005c340f3402ff6d;p=vpp.git diff --git a/src/plugins/gbp/gbp_api.c b/src/plugins/gbp/gbp_api.c index 4402ec15b8c..665d97ea0b1 100644 --- a/src/plugins/gbp/gbp_api.c +++ b/src/plugins/gbp/gbp_api.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,8 @@ _(GBP_ROUTE_DOMAIN_DUMP, gbp_route_domain_dump) \ _(GBP_RECIRC_ADD_DEL, gbp_recirc_add_del) \ _(GBP_RECIRC_DUMP, gbp_recirc_dump) \ + _(GBP_EXT_ITF_ADD_DEL, gbp_ext_itf_add_del) \ + _(GBP_EXT_ITF_DUMP, gbp_ext_itf_dump) \ _(GBP_CONTRACT_ADD_DEL, gbp_contract_add_del) \ _(GBP_CONTRACT_DUMP, gbp_contract_dump) \ _(GBP_ENDPOINT_LEARN_SET_INACTIVE_THRESHOLD, gbp_endpoint_learn_set_inactive_threshold) \ @@ -95,12 +98,14 @@ gbp_endpoint_flags_decode (vl_api_gbp_endpoint_flags_t v) v = ntohl (v); - if (v & BOUNCE) + if (v & GBP_API_ENDPOINT_FLAG_BOUNCE) f |= GBP_ENDPOINT_FLAG_BOUNCE; - if (v & REMOTE) + if (v & GBP_API_ENDPOINT_FLAG_REMOTE) f |= GBP_ENDPOINT_FLAG_REMOTE; - if (v & LEARNT) + if (v & GBP_API_ENDPOINT_FLAG_LEARNT) f |= GBP_ENDPOINT_FLAG_LEARNT; + if (v & GBP_API_ENDPOINT_FLAG_EXTERNAL) + f |= GBP_ENDPOINT_FLAG_EXTERNAL; return (f); } @@ -112,11 +117,13 @@ gbp_endpoint_flags_encode (gbp_endpoint_flags_t f) if (f & GBP_ENDPOINT_FLAG_BOUNCE) - v |= BOUNCE; + v |= GBP_API_ENDPOINT_FLAG_BOUNCE; if (f & GBP_ENDPOINT_FLAG_REMOTE) - v |= REMOTE; + v |= GBP_API_ENDPOINT_FLAG_REMOTE; if (f & GBP_ENDPOINT_FLAG_LEARNT) - v |= LEARNT; + v |= GBP_API_ENDPOINT_FLAG_LEARNT; + if (f & GBP_ENDPOINT_FLAG_EXTERNAL) + v |= GBP_API_ENDPOINT_FLAG_EXTERNAL; v = htonl (v); @@ -147,7 +154,7 @@ vl_api_gbp_endpoint_add_t_handler (vl_api_gbp_endpoint_add_t * mp) ip_address_decode (&mp->endpoint.ips[ii], &ips[ii]); } } - mac_address_decode (&mp->endpoint.mac, &mac); + mac_address_decode (mp->endpoint.mac, &mac); if (GBP_ENDPOINT_FLAG_REMOTE & gef) { @@ -253,7 +260,7 @@ gbp_endpoint_send_details (index_t gei, void *args) mp->endpoint.flags = gbp_endpoint_flags_encode (gef->gef_flags); mp->handle = htonl (gei); mp->age = vlib_time_now (vlib_get_main ()) - ge->ge_last_time; - mac_address_encode (&ge->ge_key.gek_mac, &mp->endpoint.mac); + mac_address_encode (&ge->ge_key.gek_mac, mp->endpoint.mac); vec_foreach_index (ii, ge->ge_key.gek_ips) { @@ -291,6 +298,7 @@ static void int rv = 0; rv = gbp_endpoint_group_add_and_lock (ntohs (mp->epg.epg_id), + ntohs (mp->epg.sclass), ntohl (mp->epg.bd_id), ntohl (mp->epg.rd_id), ntohl (mp->epg.uplink_sw_if_index)); @@ -334,7 +342,8 @@ vl_api_gbp_bridge_domain_add_t_handler (vl_api_gbp_bridge_domain_add_t * mp) gbp_bridge_domain_flags_from_api (mp->bd.flags), ntohl (mp->bd.bvi_sw_if_index), - ntohl (mp->bd.uu_fwd_sw_if_index)); + ntohl (mp->bd.uu_fwd_sw_if_index), + ntohl (mp->bd.bm_flood_sw_if_index)); REPLY_MACRO (VL_API_GBP_BRIDGE_DOMAIN_ADD_REPLY + GBP_MSG_BASE); } @@ -386,6 +395,9 @@ gub_subnet_type_from_api (vl_api_gbp_subnet_type_t a, gbp_subnet_type_t * t) case GBP_API_SUBNET_TRANSPORT: *t = GBP_SUBNET_TRANSPORT; return (0); + case GBP_API_SUBNET_L3_OUT: + *t = GBP_SUBNET_L3_OUT; + return (0); case GBP_API_SUBNET_STITCHED_INTERNAL: *t = GBP_SUBNET_STITCHED_INTERNAL; return (0); @@ -440,6 +452,9 @@ gub_subnet_type_to_api (gbp_subnet_type_t t) case GBP_SUBNET_STITCHED_EXTERNAL: a = GBP_API_SUBNET_STITCHED_EXTERNAL; break; + case GBP_SUBNET_L3_OUT: + a = GBP_API_SUBNET_L3_OUT; + break; } a = clib_host_to_net_u32 (a); @@ -510,8 +525,9 @@ gbp_endpoint_group_send_details (gbp_endpoint_group_t * gg, void *args) mp->epg.uplink_sw_if_index = ntohl (gg->gg_uplink_sw_if_index); mp->epg.epg_id = ntohs (gg->gg_id); + mp->epg.sclass = ntohs (gg->gg_sclass); mp->epg.bd_id = ntohl (gbp_endpoint_group_get_bd_id (gg)); - mp->epg.rd_id = ntohl (gg->gg_rd); + mp->epg.rd_id = ntohl (gbp_route_domain_get_rd_id (gg->gg_rd)); vl_api_send_msg (ctx->reg, (u8 *) mp); @@ -554,6 +570,7 @@ gbp_bridge_domain_send_details (gbp_bridge_domain_t * gb, void *args) mp->bd.bd_id = ntohl (gb->gb_bd_id); mp->bd.bvi_sw_if_index = ntohl (gb->gb_bvi_sw_if_index); mp->bd.uu_fwd_sw_if_index = ntohl (gb->gb_uu_fwd_sw_if_index); + mp->bd.bm_flood_sw_if_index = ntohl (gb->gb_bm_flood_sw_if_index); vl_api_send_msg (ctx->reg, (u8 *) mp); @@ -632,17 +649,17 @@ vl_api_gbp_recirc_add_del_t_handler (vl_api_gbp_recirc_add_del_t * mp) goto bad_sw_if_index; if (mp->is_add) - gbp_recirc_add (sw_if_index, - ntohs (mp->recirc.epg_id), mp->recirc.is_ext); + rv = gbp_recirc_add (sw_if_index, + ntohs (mp->recirc.epg_id), mp->recirc.is_ext); else - gbp_recirc_delete (sw_if_index); + rv = gbp_recirc_delete (sw_if_index); BAD_SW_IF_INDEX_LABEL; REPLY_MACRO (VL_API_GBP_RECIRC_ADD_DEL_REPLY + GBP_MSG_BASE); } -static int +static walk_rc_t gbp_recirc_send_details (gbp_recirc_t * gr, void *args) { vl_api_gbp_recirc_details_t *mp; @@ -651,7 +668,7 @@ gbp_recirc_send_details (gbp_recirc_t * gr, void *args) ctx = args; mp = vl_msg_api_alloc (sizeof (*mp)); if (!mp) - return 1; + return (WALK_STOP); clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_GBP_RECIRC_DETAILS + GBP_MSG_BASE); @@ -659,11 +676,11 @@ gbp_recirc_send_details (gbp_recirc_t * gr, void *args) mp->recirc.epg_id = ntohs (gr->gr_epg); mp->recirc.sw_if_index = ntohl (gr->gr_sw_if_index); - mp->recirc.is_ext = ntohl (gr->gr_is_ext); + mp->recirc.is_ext = gr->gr_is_ext; vl_api_send_msg (ctx->reg, (u8 *) mp); - return (1); + return (WALK_CONTINUE); } static void @@ -683,6 +700,73 @@ vl_api_gbp_recirc_dump_t_handler (vl_api_gbp_recirc_dump_t * mp) gbp_recirc_walk (gbp_recirc_send_details, &ctx); } +static void +vl_api_gbp_ext_itf_add_del_t_handler (vl_api_gbp_ext_itf_add_del_t * mp) +{ + vl_api_gbp_ext_itf_add_del_reply_t *rmp; + u32 sw_if_index = ~0; + vl_api_gbp_ext_itf_t *ext_itf; + int rv = 0; + + ext_itf = &mp->ext_itf; + if (ext_itf) + sw_if_index = ntohl (ext_itf->sw_if_index); + + if (!vnet_sw_if_index_is_api_valid (sw_if_index)) + goto bad_sw_if_index; + + if (mp->is_add) + rv = gbp_ext_itf_add (sw_if_index, + ntohl (ext_itf->bd_id), ntohl (ext_itf->rd_id)); + else + rv = gbp_ext_itf_delete (sw_if_index); + + BAD_SW_IF_INDEX_LABEL; + + REPLY_MACRO (VL_API_GBP_EXT_ITF_ADD_DEL_REPLY + GBP_MSG_BASE); +} + +static walk_rc_t +gbp_ext_itf_send_details (gbp_ext_itf_t * gx, void *args) +{ + vl_api_gbp_ext_itf_details_t *mp; + gbp_walk_ctx_t *ctx; + + ctx = args; + mp = vl_msg_api_alloc (sizeof (*mp)); + if (!mp) + return (WALK_STOP); + + clib_memset (mp, 0, sizeof (*mp)); + mp->_vl_msg_id = ntohs (VL_API_GBP_EXT_ITF_DETAILS + GBP_MSG_BASE); + mp->context = ctx->context; + + mp->ext_itf.bd_id = ntohl (gbp_bridge_domain_get_bd_id (gx->gx_bd)); + mp->ext_itf.rd_id = ntohl (gbp_route_domain_get_rd_id (gx->gx_rd)); + mp->ext_itf.sw_if_index = ntohl (gx->gx_itf); + + vl_api_send_msg (ctx->reg, (u8 *) mp); + + return (WALK_CONTINUE); +} + +static void +vl_api_gbp_ext_itf_dump_t_handler (vl_api_gbp_ext_itf_dump_t * mp) +{ + vl_api_registration_t *reg; + + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; + + gbp_walk_ctx_t ctx = { + .reg = reg, + .context = mp->context, + }; + + gbp_ext_itf_walk (gbp_ext_itf_send_details, &ctx); +} + static int gbp_contract_rule_action_deocde (vl_api_gbp_rule_action_t in, gbp_rule_action_t * out) @@ -744,7 +828,7 @@ gbp_next_hop_decode (const vl_api_gbp_next_hop_t * in, index_t * gnhi) return (VNET_API_ERROR_NO_SUCH_FIB); ip_address_decode (&in->ip, &ip); - mac_address_decode (&in->mac, &mac); + mac_address_decode (in->mac, &mac); *gnhi = gbp_next_hop_alloc (&ip, grd, &mac, gbd); @@ -847,8 +931,11 @@ static void vl_api_gbp_contract_add_del_t_handler (vl_api_gbp_contract_add_del_t * mp) { vl_api_gbp_contract_add_del_reply_t *rmp; + u16 *allowed_ethertypes; index_t *rules; - int rv = 0; + int ii, rv = 0; + u8 *data, n_et; + u16 *et; if (mp->is_add) { @@ -857,9 +944,28 @@ vl_api_gbp_contract_add_del_t_handler (vl_api_gbp_contract_add_del_t * mp) if (0 != rv) goto out; + allowed_ethertypes = NULL; + + /* + * move past the variable legnth array of rules to get to the + * allowed ether types + */ + data = (((u8 *) & mp->contract.n_ether_types) + + (sizeof (mp->contract.rules[0]) * mp->contract.n_rules)); + n_et = *data; + et = (u16 *) (++data); + vec_validate (allowed_ethertypes, n_et - 1); + + for (ii = 0; ii < n_et; ii++) + { + /* leave the ether types in network order */ + allowed_ethertypes[ii] = et[ii]; + } + rv = gbp_contract_update (ntohs (mp->contract.src_epg), ntohs (mp->contract.dst_epg), - ntohl (mp->contract.acl_index), rules); + ntohl (mp->contract.acl_index), + rules, allowed_ethertypes); } else rv = gbp_contract_delete (ntohs (mp->contract.src_epg),