acl-plugin: fix acl plugin test failing sporadically (VPP-898) 09/7409/2
authorAndrew Yourtchenko <ayourtch@gmail.com>
Mon, 3 Jul 2017 14:25:37 +0000 (16:25 +0200)
committerNeale Ranns <nranns@cisco.com>
Tue, 4 Jul 2017 08:57:54 +0000 (08:57 +0000)
The "acl_plugin" tests has one of the tests sporadically fail with the following traceback:

r.reply.decode().rstrip('\x00') UnicodeDecodeError: 'ascii' codec can't decode byte
0xd8 in position 20666: ordinal not in range(128)

This occurs in the newly added "show acl-plugin table" debug CLI.
This CLI has only the numeric outputs, so the conclusion is that it is
the incorrect termination (trailing zero) that might be most probably
causing it. The other acl-plugins show commands also
lack the zero-termination termination, so fix all of them.
The particularity of this command vs. the other acl-plugin debug CLIs
is that the accumulator is freed and allocated multiple times,
this might explain the issue is not seen with them.

Change-Id: I87b5c0d6152fbebcae9c7d0ce97155c1ae6666db
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
(cherry picked from commit be055bd719559fc79d8a4c06479497c4c0bfae93)

src/plugins/acl/acl.c

index 704a839..02fcb4f 100644 (file)
@@ -1974,6 +1974,7 @@ acl_show_aclplugin_fn (vlib_main_t * vm,
 #define _(cnt, desc) out0 = format(out0, "             %20lu: %s\n", am->cnt, desc);
       foreach_fa_cleaner_counter;
 #undef _
+      vec_terminate_c_string(out0);
       vlib_cli_output(vm, "\n\n%s\n\n", out0);
       vlib_cli_output(vm, "Sessions per interval: min %lu max %lu increment: %f ms current: %f ms",
               am->fa_min_deleted_sessions_per_interval, am->fa_max_deleted_sessions_per_interval,
@@ -2011,6 +2012,7 @@ acl_show_aclplugin_fn (vlib_main_t * vm,
         }
 
       }
+      vec_terminate_c_string(out0);
       vlib_cli_output(vm, "\n%s\n", out0);
       vec_free(out0);
     }
@@ -2067,6 +2069,7 @@ acl_show_aclplugin_fn (vlib_main_t * vm,
           out0 = format(out0, "\n");
         }
       }
+      vec_terminate_c_string(out0);
       vlib_cli_output(vm, "\n%s\n", out0);
       vec_free(out0);
     }
@@ -2138,6 +2141,7 @@ acl_show_aclplugin_fn (vlib_main_t * vm,
                                 pa->src_portrange_not_powerof2, pa->dst_portrange_not_powerof2);
           }
         }
+        vec_terminate_c_string(out0);
         vlib_cli_output(vm, "\n%s\n", out0);
         vec_free(out0);
       }
@@ -2184,6 +2188,7 @@ acl_show_aclplugin_fn (vlib_main_t * vm,
           }
 
         }
+        vec_terminate_c_string(out0);
         vlib_cli_output(vm, "\n%s\n", out0);
         vec_free(out0);
       }