From c4e5033d44b4e6ff5a2b35e0087a26539bd9d785 Mon Sep 17 00:00:00 2001
From: Honggang LI <honggangli@163.com>
Date: Mon, 13 Nov 2023 09:35:57 +0800
Subject: [PATCH] Fix coredump issue and skip rte_pdump_init for secondary
 process

Signed-off-by: Honggang LI <honggangli@163.com>
---
 src/lstack/core/lstack_dpdk.c | 14 ++++++++------
 src/lstack/core/lstack_lwip.c |  2 +-
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
index 1a5b568..5fc641e 100644
--- a/src/lstack/core/lstack_dpdk.c
+++ b/src/lstack/core/lstack_dpdk.c
@@ -125,12 +125,14 @@ int32_t dpdk_eal_init(void)
         LSTACK_PRE_LOG(LSTACK_INFO, "dpdk_eal_init success\n");
     }
 
-    ret = rte_pdump_init();
-    if (ret < 0) {
-        LSTACK_PRE_LOG(LSTACK_ERR, "rte_pdump_init failed init, rte_errno %d\n", rte_errno);
-	/* We do not care whether the pdump is successfully loaded. So, just print an alarm. */
-    } else {
-        LSTACK_PRE_LOG(LSTACK_INFO, "rte_pdump_init success\n");
+    if (get_global_cfg_params()->is_primary) {
+        ret = rte_pdump_init();
+        if (ret < 0) {
+            LSTACK_PRE_LOG(LSTACK_ERR, "rte_pdump_init failed init, rte_errno %d\n", rte_errno);
+	    /* We do not care whether the pdump is successfully loaded. So, just print an alarm. */
+        } else {
+            LSTACK_PRE_LOG(LSTACK_INFO, "rte_pdump_init success\n");
+        }
     }
 
     return ret;
diff --git a/src/lstack/core/lstack_lwip.c b/src/lstack/core/lstack_lwip.c
index cdb0089..a2b02df 100644
--- a/src/lstack/core/lstack_lwip.c
+++ b/src/lstack/core/lstack_lwip.c
@@ -1216,7 +1216,7 @@ uint32_t do_lwip_get_conntable(struct gazelle_stat_lstack_conn_info *conn,
         conn[conn_num].l_port = pcbl->local_port;
         conn[conn_num].tcp_sub_state = pcbl->state;
         struct netconn *netconn = (struct netconn *)pcbl->callback_arg;
-        conn[conn_num].fd = netconn->socket;
+	conn[conn_num].fd = netconn != NULL ? netconn->socket : -1;
         if (netconn != NULL && netconn->acceptmbox != NULL) {
             conn[conn_num].recv_cnt = rte_ring_count(netconn->acceptmbox->ring);
         }
-- 
2.23.0

