diff options
| author | yangwei <[email protected]> | 2024-09-12 15:33:29 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2024-09-12 15:33:29 +0800 |
| commit | adfc240bd036c3467b785e183e2ecd6f82e65a50 (patch) | |
| tree | eaf906562947215d709dfbf83da02ccf44405085 | |
| parent | 44797065bc0886ba3dd430ee4ec8968c9d18fdb2 (diff) | |
🌈 style(remove unicode comments): 移除乱码注释
| -rw-r--r-- | include/private/deal_ipv4.h | 21 | ||||
| -rw-r--r-- | include/private/ip_reassembly.h | 83 | ||||
| -rw-r--r-- | include/private/stream_manage.h | 8 | ||||
| -rw-r--r-- | src/dealpkt/deal_ipv4.c | 295 | ||||
| -rw-r--r-- | src/dealpkt/deal_tcp.c | 547 |
5 files changed, 149 insertions, 805 deletions
diff --git a/include/private/deal_ipv4.h b/include/private/deal_ipv4.h index d700395..2012d75 100644 --- a/include/private/deal_ipv4.h +++ b/include/private/deal_ipv4.h @@ -14,14 +14,10 @@ #endif
//#define IPV4_FRAG_TIMEOUT (30)
-/*
- 2015-12-02 lijia modify,
- ��ȻRFC�涨, 30�������з�Ƭ������ɾ��ǺϷ���,
- ���ʵ�����, IPv4��Ƭ�����6���ڻ�δ�������, ����Ϊ�ǹ�����Ϊ��, ֱ��free.
-*/
+
#define IPV4_FRAG_TIMEOUT (6)
-#define IPV4_FRAG_RESERVED_HDR_LEN (20) /* Ԥ����һ��IP��Ƭͷ������ */
+#define IPV4_FRAG_RESERVED_HDR_LEN (20)
#define IPV4_FRAG_NUM_PER_IPQ (100)
@@ -33,25 +29,20 @@ #define IPv4_FRAG_MF 0x2000 /* Flag: "More Fragments" */
#define IPv4_FRAG_OFFSET 0x1FFF /* "Fragment Offset" part */
-#define IPv4_HDR_MAX_LEN (60) /* IPv4���ͷ������ */
+#define IPv4_HDR_MAX_LEN (60)
struct ipv4_frag_key{
unsigned int ip_src; /* source address, network order */
unsigned int ip_dst; /* dest address, network order */
unsigned short identification; /* network order */
unsigned char protocol;
- char __pad__[5]; /* ����ṹ8�ֽڶ��� */
+ char __pad__[5];
#if USE_MESA_STREAM_HASH
- struct streaminfo_private *pstream_pr; /* �����ڱȽϵ�ַ, ʵ�ʲ�����HASH���� */
+ struct streaminfo_private *pstream_pr;
#endif
};
struct ipv4_frag_private{
- /*
- ԭʼIP���ĵ�һ����Ƭͷ������, ��ʼ��ʱ��Ϊinit_len = 20, ����IPͷ������, �Ա�֤�����������ȷ��.
- ����յ���һ����Ƭ��, ԭʼ��ͷʵ�ʳ���actual_len = 40, ����init_len,
- ��Ҫ��realloc�ڴ�, Ȼ��ʵ�����ݲ������memmove(actual_len - init_len).
- */
int raw_ip_hdr_len;
};
@@ -59,7 +50,6 @@ struct ipv4_frag_private{ extern "C" {
#endif
-/* �Ƿ�ΪIPv4˽�е�ַ */
static inline int is_private_addr_v4(u_int ip_add)
{
/* 10/8 */
@@ -79,7 +69,6 @@ static inline int is_private_addr_v4(u_int ip_add) return 0;
}
-/* �Ƿ�ΪIPv4�鲥��ַ */
static inline int is_multicast_addr_v4(u_int ip_add)
{
/* 224~239 */
diff --git a/include/private/ip_reassembly.h b/include/private/ip_reassembly.h index 6b91f1c..5248177 100644 --- a/include/private/ip_reassembly.h +++ b/include/private/ip_reassembly.h @@ -4,20 +4,20 @@ #include "stream_internal.h"
-#define USE_MESA_STREAM_HASH (1) /* ʹ�û�������ģʽ�µ�HASH�� */
+#define USE_MESA_STREAM_HASH (1)
#if USE_MESA_STREAM_HASH
#include "MESA_htable.h"
#endif
-#define IP_FRAG_DEFAULT_BUF_SIZE (2048) /* Ԥ����Ĭ��IP��Ƭ���黺������С, ͨ��ͳ�Ƶó�, ������IP������С��2KB��ռ90%���� */
+#define IP_FRAG_DEFAULT_BUF_SIZE (2048)
-#define IP_FRAG_OK (0x00) /* ������� */
-#define IP_FRAG_INVALID_PACKET (0x10) /* ��Ч��Ƭ�����˷�Ƭ�����ٴ���������������ͬһIPQ����һ����Ƭ�� */
-#define IP_FRAG_DISCARD (0x08) /* ������Ƭ���������ͷ�����IPQ���� */
-#define IP_FRAG_IGNORE (0x04) /* ������Ƭ�����Ժ�ͬһIPQ���еķ�Ƭ�������ٴ������������IPQ��ֱ����ʱ */
+#define IP_FRAG_OK (0x00)
+#define IP_FRAG_INVALID_PACKET (0x10)
+#define IP_FRAG_DISCARD (0x08)
+#define IP_FRAG_IGNORE (0x04)
-#define IP_FRAG_FIRST_IN (0x02) /* ���յ��˵�һ����Ƭ�� */
-#define IP_FRAG_LAST_IN (0x01) /* ���յ������һ����Ƭ�� */
+#define IP_FRAG_FIRST_IN (0x02)
+#define IP_FRAG_LAST_IN (0x01)
struct addr_list{
@@ -26,59 +26,56 @@ struct addr_list{ };
-/* һ����Ƭ�� */
struct ip_frags{
- int offset; /* �˷�Ƭ����һ���ֽ����ԭʼ����ƫ���� */
- int end; /* �˷�Ƭ�����һ���ֽ����ԭʼ����ƫ���� */
- struct ip_frags *next; /* �˷�Ƭ���ڷ�Ƭ�����еĺ�̽ڵ� */
- struct ip_frags *prev; /* �˷�Ƭ���ڷ�Ƭ�����е�ǰ���ڵ� */
+ int offset;
+ int end;
+ struct ip_frags *next;
+ struct ip_frags *prev;
};
-/* ��Ƭ������� */
struct frag_ipq{
- int buf_size; /* ��IP������ij��� */
- short last_in; /* ��־λ���յ���һ���������һ���� */
- short attack_flag; /* ��־λ���Ƿ����������ݰ� */
- int tot_len; /* ��ǰ�յ���Ƭ�������ƫ���� */
- int meat; /* ʵ���յ���IP��Ƭ����Ч���ݳ��� */
- unsigned int hash_index; /* ����������HASHֵ���Ժ��ظ�ʹ�ã������ٴμ��� */
+ int buf_size;
+ short last_in;
+ short attack_flag;
+ int tot_len;
+ int meat;
+ unsigned int hash_index;
int hash_key_size;
- int private_len; /* ��Э��������صĶ����������� */
- int frags_num; /* �յ��ķ�Ƭ������ */
- time_t create_time; /* ipq����ʱ�䣬���յ���һ����Ƭ����ʱ�� */
- void *new_iph; /* ��������IP��ͷ��ָ�� */
- struct ip_frags *fragments; /* ��Ƭ������ͷ */
- struct ip_frags *fragments_tail; /* ��Ƭ������β */
+ int private_len;
+ int frags_num;
+ time_t create_time;
+ void *new_iph;
+ struct ip_frags *fragments;
+ struct ip_frags *fragments_tail;
int frags_len;
#if USE_MESA_STREAM_HASH
- int thread_num; /* ʹ����HASHʱ, thread_num���ô���, ���ڴ˽ṹ�� */
+ int thread_num;
#else
- struct frag_ipq *hash_prev; /* HASH��ͻ������ǰ���ڵ� */
- struct frag_ipq *hash_next; /* HASH��ͻ�����ĺ�̽ڵ� */
- struct frag_ipq *lru_prev; /* LRU������ǰ���ڵ� */
- struct frag_ipq *lru_next; /* LRU�����ĺ�̽ڵ� */
+ struct frag_ipq *hash_prev;
+ struct frag_ipq *hash_next;
+ struct frag_ipq *lru_prev;
+ struct frag_ipq *lru_next;
#endif
- void *hash_key; /* hash key����Э���أ��ɹ���ģ������ռ䣬������hash_key_sizeָ�� */
- void *private_info; /* ��Э��������صĶ�������������������ռ�, ������private_lenָ�� */
- raw_ipfrag_list_t *ipfrag_list; /* ��ʱ�洢����ԭʼ��Ƭ�� */
+ void *hash_key;
+ void *private_info;
+ raw_ipfrag_list_t *ipfrag_list;
};
-/* ��Ƭ����Ĺ����ṹ�������Э��汾�� */
struct frag_manage{
- int thread_num; /* �߳�ID */
- unsigned int total_mem; /* ��ǰռ���ڴ����� */
+ int thread_num;
+ unsigned int total_mem;
#if USE_MESA_STREAM_HASH
MESA_htable_handle frag_hash_table;
#else
- unsigned int hash_table_size; /* HASH����С */
+ unsigned int hash_table_size;
int __pad__;
- struct frag_ipq **frag_hash_table; /* HASH��ͷָ�� */
- unsigned int (*hash_index)(void *hash_key); /* HASH����ָ�� */
- int (*hash_cmp)(void *hash_key1, void *hash_key2); /* key�ȽϺ���ָ�� */
- struct frag_ipq *lru_head; /* lru����ͷ */
- struct frag_ipq *lru_tail; /* lru����β */
+ struct frag_ipq **frag_hash_table;
+ unsigned int (*hash_index)(void *hash_key);
+ int (*hash_cmp)(void *hash_key1, void *hash_key2);
+ struct frag_ipq *lru_head;
+ struct frag_ipq *lru_tail;
#endif
int scratch_frag_cnt;
int scratch_frag_len;
diff --git a/include/private/stream_manage.h b/include/private/stream_manage.h index 38a7988..d6bcb95 100644 --- a/include/private/stream_manage.h +++ b/include/private/stream_manage.h @@ -62,7 +62,7 @@ extern int tcp_support_all; #define STREAM_LINK_RESET 4
#define STREAM_LINK_TIMEOUT 5
#define STREAM_LINK_LRU_OUT 6
-#define STREAM_FAKE_CLOSE_BY_DEPRIVE 7 /* �����������KILL_FOLLOW, KILL_OTHER��, ��ǿ��CLOSE�IJ��״̬ */
+#define STREAM_FAKE_CLOSE_BY_DEPRIVE 7
#define STREAM_CLOSE_BY_DUMPFILE_END 8 /* 2021-05-20 lijia add, for pcap dumpfile mode */
@@ -104,11 +104,11 @@ struct stream_index_list_item struct global_stream
{
struct streamindex **tcp_stream_table;
- unsigned short *tcp_stream_talbe_hash_count; /* lijia comment: һ��HASH_Slot�³�ͻ����Ԫ�ظ��� */
+ unsigned short *tcp_stream_talbe_hash_count;
struct stream_list tcpList[MAX_TCP_STATE];
struct streamindex **udp_stream_table;
- unsigned short *udp_stream_talbe_hash_count;/* lijia comment: һ��HASH_Slot�³�ͻ����Ԫ�ظ��� */
+ unsigned short *udp_stream_talbe_hash_count;
struct stream_list udpList[MAX_UDP_STATE];
STAILQ_HEAD(STREAM_INDEX_LIST,stream_index_list_item) freeList;
@@ -131,7 +131,7 @@ typedef struct _stStreamFunInfo struct timeout timeout;
const struct streaminfo *pstream;
int set_timer_s;
- int entry_id; /* ȫ��Ψһ��id, ����ÿ�������ں�����ִ��ʱ��ͳ�� */
+ int entry_id;
char pad[7];
char appState;
enum fun_type_t funtype;/* 2014-12-31 lqy add */
diff --git a/src/dealpkt/deal_ipv4.c b/src/dealpkt/deal_ipv4.c index 720ec37..9bbfe1b 100644 --- a/src/dealpkt/deal_ipv4.c +++ b/src/dealpkt/deal_ipv4.c @@ -1,15 +1,3 @@ -/*
- This file is taken from Libnids-1.2.4.
- Modified in Nov 2011 by liuganggang.
- This is "release+debug" version.
-
- update log:
- 2012-06-28, by LiJia<[email protected]>
- ʹ��IP��Ƭ������������汾��ز��ֶ�������, ����ʹ��thread_node�ṹ��
- �������̼��ܹ�δ�仯.
-
-*/
-
#include "stream_internal.h"
#include <MESA_handle_logger.h>
#include <sysinfo.h>
@@ -52,22 +40,6 @@ static void ipv4_frag_ipq_free_all(void *data); static uchar * ipv4_frag_key_dup(const uchar *key, uint key_size);
static void ipv4_frag_key_free(uchar *key, uint key_size);
#endif
-#if IPV4_DEBUG
-/* 2012-04-10 LiJia add,
- ��ICMPͷ��������ڸ��ӣ�
- ��ICMPЭ��ͷ���������������ECHO_REQUEST��ECHO_REPLAY.
-*/
-void test_print_icmp(const struct mesa_ip4_hdr *a_packet)
-{
- const struct mesa_icmp_echo_hdr *icmp_hdr = (const struct mesa_icmp_echo_hdr *)((char *)a_packet + a_packet->ip_hl * 4);
-
- if(8 == icmp_hdr->icmp_type)
- {
- printf("Icmpv4 len:%d\n", ntohs(a_packet->ip_len) - a_packet->ip_hl * 4 - 8);
- }
-
-}
-#endif
static inline int ipv4_buff_size(int tot_len)
@@ -77,33 +49,6 @@ static inline int ipv4_buff_size(int tot_len) }
-#if (0 == USE_MESA_STREAM_HASH )
-/*
- return value:
- 0: keyֵ��ͬ
- ����:keyֵ��ͬ
-*/
-static int ipv4_frag_hash_cmp(void *hash_key1, void *hash_key2)
-{
-#if 0 /* ipv4_frag_key�ṹ����pad�ֶ�, �辫ȷ�Ƚ�ÿ������ */
- return memcmp(hash_key1, hash_key2, sizeof(struct ipv4_frag_key));
-#else
- const struct ipv4_frag_key *ipv4_fkey1 = (const struct ipv4_frag_key *)hash_key1;
- const struct ipv4_frag_key *ipv4_fkey2 = (const struct ipv4_frag_key *)hash_key2;
-
- if((ipv4_fkey1->ip_src == ipv4_fkey2->ip_src)
- &&(ipv4_fkey1->ip_dst == ipv4_fkey2->ip_dst)
- &&(ipv4_fkey1->identification == ipv4_fkey2->identification)
- &&(ipv4_fkey1->protocol== ipv4_fkey2->protocol)){
- return 0;
- }
-
- return 1;
-#endif
-}
-#endif
-
-
static unsigned int ipv4_frag_hash_algo(unsigned short id, unsigned char pro,
unsigned int sip, unsigned int dip, unsigned int frand)
{
@@ -113,23 +58,8 @@ static unsigned int ipv4_frag_hash_algo(unsigned short id, unsigned char pro, }
-#if (0 == USE_MESA_STREAM_HASH)
-static unsigned int ipv4_frag_hash_index(void *hash_key)
-{
- struct ipv4_frag_key *ipv4_key = (struct ipv4_frag_key *)hash_key;
-
- return ipv4_frag_hash_algo(ipv4_key->identification,
- ipv4_key->protocol,
- ipv4_key->ip_src,
- ipv4_key->ip_dst,
- FRAG_IP4_RANDOM);
-}
-#endif
-
-
static int ipv4_attack_detect(struct frag_ipq *ipv4_qp)
{
- /* ����Ѿ������й�����Ϊ */
if(ipv4_qp->attack_flag != 0)
{
return ipv4_qp->attack_flag;
@@ -141,91 +71,9 @@ static int ipv4_attack_detect(struct frag_ipq *ipv4_qp) return IP_FRAG_IGNORE;
}
- // to do: ��������������
-
return IP_FRAG_OK;
}
-#if (0 == USE_MESA_STREAM_HASH)
-/* ���ݳ�ʱ���������ڴ� */
-static void ipv4_frag_mem_clean_by_time(struct frag_manage *handle)
-{
- struct frag_ipq *tmp, *next;
- int raw_mem_size = handle->total_mem;
- tmp = handle->lru_head;
-
- while(tmp && (tmp->create_time + (time_t)IPV4_FRAG_TIMEOUT < g_CurrentTime)) /* timeout */
- {
- next = tmp->lru_next;
-
- frag_ipq_kill(handle, tmp);
-
- /* ÿ��ֻ�ͷ�һ���������ڴ棬���ⳤʱ���ڴ˺������У���������������� */
- if(raw_mem_size-handle->total_mem >= IPV4_FRAG_MEM_FREE_ONCE)
- {
- break;
- }
-
- tmp = next;
- }
-}
-
-
-/* ����ռ���ڴ����������ڴ� */
-static void ipv4_frag_mem_clean_by_size(struct frag_manage *handle)
-{
- struct frag_ipq *tmp, *next;
- int raw_mem_size = handle->total_mem;
- tmp = handle->lru_head;
-
- while(tmp && (handle->total_mem >= IPV4_FRAG_MEM_HIGH_THRESH))
- {
- next = tmp->lru_next;
-
- frag_ipq_kill(handle, tmp);
-
- /* ÿ��ֻ�ͷ�һ���������ڴ棬���ⳤʱ���ڴ˺������У���������������� */
- if(raw_mem_size-handle->total_mem >= IPV4_FRAG_MEM_FREE_ONCE)
- {
- break;
- }
-
- tmp = next;
- }
-}
-
-
-/* �����ڴ棬��ʱ���ռ���ڴ����� */
-static inline void ipv4_frag_mem_clean(struct frag_manage *handle)
-{
- ipv4_frag_mem_clean_by_time(handle);
- ipv4_frag_mem_clean_by_size(handle);
-}
-#endif
-
-
-#if (0 == USE_MESA_STREAM_HASH)
-static struct frag_ipq *ipv4_frag_queue_find(struct streaminfo *pstream,
- struct frag_manage *handle, const struct mesa_ip4_hdr *a_packet)
-{
- struct ipv4_frag_key ip4_key;
-
- ip4_key.ip_src = a_packet->ip_src.s_addr;
- ip4_key.ip_dst = a_packet->ip_dst.s_addr;
- ip4_key.identification = a_packet->ip_id;
- ip4_key.protocol = a_packet->ip_p;
- memset(ip4_key.__pad__ , 0, sizeof(ip4_key.__pad__));
-
- return frag_ipq_find(handle, &ip4_key, sizeof(struct ipv4_frag_key));
-}
-#endif
-
-
-/* IP��Ƭ���麯�����
- return value:
- NULL: ��Ƭ������δ��ɣ����Ǵ���ķ�Ƭ��;
- ��NULL: ������ɺ������IP��ͷ��ָ�룬ʹ�������Ҫfree().
-*/
static /*@null@*/ struct mesa_ip4_hdr *process_ipv4_frag(struct streaminfo_private *pfstream_pr,
const struct mesa_ip4_hdr *a_packet, int thread_num,const raw_pkt_t *raw_pkt)
{
@@ -243,24 +91,10 @@ static /*@null@*/ struct mesa_ip4_hdr *process_ipv4_frag(struct streaminfo_priva unsigned short raw_ip_len;
struct streaminfo *pfstream = &pfstream_pr->stream_public;
-#if USE_MESA_STREAM_HASH
struct ipv4_frag_key ip4_frag_key;
build_ipv4_frag_key(pfstream_pr, a_packet, &ip4_frag_key);
-#endif
-
-
-#if (USE_MESA_STREAM_HASH==0) /* ����MESA_htable�Զ���ʱ��̭ */
- ipv4_frag_mem_clean(ip4_frag_handle);
-#else
- /* ʹ��MESA_htable��, �Զ�����ʱ��̭ */
-
-#endif
-
-#if USE_MESA_STREAM_HASH
ipv4_qp = ipv4_frag_queue_find(pfstream, ip4_frag_handle, &ip4_frag_key);
-#else
- ipv4_qp = ipv4_frag_queue_find(pfstream, ip4_frag_handle, a_packet);
-#endif
+
if(unlikely(NULL == ipv4_qp))
{
@@ -270,7 +104,6 @@ static /*@null@*/ struct mesa_ip4_hdr *process_ipv4_frag(struct streaminfo_priva IPV4_PRINT("##### ipv4_qp: %p\n", ipv4_qp);
- /* ������� */
attack_flag = ipv4_attack_detect(ipv4_qp);
switch(attack_flag)
{
@@ -278,15 +111,9 @@ static /*@null@*/ struct mesa_ip4_hdr *process_ipv4_frag(struct streaminfo_priva break;
case IP_FRAG_DISCARD:
-#if USE_MESA_STREAM_HASH
- MESA_htable_del(ip4_frag_handle->frag_hash_table,
- (const uchar *)&ip4_frag_key,
- sizeof(struct ipv4_frag_key),
- NULL);
-#else
- frag_ipq_kill(ip4_frag_handle, ipv4_qp);
-#endif
- return NULL;
+ MESA_htable_del(ip4_frag_handle->frag_hash_table, (const uchar *)&ip4_frag_key,
+ sizeof(struct ipv4_frag_key), NULL);
+ return NULL;
break;
case IP_FRAG_INVALID_PACKET:
@@ -311,7 +138,7 @@ static /*@null@*/ struct mesa_ip4_hdr *process_ipv4_frag(struct streaminfo_priva ip_hl = a_packet->ip_hl * 4;
end = offset + ntohs(a_packet->ip_len) - ip_hl;
- if(NULL == ipv4_qp->private_info) /* �յ��ĵ�һ����Ƭ�� */
+ if(NULL == ipv4_qp->private_info)
{
IPV4_PRINT("##### ipv4 frag first pkt!\n");
ipv4_qp->private_info = frag_malloc(ip4_frag_handle, sizeof(struct ipv4_frag_private));
@@ -325,18 +152,14 @@ static /*@null@*/ struct mesa_ip4_hdr *process_ipv4_frag(struct streaminfo_priva /* 2013-06-06 lijia add, frag attack check */
if(end + private_info->raw_ip_hdr_len > 65535)
{
-#if USE_MESA_STREAM_HASH
MESA_htable_del(ip4_frag_handle->frag_hash_table,
(const uchar *)&ip4_frag_key,
sizeof(struct ipv4_frag_key),
NULL);
-#else
- frag_ipq_kill(ip4_frag_handle, ipv4_qp);
-#endif
+
return NULL;
}
- /* �����ж� */
if((flags & IPv4_FRAG_MF) == 0)
{
/* If we already have some bits beyond end
@@ -353,7 +176,7 @@ static /*@null@*/ struct mesa_ip4_hdr *process_ipv4_frag(struct streaminfo_priva }
else
{
- if(end & 7) /* ��8�������� */
+ if(end & 7)
{
goto err;
}
@@ -370,8 +193,8 @@ static /*@null@*/ struct mesa_ip4_hdr *process_ipv4_frag(struct streaminfo_priva {
ipv4_qp->last_in |= IP_FRAG_FIRST_IN;
IPV4_PRINT("### ipv4 frag first flag!\n");
- if(ip_hl > private_info->raw_ip_hdr_len){ /* ʵ��ͷ�����ȳ���Ԥ��ͷ������ */
- if (end + ip_hl > ipv4_qp->buf_size){ /* �Ƿ���Ҫ���仺��ռ� */
+ if(ip_hl > private_info->raw_ip_hdr_len){
+ if (end + ip_hl > ipv4_qp->buf_size){
new_buf_size = ipv4_buff_size(end + ip_hl);
new_ip4h = (struct mesa_ip4_hdr *)frag_malloc(ip4_frag_handle, new_buf_size);
if(ipv4_qp->meat > 0){ /* meat>0, ֮ǰ�Ѿ��洢������, ͨ�������Ƿ�Ƭ����, �����յ������ķ�Ƭ�� */
@@ -382,8 +205,8 @@ static /*@null@*/ struct mesa_ip4_hdr *process_ipv4_frag(struct streaminfo_priva ipv4_qp->buf_size = new_buf_size;
}
}
- private_info->raw_ip_hdr_len = ip_hl; /* ���µ�һ������ʵ��ͷ������ */
- memcpy(ipv4_qp->new_iph, a_packet, ip_hl); /* ������һ��IP��Ƭ��ͷ�� */
+ private_info->raw_ip_hdr_len = ip_hl;
+ memcpy(ipv4_qp->new_iph, a_packet, ip_hl);
}
}
if(end <= offset)
@@ -552,9 +375,6 @@ found: ipv4_qp->ipfrag_list = NULL;
#endif
- /* Warning, ����frag_reassemble()��ipv4_qp����free��
- ���ԣ�Ҫ�Ƚ��������õ���Ϣ��ȡ����������ԭʼIP������.
- */
raw_ip_len = ntohs(ipv4_qp->meat + private_info->raw_ip_hdr_len);
//set scratch before frag_reassemble, cause frag_reassemble will free ipq
ip4_frag_handle->scratch_frag_cnt=ipv4_qp->frags_num;
@@ -588,20 +408,19 @@ static inline void set_ipv4_addr(struct stream_tuple4_v4 *addr, struct mesa_ip4_ {
addr->saddr = iphdr->ip_src.s_addr;
addr->daddr = iphdr->ip_dst.s_addr;
- addr->source = 0; /* �˿���Ϣ��tcp/udp������ */
- addr->dest = 0;/* �˿���Ϣ��tcp/udp������ */
+ addr->source = 0;
+ addr->dest = 0;
}
extern int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, const raw_pkt_t *rawpkt);
extern int stream_process_overlay_ipv4(struct streaminfo *pfstream, const struct ip* this_layer_hdr,
int thread_num,unsigned char routedir, const raw_pkt_t *raw_pkt);
-/* IPv4���ݰ���ں���, ������Ƭ�� */
int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_data, int thread_num,
unsigned char routedir, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr)
{
const struct mesa_ip4_hdr *a_packet = (const struct mesa_ip4_hdr *)this_layer_data;
- struct mesa_ip4_hdr *new_iph = NULL; /* ���ԭʼ������Ƭ����ָ��ָ��������ɺ����IP�� */
+ struct mesa_ip4_hdr *new_iph = NULL;
unsigned short offset, flags;
int ret = PASS;
char need_free = 0;
@@ -612,7 +431,6 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da struct streaminfo_private *pstream_pr;
struct streaminfo *pstream;
sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[thread_num]->sys_stat;
- /* ע��, �˴���ȡ��ǰ�㳤����ipͷ���ֶμ���ó�, ������this_layer_data- raw_pkt->raw_pkt_data, ��ΪijЩ����64�ֽڵ�С���������triler, ���������㲻һ�� */
int this_layer_len = ntohs(a_packet->ip_len);
int this_layer_is_overlay = 0;
@@ -623,11 +441,6 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da local_sys_stat->length_per_layer[__ADDR_TYPE_IP_PAIR_V4][pfstream_pr->layer_index + 1] += this_layer_len;
}
-
- /* NOTE, ע��, �м�:
- ��������������Ī�������IPv4��, ͷ���ֶβ��Ϸ�,
- �����ƽ̨coredump, ��������ѭ��, һ��Ҫ��ͷ���Ϸ��Լ��!!
- */
if(unlikely(checkipv4pkt(a_packet, raw_pkt) < 0)){
local_sys_stat->count[SAPP_STAT_DROP_IPV4]++;
local_sys_stat->length[SAPP_STAT_DROP_IPV4]+=this_layer_len;
@@ -651,9 +464,8 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da }
set_ipv4_addr(&addr, (struct mesa_ip4_hdr *)a_packet);
pstream->addr.paddr = &addr;
- /* ��IP��������Ϊ__ADDR_TYPE_IP_PAIR_V4, ����ϲ���TCP/UDP, ����������ΪADDR_TYPE_IPV4, �����Ipv6_over_ipv4����, ������IP���ַ���� */
pstream->addr.addrtype = __ADDR_TYPE_IP_PAIR_V4;
- pstream->addr.addrlen = sizeof(struct stream_tuple4_v4); /* ��ַ���ȹ̶�ʹ����Ԫ���ʽ��, ���������, ���˷������˿�,4�ֽڿռ� */
+ pstream->addr.addrlen = sizeof(struct stream_tuple4_v4);
pstream->addr.pkttype = PKT_TYPE_NORMAL;
pstream->addr.pktipfragtype = PKT_TYPE_NORMAL; /* 2014-12-25 lijia add */
this_layer_is_overlay = sapp_is_overlay_layer(pstream_pr, raw_pkt);
@@ -664,7 +476,6 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da pstream_pr->addr_use_as_hash = 1;
}
- /* 2012-11-01 add, ��inlineģʽ�£����overlay�㲻�����鲥��ַ */
if((g_topology_mode & __NET_CONN_GDEV) && (this_layer_is_overlay != 0)){
if(is_multicast_addr_v4(ntohl(a_packet->ip_dst.s_addr))){
local_sys_stat->count[SAPP_STAT_DROP_IPV4]++;
@@ -678,8 +489,6 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da pstream_pr->offset_to_raw_pkt_hdr = offset_to_raw_pkt_hdr;
pstream_pr->raw_pkt = raw_pkt; /* 2014-12-30 lijia add */
- /* LiJia add, ��Ϊ��ij���㷨���ⶨ��һ�������ַ�ķ���, �����ж�memcmp�Ľ�� */
-// if(memcmp(&(a_packet->ip_src.s_addr), &(a_packet->ip_dst.s_addr), sizeof(int)) >= 0){ /* ֱ���ж�, ���ٵ���memcmp���� */
if(a_packet->ip_src.s_addr >= a_packet->ip_dst.s_addr){
pstream_pr->layer_dir = 1;
pstream->curdir = DIR_C2S;
@@ -699,14 +508,12 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da pstream->routedir=routedir;
pstream->threadnum=thread_num;
- /* 2020-12-23 lijia add, ��mrtunnatģʽ, �����overlay��, ��������ͨ��� */
if(this_layer_is_overlay != 0){
ret = stream_process_overlay_ipv4(pstream, (const struct ip *)this_layer_data, thread_num, routedir, raw_pkt);
if(DROP == ret){
return DROP;
}
int next_layer_offest = offset_to_raw_pkt_hdr + (a_packet->ip_hl << 2);
- /* �����VXLANģʽ��overlay��, ����ip��Ƭ��ԭ,ֱ����ת��udp_entry */
ret=dealipv4udppkt(ptmp,a_packet,thread_num,routedir,raw_pkt, next_layer_offest);
return ret;
}
@@ -725,21 +532,12 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da return PASS;
}
pstream->addr.pktipfragtype = PKT_TYPE_IP_FRAG;
-#if USE_MESA_STREAM_HASH
- /* ��������Ƕ��ģʽ, ʹ�ñ������ṹ, ����father->stream */
new_iph = (struct mesa_ip4_hdr *)process_ipv4_frag(&ptmp->stream, a_packet, thread_num, raw_pkt);
-#else
- new_iph = (struct mesa_ip4_hdr *)process_ipv4_frag(pfstream_pr, a_packet, thread_num, raw_pkt);
-#endif
+
if (NULL == new_iph)
{
local_sys_stat->count[SAPP_STAT_RCV_IPV4_FRAG]++;
local_sys_stat->length[SAPP_STAT_RCV_IPV4_FRAG]++;
- /* ��IP��Ƭ, ��δ�������, �˴�ֻ����IPFRAG,
- ���ؿ�sapp_global_single.ipentry_priority_over_ipfrag,
- ��������һ����Ƭ����, ��ȫ��IP���������, ��Ҫ�ж�sapp_global_single.ipentry_priority_over_ipfrag,
- �����ȵ���ip_entry, ����ip_frag_entry.
- */
stream_process_ipv4_frag(pstream, (const struct ip *)a_packet, thread_num, routedir, raw_pkt);
return PASS;
}
@@ -753,7 +551,7 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da local_sys_stat->length[SAPP_STAT_RCV_IPV4_FRAG] += this_layer_len;
}else{
//if(0 == this_layer_is_overlay)
- { /* ��overlay����ۼ���ز���� */
+ {
local_sys_stat->count[SAPP_STAT_RCV_IPV4]++;
local_sys_stat->length[SAPP_STAT_RCV_IPV4] += this_layer_len;
if (routedir == sapp_global_val->config.packet_io.inbound_route_dir)
@@ -769,18 +567,12 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da }
}
- /* 2017-05-11 lijia add,
- �ж�IP��IPFRAG��˭�����ȵ���,
- ������ģʽ��, "����"���һ��IP��Ƭ��, �ﵽ��������ԭʼIP����Ŀ��!
- */
if(unlikely(sapp_global_single.ipentry_priority_over_ipfrag != 0)){
ret = process_ipv4_pkt(ptmp, a_packet, thread_num, routedir, raw_pkt, offset_to_raw_pkt_hdr);
if((PASS == ret) && (pstream->addr.pktipfragtype & (PKT_TYPE_IP_FRAG | PKT_TYPE_IP_FRAG_LAST))){
- /* NOTE: �˴�ʹ��this_layer_data, ����������ʵ��ԭʼIP��Ƭ�� */
ret = stream_process_ipv4_frag(pstream, (const struct ip *)this_layer_data, thread_num, routedir, raw_pkt);
}
}else{
- /* NOTE: �˴�ʹ��this_layer_data, ����������ʵ��ԭʼIP��Ƭ�� */
if(pstream->addr.pktipfragtype & (PKT_TYPE_IP_FRAG | PKT_TYPE_IP_FRAG_LAST)){
ret = stream_process_ipv4_frag(pstream, (const struct ip *)this_layer_data, thread_num, routedir, raw_pkt);
}
@@ -801,7 +593,6 @@ int ipv4_entry(struct streaminfo_private *pfstream_pr, const void *this_layer_da return ret;
}
-#ifdef MESA_HTABLE_VERSION_MACRO
MESA_htable_handle ipv4_frag_htable_create(void)
{
MESA_htable_handle htable;
@@ -854,29 +645,6 @@ MESA_htable_handle ipv4_frag_htable_create(void) return htable;
}
-#else
-MESA_htable_handle ipv4_frag_htable_create(void)
-{
- MESA_htable_create_args_t hargs;
-
- memset(&hargs, 0, sizeof(MESA_htable_create_args_t));
- hargs.thread_safe = 0;
- hargs.recursive = 0;
- hargs.hash_slot_size = 1048576;
- hargs.max_elem_num = 50000; /* TODO 1: ���Ĭ��ֵ, ���������ļ�,��ָ������Ƭ�������� !! */
- hargs.eliminate_type = HASH_ELIMINATE_ALGO_LRU;
- hargs.expire_time = IPV4_FRAG_TIMEOUT;
- hargs.key_comp = ipv4_frag_key_cmp_cb;
- hargs.key2index = ipv4_frag_hash_index;
- hargs.data_free = ipv4_frag_ipq_free_all;
- hargs.data_expire_with_condition = NULL;
- hargs.complex_key_dup = ipv4_frag_key_dup; /* ���ڸ��ӽṹ��key����, ��copyһ����ַ���� */
- hargs.complex_key_free = ipv4_frag_key_free; /* ɾ��ʱ�ͷ�key���ڴ���Դ */
-
- return MESA_htable_create(&hargs, sizeof(MESA_htable_create_args_t));
-}
-#endif
-
int ipv4_frag_init(int thread_count, uint32 hash_size)
{
@@ -915,17 +683,13 @@ err: void ipv4_frag_per_thread_exit(int thread_seq)
{
-#if USE_MESA_STREAM_HASH
MESA_htable_destroy(g_ipv4_frag_manage[thread_seq].frag_hash_table, NULL);
-#endif
}
void ipv4_frag_exit(void)
{
-#if USE_MESA_STREAM_HASH
SAPP_GLOBAL_FREE(g_ipv4_frag_manage);
-#endif
}
static inline int checkipv4pkt(const struct mesa_ip4_hdr * iph, const raw_pkt_t *raw_pkt)
@@ -962,33 +726,11 @@ static inline int checkipv4pkt(const struct mesa_ip4_hdr * iph, const raw_pkt_t }
}
-#if 0
- switch(iph->ip_p){
- /* Ŀǰƽֻ̨�������¼���Э��, �����ݲ�֧�ֻ����쳣���ݰ� */
- case IPPROTO_TCP:
- case IPPROTO_UDP:
- case IPPROTO_IPV6:
- case IPPROTO_GRE:
- case IPPROTO_IPIP:
- case IPPROTO_ICMP:
- case IPPROTO_ICMPV6:
- case IPPROTO_IGMP:
- case IPPROTO_ESP: /* for IPSEC */
- case IPPROTO_AH:
- case IPPROTO_ENCAP:
- break;
-
- default:
- sapp_runtime_log(20, "ipv4 packet check error; not support proto:%d\n", iph->ip_p);
- return -1;
- }
-#else
ip_proto = iph->ip_p;
- if(ip_proto >= 0x8F){ /* IPЭ���ֶδ���0x8f��Ŀǰ���Ϸ� */
+ if(ip_proto >= 0x8F){
sapp_runtime_log(RLOG_LV_DEBUG, "ipv4 packet check error: unknow proto: %u", ip_proto);
return -1;
}
-#endif
return 0;
}
@@ -1097,7 +839,6 @@ static void ipv4_frag_ipq_free_all(void *data) {
struct frag_ipq *ipq = (struct frag_ipq *)data;
- /* ���������ɾ��ʱ, Ҫ�ͷ�new_iph�ڴ� */
if(ipq->new_iph){
sapp_mem_free(SAPP_MEM_DYN_IP_FRAG_PKT,ipq->thread_num, ipq->new_iph);
}
diff --git a/src/dealpkt/deal_tcp.c b/src/dealpkt/deal_tcp.c index a5d025a..660499b 100644 --- a/src/dealpkt/deal_tcp.c +++ b/src/dealpkt/deal_tcp.c @@ -1,39 +1,3 @@ -/* -20120603 : 1)?????????????? ??datalen>0????????????? - 2)??��??????????????nouse???????????????? - -20140322 : 1)????????��?????data????????pdetail???????????? - ????????????pdetail??????????data??????half???? - 2)????????????��?????????????pdetail - 3) ???????????????????????hash???????????��?? - -20140329 1)?????tcpdetail??????��????????pdetail->lostlen - 2)??????tcpallpkt????????????????????�???????fin??rst??????shunx - ???????????????close????????????? - 3)???????��????????????????��?????????????????? - ?????????��?????????????????????????��????????????? - -20141210 1)??????streaminfo???????��??��????????????? -20141213 1)????tcp_add_new_stream_bydata???ˮtcplen=0??????????????nouse???? - nouse????????????????????data????????opstate=close????? - ????????????????????nouse?????opsate=pending, - 2) ??????????????nouse???????????????????data?????? - -20141217 1)????c2s????????????????ack?????????????????????� - ???��?��???????? - - -20150114 ??????????????????????tcpall?????????????tcp??????????????? - ????????tcpall???????tcp???????syn???????��??????��????????? - ?????????tcp???????tcpall?????? ???????????tcp????????tcpall???? - ?????????????????????data????????????????all???????tcp?? -20150126 ?????? - ????tcp_free_stream,tcp_reset_stream???????????????tcp???????tcpall -20150210 lqy - ????syn+ack????syn???????????????��???????seq???��?????syn - nouse?????????????? - ??????? ,syn?????????tcp???? -*/ #include "sapp_api.h" #include "sapp_private_api.h" #include "sapp_declaration.h" @@ -56,10 +20,9 @@ int copy_ipport_union_addr(struct streaminfo *pstream_heap, struct streaminfo *p void iterate_stream_list(const struct streaminfo *stream); int del_stream_by_time(struct stream_list *plist, const struct streamindex *current_drive_index, int thread_id, enum stream_type_t type); -//int g_kill_tcp_remedy_sw = 0; /* 2016-06-21 lijia add, ??????FD???? */ int G_TCP_FLOW_STAT_PROJECT_ID = -1; /* 2016-07-14 lijia copy from sapp */ -int G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID = -1; /* ??????, ????ACK?????????????????????????? */ +int G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID = -1; #if DEBUG static void packet_io_status_tcp_pkt_update(int tid, unsigned char tcp_flags, int payload_len); @@ -104,9 +67,7 @@ static int checkcreatlinkseq(struct streaminfo_private*pstream_pr,int this_seq) curseq=pdetail_pr->iclientseq; } //adjust by lqy 20120923 - //????��????????????????? if(curseq==0) return 1; - //??��???syn????????????????? if(pdetail_pr->multisynflag==1) { if(pstream->curdir == DIR_C2S) @@ -137,7 +98,7 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re const unsigned char *opt; int opt_num = 0, opt_len; struct tcp_option *out_raw_result = raw_result; - int parsed_opt; /* ?????????OPT???�� */ + int parsed_opt; if((NULL == raw_result) || (res_num <= 0)){ return -1; @@ -158,10 +119,10 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re switch (*opt) { - case TCP_OPT_EOL: /* ?????????, ???????????????? */ + case TCP_OPT_EOL: return opt_num; - case TCP_OPT_NOP: /* ?????????, ???????????????? */ + case TCP_OPT_NOP: opt++; opt_len--; /* Ref: RFC 793 section 3.1 */ continue; @@ -239,7 +200,7 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re goto err; } out_raw_result->len -= 2; - out_raw_result->char_value = 1; /* SACK???????, ?????????????????????? */ + out_raw_result->char_value = 1; opt_len -= 2; parsed_opt = 1; break; @@ -267,7 +228,6 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re parsed_opt = 1; break; - /* ???????????????????, ???? */ case TCP_OPT_SACK_EDGE: case TCP_OPT_MD5: case TCP_OPT_MULTI_PATH_TCP: @@ -277,7 +237,7 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re int this_opt_len; if (opt_len <= 1) - { /* ?????????0, ???????????????????, ??????????0??1, ?????! */ + { goto err; } this_opt_len = opt[1]; @@ -296,7 +256,7 @@ int MESA_get_tcp_pkt_opts(const struct tcphdr *tcphdr, struct tcp_option *raw_re int this_opt_len; if (opt_len <= 1) - { /* ?????????0, ???????????????????, ??????????0??1, ?????! */ + { goto err; } this_opt_len = opt[1]; @@ -336,7 +296,7 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext const unsigned char *opt; int opt_num = 0, opt_len; struct tcp_option_ext *out_raw_result = raw_result; - int parsed_opt; /* ?????????OPT???�� */ + int parsed_opt; if((NULL == raw_result) || (res_num <= 0)){ return -1; @@ -357,10 +317,10 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext switch (*opt) { - case TCP_OPT_EOL: /* ?????????, ???????????????? */ + case TCP_OPT_EOL: return opt_num; - case TCP_OPT_NOP: /* ?????????, ???????????????? */ + case TCP_OPT_NOP: opt++; opt_len--; /* Ref: RFC 793 section 3.1 */ continue; @@ -438,7 +398,7 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext goto err; } out_raw_result->len -= 2; - out_raw_result->char_value = 1; /* SACK???????, ?????????????????????? */ + out_raw_result->char_value = 1; opt_len -= 2; parsed_opt = 1; break; @@ -485,7 +445,6 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext } break; - /* ???????????????????, ???? */ case TCP_OPT_SACK_EDGE: case TCP_OPT_MD5: case TCP_OPT_RIVER_PROBE: @@ -494,7 +453,7 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext int this_opt_len; if (opt_len <= 1) - { /* ?????????0, ???????????????????, ??????????0??1, ?????! */ + { goto err; } this_opt_len = opt[1]; @@ -513,7 +472,7 @@ int MESA_get_tcp_pkt_opts_ext(const struct tcphdr *tcphdr, struct tcp_option_ext int this_opt_len; if (opt_len <= 1) - { /* ?????????0, ???????????????????, ??????????0??1, ?????! */ + { goto err; } this_opt_len = opt[1]; @@ -600,9 +559,7 @@ static char tcp_processallpkt( struct streaminfo *pstream, const void *this_iphd } -/* LiJia comment: ????????????, ??resetflag=0, ????pindex??????????; - ??????????????, ????pindex??????????; -*/ + static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, const void *this_iphdr, struct mesa_tcp_hdr *this_tcphdr,int datalen,int resetflag, const raw_pkt_t *raw_pkt) { @@ -613,8 +570,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, struct streaminfo *pstream; struct tcpdetail *pdetail=NULL; struct tcpdetail_private *pdetail_pr=NULL; - int need_reverse = 0; /* copy????, ????????src, dst??? */ - + int need_reverse = 0; if ((this_tcphdr->th_flags & TH_SYN) && !(this_tcphdr->th_flags & TH_ACK) )//&& !(this_tcphdr->th_flags & TH_RST)) @@ -631,12 +587,10 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, { //runtime_log(RLOG_LV_FATAL, "[tcp_add_new_stream_bysyn]:","tcpflags=:%0x\n",this_tcphdr->th_flags); //adjust by lqy 20130530 - //??��????��?????????? if(resetflag==0) return NULL; } if(likely(0 == resetflag)){ - /* ?????copy??????pindex??, ??addr?????????????????, ????????copy, ????????pindex?????????? */ pindex_tcp=malloc_and_copy_streamindex(threadnum, pindex); //memcpy(pindex_tcp,pindex,sizeof(struct streamindex)); @@ -644,18 +598,17 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, pstream = &pstream_pr->stream_public; /* 2014-11-13 lijia modify */ - if(DIR_C2S == createdir){ /* ????????TCP????????????C->S?????? */ + if(DIR_C2S == createdir){ if(1 == pstream_pr->layer_dir){ - pstream_pr->stream_dir = 1; /* ???????????, ??"??????????"?????? */ + pstream_pr->stream_dir = 1; }else{ pstream_pr->stream_dir = 0; } need_reverse = 0; pstream_pr->stream_c2s_route_dir = raw_pkt->route_dir; }else{ - need_reverse = 1; /* ?????????????, ????????????, src???????????????? */ + need_reverse = 1; if(1 == pstream_pr->layer_dir){ - /* ?????copy_stream_info_to_heap()?��?????????, ?????????"??????????"????????? */ pstream_pr->stream_dir = 0; }else{ pstream_pr->stream_dir = 1; @@ -664,11 +617,6 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, } #if USE_RBTREE_INSTEAD_LIST - /* note: - ???????rbtree?????????????????????, ???????????left????right???, - ??????????, layer_dir?????????????, ?????????????????????��, - ?????layer_dir = stream_dir; - */ pstream_pr->layer_dir = pstream_pr->stream_dir; #endif @@ -682,11 +630,9 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, #if SAPP_INSECTICIDE iterate_stream_list(pstream); #endif - /* 2016-07-25 lijia add, ????????????????????, ????????????????��??? */ get_stream_carry_tunnel_type(pstream, NULL, &pstream_pr->stream_low_layer_tunnel_type); #if 0 - /* TCP??��???????, ??????????��??IP??, ????? */ //set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream.addr); //set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream); @@ -702,7 +648,6 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, memset(pdetail_pr,0,sizeof(struct tcpdetail_private)); pdetail->createtime=g_CurrentTime; pstream_pr->stream_create_timestamp_ms=g_CurrentTime_ms; - //adjust by lqy 20140515 ??????????? if(createdir==DIR_S2C){ pdetail->clientpktnum++; pdetail->clientbytes+= datalen; /* 2014-12-19 lijia add, for SYN pkt append data */ @@ -719,10 +664,6 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, } else { - /* TODO 1: - ???????????, ??��?????????streamindex??, free??????????????, - ?????streamindex?????????????, ???????DEBUG. - */ pindex_tcp = pindex; pstream_pr = &pindex_tcp->stream; pstream = &pstream_pr->stream_public; @@ -783,7 +724,6 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, pstream->dir=createdir; pstream->curdir=createdir; - //��????????????????????, add by lqy 20141213 if(tcp_support_all==TCP_SUPPORT_ENTRYALL_OFF) { pstream->pktstate=OP_STATE_CLOSE; @@ -797,15 +737,13 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, if(createdir==DIR_S2C) { - //????????????seq pdetail_pr->iclientseq =ntohl (this_tcphdr->th_seq) + 1; pdetail_pr->iserverseq=ntohl (this_tcphdr->th_ack); - //pdetail->clientpkt++; //adjust by lqy 20140515 ??????????? pdetail_pr->S2C_first_ack_seq = pdetail_pr->iserverseq; } else if(createdir==DIR_C2S) { - pdetail_pr->iclientseq = 0; /* 2017-12-06 lijia add, ???S2C?????ISN??��????? */ + pdetail_pr->iclientseq = 0; pdetail_pr->iserverseq=ntohl (this_tcphdr->th_seq)+1; //pdetail->serverpkt++; //adjust by lqy 20140515 ??????????? pdetail_pr->C2S_first_ack_seq = ntohl (this_tcphdr->th_ack); @@ -816,14 +754,12 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, pstream->stream_state=TCP_SYN_STATE; if(pstream_pr->under_ddos_bypass){ - /* bypass?????????�ʦ�??, ??????project, parse_tcp_option????????????????,????cpu??? */ pstream->stream_state=TCP_NOUSE_STATE; streamaddlist(pindex_tcp,&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state])); return pindex_tcp; } streamaddlist(pindex_tcp,&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state])); - /* LiJia add, ?��?????????��????, ????????IP????��??? */ pstream_pr->pproject = project_requirement_create(SAPP_MEM_DYN_TCP_PROJECT, pstream->threadnum); pstream_pr->stream_bridge = stream_bridge_create_per_stream(SAPP_MEM_DYN_TCP_BRIDGE, pstream->threadnum); @@ -916,7 +852,7 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, if(DIR_S2C == createdir){ pdetail_pr->S2C_first_ack_seq = ntohl(this_tcphdr->th_ack); }else{ - ; /* SYN?????ACK, ???? */ + ; } } @@ -934,12 +870,6 @@ static struct streamindex *tcp_add_new_stream_bysyn(struct streamindex *pindex, return pindex_tcp; } -/* - 1)??????????syn?????????????????????????????? - 2) ????????????????????????????????????????NOUSE ?? - - 2015-06-10 lijia add "resetflag", ???????????????????. -*/ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, struct mesa_tcp_hdr *this_tcphdr, int datalen, int resetflag, const raw_pkt_t * raw_pkt) { @@ -974,7 +904,6 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, iterate_stream_list(pstream); #endif - /* 2016-07-25 lijia add, ????????????????????, ????????????????��??? */ get_stream_carry_tunnel_type(pstream, NULL, &pstream_pr->stream_low_layer_tunnel_type); pstream->dir=createdir; @@ -986,24 +915,19 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, #if USE_RBTREE_INSTEAD_LIST if(1 == pstream_pr->layer_dir){ - pstream_pr->stream_dir = 1; /* ??????DATA??????, ????stream_dir?????????????? */ + pstream_pr->stream_dir = 1; //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir; //set_stream_addr(pstream->pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, pstream); }else{ - pstream_pr->stream_dir = 1; /* ??????DATA??????, ????stream_dir?????????????? */ - //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir ^ 1; /* IP???????????????????????? */ + pstream_pr->stream_dir = 1; + //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir ^ 1; //set_stream_addr(pstream->pfather, this_tcphdr->th_dport, this_tcphdr->th_sport, pstream); } - /* note: - ???????rbtree?????????????????????, ???????????left????right???, - ??????????, layer_dir?????????????, ?????????????????????��, - ??data????????, layer_dir = 1; - */ pstream_pr->layer_dir = 1; #endif - hash_add_stream(pindex_tcp); /* ???resetflag=1, ????????????, tcp_reset_stream()??��?hash???????, ??????????????? */ + hash_add_stream(pindex_tcp); }else{ pindex_tcp=pindex; pstream_pr=&(pindex_tcp->stream); @@ -1031,11 +955,9 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, pstream_pr->stream_c2s_route_dir = raw_pkt->route_dir; } pstream_pr->stream_killed_flag = 0; - /* ???????, ??????????????streamid */ pindex_tcp->stream.global_stream_id = get_global_stream_id(threadnum); pindex_tcp->stream.stream_trace_id=0; - /* ???????, ?????��????ddos ?? */ if(pstream_pr->create_dir_by_well_known_port != 1) { pstream_pr->under_ddos_bypass = packet_io_under_ddos_should_bypass(threadnum); @@ -1046,9 +968,6 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, pstream->curdir=createdir; //pindex_tcp->stream.stream_dir=pindex_tcp->stream.layer_dir; - //???????????????data??, by lqy 20141213 - //if(datalen>0) - //????????????????????????adjust by lqy 20150215 if((datalen>0) && (!(this_tcphdr->th_flags & TH_FIN)) && (!(this_tcphdr->th_flags & TH_RST))) { pstream->stream_state=TCP_DATA_STATE; @@ -1058,7 +977,6 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, pstream->stream_state=TCP_NOUSE_STATE; } - /* TCP??��???????, ??????????��??IP??, ????? */ //set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream.addr); //set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream); @@ -1066,12 +984,12 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, set_stream_addr(pindex_tcp->stream.pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, &pindex_tcp->stream); #else /* 2014-12-16 lijia modify */ if(1 == pstream_pr->layer_dir){ - pstream_pr->stream_dir = 1; /* ??????DATA??????, ????stream_dir?????????????? */ + pstream_pr->stream_dir = 1; //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir; //set_stream_addr(pstream->pfather, this_tcphdr->th_sport, this_tcphdr->th_dport, pstream); }else{ - pstream_pr->stream_dir = 1; /* ??????DATA??????, ????stream_dir?????????????? */ - //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir ^ 1; /* IP???????????????????????? */ + pstream_pr->stream_dir = 1; + //((struct streaminfo_private *)pstream->pfather)->stream_dir = ((struct streaminfo_private *)pstream->pfather)->layer_dir ^ 1; //set_stream_addr(pstream->pfather, this_tcphdr->th_dport, this_tcphdr->th_sport, pstream); } #endif @@ -1094,7 +1012,6 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, pdetail_pr->link_state=STREAM_LINK_DATA; if(pstream_pr->under_ddos_bypass){ - /* bypass?????????�ʦ�??, ??????project, bridge,parse_opt,?????half_stream???????????????? */ pstream->stream_state=TCP_NOUSE_STATE; streamaddlist(pindex_tcp,&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state])); return pindex_tcp; @@ -1103,14 +1020,12 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, streamaddlist(pindex_tcp,&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state])); //if(datalen>0) - //????????????????????????adjust by lqy 20150325 if((datalen>0) && (!(this_tcphdr->th_flags & TH_FIN)) && (!(this_tcphdr->th_flags & TH_RST))) { if(pstream->dir==DIR_C2S) { pdetail_pr->pserver=(struct half_tcpstream *)sapp_mem_malloc(SAPP_MEM_DYN_TCP_HALF_STREAM, threadnum,sizeof(struct half_tcpstream)); memset(pdetail_pr->pserver,0,sizeof(struct half_tcpstream)); - //?????? pdetail_pr->pserver->first_data_seq=(ntohl (this_tcphdr->th_seq) ); /* 2014-07-31 LiJia add, for set one stream unorder number */ pdetail_pr->pserver->maxunorder = tcp_default_unorder; @@ -1119,17 +1034,16 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, { pdetail_pr->pclient=(struct half_tcpstream *)sapp_mem_malloc(SAPP_MEM_DYN_TCP_HALF_STREAM,threadnum,sizeof(struct half_tcpstream)); memset(pdetail_pr->pclient,0,sizeof(struct half_tcpstream)); - //?????? pdetail_pr->pclient->first_data_seq=(ntohl (this_tcphdr->th_seq) ); /* 2014-07-31 LiJia add, for set one stream unorder number */ pdetail_pr->pclient->maxunorder = tcp_default_unorder; } } - else //????????????????seq? + else { if(createdir==DIR_S2C) { - //????????????seq + pdetail_pr->iclientseq =ntohl (this_tcphdr->th_seq) ; pdetail_pr->iserverseq=ntohl (this_tcphdr->th_ack); @@ -1142,7 +1056,6 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, } pstream->pdetail=(void *)pdetail_pr; - /* 2014-03-26 LiJia add, ?��?????????��????, ????????IP????��??? */ pstream_pr->pproject = project_requirement_create(SAPP_MEM_DYN_TCP_PROJECT,threadnum); pstream_pr->stream_bridge = stream_bridge_create_per_stream(SAPP_MEM_DYN_TCP_BRIDGE,pstream->threadnum); @@ -1190,7 +1103,6 @@ static struct streamindex *tcp_add_new_stream_bydata(struct streamindex *pindex, } } } - /* NOTE, tcp_data??????stream_process_tcp()????? */ } if(G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID != -1){ @@ -1250,7 +1162,6 @@ static void tcp_change_stream_todata(struct streamindex *pindex,struct mesa_tcp_ memset(pdetail_pr->pserver,0,sizeof(struct half_tcpstream)); //?????? pdetail_pr->pserver->first_data_seq=pdetail_pr->iserverseq; - /* pdetail_pr->iserverseq=0; */ /* 2016-04-27 lijia modify, ?????????????ISN */ /* 2014-10-20 LiJia add, for set one stream unorder number */ pdetail_pr->pserver->maxunorder = tcp_default_unorder; @@ -1261,9 +1172,7 @@ static void tcp_change_stream_todata(struct streamindex *pindex,struct mesa_tcp_ if(NULL == pdetail_pr->pclient){ pdetail_pr->pclient=(struct half_tcpstream *)sapp_mem_malloc(SAPP_MEM_DYN_TCP_HALF_STREAM,threadnum,sizeof(struct half_tcpstream)); memset(pdetail_pr->pclient,0,sizeof(struct half_tcpstream)); - //?????? pdetail_pr->pclient->first_data_seq=pdetail_pr->iclientseq; - /* pdetail_pr->iclientseq=0; */ /* 2016-04-27 lijia modify, ?????????????ISN */ /* 2014-10-20 LiJia add, for set one stream unorder number */ pdetail_pr->pclient->maxunorder = tcp_default_unorder; @@ -1287,7 +1196,6 @@ static void tcp_free_half(struct half_tcpstream *phalf,int threadnum) //phalf = NULL; } -/* ???????pindex?????plist?? */ static int inline stream_in_timeout_list(const struct streamindex *pindex, const struct stream_list *plist) { if(timeout_pending((struct timeout *)&(pindex->timeout))) @@ -1308,10 +1216,7 @@ static void tcp_change_stream_tonouse(struct streamindex *pindex) int threadnum=pstream->threadnum; plist=&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state]); - /* 2017-01-03 lijia add, - ?????tcp_reset_stream()???????, ??????tcp_change_stream_tonouse, - pindex???????????????list, ????????????streamleavlist??streamaddlist??. - */ + if(stream_in_timeout_list(pindex, plist) == 0){ return; } @@ -1334,17 +1239,11 @@ static void tcp_change_stream_tonouse(struct streamindex *pindex) tcp_free_half(pdetail_pr->pserver,threadnum); pdetail_pr->pserver = NULL; } - /* 2017-12-20 lijia add, - ??FIN????????????NOUSE??, - deal_tcp_stream()??��???TCP_SYN_STATE??TCP_DATA_STATE??, - ?????TCP_NOUSE_STATE?????????????, - ??????????????TCP_NOUSE_STATE??????. - */ + del_stream_by_time(plist, pindex, threadnum, STREAM_TYPE_TCP); } -/* ?????????tcp?????????????, ???????TCP_ALL???, ????????????free, ?????????????TIMEOUT??KICKOUT???? */ static inline void tcp_update_should_close_reason_stat(int tid) { sapp_gval_mthread_sys_stat_t *local_sys_stat; @@ -1411,41 +1310,22 @@ int tcp_free_stream(struct streamindex *pindex, const void *this_ip_hdr, const v tcp_update_close_reason_stat(threadnum, pdetail_pr); plist=&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state]); - /* TODO 1, - free??????time, list_lru???, ?????????????free, - ???????????CLOSEME, ?????????pdetail???, ?????tcp????????, ???FD???????. - - ????????????: - tcp_lite_free(); //?free data, ?????????? - - tcp_struct_free(); //free ??��????? - - tcp_thorough_free(); // del_stream_by_time(), streamaddlist()??????????????????????, ??????free - // ????tcp_light_free(); tcp_struct_free();???????? - - TODO 1: - ????????tcp_deal_unorder()??, ?????????????kill_tcp, ????��?stream_killed_flag???, - ???stream_killed_flag=1, ???????????????, ???tcp_free_half()???. - */ - - /* 2014-07-24 lijia add, ???????????????? */ - saved_curdir = pstream->curdir; /* 2015-11-16 LiJia add, ???��???????, ??????????????????? */ + saved_curdir = pstream->curdir; if(pclient && (pclient->unorderlist != NULL)){ - pstream->curdir = DIR_S2C; /* ?????? */ + pstream->curdir = DIR_S2C; tcp_deal_unorder(pindex, pstream, pclient, pserver, !CHECK_ORDER_DATA); } if(pserver && (pserver->unorderlist != NULL)){ - pstream->curdir = DIR_C2S; /* ?????? */ + pstream->curdir = DIR_C2S; tcp_deal_unorder(pindex, pstream, pserver, pclient, !CHECK_ORDER_DATA); } pstream->curdir = saved_curdir; - pstream_pr->raw_pkt = raw_pkt; /* ???????????, ????NULL; ?????RST???????, ???????? */ + pstream_pr->raw_pkt = raw_pkt; if (pdetail_pr->apme != NULL) { pstream->opstate = OP_STATE_CLOSE; - // tcp stream ??? pkt_ret = stream_process_tcp(pstream, this_ip_hdr, transport_hdr, raw_pkt, &(pdetail_pr->apme), &(pstream->opstate)); pdetail_pr->apme = NULL; @@ -1472,7 +1352,6 @@ int tcp_free_stream(struct streamindex *pindex, const void *this_ip_hdr, const v tcp_free_half(pserver, threadnum); pserver = NULL; } - /* ???????????????????, ??????��???, ????????stream_set_single_stream_timeout(), ????????????LRU?????��?��?? */ streamleavlist(pindex, plist); hash_del_stream(pindex); @@ -1484,7 +1363,7 @@ int tcp_free_stream(struct streamindex *pindex, const void *this_ip_hdr, const v - if(pstream_pr->set_special_timeout != 0){ /* ??????��?????, ??????? */ + if(pstream_pr->set_special_timeout != 0){ sapp_global_mthread[threadnum].tcp_stream_special_timeout_num--; } @@ -1542,7 +1421,6 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, int ret = 0; sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[threadnum]->sys_stat; - //add by lqy 20150107 ??????? if(pstream->curdir==DIR_S2C) { pdetail->clientpktnum--; @@ -1578,8 +1456,7 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, plist=&(G_MESA_GLOBAL_STREAM[threadnum]->tcpList[pstream->stream_state]); - /* 2014-07-24 lijia add, ???????????????? */ - saved_curdir = pstream->curdir; /* 2015-11-16 LiJia add, ???��???????, ??????????????????? */ + saved_curdir = pstream->curdir; if(pdetail_pr->pclient && pdetail_pr->pclient->unorderlist != NULL){ pstream->curdir = DIR_S2C; tcp_deal_unorder(pindex, pstream, pdetail_pr->pclient, pdetail_pr->pserver, !CHECK_ORDER_DATA); @@ -1588,14 +1465,9 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, pstream->curdir = DIR_C2S; tcp_deal_unorder(pindex, pstream, pdetail_pr->pserver, pdetail_pr->pclient, !CHECK_ORDER_DATA); } - /* tcp_deal_unorder()????????????pstream_pr->raw_pkt, ??????raw_pkt */ pstream_pr->raw_pkt = raw_pkt; pstream->curdir = saved_curdir; - /* 2015-02-04 lijia add, - ??????????????????????????, ??????????????????????, - ?????????��?????????MESA_kill_xxx, ??????pstream_pr->raw_pkt = NULL. - */ const raw_pkt_t *saved_raw_pkt = pstream_pr->raw_pkt; pstream_pr->raw_pkt = NULL; pstream_pr->stream_killed_flag = 0; @@ -1620,7 +1492,6 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, if(pdetail_pr->pAllpktpme!=NULL) { pstream->pktstate=OP_STATE_CLOSE; - //tcp stream ??? stream_process_tcp_allpkt(pstream,NULL,NULL,NULL,&(pdetail_pr->pAllpktpme),&(pstream->pktstate)); pdetail_pr->pAllpktpme=NULL; } @@ -1632,16 +1503,14 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, - /* ???????????????????, ??????��???, ????????stream_set_single_stream_timeout(), ????????????LRU?????��?��?? */ streamleavlist(pindex, plist); - /* ??????��??raw_pkt */ pstream_pr->raw_pkt = saved_raw_pkt; - pstream_pr->syn_opt_num = 0; /* ????????? */ - pstream_pr->synack_opt_num = 0; /* ????????? */ + pstream_pr->syn_opt_num = 0; + pstream_pr->synack_opt_num = 0; if(pstream_pr->syn_opt_array){ sapp_mem_free(SAPP_MEM_DYN_TCP_SYN_OPT, threadnum, pstream_pr->syn_opt_array); pstream_pr->syn_opt_array = NULL; @@ -1671,7 +1540,7 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, } if (pstream_pr->set_special_timeout != 0) - { /* ??????��?????, ??????? */ + { sapp_global_mthread[threadnum].tcp_stream_special_timeout_num--; } if(this_tcphdr->th_flags & TH_SYN){ @@ -1682,7 +1551,6 @@ static int tcp_reset_stream(struct streamindex *pindex,const void *this_iphdr, tcp_add_new_stream_bydata(pindex,this_tcphdr,datalen,REUSE_OLD_LINK, raw_pkt); ret = 1; }else{ - /* 20190506 lijia add, reset??????????????, ???free?? */ hash_del_stream(pindex); if(pstream->pdetail != NULL) { @@ -1755,14 +1623,13 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p { if (thisack == curseq) { - pstream->dir = DIR_DOUBLE; /* ????dir */ + pstream->dir = DIR_DOUBLE; pdetail_pr->link_state = STREAM_LINK_RESET; tcp_free_stream(pindex, this_iphdr, this_tcphdr, raw_pkt); return PASS; } } else - //?????????????????? if (thisack == curseq) { pstream->dir = DIR_DOUBLE; @@ -1779,11 +1646,10 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p return PASS; } } - else //??????? + else { pdetail_pr->C2S_ack_seq = thisack; pdetail_pr->last_c2s_pkt_rcv_time = ABBR_CURRENT_TIME_MS; - //?????? if (thisseq == curseq) { if ((this_tcphdr->th_flags & TH_RST) && (datalen == 0)) @@ -1792,8 +1658,6 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p tcp_free_stream(pindex, this_iphdr, this_tcphdr, raw_pkt); return PASS; } - // add by lqy 20130802 ?????????????????��??????? - //???????????ack else if ((this_tcphdr->th_flags == TH_ACK) && (datalen == 0)) { pdetail_pr->tcpstateflag = TCP_SYN_RECV; @@ -1801,10 +1665,7 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p } else { - // if(TCP_SYN_SENT==pdetail_pr->tcpstateflag ){ - // return DROP; return PASS; // 2014-12-05 lijia modify, for xj serial - //} } // end add by lqy 20130802 } @@ -1819,7 +1680,7 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p pdetail_pr->last_c2s_pkt_rcv_time = ABBR_CURRENT_TIME_MS; if ((this_tcphdr->th_flags & TH_RST) && (datalen == 0)) { - pstream->dir = DIR_DOUBLE; /* ????dir */ + pstream->dir = DIR_DOUBLE; pdetail_pr->link_state = STREAM_LINK_RESET; tcp_free_stream(pindex, this_iphdr, this_tcphdr, raw_pkt); return PASS; @@ -1834,10 +1695,9 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p return PASS; } } - else //??????? + else { pdetail_pr->last_s2c_pkt_rcv_time = ABBR_CURRENT_TIME_MS; - //????rst if ((thisseq == curseq) && (this_tcphdr->th_flags & TH_RST) && (datalen == 0)) { @@ -1847,7 +1707,6 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p } } } - // add by lqy 20130805 ????????????????????????data?? else if (pstream->dir == DIR_DOUBLE) { if ((pdetail_pr->tcpstateflag == TCP_SYN_RECV) && (curdir == DIR_C2S)) @@ -1859,12 +1718,7 @@ static int tcp_deal_syn_stream(struct streamindex *pindex,const raw_pkt_t *raw_p } } } - //syn??? - /* - TODO, - ??????????????SYN??, ?????????��?SEQ??????????????, ???????????????, - ???reset. - */ + if(this_tcphdr->th_flags == TH_SYN) { pdetail_pr->iserverseq=thisseq + 1; @@ -1891,33 +1745,24 @@ static void tcp_half_handle_ack_and_seq(struct half_tcpstream *phalf, struct mes rcv = phalf; - //????????ack_seq???0??????????????ack_seq?????rcv->ack_seq if (0 == *cur_half_stream_ack) *cur_half_stream_ack = ntohl(this_tcphdr->th_ack); else { ackdiff = (int)(ntohl (this_tcphdr->th_ack) - *cur_half_stream_ack); -#if 0 /* 20160930 lijia modify, ?????????? */ - if (ackdiff > 0 || ackdiff < -(2 << 30)) //?????????????????? -#else - if (ackdiff > 0 || ackdiff < (int)0x80000000) //?????????????????? -#endif + + if (ackdiff > 0 || ackdiff < (int)0x80000000) { *cur_half_stream_ack = ntohl (this_tcphdr->th_ack); } } - //??? if (0 == rcv->seq) rcv->seq = ntohl(this_tcphdr->th_seq); else { seqdiff = (int)(ntohl(this_tcphdr->th_seq) - rcv->seq); -#if 0 /* 20160930 lijia modify, ??????????, ?????????0x80000000 */ - if (seqdiff > 0 || seqdiff < -(2 << 30)) -#else - if (seqdiff > 0 || seqdiff < (int)0x80000000) //?????????????????? -#endif + if (seqdiff > 0 || seqdiff < (int)0x80000000) { rcv->seq = ntohl(this_tcphdr->th_seq); } @@ -1971,7 +1816,6 @@ static int tcp_deal_ack(struct streaminfo *a_tcp,struct mesa_tcp_hdr *this_tcphd { phalf=pdetail_pr->pclient; phother=pdetail_pr->pserver; - /* 2017-08-02 lijia modify, ???????????ACK??, ??ack_seq???????????????????????????? */ if(0 == pdetail_pr->S2C_first_ack_seq){ pdetail_pr->S2C_first_ack_seq = ntohl (this_tcphdr->th_ack); } @@ -1982,12 +1826,10 @@ static int tcp_deal_ack(struct streaminfo *a_tcp,struct mesa_tcp_hdr *this_tcphd { phalf=pdetail_pr->pserver; phother=pdetail_pr->pclient; - /* 2017-08-02 lijia add, C2S????????????ISN */ if((0 == pdetail_pr->iclientseq) - &&(ntohl(this_tcphdr->th_seq) == pdetail_pr->iserverseq)){ /* C2S????SYN?????????ACK?? */ + &&(ntohl(this_tcphdr->th_seq) == pdetail_pr->iserverseq)){ pdetail_pr->iclientseq = ntohl (this_tcphdr->th_ack); } - /* 2017-08-02 lijia modify, ???????????ACK??, ??ack_seq???????????????????????????? */ if(0 == pdetail_pr->C2S_first_ack_seq){ pdetail_pr->C2S_first_ack_seq = ntohl (this_tcphdr->th_ack); } @@ -1995,23 +1837,22 @@ static int tcp_deal_ack(struct streaminfo *a_tcp,struct mesa_tcp_hdr *this_tcphd cur_half_stream_ack = &pdetail_pr->C2S_ack_seq; } - /* 2017-08-03 lijia add, ??????, ??????ack????????????????????????? */ if(DIR_C2S == a_tcp->dir){ pdetail = a_tcp->ptcpdetail; //pdetail->clientbytes = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; if(G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID != -1){ - pdetail_pr->deduce_flow_stat->C2S_data_byte = pdetail->serverbytes; /* ????????????????????��???? */ - pdetail_pr->deduce_flow_stat->C2S_data_pkt = pdetail->serverpktnum;/* ????????????????????��???? */ + pdetail_pr->deduce_flow_stat->C2S_data_byte = pdetail->serverbytes; + pdetail_pr->deduce_flow_stat->C2S_data_pkt = pdetail->serverpktnum; - pdetail_pr->deduce_flow_stat->S2C_all_byte = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; /* ????????, all??data???????, ?????pkt */ - pdetail_pr->deduce_flow_stat->S2C_data_byte = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; /* ????????, all??data???????, ?????pkt */ + pdetail_pr->deduce_flow_stat->S2C_all_byte = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; + pdetail_pr->deduce_flow_stat->S2C_data_byte = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; } }else if(DIR_S2C == a_tcp->dir){ pdetail = a_tcp->ptcpdetail; //pdetail->serverbytes = pdetail_pr->C2S_ack_seq - pdetail_pr->C2S_first_ack_seq; if(G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID != -1){ - pdetail_pr->deduce_flow_stat->S2C_data_byte = pdetail->clientbytes; /* ????????????????????��???? */ - pdetail_pr->deduce_flow_stat->S2C_data_pkt = pdetail->clientpktnum;/* ????????????????????��???? */ + pdetail_pr->deduce_flow_stat->S2C_data_byte = pdetail->clientbytes; + pdetail_pr->deduce_flow_stat->S2C_data_pkt = pdetail->clientpktnum; pdetail_pr->deduce_flow_stat->C2S_all_byte = pdetail_pr->S2C_ack_seq - pdetail_pr->S2C_first_ack_seq; pdetail_pr->deduce_flow_stat->C2S_data_byte = pdetail_pr->S2C_ack_seq - pdetail_pr->S2C_first_ack_seq; @@ -2056,19 +1897,17 @@ static void tcp_set_new_data(struct streaminfo *a_tcp,struct half_tcpstream * if(is_ctrl_pkt==0) { - //??????????????????????????????????? if(this_seq< EXP_SEQ) { havelen = EXP_SEQ - this_seq; if (datalen - havelen > 0) { - //20150225 ??????????? pdetail_pr->tcpoverlen=havelen; len_new= datalen - havelen; pdata_new=data+havelen; } } - else //???????? + else { len_new=datalen; pdata_new=data; @@ -2087,19 +1926,6 @@ static void tcp_set_new_data(struct streaminfo *a_tcp,struct half_tcpstream * len_new=datalen; pdata_new=data; } -/* - if((long long)(rcv->count_ideal - rcv->count - rcv->totallost) < 0) - { - pdetail->lostlen=0; - sapp_runtime_log(RLOG_LV_FATAL, "TCP stream:%s lostlen anomaly, TCP count_ideal:%u, count:%u, total_lost:%u", - printaddr(&a_tcp->addr, - this_seq), - rcv->count_ideal, - rcv->count, - rcv->totallost); - } - else -*/ { pdetail->lostlen=rcv->count_ideal - rcv->count- rcv->totallost; } @@ -2125,22 +1951,11 @@ static void tcp_set_new_data(struct streaminfo *a_tcp,struct half_tcpstream * } -/* - LiJia add, to do: - ??????????????, 1,2,3,4,x,6, ??5????????, ??6??????????, - ?????6???????????????, ???kill_tcp, - ????5?????????, streaminfo??��??????5?????????, - ?????????????��?6??????????, ???????kill_tcp, ????????????, - ????seq??ack???????5??????! - ??????buf_unorder?��?seq??ack, ????????????????. -*/ -#if 0 -int tcp_save_unorder(struct streaminfo *a_tcp,struct half_tcpstream *rcv,char *rawdata,int rawlen,struct mesa_tcp_hdr *this_tcphdr,int tcpdatalen) -#else + + static int tcp_save_unorder(struct streaminfo *a_tcp,struct half_tcpstream *rcv, const void *this_iphdr, const raw_pkt_t *stack_raw_pkt,struct mesa_tcp_hdr *this_tcphdr, unsigned char *tcpdata, int tcpdatalen) -#endif { int threadnum = a_tcp->threadnum; struct buf_unorder *p = rcv->unorderlisttail; @@ -2252,7 +2067,6 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, if (after (unorder_packet->seq + unorder_packet->tcpdatalen+unorder_packet->fin+unorder_packet->rst, EXP_SEQ)) { - /* 2015-01-13 lijia add, ??????????????kill_tcp??inject??????, ?????????????? */ update_stream_list_raw_pkt_pointer(a_tcp_pr, &unorder_packet->raw_pkt); if(unorder_packet->rst )//add by lqy 20100805) @@ -2275,14 +2089,12 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, stream_process_tcp(a_tcp,unorder_packet->this_ip_hdr, unorder_packet->this_tcp_hdr, &(unorder_packet->raw_pkt),&(pdetail_pr->apme),&(a_tcp->opstate)); } a_tcp->addr.pkttype=tmpktype; - /* 2016-05-12 lijia add, ??????????????unorder_list????BUG, ????????????nouse?? */ if(STREAM_LINK_DATA == last_link_state){ tcp_update_should_close_reason_stat(a_tcp->threadnum); tcp_change_stream_tonouse(pindex); ret = DROP; goto done; } - /* ?????????update_stream_list_raw_pkt_pointer, ??????????, ??????????? */ ret = PASS; goto done; } @@ -2300,13 +2112,10 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, orderflag = CHECK_ORDER_DATA; } - //get tcp??data??len - tcp_set_new_data(a_tcp,rcv,snd,(u_char *)(unorder_packet->tcpdata), unorder_packet->tcpdatalen,unorder_packet->seq,unorder_packet->fin, 0); if(unorder_packet->tcpdatalen >0) { - /* 2021-04-29 lijia add, ?????????Kill_tcp,??????????MSO_DROP_STREAM, ???????????????, ???????��?? */ if((0 == a_tcp_pr->stream_killed_flag) && (0 == pdetail_pr->drop_stream_flag)){ tmpktype=a_tcp->addr.pkttype; a_tcp->addr.pkttype = PKT_TYPE_TCPREORDER; @@ -2326,13 +2135,8 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, tcp_clear_newdata(a_tcp,rcv); } - //?????????????????? - //if(ret!=PASS) - /* 2015-01-16 lijia modify, ????????, ?????????Kill_tcp(), ????????DROP, ??????????????????????? */ - //if((ret!=PASS) || (a_tcp_pr->stream_killed_flag != 0)) - if((a_tcp_pr->stream_killed_flag != 0) || (pdetail_pr->drop_stream_flag != 0)) /* 2015-11-02 lqy modify, ????????????��????? */ + if((a_tcp_pr->stream_killed_flag != 0) || (pdetail_pr->drop_stream_flag != 0)) { - /* ?????????update_stream_list_raw_pkt_pointer, ??????????, ??????????? */ goto done; } } @@ -2346,19 +2150,7 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp, else rcv->unorderlisttail= unorder_packet->prev; tmp = unorder_packet->next; -#if 0 /* 2015-01-12 lijia modify */ - if(pakiet->data){ - dictator_free(a_tcp->threadnum,pakiet->data); - } - if(pakiet->ipfrag_list){//2014-11-25 lijia add for memory leak. - raw_frags_list_free_one(a_tcp->threadnum, pakiet->ipfrag_list); - pakiet->ipfrag_list = NULL; - } - dictator_free(a_tcp->threadnum, (void *)pakiet->raw_pkt.raw_pkt_data); - dictator_free(a_tcp->threadnum,pakiet); -#else tcp_free_unorder_pkt(a_tcp->threadnum, unorder_packet); -#endif unorder_packet = tmp; rcv->unorder_cnt--; } @@ -2374,13 +2166,9 @@ done: pdetail_pr->tcpoverlen = t_tcpoverlen;//add by yw 20150316 set tcpoverlen back return ret; } -#if 0 -int tcp_deal_data(struct streamindex *pindex,void *rawdata,int rawlen, - struct mesa_tcp_hdr *this_tcphdr,unsigned char *tcpdata,int datalen) -#else + static int tcp_deal_data(struct streamindex *pindex,const void *this_iphdr,const raw_pkt_t *raw_pkt, struct mesa_tcp_hdr *this_tcphdr,unsigned char *tcpdata,int datalen) -#endif { struct streaminfo_private *pstream_pr=&(pindex->stream); struct streaminfo *pstream = &pstream_pr->stream_public; @@ -2403,7 +2191,6 @@ static int tcp_deal_data(struct streamindex *pindex,const void *this_iphdr,const if (!after (this_seq, EXP_SEQ)) { - //????????? if (after(this_seq + datalen + (this_tcphdr->th_flags & TH_FIN), EXP_SEQ)) { @@ -2413,28 +2200,19 @@ static int tcp_deal_data(struct streamindex *pindex,const void *this_iphdr,const ret=stream_process_tcp(pstream,this_iphdr,(const void *)this_tcphdr, raw_pkt,&(pdetail_pr->apme),&(pstream->opstate)); //tcp_clear_newdata(pstream,rcv); /* 2016-09-12 lijia move to outside if(datalen > 0) */ } - tcp_clear_newdata(pstream,rcv); /* 2016-09-12 lijia move to here, ????datalen???>0, ?????????tcp_set_new_data, ?????????clear */ + tcp_clear_newdata(pstream,rcv); + -#if 0 /* lqy 2015-11-02 modify, ???????????????, ?????????????? */ - if(ret==PASS) - { - ret = tcp_deal_unorder(pindex,pstream,rcv,snd,CHECK_ORDER_DATA); - - } -#else - /* 2020-04-24 lijia modify, ???ret=stream_process_tcp???????DROP, tcp_deal_unorder()???????PASS, ?????????PASS, ?????CT??! */ ret_unorder = tcp_deal_unorder(pindex,pstream,rcv,snd,CHECK_ORDER_DATA); -#endif + if((DROP == ret_unorder) || (DROP == ret)){ ret = DROP; } return ret; } - //?????????????????????????????��??? } else { - //????????????? tcp_save_unorder(pstream,rcv,this_iphdr,raw_pkt,this_tcphdr,tcpdata, datalen); if(rcv->unorder_cnt > rcv->maxunorder) { @@ -2445,12 +2223,6 @@ static int tcp_deal_data(struct streamindex *pindex,const void *this_iphdr,const return ret; } -/* - 2017-10-16 lijia add, - ?��?NOUSE????, ???SYN, SYN/ACK??????????????, ???????????, ??????????????????. - TODO: - ???????��?, ??????????, ??????????????????????30??????. -*/ static inline int tcp_tuple4_reuse(const struct streaminfo *pstream, const struct tcpdetail_private *pdetail_pr, const struct mesa_tcp_hdr *this_tcphdr) { int is_reuse = 0; @@ -2473,20 +2245,15 @@ static inline int tcp_tuple4_reuse(const struct streaminfo *pstream, const struc /* lijia 2017-12-06 add */ if((1 == is_reuse) && (sapp_global_val->config.stream.tcp.tuple4_reuse_time_interval > 0)){ if(pdetail_pr->tcpdetail_public.createtime + sapp_global_val->config.stream.tcp.tuple4_reuse_time_interval >= (UINT64)g_CurrentTime){ - is_reuse = 0; /* ????????, ????????????????????????, ???30??????, ????????????? */ + is_reuse = 0; } } return is_reuse; } - -#if 0 -static int tcp_deal_data_stream(struct streamindex *pindex,const raw_pkt_t *raw_pkt,struct mesa_tcp_hdr *this_tcphdr,int datalen) -#else static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphdr, const raw_pkt_t *raw_pkt,struct mesa_tcp_hdr *this_tcphdr,int datalen) -#endif { int ret=PASS; int finclose=0; @@ -2525,7 +2292,6 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd pcurhalf->pktcout++; curseq=pcurhalf->first_data_seq + pcurhalf->count_ideal ; thisseq=ntohl (this_tcphdr->th_seq); - //????????? //if((thisseq<curseq)&&(thisseq+datalen<=curseq)&&(!(this_tcphdr->th_flags & TH_SYN))){ // modify by lqy 20150325 if(before(thisseq,curseq)&&before(thisseq+datalen,curseq+1)&&(!(th_flags & TH_SYN))){ pstream->addr.pkttype = PKT_TYPE_TCPRETRANS; @@ -2542,11 +2308,7 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd return PASS; } //rst -#if 0 - if( (this_tcphdr->th_flags & TH_RST)&&(curseq!=0)) -#else //modify by LiJia 2015-11-12 if( (th_flags & TH_RST)&&(curseq!=0)&&(pdetail_pr->ignore_rst_fin==0)) -#endif { /* 2014-07-31 LiJia modify, for one stream unorder number */ //if(thisseq>curseq+(pcurhalf->maxunorder+1)*1460) @@ -2555,7 +2317,6 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd //syn+rst drop packet if(th_flags & TH_SYN) return PASS; - //?????rst???? //if((thisseq-curseq<=1)&&(datalen==0)) if(before(thisseq, curseq+2)&&(datalen==0))//modify by lqy 20150325 { @@ -2579,13 +2340,10 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd return PASS; } - //?????rst????????????��?????????????????????????????????? } - //??????? if (th_flags & TH_SYN) { - //syn??? add by lqy 20100808 if((datalen>0) || ((UINT32)thisseq+1 == rcv->first_data_seq) || ((UINT32)thisseq==rcv->first_data_seq)) { pstream->addr.pkttype = PKT_TYPE_TCPRETRANS; @@ -2601,20 +2359,12 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd } return PASS; }else{ - /* 2017-12-19 lijia add, - ??SYN???, ??��??????, ??????????????????????????? , - ??????????????, ????????3??, ??????????????????????, - ????????????. - - ????????????, ????????????????????????????????. - */ if(tcp_tuple4_reuse(pstream, pdetail_pr, this_tcphdr) == 0){ return PASS; } } //adjust by lqy 20150107 //if(thisseq==rcv->first_data_seq) return PASS; - //add by lqy 20110507 syn??????????????????? //if(datalen>0) return PASS; //return PASS; if(th_flags & TH_RST) @@ -2625,9 +2375,6 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd pdetail_pr->link_state=STREAM_LINK_REUSE_BYSYN; pstream->opstate= OP_STATE_CLOSE; -#if 0 //del by lqy 20150107 tcp_reset_stream????????????????? - ret=stream_process_tcp(pstream,raw_pkt,&(pdetail_pr->apme),&(pstream->opstate)); -#endif tcp_reset_stream(pindex,this_iphdr,this_tcphdr,datalen,raw_pkt); return PASS; } @@ -2635,11 +2382,6 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd { tcpdata=(unsigned char*)(this_tcphdr) + 4 * this_tcphdr->th_off; ret=tcp_deal_data(pindex,this_iphdr,raw_pkt,this_tcphdr,tcpdata,datalen); - -/* 2016-05-12 lijia modify, ??????????????unorder_list????BUG, ?????????????CLOSE??, ??????????return, ???��?????? */ - - - //????????????????????????????rst???? if((pstream->opstate==OP_STATE_CLOSE)&&(pdetail_pr->link_state!=STREAM_LINK_RESET)) { tcp_change_stream_tonouse(pindex); @@ -2649,12 +2391,9 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd if(ret==DROP) return DROP; } - //add by lqy 20120922 ??????ack????????????????????? else if(pdetail_pr->needackflag!=0) { ret=stream_process_tcp(pstream,this_iphdr,this_tcphdr, raw_pkt,&(pdetail_pr->apme),&(pstream->opstate)); - //????????????????????????????rst???? - /* 2017-08-01 lijia modify, ????��?TCPALL?????, ?????????TCPALL????, opstate?????CLOSE??, ????????NOUSE? */ if((pstream->opstate==OP_STATE_CLOSE) && (OP_STATE_CLOSE == pstream->pktstate) &&(pdetail_pr->link_state!=STREAM_LINK_RESET)) @@ -2685,13 +2424,11 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd pdetail_pr->link_state=STREAM_LINK_CLOSE; finclose=1; } - //??????????rst???????? if ((th_flags & TH_RST)&&(thisseq==curseq) &&(datalen!=0)) { pdetail_pr->link_state=STREAM_LINK_RESET; finclose=1; } - /* 2015-11-12 lijia add, ??????RST, FIN?????????? */ if(pdetail_pr->ignore_rst_fin != 0){ finclose = 0; } @@ -2700,7 +2437,6 @@ static int tcp_deal_data_stream(struct streamindex *pindex,const void *this_iphd pstream->opstate = OP_STATE_CLOSE; ret=stream_process_tcp(pstream,this_iphdr,this_tcphdr, raw_pkt,&(pdetail_pr->apme),&(pstream->opstate)); - //adjust by lqy ????????????????????? if(pstream->pktstate!=OP_STATE_CLOSE) { tcp_update_should_close_reason_stat(pstream->threadnum); @@ -2722,9 +2458,6 @@ static int tcp_deal_nouse_stream(struct streamindex *pindex,const void *this_iph struct streaminfo *pstream=(struct streaminfo *)(&(pindex->stream)); struct tcpdetail_private *pdetail_pr=(struct tcpdetail_private *)pstream->pdetail; - //add by lqy 20141213 - //??????ack?????????????��?��??????,???????????????��??? - //if((pstream->opstate == OP_STATE_PENDING) && (datalen>0)) //modify by lqy 20150325 if((pstream->opstate == OP_STATE_PENDING) && (datalen>0) && (!(this_tcphdr->th_flags & TH_FIN)) @@ -2735,11 +2468,6 @@ static int tcp_deal_nouse_stream(struct streamindex *pindex,const void *this_iph return tcp_deal_data_stream(pindex,this_iphdr,raw_pkt,this_tcphdr,datalen); } - - //fin??rst???��?????????????????????????????????��??????????????????????????????? - - //??????? add by lqy 20150210 ???????????????????????data?????? - //add by lqy 20130822 ???????��????????????????????????????? if (this_tcphdr->th_flags & TH_SYN) { if(1 == tcp_tuple4_reuse(pstream, pdetail_pr, this_tcphdr)){ @@ -2832,13 +2560,9 @@ static char tcp_process_newstreambydata(struct streamindex *pindex_tcp,const voi } } - //???????????????all???? ret=tcp_processallpkt(pstream,this_iphdr,this_tcphdr,tcplen,raw_pkt); if(DROP == ret){ - /* 2016-06-08 lijia add, - for HMD, ??????��????????kill, ??????????��??????. - */ return DROP; } @@ -2867,16 +2591,14 @@ static int deal_tcp_stream_dup_pkt_check(int tid, struct streaminfo_private *pst if ((ADDR_TYPE_IPV4 == pstream_pr->stream_public.addr.addrtype) && (dup_pkt_para->dup_pkt_distinguish_ipv4_tcp || dup_pkt_para->dup_pkt_distinguish_all_inject)) { - // ???????????, ??��??N????, ???????????????, ???????????????????! if((0 == pstream_pr->has_duplicate_pkt) - && (ptcpdetail_pr->tcpdetail_public.clientpktnum+ptcpdetail_pr->tcpdetail_public.serverpktnum >= dup_pkt_para->first_packets)){ + && (ptcpdetail_pr->tcpdetail_public.clientpktnum+ptcpdetail_pr->tcpdetail_public.serverpktnum >= (unsigned int)dup_pkt_para->first_packets)){ dup_check_enabled = 0; }else{ dup_check_enabled = 1; } } - /* 24.04: ????IPv6???, ????????????????????, ????????????????????��??. */ if ((ADDR_TYPE_IPV6 == pstream_pr->stream_public.addr.addrtype) && (dup_pkt_para->dup_pkt_distinguish_all_inject != 0)) { @@ -2902,9 +2624,7 @@ static int deal_tcp_tfo(struct streaminfo *pstream, const void *this_iphdr, stru if(NULL == pdetail_pr->pserver){ pdetail_pr->pserver=(struct half_tcpstream *)sapp_mem_malloc(SAPP_MEM_DYN_TCP_HALF_STREAM,pstream->threadnum,sizeof(struct half_tcpstream)); memset(pdetail_pr->pserver,0,sizeof(struct half_tcpstream)); - //?????? pdetail_pr->pserver->first_data_seq=pdetail_pr->iserverseq; - /* pdetail_pr->iserverseq=0; */ /* 2016-04-27 lijia modify, ?????????????ISN */ /* 2014-10-20 LiJia add, for set one stream unorder number */ pdetail_pr->pserver->maxunorder = tcp_default_unorder; @@ -2917,10 +2637,7 @@ static int deal_tcp_tfo(struct streaminfo *pstream, const void *this_iphdr, stru if(NULL == pdetail_pr->pclient){ pdetail_pr->pclient=(struct half_tcpstream *)sapp_mem_malloc(SAPP_MEM_DYN_TCP_HALF_STREAM,pstream->threadnum,sizeof(struct half_tcpstream)); memset(pdetail_pr->pclient,0,sizeof(struct half_tcpstream)); - //?????? pdetail_pr->pclient->first_data_seq=pdetail_pr->iclientseq; - /* pdetail_pr->iclientseq=0; */ /* 2016-04-27 lijia modify, ?????????????ISN */ - /* 2014-10-20 LiJia add, for set one stream unorder number */ pdetail_pr->pclient->maxunorder = tcp_default_unorder; } @@ -2928,12 +2645,11 @@ static int deal_tcp_tfo(struct streaminfo *pstream, const void *this_iphdr, stru snd=pdetail_pr->pserver; } - tcp_set_new_data(pstream,rcv,snd,(char *)this_tcphdr + this_tcphdr->th_off*4,tcplen,this_tfo_first_seq,this_tcphdr->th_flags & TH_FIN, raw_pkt->is_ctrl_pkt); + tcp_set_new_data(pstream,rcv,snd,(uchar *)this_tcphdr + this_tcphdr->th_off*4,tcplen,this_tfo_first_seq,this_tcphdr->th_flags & TH_FIN, raw_pkt->is_ctrl_pkt); ret = stream_process_tcp(pstream, this_iphdr, this_tcphdr, raw_pkt, &(pdetail_pr->apme),&(pstream->opstate)); return ret; } -/* LiJia comment: pstream?????????? */ //int deal_tcp_stream(struct streamindex *pstream,struct mesa_tcp_hdr *this_tcphdr,int tcplen,const void *rawippkt,int iplen) static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, struct mesa_tcp_hdr *this_tcphdr, int tcplen,const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr) @@ -2946,12 +2662,11 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s struct streaminfo_private *pstream_pr = &pindex->stream; struct streaminfo *pstream = &pstream_pr->stream_public; int try_to_update_addr_info = 0; - int call_tcpall_after_reset = 0; /* 2019-10-18 lijia modify, ???????reset???,????????tcpall,?????tcp */ + int call_tcpall_after_reset = 0; sapp_gval_mthread_sys_stat_t *local_sys_stat = &sapp_global_val->mthread_volatile[pstream->threadnum]->sys_stat; pindex_tcp = findstreamindex (pindex, raw_pkt); if(unlikely(!pindex_tcp)){ - /* ????????????????, ?????????????, ???????bloom filter */ if((ADDR_TYPE_IPV4 == pstream->addr.addrtype) && sapp_global_val->config.packet_io.dup_pkt_para.dup_pkt_distinguish_ipv4_tcp){ sapp_dup_pkt_mark_l4(pstream, this_iphdr, (const void *)this_tcphdr); @@ -2993,14 +2708,9 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s } else { - /* 2017-12-07 lijia add, - TCPRFC?��, ???????��???????????, ????????????, ?????RST??????0, - ????????????????, ?????seq=0??RST??, ?????????????, ??????. - */ if((this_tcphdr->th_flags & TH_RST) && (0 == this_tcphdr->th_seq)){ return PASS; } - //add by lqy 20141213???????????tcplen=0????????? if((tcplen==0)&&(tcp_support_all==TCP_SUPPORT_ENTRYALL_OFF)) return PASS; if(TCP_CTEAT_LINK_BYDATA & tcp_creatlink_model ) @@ -3012,7 +2722,6 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s pstream_pr = &pindex_tcp->stream; pstream = &pstream_pr->stream_public; pstream_pr->raw_pkt = raw_pkt; //add by lijia 20171206 - //add by lqy 20150114 ???????????????????all???? if(pstream_pr->under_ddos_bypass) { local_sys_stat->count[SAPP_STAT_TCP_BYPASS_STREAM]++; @@ -3050,7 +2759,6 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s // pindex_tcp->stream.offset_to_raw_pkt_hdr = (char *)this_tcphdr - (char *)raw_pkt->raw_pkt_data; //pstream_pr->offset_to_raw_pkt_hdr = offset_to_raw_pkt_hdr; pstream_pr->raw_pkt = raw_pkt; /* 2014-12-30 lijia add */ - /* 2015-11-04 lijia add, IP??????????, pstream????????��??, pindex????????? */ pstream->addr.pktipfragtype = pindex->stream.stream_public.addr.pktipfragtype; } @@ -3058,11 +2766,9 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s pdetail =(struct tcpdetail *)(&pdetail_pr->tcpdetail_public); - /* ddos bypass???????? */ if(pstream_pr->under_ddos_bypass){ local_sys_stat->count[SAPP_STAT_TCP_BYPASS_PKTS]++; local_sys_stat->length[SAPP_STAT_TCP_BYPASS_BYTES]+= tcplen; - /* ????ddos???????????????, ?????��?????CPU, ????????��???????, ?????????PASS */ cycle_pkt_dump_by_classify(pstream->threadnum, raw_pkt, PKT_CLASSIFY_BYPASS); return PASS; } @@ -3070,33 +2776,15 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s - /* 2014-10-11 lijia add, Fd??????????? */ if(unlikely(pstream_pr->stream_killed_flag != 0) && raw_pkt->is_ctrl_pkt==0){ - if((pdetail_pr->auto_remedy_flag != 0) && (tcplen > 0)){ /* ???flood????, ??��??????????RST */ + if((pdetail_pr->auto_remedy_flag != 0) && (tcplen > 0)){ sapp_runtime_log(RLOG_LV_DEBUG, "TCP stream: %s, kill_tcp remedy, curdir:%d, send RST pkt.", printaddr(&pstream->addr, pstream->threadnum), pstream->curdir); pstream_pr->plugin_process_context=1; MESA_kill_tcp_remedy(pstream, raw_pkt); pstream_pr->plugin_process_context=0; } - -#if 0 /* MSO_TCPALL_VALID_AFTER_KILL option is obsoleted! */ - pdetail_pr = (struct tcpdetail_private *)(pindex_tcp->stream.stream_public.pdetail); - if(pdetail_pr->tcpall_valid_after_kill != 0){ - tcp_processallpkt(pstream,this_iphdr,this_tcphdr,tcplen,raw_pkt); - } -#endif - //return DROP; /* 2019-11-20 lijia modify, kill_tcp????????????DROP, ?????rst??, ?????????drop_stream_flag */ } - - /* - 2021-05-18 lijia close ipv6 dup pkt check: - IPv6??????Ipid???, ???????????????��?????????????, ????????????????CT, ????????!!! - - ????IPv6?????????: - 1)????????????????, ?????????????????????, sapp?????PASS??, ???????????????????????, ??��???tfe????, ??????????. - 2)?????????firewall??drop????, ?????drop?????, ????��?????, ?????????????????????, sapp?????PASS??, ????CT. - */ if(raw_pkt->is_ctrl_pkt==0 && deal_tcp_stream_dup_pkt_check(pstream->threadnum, pstream_pr, pdetail_pr, (const struct mesa_ip4_hdr *)this_iphdr, this_tcphdr) != 0){ local_sys_stat->count[SAPP_STAT_RCV_DUP_TCP]++; @@ -3121,7 +2809,6 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s } } -// ????kill remedy??drop stream???????????sapp????????????????????sid,?????????service chain??????????SF?????? if(pstream_pr->sid_append_list != NULL) { ((raw_pkt_t *)raw_pkt)->append_list=pstream_pr->sid_append_list; @@ -3138,7 +2825,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s if(pstream->curdir==DIR_S2C) { - if(pdetail->clientpktnum == 0) /* ??????????????, ???????????????????????(??MPLS, GTP) */ + if(pdetail->clientpktnum == 0) { try_to_update_addr_info = 1; } @@ -3147,7 +2834,7 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s } else { - if(pdetail->serverpktnum == 0) /* ??????????????, ???????????????????????(??MPLS, GTP) */ + if(pdetail->serverpktnum == 0) { try_to_update_addr_info = 1; } @@ -3164,7 +2851,6 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s int frag_cnt = 0, frag_len = 0; stream_get_scratch_frag_stat(pstream, &frag_cnt, &frag_len); - /* flow_stat????????????, ??????????????????? */ if(G_TCP_FLOW_STAT_PROJECT_ID != -1 && raw_pkt->is_ctrl_pkt == 0){ if(DIR_C2S == pstream->curdir){ pdetail_pr->flow_stat->C2S_syn_pkt+=((this_tcphdr->th_flags & TH_SYN) ? 1 : 0); @@ -3219,13 +2905,11 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s pstream_pr->ip_ttl_s2c = pindex->stream.ip_ttl_c2s; /* Not a mistake, that's it! */ } - /* note: reset?????��???, ????clientbytes+=, clientpktnum++??????? */ if(1 == lrustream(pindex_tcp)){ ret = tcp_reset_stream(pindex_tcp, this_iphdr,this_tcphdr, tcplen,raw_pkt); if(0 == ret){ return PASS; } - /* ?????tcp_reset_stream()??????, ????????bypass???, ?????????, ?????????tcp_processallpkt */ if(pstream_pr->under_ddos_bypass){ return PASS; } @@ -3268,10 +2952,8 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s else if (pstream->stream_state == TCP_SYN_STATE) { ret = tcp_deal_syn_stream(pindex_tcp, raw_pkt, this_iphdr, this_tcphdr, tcplen); - // ?????????????????????��????? if (DROP == ret) { - // return PASS;//?????��????????????????PASS????????????? ret = PASS; goto fun_exit; } @@ -3281,7 +2963,6 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s // ret=tcp_deal_data_stream(pindex_tcp,rawippkt,iplen,this_tcphdr,tcplen); ret = tcp_deal_data_stream(pindex_tcp, this_iphdr, raw_pkt, this_tcphdr, tcplen); } - // add by lqy 20150215 ?????????????????? else { pindex_tcp->stream.stream_public.addr.pkttype = PKT_TYPE_TCPUNORDER; @@ -3293,19 +2974,14 @@ static int deal_tcp_stream(struct streamindex *pindex, const void *this_iphdr, s } } } - - /* ?????tcp_deal_nouse_stream(),tcp_deal_data_stream()??????, ???��?tcp_reset_stream()?????????, - ???????????bypass???, ??????????, ?????????stream_process_tcp_allpkt() - */ + if(pstream_pr->under_ddos_bypass){ return ret; } pdetail_pr =(struct tcpdetail_private*)(pstream->pdetail); - //adjust by lqy 20150107 ?????SYN????????SYN???????????? if((pdetail_pr != NULL) && (0 == call_tcpall_after_reset) && pindex_tcp && (pstream->pktstate!=OP_STATE_CLOSE)) { - //????????????????????????????? if(tcplen == 0) { pdetail->pdata = NULL; @@ -3346,20 +3022,12 @@ fun_exit: return ret; } -/* - lijia 2015-01-12 add this_iphdr, - ?????IP?????????, ????????????IP???, ???????tcp_hdr??raw_hdr, ????????????IP???. -*/ + static int dealtcppkt(struct streamindex *pfindex, const void *this_iphdr, struct mesa_tcp_hdr *this_tcphdr, int thread_num,unsigned char routedir, int tcpdatalen, const raw_pkt_t *raw_packet, int offset_to_raw_pkt_hdr) { -#if 0 - struct layer_addr_tcp tcp_addr; -#else - //struct layer_addr *tcp_stream_addr; -#endif - /* IPPORT-union?��, IP??TCP?????????index??, ????????IP?????pfindex */ + //struct streamindex tmp_tcp_stream; //struct streamindex *ptmp=&tmp_tcp_stream; struct streaminfo_private *pstream_pr = (struct streaminfo_private *)(&pfindex->stream); @@ -3385,7 +3053,7 @@ static int dealtcppkt(struct streamindex *pfindex, const void *this_iphdr, struc pstream->addr.pkttype = PKT_TYPE_NORMAL;//add by lqy 20151222, init pkttype - pstream_pr->addr_use_as_hash = 1; /* ????????????IP?? */ + pstream_pr->addr_use_as_hash = 1; // ptmp->stream.p_layer_header = this_tcphdr; //ptmp->stream.offset_to_raw_pkt_hdr = (char *)this_tcphdr - (char *)raw_packet->raw_pkt_data; pstream_pr->offset_to_ip_hdr = (char *)this_tcphdr - (char *)this_iphdr; @@ -3394,14 +3062,13 @@ static int dealtcppkt(struct streamindex *pfindex, const void *this_iphdr, struc pstream->routedir=routedir; pstream->threadnum=thread_num; - local_sys_stat->count_per_layer[ADDR_TYPE_TCP][pstream_pr->layer_index]++; /* tcp??ip??????? */ - local_sys_stat->length_per_layer[ADDR_TYPE_TCP][pstream_pr->layer_index] += tcpdatalen + this_tcphdr->th_off*4; /* tcp??ip??????? */ + local_sys_stat->count_per_layer[ADDR_TYPE_TCP][pstream_pr->layer_index]++; + local_sys_stat->length_per_layer[ADDR_TYPE_TCP][pstream_pr->layer_index] += tcpdatalen + this_tcphdr->th_off*4; //return deal_tcp_stream(ptmp,this_tcphdr,tcpdatalen,raw_packet,raw_len); return deal_tcp_stream(pfindex,this_iphdr, this_tcphdr,tcpdatalen, raw_packet, offset_to_raw_pkt_hdr); } -/* lijia comment: this_iphdr?????????????, ???????malloc??IP?????, ??addr.pkttype???? */ int dealipv4tcppkt(struct streamindex *pfindex, const struct mesa_ip4_hdr *this_iphdr,int thread_num, unsigned char routedir, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr) { @@ -3429,8 +3096,7 @@ int dealipv4tcppkt(struct streamindex *pfindex, const struct mesa_ip4_hdr *this_ } - /* lijia 2016-06-15 add, ???????, ??????ACK?? */ -#if HIGH_PERF /* ?????????????????ACK */ +#if HIGH_PERF if((0 == datalen) && (TH_ACK == this_tcphdr->th_flags)){ return PASS; } @@ -3541,12 +3207,6 @@ void set_tcp_takeoverflag(struct streaminfo *pstream,int flag) } -/* - ??????????: etc/well_known_port.conf - return value: - 0 : not found in well known port array; - 1: in well known port array; -*/ static int is_well_known_port(int stream_type, unsigned short port_host_order) { int i; @@ -3576,31 +3236,19 @@ static int is_well_known_port(int stream_type, unsigned short port_host_order) return 0; } - -/* - 2021-06-08??, ????udp??tcp??SYN???????, ?????"??????????"??????????????, - 2021-06-08???, ?????��??????, ????80, 8088, 53?????, ?????????. - - return value: - 0 : not found in well known port array; - DIR_C2S: in well known port array, and it's dir; - DIR_S2C: in well known port array, and it's dir; -*/ static int adjust_stream_dir_by_well_known_ports(unsigned char stream_type,UINT16 sport_host, UINT16 dport_host) { int ret; ret = is_well_known_port(stream_type,dport_host); if(ret != 0){ - return DIR_C2S; /* dport???��???, ??C2S???? */ + return DIR_C2S; } ret = is_well_known_port(stream_type,sport_host); if(ret != 0){ - return DIR_S2C; /* sport???��???, ??S2C???? */ + return DIR_S2C; } - - /* ???????????????well known port, ???????��????, "??????????"???? */ return 0; } @@ -3614,8 +3262,6 @@ int set_transport_addr(struct streaminfo *this_stream, int enable_well_known_por if(__ADDR_TYPE_IP_PAIR_V4 == this_addr->addrtype){ struct stream_tuple4_v4 *ip4_addr = this_addr->tuple4_v4; - /* ??????, ??IP-PORT-union?��??port??????layer_dir?????, - ??????layer_dir, ???????HASH?, ?????????? */ if(enable_well_known_port){ dir_by_well_known_port = adjust_stream_dir_by_well_known_ports(this_stream->type, ntohs(sport), ntohs(dport)); } @@ -3630,7 +3276,7 @@ int set_transport_addr(struct streaminfo *this_stream, int enable_well_known_por this_stream_pr->create_dir_by_well_known_port = 1; }else{ if(ntohs(sport) > ntohs(dport)){ - this_stream_pr->layer_dir = 1; /* ????????????????layer_dir */ + this_stream_pr->layer_dir = 1; this_stream->curdir = DIR_C2S; }else{ if(unlikely(sport == dport)){ @@ -3649,7 +3295,7 @@ int set_transport_addr(struct streaminfo *this_stream, int enable_well_known_por } ip4_addr->source = sport; ip4_addr->dest = dport; - this_addr->addrtype = ADDR_TYPE_IPV4; /* ????papp??, ??????????????'ADDR_TYPE_IPV4???' */ + this_addr->addrtype = ADDR_TYPE_IPV4; this_addr->addrlen = sizeof(struct stream_tuple4_v4); }else if(__ADDR_TYPE_IP_PAIR_V6 == this_addr->addrtype){ struct stream_tuple4_v6 *ip6_addr = this_addr->tuple4_v6; @@ -3687,7 +3333,7 @@ int set_transport_addr(struct streaminfo *this_stream, int enable_well_known_por ip6_addr->source = sport; ip6_addr->dest = dport; - this_addr->addrtype = ADDR_TYPE_IPV6; /* ????papp??, ??????????????'ADDR_TYPE_IPV6???' */ + this_addr->addrtype = ADDR_TYPE_IPV6; this_addr->addrlen = sizeof(struct stream_tuple4_v6); }else{ assert(0); @@ -3699,7 +3345,6 @@ int set_transport_addr(struct streaminfo *this_stream, int enable_well_known_por -/* 2014-12-30 lijia add, ?????????????????, ?????????????????, ????? */ struct streaminfo *skip_proxy_phony_stream(struct streaminfo *a_tcp) { int proxy_layer_num = 0; @@ -3743,23 +3388,7 @@ static struct buf_unorder *tcp_save_unorder_pkt(struct streaminfo *a_tcp,const v memcpy((void *)uo_packet->raw_pkt.raw_pkt_data, stack_raw_pkt->raw_pkt_data, stack_raw_pkt->raw_pkt_len); - /* iphdr?????????: - 1)??IP?????: - ???��??????????, ????????????????, ???free???; - 2)IP??????: - ?��??????????(?????????), ???????malloc??IP??, ??????????????; - */ -#if 0 - -#else - /* ???IPv4?��????????, ????: MAC->IPv4->UDP->IPv6->IPv4->TCP->APP, - ??????��???????IPv4?????????, ?????IPv4????????????IP?????????. - ????, ?????????????IP???????????????��?, - ???????, ???????????????????????????MTU??��??, - ?????????MTU, ???IP?????????malloc??, ???????????. - */ if(labs((char *)this_iphdr - (char *)stack_raw_pkt->raw_pkt_data) > MTU_MAX){ -#endif uo_packet->ip_reassemble_pkt = 1; this_ip_tot_len = get_ip_pkt_tot_len(carry_ip_stream, this_iphdr); uo_packet->this_ip_hdr = sapp_mem_malloc(SAPP_MEM_DYN_TCP_UNORDER,a_tcp->threadnum, this_ip_tot_len); @@ -3788,7 +3417,6 @@ static struct buf_unorder *tcp_save_unorder_pkt(struct streaminfo *a_tcp,const v uo_packet->urg = (this_tcphdr->th_flags & TH_URG); uo_packet->urg_ptr = ntohs (this_tcphdr->th_urp); - /* IP???????????????pakiet????, ??????G_IP_FRAG_LIST[tid]??????, ????ip_entry????? */ uo_packet->ipfrag_list = raw_ip_frag_list_global_move_pkt(a_tcp); a_tcp->addr.pkttype = PKT_TYPE_TCPUNORDER;//add by lqy 20151222, mark unorder @@ -3830,17 +3458,9 @@ static int get_ip_pkt_tot_len(struct streaminfo *ipinfo, const void *this_iphdr) return ip_tot_len; } -/* 2015-01-13 lijia add, - ???kill_xxx??��??????stream_pr???��?raw_pkt???, - ?????????????????????, ????kill_xxx??��???, - ????? -*/ static inline void update_stream_list_raw_pkt_pointer(struct streaminfo_private *a_tcp_pr, const raw_pkt_t *raw_pkt) { a_tcp_pr->raw_pkt = raw_pkt; - - /* TODO 3: ???????????a_tcp->pfather->raw_pkt?????????! */ - return; } @@ -3851,7 +3471,6 @@ static void tcp_flow_stat_free(int thread_seq, void *project_req_value) } -/* 2015-12-25 lijia add, for TCP/UDP??????? */ int tcp_flow_stat_init(void) { int project_req_id; @@ -3860,7 +3479,6 @@ int tcp_flow_stat_init(void) if(project_req_id >= 0){ G_TCP_FLOW_STAT_PROJECT_ID = project_req_id; }else{ - /* ??????????'tcp_flow_stat'??, ??????? */ G_TCP_FLOW_STAT_PROJECT_ID = -1; } @@ -3868,7 +3486,6 @@ int tcp_flow_stat_init(void) if(project_req_id >= 0){ G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID = project_req_id; }else{ - /* ??????????'tcp_flow_stat'??, ??????? */ G_TCP_DEDUCE_FLOW_STAT_PROJECT_ID = -1; } |
