diff options
author | Andrew Yourtchenko <ayourtch@gmail.com> | 2017-06-06 14:50:03 +0200 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-06-07 13:38:29 +0000 |
commit | 6295d50b37ded4a335058722545dd5310202b8c0 (patch) | |
tree | 4bd4c273646fba5990a4c71b10747e7404619fe6 | |
parent | 5dbfbb7110a52595915acd5ec034f82ce517846a (diff) |
acl-plugin: add a plugin-specific control-ping message api and make the test code use it
This fixes the undesirable pause in the dump commands in case there is nothing to dump.
Change-Id: I0554556c9e442038aa2a1ed8c88234f21f7fe9b9
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
-rw-r--r-- | src/plugins/acl/acl.api | 24 | ||||
-rw-r--r-- | src/plugins/acl/acl.c | 15 | ||||
-rw-r--r-- | src/plugins/acl/acl.h | 2 | ||||
-rw-r--r-- | src/plugins/acl/acl_test.c | 35 |
4 files changed, 75 insertions, 1 deletions
diff --git a/src/plugins/acl/acl.api b/src/plugins/acl/acl.api index 3b334113..d34f374e 100644 --- a/src/plugins/acl/acl.api +++ b/src/plugins/acl/acl.api @@ -44,6 +44,30 @@ define acl_plugin_get_version_reply u32 minor; }; +/** \brief Control ping from client to api server request + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request +*/ +define acl_plugin_control_ping +{ + u32 client_index; + u32 context; +}; + +/** \brief Control ping from the client to the server response + @param client_index - opaque cookie to identify the sender + @param context - sender context, to match reply w/ request + @param retval - return code for the request + @param vpe_pid - the pid of the vpe, returned by the server +*/ +define acl_plugin_control_ping_reply +{ + u32 context; + i32 retval; + u32 client_index; + u32 vpe_pid; +}; + /** \brief Access List Rule entry @param is_permit - deny (0), permit (1), or permit+reflect(2) action on this rule. @param is_ipv6 - IP addresses in this rule are IPv6 (1) or IPv4 (0) diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c index 84ed7af6..d52f70af 100644 --- a/src/plugins/acl/acl.c +++ b/src/plugins/acl/acl.c @@ -62,6 +62,7 @@ acl_main_t acl_main; #define foreach_acl_plugin_api_msg \ _(ACL_PLUGIN_GET_VERSION, acl_plugin_get_version) \ +_(ACL_PLUGIN_CONTROL_PING, acl_plugin_control_ping) \ _(ACL_ADD_REPLACE, acl_add_replace) \ _(ACL_DEL, acl_del) \ _(ACL_INTERFACE_ADD_DEL, acl_interface_add_del) \ @@ -106,6 +107,20 @@ vl_api_acl_plugin_get_version_t_handler (vl_api_acl_plugin_get_version_t * mp) vl_msg_api_send_shmem (q, (u8 *) & rmp); } +static void +vl_api_acl_plugin_control_ping_t_handler (vl_api_acl_plugin_control_ping_t * mp) +{ + vl_api_acl_plugin_control_ping_reply_t *rmp; + acl_main_t *am = &acl_main; + int rv = 0; + + /* *INDENT-OFF* */ + REPLY_MACRO2 (VL_API_ACL_PLUGIN_CONTROL_PING_REPLY, + ({ + rmp->vpe_pid = ntohl (getpid ()); + })); + /* *INDENT-ON* */ +} static int acl_add_list (u32 count, vl_api_acl_rule_t rules[], diff --git a/src/plugins/acl/acl.h b/src/plugins/acl/acl.h index e35e0ea7..02623a9c 100644 --- a/src/plugins/acl/acl.h +++ b/src/plugins/acl/acl.h @@ -28,7 +28,7 @@ #include "fa_node.h" #define ACL_PLUGIN_VERSION_MAJOR 1 -#define ACL_PLUGIN_VERSION_MINOR 2 +#define ACL_PLUGIN_VERSION_MINOR 3 #define UDP_SESSION_IDLE_TIMEOUT_SEC 600 #define TCP_SESSION_IDLE_TIMEOUT_SEC (3600*24) diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c index 8f6179f8..65ef8009 100644 --- a/src/plugins/acl/acl_test.c +++ b/src/plugins/acl/acl_test.c @@ -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) @@ -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; |