From 4ad6ed1716dc917a0b80ddfbbefc43c734eeaab6 Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Wed, 2 Sep 2015 20:30:33 +0300 Subject: - fix valgrind gtest simulation errors - remove 32bit sim images for faster dev --- src/bp_gtest.cpp | 37 +++++++++++++++++++++++++++++++------ src/bp_sim.cpp | 1 + src/bp_sim.h | 1 + src/rx_check.cpp | 14 +++++++++----- src/rx_check_header.h | 3 +++ src/timer_wheel_pq.cpp | 7 +++++-- 6 files changed, 50 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/bp_gtest.cpp b/src/bp_gtest.cpp index 020276cf..78efbecb 100755 --- a/src/bp_gtest.cpp +++ b/src/bp_gtest.cpp @@ -1426,6 +1426,8 @@ TEST_F(rx_check, rx_check_normal) { for (i=0; i<10; i++) { CRx_check_header rxh; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1454,6 +1456,8 @@ TEST_F(rx_check, rx_check_drop) { for (i=0; i<10; i++) { CRx_check_header rxh; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1490,8 +1494,10 @@ TEST_F(rx_check, rx_check_ooo) { for (i=0; i<10; i++) { CRx_check_header rxh; - rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; - rxh.m_option_len=RX_CHECK_V4_OPT_LEN; + rxh.clean(); + + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; + rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; rxh.m_magic=RX_CHECK_MAGIC; rxh.m_aging_sec=10; @@ -1531,8 +1537,9 @@ TEST_F(rx_check, rx_check_ooo_1) { for (i=0; i<10; i++) { CRx_check_header rxh; - rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; - rxh.m_option_len=RX_CHECK_V4_OPT_LEN; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; + rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; rxh.set_dir(0); rxh.set_both_dir(0); @@ -1568,8 +1575,9 @@ TEST_F(rx_check, rx_check_ooo_2) { for (i=0; i<10; i++) { CRx_check_header rxh; - rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; - rxh.m_option_len=RX_CHECK_V4_OPT_LEN; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; + rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; rxh.m_magic=RX_CHECK_MAGIC; rxh.m_aging_sec=10; @@ -1606,6 +1614,7 @@ TEST_F(rx_check, rx_check_normal_two_dir) { for (i=0; i<10; i++) { CRx_check_header rxh; + rxh.clean(); rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1635,6 +1644,7 @@ TEST_F(rx_check, rx_check_normal_two_dir_fails) { for (i=0; i<10; i++) { CRx_check_header rxh; + rxh.clean(); rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1661,6 +1671,8 @@ TEST_F(rx_check, rx_check_normal_two_dir_ok) { int i; CRx_check_header rxh; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1695,6 +1707,8 @@ TEST_F(rx_check, rx_check_normal_one_pkt_one_dir) { int i; CRx_check_header rxh; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1721,6 +1735,8 @@ TEST_F(rx_check, rx_check_normal_one_pkt_one_dir_0) { int i; CRx_check_header rxh; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1746,6 +1762,8 @@ TEST_F(rx_check, rx_check_normal_one_pkt_two_dir_0) { int i; CRx_check_header rxh; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1778,6 +1796,8 @@ TEST_F(rx_check, rx_check_normal_one_pkt_two_dir_err1) { int i; CRx_check_header rxh; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1821,6 +1841,8 @@ TEST_F(rx_check, rx_check_normal_two_dir_oo) { int i; CRx_check_header rxh; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_time_stamp=0; @@ -1865,6 +1887,8 @@ TEST_F(rx_check, rx_check_normal_aging) { int i; CRx_check_header rxh; + rxh.clean(); + rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_magic=RX_CHECK_MAGIC; @@ -1899,6 +1923,7 @@ TEST_F(rx_check, rx_check_normal_no_aging) { int i; CRx_check_header rxh; + rxh.clean(); rxh.m_option_type=RX_CHECK_V4_OPT_TYPE; rxh.m_option_len=RX_CHECK_V4_OPT_LEN; rxh.m_magic=RX_CHECK_MAGIC; diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp index b0d493e1..1cf70bba 100755 --- a/src/bp_sim.cpp +++ b/src/bp_sim.cpp @@ -4553,6 +4553,7 @@ void CCPortLatency::reset(){ m_tx_pkt_err=0; m_tx_pkt_ok =0; m_pkt_ok=0; + m_rx_check=0; m_no_magic=0; m_unsup_prot=0; m_no_id=0; diff --git a/src/bp_sim.h b/src/bp_sim.h index 002c9d0a..7d659d1c 100755 --- a/src/bp_sim.h +++ b/src/bp_sim.h @@ -1249,6 +1249,7 @@ struct CFlowYamlInfo { CFlowYamlInfo(){ m_dpPkt=0; m_server_addr=0; + m_cap_mode=false; } std::string m_name; diff --git a/src/rx_check.cpp b/src/rx_check.cpp index 67ce89e1..3a67ca23 100755 --- a/src/rx_check.cpp +++ b/src/rx_check.cpp @@ -243,6 +243,11 @@ bool RxCheckManager::Create(){ m_hist.Create(); m_cur_time=0.00000001; m_on_drain=false; + + int i; + for (i=0; im_flow_id); m_stats.m_lookup++; - if ((m_stats.m_lookup & 0xff)==0) { - /* handle aging from time to time */ - - tw_handle() ; - } bool any_err=false; if ( rxh->is_fif_dir() ) { @@ -393,6 +393,10 @@ void RxCheckManager::handle_packet(CRx_check_header * rxh){ on_flow_end(lf); } + if ((m_stats.m_lookup & 0xff)==0) { + /* handle aging from time to time */ + tw_handle() ; + } } void RxCheckManager::update_template_err(uint8_t template_id){ diff --git a/src/rx_check_header.h b/src/rx_check_header.h index 3ac5dd1f..54af2451 100755 --- a/src/rx_check_header.h +++ b/src/rx_check_header.h @@ -85,6 +85,9 @@ public: int get_dir(void){ return (btGetMaskBit8(m_flags,0,0) ? 1:0); } + void clean(){ + memset(this,0,sizeof(CRx_check_header)); + } /* need to mark if we expect to see both sides of the flow, this is know offline */ void set_both_dir(int both){ diff --git a/src/timer_wheel_pq.cpp b/src/timer_wheel_pq.cpp index 172d061e..bb480abd 100755 --- a/src/timer_wheel_pq.cpp +++ b/src/timer_wheel_pq.cpp @@ -169,11 +169,14 @@ bool CTimerWheel::handle(){ assert(timer->m_flow); CFlowTimerHandle * flow =timer->m_flow; m_st_handle++; + + timer->m_flow=0;/* stop the timer */ + flow->m_timer=0; + if ( flow->m_callback ){ flow->m_callback(flow); } - timer->m_flow=0;/* stop the timer */ - flow->m_timer=0; + m_pq.pop(); m_st_free++; delete timer; -- cgit 1.2.3-korg From 463cb7c212e927a732fb5b702a288a06550c5eb8 Mon Sep 17 00:00:00 2001 From: Hanoh Haim Date: Wed, 2 Sep 2015 22:43:23 +0300 Subject: error in case of invalid pcap file --- src/bp_sim.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/bp_sim.cpp b/src/bp_sim.cpp index 1cf70bba..555696f1 100755 --- a/src/bp_sim.cpp +++ b/src/bp_sim.cpp @@ -1294,7 +1294,9 @@ bool CPacketIndication::ConvertPacketToIpv6InPlace(CCapPktRaw * pkt, void CPacketIndication::ProcessPacket(CPacketParser *parser, CCapPktRaw * pkt){ _ProcessPacket(parser,pkt); - UpdateOffsets(); /* update fast offsets */ + if ( m_desc.IsValidPkt() ){ + UpdateOffsets(); /* update fast offsets */ + } } @@ -2119,7 +2121,13 @@ int CCapFileFlowInfo::load_cap_file(std::string cap_file,uint16_t _id,uint8_t pl } } + }else{ + printf("ERROR packet %d is not supported, should be IP(0x0800)/TCP/UDP format try to convert it using Wireshark !\n",cnt); + exit(-1); } + }else{ + printf("ERROR packet %d is not supported, should be IP(0x0800)/TCP/UDP format try to convert it using Wireshark !\n",cnt); + exit(-1); } } -- cgit 1.2.3-korg