X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fmap%2Fmap_api.c;h=92abecd343069b48aa5f003a72a684d54e903898;hb=4dc5c7b90;hp=b32b7c2896174a0c3e5a878947212be45129a70e;hpb=21bb9af16e5fc1fd2ddf811f2a8011c973a20852;p=vpp.git diff --git a/src/plugins/map/map_api.c b/src/plugins/map/map_api.c index b32b7c28961..92abecd3430 100644 --- a/src/plugins/map/map_api.c +++ b/src/plugins/map/map_api.c @@ -53,12 +53,16 @@ vl_api_map_add_domain_t_handler (vl_api_map_add_domain_t * mp) int rv = 0; u32 index; u8 flags = 0; + char *tag = 0; + u32 len; - if (mp->is_translation) - flags |= MAP_DOMAIN_TRANSLATION; - - if (mp->is_rfc6052) - flags |= MAP_DOMAIN_RFC6052; + len = ntohl (mp->tag.length); + if (len > 0) + { + tag = clib_mem_alloc (len + 1); + clib_memcpy (tag, (char *) mp->tag.buf, len); + tag[len] = 0; + } rv = map_create_domain ((ip4_address_t *) & mp->ip4_prefix.prefix, @@ -67,7 +71,10 @@ vl_api_map_add_domain_t_handler (vl_api_map_add_domain_t * mp) mp->ip6_prefix.len, (ip6_address_t *) & mp->ip6_src.prefix, mp->ip6_src.len, mp->ea_bits_len, mp->psid_offset, - mp->psid_length, &index, ntohs (mp->mtu), flags); + mp->psid_length, &index, ntohs (mp->mtu), flags, tag); + + if (tag) + clib_mem_free (tag); /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_MAP_ADD_DOMAIN_REPLY, @@ -109,7 +116,9 @@ vl_api_map_domain_dump_t_handler (vl_api_map_domain_dump_t * mp) vl_api_map_domain_details_t *rmp; map_main_t *mm = &map_main; map_domain_t *d; + map_domain_extra_t *de; vl_api_registration_t *reg; + u32 map_domain_index; if (pool_elts (mm->domains) == 0) return; @@ -121,11 +130,21 @@ vl_api_map_domain_dump_t_handler (vl_api_map_domain_dump_t * mp) /* *INDENT-OFF* */ pool_foreach(d, mm->domains, ({ + u32 len; + + map_domain_index = d - mm->domains; + de = vec_elt_at_index(mm->domain_extras, map_domain_index); + + len = 0; + if (de->tag) + len = strlen(de->tag); + /* Make sure every field is initiated (or don't skip the clib_memset()) */ - rmp = vl_msg_api_alloc (sizeof (*rmp)); + rmp = vl_msg_api_alloc (sizeof (*rmp) + sizeof(rmp->tag.length) + len); + rmp->_vl_msg_id = htons(VL_API_MAP_DOMAIN_DETAILS + mm->msg_id_base); rmp->context = mp->context; - rmp->domain_index = htonl(d - mm->domains); + rmp->domain_index = htonl(map_domain_index); clib_memcpy(&rmp->ip6_prefix.prefix, &d->ip6_prefix, sizeof(rmp->ip6_prefix.prefix)); clib_memcpy(&rmp->ip4_prefix.prefix, &d->ip4_prefix, sizeof(rmp->ip4_prefix.prefix)); clib_memcpy(&rmp->ip6_src.prefix, &d->ip6_src, sizeof(rmp->ip6_src.prefix)); @@ -137,7 +156,12 @@ vl_api_map_domain_dump_t_handler (vl_api_map_domain_dump_t * mp) rmp->psid_length = d->psid_length; rmp->flags = d->flags; rmp->mtu = htons(d->mtu); - rmp->is_translation = (d->flags & MAP_DOMAIN_TRANSLATION); // Redundant + + if (de->tag) + { + rmp->tag.length = htonl (len); + clib_memcpy ((char *)rmp->tag.buf, de->tag, len); + } vl_api_send_msg (reg, (u8 *) rmp); })); @@ -337,7 +361,7 @@ static void int rv = 0; map_pre_resolve ((ip4_address_t *) & mp->ip4_nh_address, - (ip6_address_t *) & mp->ip6_nh_address, mp->is_add); + (ip6_address_t *) & mp->ip6_nh_address, !mp->is_add); REPLY_MACRO (VL_API_MAP_PARAM_ADD_DEL_PRE_RESOLVE_REPLY); } @@ -526,6 +550,29 @@ static void } +int +map_param_set_tcp (u16 tcp_mss) +{ + map_main_t *mm = &map_main; + + mm->tcp_mss = tcp_mss; + + return 0; +} + + +static void +vl_api_map_param_set_tcp_t_handler (vl_api_map_param_set_tcp_t * mp) +{ + map_main_t *mm = &map_main; + vl_api_map_param_set_tcp_reply_t *rmp; + int rv = 0; + + map_param_set_tcp (ntohs (mp->tcp_mss)); + REPLY_MACRO (VL_API_MAP_PARAM_SET_TCP_REPLY); +} + + static void vl_api_map_param_get_t_handler (vl_api_map_param_get_t * mp) { @@ -562,14 +609,14 @@ vl_api_map_param_get_t_handler (vl_api_map_param_get_t * mp) rmp->ip4_pool_size = clib_net_to_host_u16 (mm->ip4_reass_conf_pool_size); rmp->ip4_buffers = clib_net_to_host_u32 (mm->ip4_reass_conf_buffers); rmp->ip4_ht_ratio = - clib_net_to_host_u32 ((u32) mm->ip4_reass_conf_ht_ratio); + clib_net_to_host_u64 ((u64) mm->ip4_reass_conf_ht_ratio); rmp->ip6_lifetime_ms = clib_net_to_host_u16 (mm->ip6_reass_conf_lifetime_ms); rmp->ip6_pool_size = clib_net_to_host_u16 (mm->ip6_reass_conf_pool_size); rmp->ip6_buffers = clib_net_to_host_u32 (mm->ip6_reass_conf_buffers); rmp->ip6_ht_ratio = - clib_net_to_host_u32 ((u32) mm->ip6_reass_conf_ht_ratio); + clib_net_to_host_u64 ((u64) mm->ip6_reass_conf_ht_ratio); rmp->sec_check_enable = mm->sec_check; rmp->sec_check_fragments = mm->sec_check_frag; @@ -581,12 +628,80 @@ vl_api_map_param_get_t_handler (vl_api_map_param_get_t * mp) } +int +map_if_enable_disable (bool is_enable, u32 sw_if_index, bool is_translation) +{ + map_main_t *mm = &map_main; + + if (pool_is_free_index (mm->vnet_main->interface_main.sw_interfaces, + sw_if_index)) + return VNET_API_ERROR_INVALID_SW_IF_INDEX; + + is_enable = ! !is_enable; + + if (is_translation) + { + if (clib_bitmap_get (mm->bm_trans_enabled_by_sw_if, sw_if_index) + == is_enable) + return 0; + } + else + { + if (clib_bitmap_get (mm->bm_encap_enabled_by_sw_if, sw_if_index) + == is_enable) + return 0; + } + + if (is_translation == false) + { + vnet_feature_enable_disable ("ip4-unicast", "ip4-map", sw_if_index, + is_enable ? 1 : 0, 0, 0); + vnet_feature_enable_disable ("ip6-unicast", "ip6-map", sw_if_index, + is_enable ? 1 : 0, 0, 0); + mm->bm_encap_enabled_by_sw_if = + clib_bitmap_set (mm->bm_encap_enabled_by_sw_if, sw_if_index, + is_enable); + } + else + { + vnet_feature_enable_disable ("ip4-unicast", "ip4-map-t", sw_if_index, + is_enable ? 1 : 0, 0, 0); + vnet_feature_enable_disable ("ip6-unicast", "ip6-map-t", sw_if_index, + is_enable ? 1 : 0, 0, 0); + mm->bm_trans_enabled_by_sw_if = + clib_bitmap_set (mm->bm_trans_enabled_by_sw_if, sw_if_index, + is_enable); + } + + return 0; +} + + +static void +vl_api_map_if_enable_disable_t_handler (vl_api_map_if_enable_disable_t * mp) +{ + map_main_t *mm = &map_main; + vl_api_map_if_enable_disable_reply_t *rmp; + int rv = 0; + + VALIDATE_SW_IF_INDEX (mp); + + rv = + map_if_enable_disable (mp->is_enable, htonl (mp->sw_if_index), + mp->is_translation); + + BAD_SW_IF_INDEX_LABEL; + REPLY_MACRO (VL_API_MAP_IF_ENABLE_DISABLE_REPLY); +} + + #define foreach_map_plugin_api_msg \ _(MAP_ADD_DOMAIN, map_add_domain) \ _(MAP_DEL_DOMAIN, map_del_domain) \ _(MAP_ADD_DEL_RULE, map_add_del_rule) \ _(MAP_DOMAIN_DUMP, map_domain_dump) \ _(MAP_RULE_DUMP, map_rule_dump) \ +_(MAP_IF_ENABLE_DISABLE, map_if_enable_disable) \ _(MAP_SUMMARY_STATS, map_summary_stats) \ _(MAP_PARAM_SET_FRAGMENTATION, map_param_set_fragmentation) \ _(MAP_PARAM_SET_ICMP, map_param_set_icmp) \ @@ -595,6 +710,7 @@ _(MAP_PARAM_ADD_DEL_PRE_RESOLVE, map_param_add_del_pre_resolve) \ _(MAP_PARAM_SET_REASSEMBLY, map_param_set_reassembly) \ _(MAP_PARAM_SET_SECURITY_CHECK, map_param_set_security_check) \ _(MAP_PARAM_SET_TRAFFIC_CLASS, map_param_set_traffic_class) \ +_(MAP_PARAM_SET_TCP, map_param_set_tcp) \ _(MAP_PARAM_GET, map_param_get) #define vl_msg_name_crc_list