From 409dfb7e4b785d8f93d28d00dfbecc4f07d63ac1 Mon Sep 17 00:00:00 2001 From: wangmenglan Date: Mon, 5 Jun 2023 13:57:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E8=B0=83=E6=95=B4TFE=20c?= =?UTF-8?q?onf=20=E6=96=87=E4=BB=B6,=20=E4=BD=BF=E7=94=A8=E5=9B=9B?= =?UTF-8?q?=E5=85=83=E7=BB=84=E5=88=86=E6=B5=81;=20=E8=B0=83=E6=95=B4metri?= =?UTF-8?q?c=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/include/tfe_cmsg.h | 2 +- common/src/tfe_cmsg.cpp | 18 +++++++++--------- common/src/tfe_ctrl_packet.cpp | 4 ++-- common/src/tfe_packet_io.cpp | 4 ++-- common/test/test_cmsg.cpp | 4 ++-- conf/tfe/tfe.conf | 2 +- platform/src/tcp_stream.cpp | 2 +- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/common/include/tfe_cmsg.h b/common/include/tfe_cmsg.h index 543d0ba..fa05b85 100644 --- a/common/include/tfe_cmsg.h +++ b/common/include/tfe_cmsg.h @@ -120,7 +120,7 @@ enum tfe_cmsg_tlv_type #define TFE_CMSG_FLAG_USER1 0x2 // 1 << 1 struct tfe_cmsg* tfe_cmsg_init(); -void tfe_cmsg_destroy(struct tfe_cmsg *cmsg); +void tfe_cmsg_destroy(struct tfe_cmsg **cmsg); void tfe_cmsg_dup(struct tfe_cmsg *cmsg); void tfe_cmsg_set_flag(struct tfe_cmsg *cmsg, uint8_t flag); diff --git a/common/src/tfe_cmsg.cpp b/common/src/tfe_cmsg.cpp index a7e0969..6b03716 100644 --- a/common/src/tfe_cmsg.cpp +++ b/common/src/tfe_cmsg.cpp @@ -52,20 +52,20 @@ struct tfe_cmsg* tfe_cmsg_init() return cmsg; } -void tfe_cmsg_destroy(struct tfe_cmsg *cmsg) +void tfe_cmsg_destroy(struct tfe_cmsg **cmsg) { - if(cmsg != NULL) + if(*cmsg != NULL) { - if ((__sync_sub_and_fetch(&cmsg->ref, 1) != 0)) + if ((__sync_sub_and_fetch(&((*cmsg)->ref), 1) != 0)) return; - pthread_rwlock_wrlock(&cmsg->rwlock); + pthread_rwlock_wrlock(&((*cmsg)->rwlock)); for(int i = 0; i < TFE_CMSG_TLV_NR_MAX; i++) { - FREE(&(cmsg->tlvs[i])); + FREE(&((*cmsg)->tlvs[i])); } - pthread_rwlock_unlock(&cmsg->rwlock); - pthread_rwlock_destroy(&cmsg->rwlock); - FREE(&cmsg); + pthread_rwlock_unlock(&((*cmsg)->rwlock)); + pthread_rwlock_destroy(&((*cmsg)->rwlock)); + FREE(cmsg); } } @@ -296,6 +296,6 @@ int tfe_cmsg_deserialize(const unsigned char *data, uint16_t len, struct tfe_cms return 0; error_out: - tfe_cmsg_destroy(cmsg); + tfe_cmsg_destroy(&cmsg); return TFE_CMSG_INVALID_FORMAT; } diff --git a/common/src/tfe_ctrl_packet.cpp b/common/src/tfe_ctrl_packet.cpp index b86d276..67a1aae 100644 --- a/common/src/tfe_ctrl_packet.cpp +++ b/common/src/tfe_ctrl_packet.cpp @@ -363,7 +363,7 @@ succ: return 0; error: mpack_tree_destroy(&tree); - tfe_cmsg_destroy(handler->cmsg); + tfe_cmsg_destroy(&handler->cmsg); return -1; } @@ -392,7 +392,7 @@ void ctrl_packet_parser_init(struct ctrl_pkt_parser *handler) void ctrl_packet_cmsg_destroy(struct ctrl_pkt_parser *handler) { if (handler) { - tfe_cmsg_destroy(handler->cmsg); + tfe_cmsg_destroy(&handler->cmsg); if (handler->seq_header) { free(handler->seq_header); diff --git a/common/src/tfe_packet_io.cpp b/common/src/tfe_packet_io.cpp index 3eefc5b..7fe0476 100644 --- a/common/src/tfe_packet_io.cpp +++ b/common/src/tfe_packet_io.cpp @@ -257,7 +257,7 @@ static void session_ctx_free(struct session_ctx *ctx) if (ctx->cmsg) { - tfe_cmsg_destroy(ctx->cmsg); + tfe_cmsg_destroy(&ctx->cmsg); } if (ctx->raw_meta_i2e) @@ -1423,9 +1423,9 @@ static int handle_session_closing(struct metadata *meta, struct ctrl_pkt_parser { struct session_ctx *s_ctx = (struct session_ctx *)node->val_data; TFE_LOG_INFO(logger, "%s: session %lu closing", LOG_TAG_PKTIO, s_ctx->session_id); + tfe_set_intercept_metric(s_ctx->cmsg, 1, s_ctx->c2s_info.rx.n_pkts, s_ctx->c2s_info.rx.n_bytes, s_ctx->s2c_info.rx.n_pkts, s_ctx->s2c_info.rx.n_bytes, thread_seq); session_table_delete_by_id(thread->session_table, meta->session_id); ATOMIC_DEC(&(packet_io_fs->session_num)); - tfe_set_intercept_metric(s_ctx->cmsg, 1, s_ctx->c2s_info.rx.n_pkts, s_ctx->c2s_info.rx.n_bytes, s_ctx->s2c_info.rx.n_pkts, s_ctx->s2c_info.rx.n_bytes, thread_seq); return 0; } diff --git a/common/test/test_cmsg.cpp b/common/test/test_cmsg.cpp index 0686564..8fb6fbb 100644 --- a/common/test/test_cmsg.cpp +++ b/common/test/test_cmsg.cpp @@ -49,7 +49,7 @@ int main() } printf("\n"); - tfe_cmsg_destroy(cmsg_encode); + tfe_cmsg_destroy(&cmsg_encode); /////////////////////////////////////////////////////////////////////////// // Get CMSG @@ -73,7 +73,7 @@ int main() assert(ret == 0); printf("cmsg_decode: TFE_CMSG_SSL_PASSTHROUGH_REASON, value is %s, size is %d\n", get_string_value, get_string_len); - tfe_cmsg_destroy(cmsg_decode); + tfe_cmsg_destroy(&cmsg_decode); free(temp_buff); return 0; diff --git a/conf/tfe/tfe.conf b/conf/tfe/tfe.conf index 3b31416..0dedc79 100644 --- a/conf/tfe/tfe.conf +++ b/conf/tfe/tfe.conf @@ -254,7 +254,7 @@ bpf_obj=/opt/tsg/tfe/resource/bpf/bpf_tun_rss_steering.o bpf_debug_log=0 # 2: BPF 使用二元组分流 # 4: BPF 使用四元组分流 -bpf_hash_mode=2 +bpf_hash_mode=4 # 配置 tap 网卡的 RPS tap_rps_enable=1 diff --git a/platform/src/tcp_stream.cpp b/platform/src/tcp_stream.cpp index 207efc8..f44970c 100644 --- a/platform/src/tcp_stream.cpp +++ b/platform/src/tcp_stream.cpp @@ -1465,7 +1465,7 @@ void tfe_stream_destory(struct tfe_stream_private * stream) if (stream->cmsg) { tfe_cmsg_set_flag(stream->cmsg, TFE_CMSG_FLAG_USER0); - tfe_cmsg_destroy(stream->cmsg); + tfe_cmsg_destroy(&stream->cmsg); } FREE(&(stream->plugin_ctxs));