-
Bug
-
Resolution: Unresolved
-
Highest
Found out when using vpp with nc (netcat).
An analysis by Shrinivasan Ganapathy:
- Looks like nc(netcat) is doing poll() system call and vcl-ldpreload library does not have an implementation for poll().
- I did strace on nc server and client before LD_PRELOAD. Looks like they do poll() on connected fd and do read and write on the polled fd.
- From the debug trace in vcl_ldpreload library I observe the following:
00. nc server’s accept() and nc client’s connect() succeeds. Expected behavior.
01. Then the server close the listen fd. Expected behavior.
02. Then the Server and Client do shutdown and close connected fd. Unexpected behavior. - The nc server and client after successfully connection, they do poll on the connected fd(vcom fd). But vcl_ldpreload has no implementation for poll system call. So poll fails and nc server and client takes the shutdown path to close the open fds before exit, which is what is observed in 02.
- Details:
vcl-ldpreload trace on nc server:
shganapa@krb-server3:/scratch/shganapa/sandbox/nc$ sudo LD_PRELOAD=$VCL_LDPRELOAD_LIB/libvcl_ldpreload.so.0.0.0 nc -l -n -v 2222
[sudo] password for shganapa:
vcom_socket_main_init
[24635] vcom_init...done!
[24635] vcom_constructor...done!
[24635][140399301695232 (0x7fb142811700)] socket: '0006'= D='0002', T='0001', P='0006'
fd='0006', sid='00000000',type='SOCKET_TYPE_VPPCOM_BOUND '
[24635] setsockopt: '0000'='0006', '0001', '0002', '0x7ffc101bf0b4', '0004'
[24635] bind: '0000'='0006', '0x20fd580', '0016'
[24635] listen: '0000'='0006', '0001'
Listening on [0.0.0.0] (family 0, port 2222)
fd='0006', sid='00000000',type='SOCKET_TYPE_VPPCOM_BOUND '
[24635][140399301695232 (0x7fb142811700)] accept1: '-001'='0006', '0x7ffc101bf1f0', '0x7ffc101bf164'
[24635][140399301695232 (0x7fb142811700)] accept2: '0007'='0006', '0x7ffc101bf1f0', '0x7ffc101bf164'
fd='0006', sid='00000000',type='SOCKET_TYPE_VPPCOM_BOUND '
fd='0007', sid='00000001',type='SOCKET_TYPE_VPPCOM_BOUND '
Connection from [0.0.0.0] port 2222 [tcp/*] accepted (family 2, sport 2222)
fd='0006', sid='00000000',type='SOCKET_TYPE_VPPCOM_BOUND '
fd='0007', sid='00000001',type='SOCKET_TYPE_VPPCOM_BOUND '
[24635] close: '0000'='0006'
fd='0007', sid='00000001',type='SOCKET_TYPE_VPPCOM_BOUND '
[24635] shutdown: '0000'='0007', '0000'
fd='0007', sid='00000001',type='SOCKET_TYPE_VPPCOM_BOUND '
[24635] close: '0000'='0007'
vcom_socket_main_destroy
[24635] vcom_destroy...done!
[24635] vcom_destructor...done!
shganapa@krb-server3:/scratch/shganapa/sandbox/nc$
vcl-ldpreload trace on nc client:
shganapa@krb-server3:/scratch/shganapa/sandbox/nc$ sudo LD_PRELOAD=$VCL_LDPRELOAD_LIB/libvcl_ldpreload.so.0.0.0 nc -v -n 127.0.0.1 2222
vcom_socket_main_init
[24749] vcom_init...done!
[24749] vcom_constructor...done!
[24749][140139051042560 (0x7f74aa5b4700)] socket: '0006'= D='0002', T='0001', P='0006'
fd='0006', sid='00000000',type='SOCKET_TYPE_VPPCOM_BOUND '
[24749] fcntl: '0002'='0006', '0003'
[24749] fcntl: '0000'='0006', '0004'
[24749][140139051042560 (0x7f74aa5b4700)] connect: '0000'='0006', '0x2630b40', '0016'
[24749] fcntl: '0000'='0006', '0004'
Connection to 127.0.0.1 2222 port [tcp/*] succeeded!
[24749] shutdown: '0000'='0006', '0000'
fd='0006', sid='00000000',type='SOCKET_TYPE_VPPCOM_BOUND '
[24749] close: '0000'='0006'
vcom_socket_main_destroy
[24749] vcom_destroy...done!
[24749] vcom_destructor...done!