I have a little program using binary API to configure VPP (v21.06). It's 
written in C. When VPP restarts, it needs to re-configure VPP. I noticed after 
VPP restarts, all API calls have no reply. So I tried to disconnect, then 
connect again. After first restart, everything works fine. But the second time 
VPP restarts, my program cored. Here is the backtrace:

[Thread 0x7fffd8f05700 (LWP 18019) exited]
vl_client_disconnect:309: peer unresponsive, give up          <===== First vpp 
restarts
[New Thread 0x7fffd8f05700 (LWP 23599)]
[New Thread 0x7fffbbffe700 (LWP 23737)]
[Thread 0x7fffbbffe700 (LWP 23737) exited]
[Thread 0x7fffd8f05700 (LWP 23599) exited]
vl_client_disconnect:309: peer unresponsive, give up          <=======Second 
vpp restarts

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffea709700 (LWP 18016)]
0x00007ffff5ef2387 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install 
fuse-libs-2.9.4-1.0.9.el7.x86_64 glibc-2.17-324.0.1.el7_9.x86_64 
keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.15.1-50.0.1.el7.x86_64 
libcom_err-1.42.9-19.el7.x86_64 libgcc-4.8.5-44.0.3.el7.x86_64 
libselinux-2.5-15.el7.x86_64 libstdc++-4.8.5-44.0.3.el7.x86_64 
numactl-libs-2.0.12-5.0.3.el7.x86_64 openssl-libs-1.0.2k-21.0.3_talari.x86_64 
pcre-8.32-17.el7.x86_64 zlib-1.2.7-19.el7_9.x86_64
(gdb) bt
#0  0x00007ffff5ef2387 in raise () from /lib64/libc.so.6
#1  0x00007ffff5ef3a78 in abort () from /lib64/libc.so.6
#2  0x00007ffff7f80cb6 in os_panic () from 
/home/talariuser/vpp_root/usr/lib/libvppinfra.so.21.06.0
#3  0x00007ffff7fd3c45 in mspace_free () from 
/home/talariuser/vpp_root/usr/lib/libvppinfra.so.21.06.0
#4  0x00007ffff7f5dd79 in clib_mem_free (p=0x7fffd8f0de98) at 
/usr/src/debug/vpp-21.06.0/src/vppinfra/mem.h:321
#5  vl_api_name_and_crc_free () at 
/usr/src/debug/vpp-21.06.0/src/vlibmemory/memory_client.c:108
#6  0x00007ffff7f5e626 in vl_api_memclnt_create_reply_t_handler 
(mp=0x13004d648) at 
/usr/src/debug/vpp-21.06.0/src/vlibmemory/memory_client.c:135
#7  0x00007ffff7f65b5b in msg_handler_internal (free_it=1, do_it=1, 
trace_it=<optimized out>, the_msg=0x13004d648, am=0x7ffff7f76560 
<api_global_main>) at /usr/src/debug/vpp-21.06.0/src/vlibapi/api_shared.c:501
#8  vl_msg_api_handler (the_msg=0x13004d648) at 
/usr/src/debug/vpp-21.06.0/src/vlibapi/api_shared.c:708
#9  0x00007ffff7f5ebc0 in vl_client_connect (name=name@entry=0x5bb157 "t3_app", 
ctx_quota=ctx_quota@entry=0, input_queue_size=input_queue_size@entry=1024)
    at /usr/src/debug/vpp-21.06.0/src/vlibmemory/memory_client.c:243
#10 0x00007ffff7f5ef95 in connect_to_vlib_internal (do_map=1, 
thread_fn_arg=0x0, thread_fn=0x7ffff7f5e4f0 <rx_thread_fn>, 
rx_queue_size=<optimized out>, client_name=0x5bb157 "t3_app",
    svm_name=0x5c2d0b "/vpe-api") at 
/usr/src/debug/vpp-21.06.0/src/vlibmemory/memory_client.c:417
#11 vl_client_connect_to_vlib (svm_name=svm_name@entry=0x5c2d0b "/vpe-api", 
client_name=client_name@entry=0x5bb157 "t3_app", 
rx_queue_size=rx_queue_size@entry=1024)
    at /usr/src/debug/vpp-21.06.0/src/vlibmemory/memory_client.c:458
#12 0x00000000004ef9ce in vpp_api_init (vpp_restarts=vpp_restarts@entry=1 
'\001') at control/vpp_api_agent.c:216
#13 0x00000000004daa47 in resend_routes_to_vpp () at control/routes_mgr.c:2275
#14 0x000000000041c5e7 in cli_process_command (msg=msg@entry=0x7fffea6c82f0) at 
manage/cli.c:425
#15 0x000000000041a2e1 in msgq_handler_thread (dummy=<optimized out>) at 
manage/console.c:4121
#16 0x00000000004b24b7 in thread_dispatcher (thread_args=0x17fd8c0 
<t2_thread_list+832>) at common/thread_manager.c:530
#17 0x00007ffff7bc6ea5 in start_thread () from /lib64/libpthread.so.0
#18 0x00007ffff5fba9fd in clone () from /lib64/libc.so.6
(gdb)

Here is the related code:
typedef struct
{
    svm_queue_t *vl_input_queue; /* vpe input queue */
    u32 my_client_index; /* API client handle */
} vpp_api_agent_main_t;

vpp_api_agent_main_t agent_main;

void vpp_api_init(boolean vpp_restarts)
{
    if (vpp_restarts)
    {
        vl_client_disconnect_from_vlib();
    }
    // Initialization
    clib_mem_init_thread_safe(0, 256 << 20);
    clib_memset(&agent_main, 0, sizeof (vpp_api_agent_main_t));

    // Create shared mem with vpp
    api_main_t *am = vlibapi_get_main();

    if (vl_client_connect_to_vlib("/vpe-api", "t3_app", DEFAULT_QUEUE_SIZE) < 0)
    {
        ROUTE_LOG_ERROR("Shmem connect failed\n");
        svm_region_exit();
    }
    else
    {
        agent_main.vl_input_queue = am->shmem_hdr->vl_input_queue;
        agent_main.my_client_index = am->my_client_index;

        ROUTE_LOG("Connected to vpp!!!\n");
    }

    // Register callback functions
    agent_api_hookup(&agent_main);
}

Anybody know what do I need to cleanup before reconnect to vpp again? Thanks in 
advance.

Wei
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#21010): https://lists.fd.io/g/vpp-dev/message/21010
Mute This Topic: https://lists.fd.io/mt/89737580/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to