MERAprojects / ops-build

Other
0 stars 0 forks source link

Terminal is stop responding after execute "exit" command in LAG configure menu #27

Closed alrukav closed 7 years ago

alrukav commented 7 years ago

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:

switch# configure terminal 
switch(config)# interface lag 1
switch(config-lag-if)# exit

^C
switch(config-lag-if)# switch(config)# 
AKochin commented 7 years ago

Needs review and merge and then to be verified and closed.

AKochin commented 7 years ago

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.

AKochin commented 7 years ago

issue can be verified on latest master.

alrukav commented 7 years ago

The fix works fine!