summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author杨威 <[email protected]>2023-01-12 11:24:59 +0800
committer杨威 <[email protected]>2023-01-16 14:42:18 +0800
commitf644218f2a285f2acf9f53b728616d9ee23a2fef (patch)
tree935e145a7cdf9d5ae61e1622676285aa9fdb5164
parent39d375589e4267f0aaab9d3fd97734147ff6901b (diff)
🐞 fix(MSO_STREAM_TIMED): 重命名opt,修复重复计数错误
-rw-r--r--include/private/mesa_net.h2
-rw-r--r--include/public/stream_inc/stream_control.h2
-rw-r--r--module_test/src/gtest_sapp_comm.cpp12
-rw-r--r--module_test/src/gtest_sapp_inject_plug.cpp16
-rw-r--r--src/dealpkt/plug_support.c4
-rw-r--r--test/test_app_sapp.c2
6 files changed, 19 insertions, 19 deletions
diff --git a/include/private/mesa_net.h b/include/private/mesa_net.h
index 5e41651..ceff7cc 100644
--- a/include/private/mesa_net.h
+++ b/include/private/mesa_net.h
@@ -861,7 +861,7 @@ struct __inline_vxlan_hdr{
}__attribute__((packed));
typedef struct __inline_vxlan_hdr inline_vxlan_hdr_t;
-
+#include "stream_inc/stream_base.h"
unsigned char net_layer_to_ipv4_protocol(int addr_type);
unsigned char net_layer_to_ipv6_protocol(int addr_type);
diff --git a/include/public/stream_inc/stream_control.h b/include/public/stream_inc/stream_control.h
index 1a8ce55..9087b98 100644
--- a/include/public/stream_inc/stream_control.h
+++ b/include/public/stream_inc/stream_control.h
@@ -46,7 +46,7 @@ enum MESA_stream_opt{
MSO_DROP_CURRENT_PKT, /* opt_val type must be int, value only be [0,1], notice the difference between MSO_DROP_CURRENT_PKT and MSO_DROP_STREAM, MSO_DROP_CURRENT_PKT only discard current packet, but MSO_DROP_STREAM discard all subsequent packets of stream */
MSO_HAVE_DUP_PKT, /* opt_val type must be int, value only be [0, 1, -2], if the current stream found duplicate packets ? 0:no; 1:yes; -2: not sure */
MSO_STREAM_LASTUPDATE_TIMESTAMP_MS,/* latest pkt arrive timestamp of this stream, opt_val type must be unsigned long long */
- MSO_STREAM_TIMER,
+ MSO_STREAM_TIMED,
__MSO_MAX,
};
diff --git a/module_test/src/gtest_sapp_comm.cpp b/module_test/src/gtest_sapp_comm.cpp
index 5dfafd4..8c5cb37 100644
--- a/module_test/src/gtest_sapp_comm.cpp
+++ b/module_test/src/gtest_sapp_comm.cpp
@@ -1237,6 +1237,7 @@ int check_tcp_pkt_equal(const struct mesa_tcp_hdr *raw_hdr, const struct mesa_tc
/* 此函数copy自sapp : deal_mpls.c->set_mpls_addr */
static int sapp_mpls_addr_net_to_mem(const struct mesa_mpls_hdr *net_mpls_hdr, struct single_layer_mpls_addr *mem_mpls_hdr)
{
+ assert(net_mpls_hdr!=NULL);
memset(mem_mpls_hdr, 0, sizeof(struct single_layer_mpls_addr));
mem_mpls_hdr->label = htonl( (net_mpls_hdr->mpls_label_low<<12) | (net_mpls_hdr->mpls_label_mid<<4) | net_mpls_hdr->mpls_label_high ); /* network order */
@@ -1298,13 +1299,16 @@ static int __sapp_guess_mpls_with_control_word(const unsigned char *maybe_eth_hd
/* 此函数copy自sapp */
int sapp_set_mpls_addr(struct layer_addr_mpls *addr, const unsigned char *raw_mpls_pkt_data)
{
- const struct mesa_mpls_hdr *this_mpls_hdr;
+ const struct mesa_mpls_hdr *this_mpls_hdr=NULL;
int i;
memset(addr, 0, sizeof(struct layer_addr_mpls));
for(i = 0; i < MAX_MPLS_ADDR_LAYER; i++)
{
this_mpls_hdr = (const struct mesa_mpls_hdr *)raw_mpls_pkt_data;
+ if (this_mpls_hdr)
+ {
+ assert(this_mpls_hdr->mpls_bls!=1);
//memcpy(&addr->src_mpls_pkt[i], raw_mpls_pkt_data, sizeof(struct mesa_mpls_hdr));
sapp_mpls_addr_net_to_mem(this_mpls_hdr, &addr->c2s_addr_array[i]); /* 函数栈里的地址, 每次暂存在c2s方向, TCP/UDP层再根据流方向翻�?*/
@@ -1314,11 +1318,7 @@ int sapp_set_mpls_addr(struct layer_addr_mpls *addr, const unsigned char *raw_mp
break;
}
raw_mpls_pkt_data += sizeof(struct mesa_mpls_hdr);
- }
-
- if(1 != this_mpls_hdr->mpls_bls) /* 超过MAX_MPLS_ADDR_LAYER, MPLS还没有结�?*/
- {
- return -1;
+ }
}
if(((*raw_mpls_pkt_data & 0xF0) != 0x40) && ((*raw_mpls_pkt_data & 0xF0) != 0x60)){ //VPLS, MPLS with Control Word
diff --git a/module_test/src/gtest_sapp_inject_plug.cpp b/module_test/src/gtest_sapp_inject_plug.cpp
index 041bd81..ca051c3 100644
--- a/module_test/src/gtest_sapp_inject_plug.cpp
+++ b/module_test/src/gtest_sapp_inject_plug.cpp
@@ -2003,7 +2003,7 @@ static int MESA_rst_tcp_test_case_c2s(struct streaminfo *pstream, void *a_packet
return -1;
}
- while((0 == g_recv_tun_rst_flag) && (g_recv_tun_rst_flag != 2)){
+ while(g_recv_tun_rst_flag != 2){
usleep(1000);
}
@@ -2097,7 +2097,7 @@ static int MESA_inject_udp_test_case_s2c(struct streaminfo *pstream, void *a_pac
return -1;
}
- while((0 == g_recv_tun_rst_flag) && (g_recv_tun_rst_flag != 2)){
+ while((g_recv_tun_rst_flag != 2)){
usleep(1000);
}
@@ -2219,7 +2219,7 @@ extern "C" char MESA_rst_tcp_plug_entry_in_double_dir(struct streaminfo *pstream
static int MESA_kill_tcp_test_check_pkt(struct streaminfo *pstream, struct inject_pkt_para *inject_paras, void *a_packet)
{
- while((0 == g_recv_tun_rst_flag) && (g_recv_tun_rst_flag != 2)){
+ while((g_recv_tun_rst_flag != 2)){
usleep(1000);
}
@@ -2326,7 +2326,7 @@ extern "C" int sapp_inject_tcp_payload_c2s(struct streaminfo *pstream,void **pme
return APP_STATE_DROPME;
}
- while((0 == g_recv_tun_rst_flag) && (g_recv_tun_rst_flag != 2)){
+ while((g_recv_tun_rst_flag != 2)){
usleep(1000);
}
@@ -2371,7 +2371,7 @@ extern "C" int sapp_inject_tcp_payload_s2c(struct streaminfo *pstream,void **pme
return APP_STATE_DROPME;
}
- while((0 == g_recv_tun_rst_flag) && (g_recv_tun_rst_flag != 2)){
+ while((g_recv_tun_rst_flag != 2)){
usleep(1000);
}
@@ -2422,7 +2422,7 @@ extern "C" int sapp_inject_udp_payload_c2s(struct streaminfo *pstream,void **pme
return APP_STATE_DROPME;
}
- while((0 == g_recv_tun_rst_flag) && (g_recv_tun_rst_flag != 2)){
+ while((g_recv_tun_rst_flag != 2)){
usleep(1000);
}
@@ -2466,7 +2466,7 @@ extern "C" int MESA_inject_tcp_payload_c2s(struct streaminfo *pstream,void **pme
return APP_STATE_DROPME;
}
- while((0 == g_recv_tun_rst_flag) && (g_recv_tun_rst_flag != 2)){
+ while((g_recv_tun_rst_flag != 2)){
usleep(1000);
}
@@ -2510,7 +2510,7 @@ extern "C" int MESA_inject_tcp_payload_s2c(struct streaminfo *pstream,void **pme
return APP_STATE_DROPME;
}
- while((0 == g_recv_tun_rst_flag) && (g_recv_tun_rst_flag != 2)){
+ while((g_recv_tun_rst_flag != 2)){
usleep(1000);
}
diff --git a/src/dealpkt/plug_support.c b/src/dealpkt/plug_support.c
index 6e11550..4fd81d7 100644
--- a/src/dealpkt/plug_support.c
+++ b/src/dealpkt/plug_support.c
@@ -787,7 +787,7 @@ int MESA_set_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o
}
}
break;
- case (int)MSO_STREAM_TIMER:
+ case (int)MSO_STREAM_TIMED:
{
if(sizeof(int) != opt_val_len){
sapp_runtime_log(RLOG_LV_INFO, "%s, MESA_set_stream_opt() MSO_TIMEOUT error:opt_val_len invalid, must be sizeof(short)\n",printaddr(&pstream->addr, pstream->threadnum));
@@ -803,9 +803,9 @@ int MESA_set_stream_opt(const struct streaminfo *pstream, enum MESA_stream_opt o
if(false == timeout_pending(&funinfo->timeout))
{
timeout_init(&funinfo->timeout, TIMEOUT_ABS);
+ G_MESA_GLOBAL_STREAM[pstream->threadnum]->user_define_timer_cnt+=1;
}
timeouts_add(G_MESA_GLOBAL_STREAM[pstream->threadnum]->user_define_timer, &funinfo->timeout, set_timer_s+g_CurrentTime);
- G_MESA_GLOBAL_STREAM[pstream->threadnum]->user_define_timer_cnt+=1;
ret = 0;
}
break;
diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c
index 7b6e35a..7eecd3a 100644
--- a/test/test_app_sapp.c
+++ b/test/test_app_sapp.c
@@ -504,7 +504,7 @@ char test_set_stream_timed(struct streaminfo *pstream, void **pme, int thread_s
if (pstream->pktstate == OP_STATE_PENDING)
{
tout_val = 1;
- ret = MESA_set_stream_opt(pstream, MSO_STREAM_TIMER, &tout_val, sizeof(int));
+ ret = MESA_set_stream_opt(pstream, MSO_STREAM_TIMED, &tout_val, sizeof(int));
if (ret < 0)
{
DPRINT("stream:%p, MESA_set_stream_opt error:\n", pstream);