From 201e8d1e2fad0d83ea1544fd14b35492d8dd72bc Mon Sep 17 00:00:00 2001
From: jiangheng <jiangheng14@huawei.com>
Date: Wed, 17 Apr 2024 15:43:07 +0800
Subject: [PATCH] adapt dpdk-23.11 remove kni

---
 src/lstack/core/lstack_dpdk.c | 4 +++-
 src/lstack/core/lstack_init.c | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
index 5d90408..016276a 100644
--- a/src/lstack/core/lstack_dpdk.c
+++ b/src/lstack/core/lstack_dpdk.c
@@ -694,6 +694,7 @@ int32_t dpdk_ethdev_start(void)
     return 0;
 }
 
+#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0)
 int32_t dpdk_init_lstack_kni(void)
 {
     struct protocol_stack_group *stack_group = get_protocol_stack_group();
@@ -712,7 +713,6 @@ int32_t dpdk_init_lstack_kni(void)
     return 0;
 }
 
-#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0)
 void dpdk_skip_nic_init(void)
 {
     /* when lstack init nic again, ltran can't read pkts from nic. unregister pci_bus to avoid init nic in lstack */
@@ -799,12 +799,14 @@ int32_t init_dpdk_ethdev(void)
         }
     }
 
+#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0)
     if (get_global_cfg_params()->kni_switch && get_global_cfg_params()->is_primary) {
         ret = dpdk_init_lstack_kni();
         if (ret < 0) {
             return -1;
         }
     }
+#endif
 
     return 0;
 }
diff --git a/src/lstack/core/lstack_init.c b/src/lstack/core/lstack_init.c
index 79b4060..c2499d7 100644
--- a/src/lstack/core/lstack_init.c
+++ b/src/lstack/core/lstack_init.c
@@ -183,6 +183,7 @@ static void gazelle_signal_init(void)
     lstack_signal_init();
 }
 
+#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0)
 static void set_kni_ip_mac()
 {
     struct cfg_params *cfg = get_global_cfg_params();
@@ -230,6 +231,7 @@ static void set_kni_ip_mac()
 
     posix_api->close_fn(fd);
 }
+#endif
 
 __attribute__((constructor)) void gazelle_network_init(void)
 {
@@ -315,9 +317,11 @@ __attribute__((constructor)) void gazelle_network_init(void)
     /* lwip initialization */
     lwip_sock_init();
 
+#if RTE_VERSION < RTE_VERSION_NUM(23, 11, 0, 0)
     if (get_global_cfg_params()->kni_switch) {
         set_kni_ip_mac();
     }
+#endif
 
     if (set_process_start_flag() != 0) {
         gazelle_exit();
-- 
2.33.0

