From b76e5452a6e75d01bca80e9c1e824307fb053836 Mon Sep 17 00:00:00 2001 From: wangmenglan Date: Wed, 14 Jun 2023 19:54:46 +0800 Subject: [PATCH] =?UTF-8?q?traffic=5Fmirror=E5=A2=9E=E5=8A=A0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B9app=5Fsymbol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/tfe/tfe.conf | 1 + .../traffic-mirror/include/traffic_mirror.h | 4 ++-- plugin/business/traffic-mirror/src/entry.cpp | 13 +++++++++++-- plugin/business/traffic-mirror/src/ethdev.cpp | 6 +++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/conf/tfe/tfe.conf b/conf/tfe/tfe.conf index 0dedc79..cac29ad 100644 --- a/conf/tfe/tfe.conf +++ b/conf/tfe/tfe.conf @@ -168,6 +168,7 @@ type=1 default_vlan_id=2 table_info=resource/pangu/table_info_traffic_mirror.conf stat_file=log/traffic_mirror.status +app_symbol=tfe-mirror [traffic_steering] enable_steering_http=0 diff --git a/plugin/business/traffic-mirror/include/traffic_mirror.h b/plugin/business/traffic-mirror/include/traffic_mirror.h index a7f2388..a062f64 100644 --- a/plugin/business/traffic-mirror/include/traffic_mirror.h +++ b/plugin/business/traffic-mirror/include/traffic_mirror.h @@ -109,8 +109,8 @@ struct traffic_mirror_rebuild_target }; struct traffic_mirror_ethdev * traffic_mirror_ethdev_pcap_create(const char * str_ethdev, void * logger); -struct traffic_mirror_ethdev * traffic_mirror_ethdev_mr4_create(const char * str_ethdev, - unsigned int nr_threads, void * logger); +struct traffic_mirror_ethdev * traffic_mirror_ethdev_mr4_create(const char * str_ethdev, + const char * str_app_name, unsigned int nr_threads, void * logger); void traffic_mirror_ethdev_destroy(struct traffic_mirror_ethdev * ethdev); int traffic_mirror_ethdev_finish(struct traffic_mirror_ethdev * ethdev, unsigned int tid, unsigned int pktlen); diff --git a/plugin/business/traffic-mirror/src/entry.cpp b/plugin/business/traffic-mirror/src/entry.cpp index 262a76e..e435534 100644 --- a/plugin/business/traffic-mirror/src/entry.cpp +++ b/plugin/business/traffic-mirror/src/entry.cpp @@ -390,6 +390,7 @@ error_out: static int traffic_mirror_ethdev_init(struct traffic_mirror_instance * instance) { char str_ethdev[TFE_SYMBOL_MAX] = {0}; + char app_symbol[TFE_SYMBOL_MAX] = {0}; const char * profile = "./conf/tfe/tfe.conf"; int ret = MESA_load_profile_string_nodef(profile, "traffic_mirror", "device", @@ -407,14 +408,22 @@ static int traffic_mirror_ethdev_init(struct traffic_mirror_instance * instance) unsigned int device_type; MESA_load_profile_uint_def(profile, "traffic_mirror", "type", &device_type, TRAFFIC_MIRROR_ETHDEV_AF_PACKET); + ret = MESA_load_profile_string_nodef(profile, "traffic_mirror", "app_symbol", app_symbol, sizeof(app_symbol)); + if (ret < 0) + { + TFE_LOG_ERROR(instance->logger, "failed at reading conffile, " + "[traffic_mirror]app_symbol is not defined."); + return -1; + } + if (device_type == TRAFFIC_MIRROR_ETHDEV_AF_PACKET) { instance->ethdev = traffic_mirror_ethdev_pcap_create(str_ethdev, instance->logger); } else if(device_type == TRAFFIC_MIRROR_ETHDEV_MARSIO) { - instance->ethdev = traffic_mirror_ethdev_mr4_create(str_ethdev, - tfe_proxy_get_work_thread_count(), instance->logger); + instance->ethdev = traffic_mirror_ethdev_mr4_create(str_ethdev, + app_symbol, tfe_proxy_get_work_thread_count(), instance->logger); } else { diff --git a/plugin/business/traffic-mirror/src/ethdev.cpp b/plugin/business/traffic-mirror/src/ethdev.cpp index ed7bfee..0d6df0a 100644 --- a/plugin/business/traffic-mirror/src/ethdev.cpp +++ b/plugin/business/traffic-mirror/src/ethdev.cpp @@ -134,8 +134,8 @@ char * traffic_mirror_ethdev_send_prepare(struct traffic_mirror_ethdev * ethdev, /* =============================== VIRTUAL INTERFACE END =========================================== */ -struct traffic_mirror_ethdev * traffic_mirror_ethdev_mr4_create(const char * str_ethdev, - unsigned int nr_threads, void * logger) +struct traffic_mirror_ethdev * traffic_mirror_ethdev_mr4_create(const char * str_ethdev, + const char * str_app_name, unsigned int nr_threads, void * logger) { struct traffic_mirror_ethdev * ethdev = ALLOC(struct traffic_mirror_ethdev, 1); ethdev->type = TRAFFIC_MIRROR_ETHDEV_MARSIO; @@ -152,7 +152,7 @@ struct traffic_mirror_ethdev * traffic_mirror_ethdev_mr4_create(const char * str detail_mr4->instance = marsio_create(); assert(detail_mr4->instance != NULL); - if (marsio_init(detail_mr4->instance, "tfe-traffic-mirror") < 0) + if (marsio_init(detail_mr4->instance, str_app_name) < 0) { TFE_LOG_ERROR(logger, "failed at init MARSIOv4 instance."); goto errout;