All,

I have been investigating this issue. Looks like nc(netcat) is doing poll() 
system call and vcl-ldpreload library does not have an implementation for 
poll().

Vcl-ldpreload library is developed as part of vppsb project.

It’s very nascent and is being actively developed. I would encourage people to 
contribute to the development.

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 below.

 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!

shganapa@krb-server3:/scratch/shganapa/sandbox/nc$

  -shrini-

From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]] On Behalf Of Peter Palmár
Sent: Monday, September 18, 2017 10:32 AM
To: [email protected]<mailto:[email protected]>
Subject: [vpp-dev] When using nc (netcat), VPP doesn't seem to work



Hi vpp developers,

I would like to use vpp with nc, but after the nc server has accepted the first 
connection from the nc client,
the server closes the session and the server and client end normally.

More precisely, they end after
  pthread_mutex_unlock (&q->mutex)
from
  unix_shared_memory_queue.c / unix_shared_memory_queue_add(...)
has been executed by the client.
Please have a look at the backtrace of the stack below.

Server:
sudo -E bash -c 'export LD_PRELOAD=/usr/local/lib/libvcl_ldpreload.so.0.0.0; 
./nc -l -n -v 2222'

Client:
sudo -E gdb --args ./nc -v -n 127.0.0.1 2222
(gdb) set environment LD_PRELOAD=/usr/local/lib/libvcl_ldpreload.so.0.0.0
(...)
(gdb) bt
#0  unix_shared_memory_queue_add (q=0x30046080, elem=0x7fffffff9828 ""\a0", 
nowait=0) at 
/home/palmar/dev/vpp/build-data/../src/vlibmemory/unix_shared_memory_queue.c:232
#1  0x00007ffff684f610 in vl_msg_api_send_shmem (q=0x30046080, 
elem=0x7fffffff9828 ""\a0") at 
/home/palmar/dev/vpp/build-data/../src/vlibmemory/memory_shared.c:581
#2  0x00007ffff6ebde6d in vppcom_send_connect_sock (session=0x7fffe1f1e52c, 
session_index=0) at /home/palmar/dev/vpp/build-data/../src/uri/vppcom.c:788
#3  0x00007ffff6ec2ba0 in vppcom_session_connect (session_index=0, 
server_ep=0x7fffffff98b0) at 
/home/palmar/dev/vpp/build-data/../src/uri/vppcom.c:2096
#4  0x00007ffff7bd1435 in vcom_socket_connect (__fd=__fd@entry=6, 
__addr=__addr@entry=0x688b40, __len=__len@entry=16) at 
libvcl-ldpreload/vcom_socket.c:990
#5  0x00007ffff7bcdf70 in vcom_connect (__fd=__fd@entry=6, 
__addr=__addr@entry=0x688b40, __len=__len@entry=16) at 
libvcl-ldpreload/vcom.c:1842
#6  0x00007ffff7bce08e in connect (__fd=6, __addr=0x688b40, __len=16) at 
libvcl-ldpreload/vcom.c:1862
#7  0x0000000000403ce1 in connect_with_timeout (ctimeout=-1, salen=16, 
sa=0x688b40, fd=6) at netcat.c:961
#8  remote_connect (host=host@entry=0x7fffffffe14c "127.0.0.1", port=0x688af0 
"2222", hints=...) at netcat.c:877
#9  0x000000000040219c in main (argc=<optimized out>, argv=<optimized out>) at 
netcat.c:641

Could you please let me know whether this is a known issue?

Regards,
Peter





_______________________________________________
vpp-dev mailing list
[email protected]
https://lists.fd.io/mailman/listinfo/vpp-dev
  • [vpp-dev] When ... Peter Palmár
    • Re: [vpp-d... Shrinivasan Ganapathy -X (shganapa - NETPACE INC at Cisco)

Reply via email to