summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-06-09 20:22:42 -0400
committerPaul Jakma <paul@quagga.net>2015-06-21 14:56:55 +0100
commitb1891fb9705b6085f81269dec0795f2065442047 (patch)
tree002bccbf21caf38ec1dab8f36020b3eab7356a30
parent1934e7895ded8d9d7a76ab3f482c381bf5f6725c (diff)
downloadquagga-b1891fb9705b6085f81269dec0795f2065442047.tar.bz2
quagga-b1891fb9705b6085f81269dec0795f2065442047.tar.xz
Add code to extract.pl.in to prevent further cli function overwrites
Currently extract.pl.in is used to build the vtysh cli. When two different cli's collide with the same command name, the original cli is never called, because it is dropped. This code notes the silent drop and tracks the number of drops. If they change then the code will fail the build. The current number of drops was figured out by running extract.pl and counting up the drops then adding code to compare the numbers returned. If you have added to the problem, the solution is to fix your cli command to not stomp on someone else's command. If you have removed a stomp, safely modify extract.pl.in as part of your commit. Signed-off-by: Donald Sharp <sharpd at cumulusnetworks.com> Acked-by: Vincent Jardin <vincent.jardin@6wind.com>
-rwxr-xr-xvtysh/extract.pl.in29
1 files changed, 29 insertions, 0 deletions
diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in
index aa90be4a..73860070 100755
--- a/vtysh/extract.pl.in
+++ b/vtysh/extract.pl.in
@@ -60,6 +60,8 @@ $ignore{'"terminal monitor"'} = "ignore";
$ignore{'"terminal no monitor"'} = "ignore";
$ignore{'"show history"'} = "ignore";
+my $cli_stomp = 0;
+
foreach (@ARGV) {
$file = $_;
@@ -136,6 +138,12 @@ foreach (@ARGV) {
$defun_body = join (", ", @defun_array);
# $cmd -> $str hash for lookup
+ if (exists($cmd2str{$cmd})) {
+ warn "Duplicate CLI Function: $cmd\n";
+ warn "\tFrom cli: $cmd2str{$cmd} to New cli: $str\n";
+ warn "\tOriginal Protocol: $cmd2proto{$cmd} to New Protocol: $protocol\n";
+ $cli_stomp++;
+ }
$cmd2str{$cmd} = $str;
$cmd2defun{$cmd} = $defun_body;
$cmd2proto{$cmd} = $protocol;
@@ -169,6 +177,27 @@ foreach (@ARGV) {
}
}
+my $bad_cli_stomps = 78;
+# Currently we have $bad_cli_stomps. This was determined by
+# running this script and counting up the collisions from what
+# was returned.
+#
+# When we have cli commands that map to the same function name, we
+# can introduce subtle bugs due to code not being called when
+# we think it is.
+#
+# If extract.pl fails with a error message and you've been
+# modifying the cli, then go back and fix your code to
+# not have cli command function collisions.
+#
+# If you've removed a cli overwrite, you can safely subtract
+# one from $bad_cli_stomps. If you've added to the problem
+# please fix your code before submittal
+if ($cli_stomp != $bad_cli_stomps) {
+ warn "Expected $bad_cli_stomps command line stomps, but got $cli_stomp instead\n";
+ exit $cli_stomp;
+}
+
# Check finaly alive $cmd;
foreach (keys %odefun) {
my ($node, $str) = (split (/,/));