vlib: vpp banner is outputted to non-interactive vppctl session 62/33562/5
authorSteven Luong <sluong@cisco.com>
Sat, 21 Aug 2021 02:14:16 +0000 (19:14 -0700)
committerDave Wallace <dwallacelf@gmail.com>
Fri, 27 Aug 2021 14:57:44 +0000 (14:57 +0000)
commit17a67218587d40541ff522c6a86f354720481fbb
tree6af63fed9c4d3a91eba878ed8ce384c924694da7
parentba46778f55e51503fa47588faddea75efca9b655
vlib: vpp banner is outputted to non-interactive vppctl session

Running a batch file which contains many vppctl commands, occasionally,
VPP may spit out the banner for some of the commands. This happens
when VPP erroneously views the vppctl session as interactive.

A simple way to recreate the problem is to run a batch script as followed
while [ 1 ]
do
     vppctl create loopback interface
     vppctl delete loopback interface intfc loop0
done

We have two processes which may display the banner,
unix_cli_new_session_process and unix_cli_process. Normally,
unix_cli_process parses the input tokens and displays the banner after
it negotiates the terminal type with the vppctl app.
unix_cli_new_session_process only displays the banner just in case the
client fails to negotiate terminal type. It runs on a timer and expires
in 1 second to display the banner if by then the terminal type is still
not yet negotiated.

The problem is when the session is killed or exitted, VPP does not remove
the element that was enqueued for cli_new_session_process. The index
for the connection (cf) is recycled. The timer for the queue element
continues to run. When the timer expires for the queue element, it
finds the wrong new session due to index recycling. If the new
session has not had negotiated the terminal type, the banner is printed
erroneously to the new session from cli_new_session_process.

The fix is to clean up the queue element to stop cli_new_session_process
from processing the wrong connection when the session is killed.

Type: fix

Signed-off-by: Steven Luong <sluong@cisco.com>
Change-Id: Ife2f1b1c95661e442f0fc6b73505e330e6641fc1
src/vlib/unix/cli.c