summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2023-05-12 17:15:50 +0800
committerliuxueli <[email protected]>2023-05-12 17:15:50 +0800
commitdc51748534bb542898c241248b44db244227ebf3 (patch)
tree1a8b2e6033912d66949cb15659f24f03105ed113
parent36dafd426749cc11cd0e8e41daabc15dfaa0616f (diff)
接收控制报文跳过检查TCP sequence的逻辑v4.3.2
-rw-r--r--src/dealpkt/deal_tcp.c97
-rw-r--r--src/dealpkt/deal_udp.c41
2 files changed, 93 insertions, 45 deletions
diff --git a/src/dealpkt/deal_tcp.c b/src/dealpkt/deal_tcp.c
index cf4c112..bc31494 100644
--- a/src/dealpkt/deal_tcp.c
+++ b/src/dealpkt/deal_tcp.c
@@ -1929,7 +1929,7 @@ static inline void tcp_clear_newdata(struct streaminfo *a_tcp,struct half_tcpst
}
static void tcp_set_new_data(struct streaminfo *a_tcp,struct half_tcpstream *rcv, struct half_tcpstream *snd,
- u_char* data, int datalen, u_int this_seq,char fin)
+ u_char* data, int datalen, u_int this_seq,char fin, unsigned char is_ctrl_pkt)
{
int havelen;
int len_new=0;
@@ -1937,33 +1937,39 @@ static void tcp_set_new_data(struct streaminfo *a_tcp,struct half_tcpstream *
struct tcpdetail_private*pdetail_pr=(struct tcpdetail_private*)a_tcp->pdetail;
struct tcpdetail *pdetail=(struct tcpdetail *)&pdetail_pr->tcpdetail_public;
- //��һ��������Ŀ������ش������dz��ȱ�ԭ����
- if(this_seq< EXP_SEQ)
- {
- havelen = EXP_SEQ - this_seq;
- if (datalen - havelen > 0)
- {
- //20150225 ��¼�ص��ij���
- pdetail_pr->tcpoverlen=havelen;
- len_new= datalen - havelen;
- pdata_new=data+havelen;
- }
- }
- else //����ı���
- {
- len_new=datalen;
- pdata_new=data;
- }
-
- if(len_new>0)
- {
- rcv->count_ideal += len_new;
- rcv->data=pdata_new;
- rcv->count_new = len_new;
- rcv->count += len_new;
-
- }
+ if(is_ctrl_pkt==0)
+ {
+ //��һ��������Ŀ������ش������dz��ȱ�ԭ����
+ if(this_seq< EXP_SEQ)
+ {
+ havelen = EXP_SEQ - this_seq;
+ if (datalen - havelen > 0)
+ {
+ //20150225 ��¼�ص��ij���
+ pdetail_pr->tcpoverlen=havelen;
+ len_new= datalen - havelen;
+ pdata_new=data+havelen;
+ }
+ }
+ else //����ı���
+ {
+ len_new=datalen;
+ pdata_new=data;
+ }
+ if(len_new>0)
+ {
+ rcv->count_ideal += len_new;
+ rcv->data=pdata_new;
+ rcv->count_new = len_new;
+ rcv->count += len_new;
+ }
+ }
+ else
+ {
+ len_new=datalen;
+ pdata_new=data;
+ }
/*
if((long long)(rcv->count_ideal - rcv->count - rcv->totallost) < 0)
{
@@ -1985,7 +1991,7 @@ static void tcp_set_new_data(struct streaminfo *a_tcp,struct half_tcpstream *
sapp_global_val->mthread_volatile[a_tcp->threadnum]->sys_stat.length[SAPP_STAT_TCP_LOST_PKT] += pdetail->lostlen;
- pdetail->datalen=len_new;
+ pdetail->datalen=len_new;
pdetail->pdata=pdata_new;
if (fin)
@@ -2207,7 +2213,7 @@ static int tcp_deal_unorder(struct streamindex *pindex,struct streaminfo *a_tcp,
pakiet->tcpdatalen,pakiet->seq,pakiet->fin);
#else
tcp_set_new_data(a_tcp,rcv,snd,(u_char *)(pakiet->tcpdata),
- pakiet->tcpdatalen,pakiet->seq,pakiet->fin);
+ pakiet->tcpdatalen,pakiet->seq,pakiet->fin, 0);
#endif
if(pakiet->tcpdatalen >0)
{
@@ -2310,7 +2316,7 @@ static int tcp_deal_data(struct streamindex *pindex,const void *this_iphdr,const
if (after(this_seq + datalen +
(this_tcphdr->th_flags & TH_FIN), EXP_SEQ))
{
- tcp_set_new_data(pstream,rcv,snd,tcpdata,datalen,this_seq,this_tcphdr->th_flags & TH_FIN);
+ tcp_set_new_data(pstream,rcv,snd,tcpdata,datalen,this_seq,this_tcphdr->th_flags & TH_FIN, raw_pkt->is_ctrl_pkt);
if(datalen >0)
{
ret=stream_process_tcp(pstream,this_iphdr,(const void *)this_tcphdr, raw_pkt,&(pdetail_pr->apme),&(pstream->opstate));
@@ -3192,16 +3198,25 @@ int dealipv4tcppkt(struct streamindex *pfindex, const struct mesa_ip4_hdr *this_
iphdr_len = this_iphdr->ip_hl << 2;
struct mesa_tcp_hdr *this_tcphdr = (struct mesa_tcp_hdr *)((char *)this_iphdr + iphdr_len);
- iplen = ntohs (this_iphdr->ip_len);
- if(unlikely(iplen - iphdr_len < (int)sizeof (struct mesa_tcp_hdr))){
- return PASS;
+ if(raw_pkt->is_ctrl_pkt==0)
+ {
+ iplen = ntohs (this_iphdr->ip_len);
+ if(unlikely(iplen - iphdr_len < (int)sizeof (struct mesa_tcp_hdr))){
+ return PASS;
+ }
+
+ datalen = iplen - iphdr_len - (this_tcphdr->th_off<<2);
}
-
- datalen = iplen - iphdr_len - (this_tcphdr->th_off<<2);
+ else
+ {
+ datalen = raw_pkt->raw_pkt_len-offset_to_raw_pkt_hdr-(this_tcphdr->th_off<<2);
+ }
+
if(unlikely(datalen < 0)){
return PASS;
}
-
+
+
/* lijia 2016-06-15 add, ������, ������ACK�� */
#if HIGH_PERF /* ������ģʽ���Զ�����ACK */
if((0 == datalen) && (TH_ACK == this_tcphdr->th_flags)){
@@ -3229,7 +3244,15 @@ int dealipv6tcppkt(struct streamindex *pfindex, const struct mesa_ip6_hdr *this_
{
struct mesa_tcp_hdr *this_tcphdr = (struct mesa_tcp_hdr *)data;
- datalen -= (this_tcphdr->th_off << 2);
+ if(raw_pkt->is_ctrl_pkt==0)
+ {
+ datalen -= (this_tcphdr->th_off << 2);
+ }
+ else
+ {
+ datalen = raw_pkt->raw_pkt_len-offset_to_raw_pkt_hdr-(this_tcphdr->th_off<<2);
+ }
+
if(unlikely(datalen < 0)){
return PASS;
}
diff --git a/src/dealpkt/deal_udp.c b/src/dealpkt/deal_udp.c
index 95ba2f5..8318077 100644
--- a/src/dealpkt/deal_udp.c
+++ b/src/dealpkt/deal_udp.c
@@ -30,7 +30,7 @@ extern int sapp_is_overlay_layer(const struct streaminfo_private *stream_pr, con
int G_UDP_FLOW_STAT_PROJECT_ID = -1;
int G_UDP_TEREDO_IDENTIFY_PROJECT_ID = -1;
-static void udp_change_stream_state(struct streamindex *pindex, struct mesa_udp_hdr *udph, const raw_pkt_t *raw_pkt)
+static void udp_change_stream_state(struct streamindex *pindex, struct mesa_udp_hdr *udph, const raw_pkt_t *raw_pkt, int offset_to_raw_pkt_hdr)
{
int ulen =0;
int datalen =0;
@@ -45,6 +45,20 @@ static void udp_change_stream_state(struct streamindex *pindex, struct mesa_udp_
ulen = ntohs (udph->uh_ulen);
datalen =ulen - sizeof (struct mesa_udp_hdr);
+ if(raw_pkt->is_ctrl_pkt==0)
+ {
+ ulen = ntohs (udph->uh_ulen);
+ datalen =ulen - sizeof (struct mesa_udp_hdr);
+ }
+ else
+ {
+ datalen = raw_pkt->raw_pkt_len-offset_to_raw_pkt_hdr-sizeof(struct mesa_udp_hdr);
+ }
+
+ if(unlikely(datalen < 0)){
+ return ;
+ }
+
if(a_udp->curdir==DIR_C2S)
{
pdetail->serverpktnum++;
@@ -535,13 +549,24 @@ int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr * this_
local_sys_stat->count_per_layer[ADDR_TYPE_UDP][pstream_pr->layer_index]++; /* udp��ip����һ�� */
local_sys_stat->length_per_layer[ADDR_TYPE_UDP][pstream_pr->layer_index] += ulen; /* udp��ip����һ�� */
-
- /* 2015-12-29 lijia modify, ijЩUDP��û�и�������, û������, ֱ�Ӷ��� */
- if(unlikely(iplen - hlen < ulen || ulen <= (int)sizeof (struct mesa_udp_hdr))){
- return PASS;
+
+ if(raw_pkt->is_ctrl_pkt==0)
+ {
+ /* 2015-12-29 lijia modify, ijЩUDP��û�и�������, û������, ֱ�Ӷ��� */
+ if(unlikely(iplen - hlen < ulen || ulen <= (int)sizeof (struct mesa_udp_hdr))){
+ return PASS;
+ }
+ datalen =ulen - sizeof (struct mesa_udp_hdr);
+ }
+ else
+ {
+ datalen = raw_pkt->raw_pkt_len-offset_to_raw_pkt_hdr-sizeof(struct mesa_udp_hdr);
}
- datalen =ulen - sizeof (struct mesa_udp_hdr);
+ if(unlikely(datalen <= 0)){
+ return PASS;
+ }
+
pstream_pr->offset_to_ip_hdr = (char *)udph - (char *)this_iphdr;
pstream_pr->raw_pkt = raw_pkt; /* 2014-12-30 lijia add */
//set_stream_addr(pfstream, udph->uh_sport, udph->uh_dport, &ptmp->stream.addr);
@@ -696,7 +721,7 @@ int dealipv4udppkt(struct streamindex *pindex, const struct mesa_ip4_hdr * this_
update_polling_inject_context(SAPP_MEM_DYN_UDP_POLLING_RAW_PKT, pstream_pr, raw_pkt);
- udp_change_stream_state(a_index,udph, raw_pkt);
+ udp_change_stream_state(a_index,udph, raw_pkt, offset_to_raw_pkt_hdr);
pstream_pr->offset_to_ip_hdr = (char *)udph - (char *)this_iphdr;
pstream_pr->raw_pkt = raw_pkt; /* 2014-12-30 lijia add */
@@ -950,7 +975,7 @@ int dealipv6udppkt(struct streamindex *pindex,const struct mesa_ip6_hdr *a_packe
(struct streaminfo_private *)(pindex->stream.pfather_pr), pstream->curdir);
}
- udp_change_stream_state(a_index,udph, raw_pkt);
+ udp_change_stream_state(a_index,udph, raw_pkt, offset_to_raw_pkt_hdr);
/* ����pstreamָ�� */
pstream_pr=&(a_index->stream);