X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Facl%2Facl_test.c;h=2b5175852e4d06a91d92fa4dd488cabbb81460e3;hb=6d157c2f91a5cf334968df5a6ac4963fedb8c706;hp=6154a238ff9b93fa9003987c6edc9e70650e4357;hpb=2fb40f80ff30cfacdaa6741d3520ecd2df71d986;p=vpp.git diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 6154a238ff9..2b5175852e4 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -144,9 +144,9 @@ static void vl_api_acl_interface_list_details_t_handler out = format(out, "sw_if_index: %d, count: %d, n_input: %d\n", mp->sw_if_index, mp->count, mp->n_input); out = format(out, " input "); for(i=0; icount; i++) { - out = format(out, "%d ", ntohl (mp->acls[i])); - if (i == mp->n_input-1) + if (i == mp->n_input) out = format(out, "\n output "); + out = format(out, "%d ", ntohl (mp->acls[i])); } out = format(out, "\n"); clib_warning("%s", out); @@ -243,6 +243,22 @@ static void vl_api_macip_acl_interface_get_reply_t_handler vam->result_ready = 1; } +static void vl_api_acl_plugin_control_ping_reply_t_handler + (vl_api_acl_plugin_control_ping_reply_t * mp) +{ + vat_main_t *vam = &vat_main; + i32 retval = ntohl (mp->retval); + if (vam->async_mode) + { + vam->async_errors += (retval < 0); + } + else + { + vam->retval = retval; + vam->result_ready = 1; + } +} + /* * Table of message reply handlers, must include boilerplate handlers @@ -260,6 +276,7 @@ _(MACIP_ACL_DEL_REPLY, macip_acl_del_reply) \ _(MACIP_ACL_DETAILS, macip_acl_details) \ _(MACIP_ACL_INTERFACE_ADD_DEL_REPLY, macip_acl_interface_add_del_reply) \ _(MACIP_ACL_INTERFACE_GET_REPLY, macip_acl_interface_get_reply) \ +_(ACL_PLUGIN_CONTROL_PING_REPLY, acl_plugin_control_ping_reply) \ _(ACL_PLUGIN_GET_VERSION_REPLY, acl_plugin_get_version_reply) static int api_acl_plugin_get_version (vat_main_t * vam) @@ -480,7 +497,7 @@ static int api_acl_add_replace (vat_main_t * vam) memset (mp, 0, msg_size); mp->_vl_msg_id = ntohs (VL_API_ACL_ADD_REPLACE + sm->msg_id_base); mp->client_index = vam->my_client_index; - if (n_rules > 0) + if ((n_rules > 0) && rules) clib_memcpy(mp->r, rules, n_rules*sizeof (vl_api_acl_rule_t)); if (tag) { @@ -728,6 +745,15 @@ static int api_acl_interface_set_acl_list (vat_main_t * vam) return ret; } +static void +api_acl_send_control_ping(vat_main_t *vam) +{ + vl_api_acl_plugin_control_ping_t *mp_ping; + + M(ACL_PLUGIN_CONTROL_PING, mp_ping); + S(mp_ping); +} + static int api_acl_interface_list_dump (vat_main_t * vam) { @@ -753,6 +779,9 @@ static int api_acl_interface_list_dump (vat_main_t * vam) /* send it... */ S(mp); + /* Use control ping for synchronization */ + api_acl_send_control_ping(vam); + /* Wait for a reply... */ W (ret); return ret; @@ -780,6 +809,9 @@ static int api_acl_dump (vat_main_t * vam) /* send it... */ S(mp); + /* Use control ping for synchronization */ + api_acl_send_control_ping(vam); + /* Wait for a reply... */ W (ret); return ret; @@ -807,6 +839,9 @@ static int api_macip_acl_dump (vat_main_t * vam) /* send it... */ S(mp); + /* Use control ping for synchronization */ + api_acl_send_control_ping(vam); + /* Wait for a reply... */ W (ret); return ret; @@ -851,7 +886,7 @@ static int api_macip_acl_add (vat_main_t * vam) else if (unformat (i, "ipv4")) { vec_validate_macip_acl_rules(rules, rule_idx); - rules[rule_idx].is_ipv6 = 1; + rules[rule_idx].is_ipv6 = 0; } else if (unformat (i, "permit")) { @@ -873,8 +908,12 @@ static int api_macip_acl_add (vat_main_t * vam) rules[rule_idx].is_permit = action; } else if (unformat (i, "ip %U/%d", - unformat_ip4_address, &src_v4address, &src_prefix_length)) + unformat_ip4_address, &src_v4address, &src_prefix_length) || + unformat (i, "ip %U", + unformat_ip4_address, &src_v4address)) { + if (src_prefix_length == 0) + src_prefix_length = 32; vec_validate_macip_acl_rules(rules, rule_idx); memcpy (rules[rule_idx].src_ip_addr, &src_v4address, 4); rules[rule_idx].src_ip_prefix_len = src_prefix_length; @@ -885,8 +924,12 @@ static int api_macip_acl_add (vat_main_t * vam) /* Everything in MACIP is "source" but allow this verbosity */ } else if (unformat (i, "ip %U/%d", - unformat_ip6_address, &src_v6address, &src_prefix_length)) + unformat_ip6_address, &src_v6address, &src_prefix_length) || + unformat (i, "ip %U", + unformat_ip6_address, &src_v6address)) { + if (src_prefix_length == 0) + src_prefix_length = 128; vec_validate_macip_acl_rules(rules, rule_idx); memcpy (rules[rule_idx].src_ip_addr, &src_v6address, 16); rules[rule_idx].src_ip_prefix_len = src_prefix_length; @@ -934,7 +977,7 @@ static int api_macip_acl_add (vat_main_t * vam) memset (mp, 0, msg_size); mp->_vl_msg_id = ntohs (VL_API_MACIP_ACL_ADD + sm->msg_id_base); mp->client_index = vam->my_client_index; - if (n_rules > 0) + if ((n_rules > 0) && rules) clib_memcpy(mp->r, rules, n_rules*sizeof (mp->r[0])); if (tag) {