summaryrefslogtreecommitdiff
path: root/src/tsg_entry.cpp
diff options
context:
space:
mode:
author刘学利 <[email protected]>2021-09-29 02:00:34 +0000
committer刘学利 <[email protected]>2021-09-29 02:00:34 +0000
commiteade71227df822fa22e706cbd675f5d47ff855ed (patch)
tree177550e5957aedcf0ce4f463d819fa0a8559ca33 /src/tsg_entry.cpp
parent36911a6b5f35364fbda937a9019f469b5527d05c (diff)
TSG-7968: TCP会话创建延迟无数据v5.4.4
Diffstat (limited to 'src/tsg_entry.cpp')
-rw-r--r--src/tsg_entry.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tsg_entry.cpp b/src/tsg_entry.cpp
index 9164cfc..c7b88c1 100644
--- a/src/tsg_entry.cpp
+++ b/src/tsg_entry.cpp
@@ -14,6 +14,7 @@
#include <MESA/stream.h>
#include <MESA/MESA_prof_load.h>
#include <MESA/MESA_handle_logger.h>
+#include <MESA/MESA_jump_layer.h>
#include "app_label.h"
#include "tsg_rule.h"
@@ -987,6 +988,37 @@ void set_session_attribute_label(const struct streaminfo *a_stream, enum TSG_ATT
return ;
}
+static int set_tcp_establish_latency_ms(const struct streaminfo *a_tcp, int thread_seq,const void *ip_hdr)
+{
+ struct tcphdr *tcp=NULL;
+
+ if(ip_hdr==NULL || a_tcp==NULL)
+ {
+ return 0;
+ }
+
+ switch(a_tcp->addr.addrtype)
+ {
+ case ADDR_TYPE_IPV4:
+ tcp=(struct tcphdr *)MESA_net_jump_to_layer(ip_hdr, __ADDR_TYPE_IP_PAIR_V4, ADDR_TYPE_TCP);
+ break;
+ case ADDR_TYPE_IPV6:
+ tcp=(struct tcphdr *)MESA_net_jump_to_layer(ip_hdr, __ADDR_TYPE_IP_PAIR_V6, ADDR_TYPE_TCP);
+ break;
+ default:
+ return 0;
+ break;
+ }
+
+ if(!(tcp->syn))
+ {
+ set_session_attribute_label(a_tcp, TSG_ATTRIBUTE_TYPE_ESTABLISH_LATECY, NULL, 0, a_tcp->threadnum);
+ return 1;
+ }
+
+ return 0;
+}
+
int tsg_set_device_id_to_telegraf(char *device_sn)
{
char buff[128]={0};
@@ -1731,6 +1763,24 @@ extern "C" unsigned char TSG_MASTER_UDP_ENTRY(const struct streaminfo *a_udp, vo
extern "C" unsigned char TSG_MASTER_TCPALL_ENTRY(const struct streaminfo *a_tcp, void **pme, int thread_seq, const void *a_packet)
{
+ if(*pme==NULL)
+ {
+ *pme=(void *)get_struct_project(a_tcp, g_tsg_para.tcpall_project_id);
+ if(*pme==NULL)
+ {
+ *pme=(struct tcpall_context *)dictator_malloc(thread_seq, sizeof(struct tcpall_context));
+ memset(*pme, 0, sizeof(struct tcpall_context));
+ set_struct_project(a_tcp, g_tsg_para.tcpall_project_id, (void *)(*pme));
+ }
+ }
+
+ struct tcpall_context *_context=(struct tcpall_context *)(*pme);
+
+ if(_context->set_latency_flag==0)
+ {
+ _context->set_latency_flag=set_tcp_establish_latency_ms(a_tcp, thread_seq, a_packet);
+ }
+
return tsg_master_all_entry(a_tcp, a_tcp->pktstate, pme, thread_seq, a_packet);
}