Closed alrukav closed 7 years ago
Needs review and merge and then to be verified and closed.
Deadlock occurs due to inappropriate "exit" cmd handler definition. It is defined as IDL blocking which is not normally used for vtysh navigation commands. DEFUNSH_NON_IDL should be used instead as in vtysh_exit_interface_cmd. Otherwise pthread_mutex_lock is called twice and process hangs up. As there is no difference between vtysh_exit_interface_cmd and vtysh_exit_lacp_interface_cmd last one can be removed.
DEFUNSH_NON_IDL (VTYSH_INTERFACE,
vtysh_exit_interface,
vtysh_exit_interface_cmd,
"exit",
"Exit current mode and down to previous mode\n")
Interface command behavior:
switch(config)# int 1
cmd_execute_command_real(3596): --> Attempting to LOCK mutex. Call pthread_mutex_lock
cmd_execute_command_real(3599): --> LOCKED. matched_element->string=interface IFNAME
cmd_execute_command_real(3609): --> UNLOCKED.
switch(config-if)# exit
/** CALLING vtysh_exit() directly **/
vtysh_exit(1327): --> vty->node=12 LINK_AGGREGATION_NODE=46 INTERFACE_NODE=12
cmd_execute_command_real(3533): --> Attempting to LOCK mutex. Call pthread_mutex_lock
cmd_execute_command_real(3535):--> --> LOCKED.
cmd_execute_command_real(3539):--> UNLOCKED.
Faulty lag command behavior:
switch(config)# int lag 1
cmd_execute_command_real(3596): --> Attempting to LOCK mutex. Call pthread_mutex_lock
cmd_execute_command_real(3599): --> LOCKED. matched_element->string=interface lag <1-2000>
cmd_execute_command_real(3609): --> UNLOCKED.
switch(config-lag-if)# exit
/** CALLING command_real first as for IDL commands **/
cmd_execute_command_real(3596): --> Attempting to LOCK mutex. Call pthread_mutex_lock !!!! mutex taken 1st time
cmd_execute_command_real(3599): --> LOCKED. matched_element->string=exit
vtysh_exit(1327): --> vty->node=46 LINK_AGGREGATION_NODE=46 INTERFACE_NODE=12
cmd_execute_command_real(3533): --> Attempting to LOCK mutex. Call pthread_mutex_lock
Deadlock occurs as double access to mutex occurs.
issue can be verified on latest master.
The fix works fine!
Problem Description:
Terminal is not responded after execute "exit" command in LAG configure menu.
OpenSwitch version:
OpenSwitch 0.4.0 (Build: appliance-ops-0.4.0-meraswitch/devel/master-20170202134441-dev)
Steps to reproduce the problem: