From 6c1446036bc64fda3d0234a3f581a1ebc51c2830 Mon Sep 17 00:00:00 2001 From: wangyu Date: Wed, 15 Jul 2020 04:35:09 -0400 Subject: [PATCH] huge_buf_len and huge_data_len fix for mp --- client.cpp | 5 +++++ common.h | 4 ++-- network.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/client.cpp b/client.cpp index e0c6c40..29129ed 100644 --- a/client.cpp +++ b/client.cpp @@ -713,6 +713,11 @@ void async_cb(struct ev_loop *loop, struct ev_async *watcher, int revents) pthread_mutex_unlock(&queue_mutex); if(empty) break; + if(g_fix_gro==0&&len>max_data_len) + { + mylog(log_warn,"huge packet %d > %d, dropped\n",len,max_data_len); + break; + } int new_len=len-pcap_link_header_len; memcpy(g_packet_buf,p+pcap_link_header_len,new_len); diff --git a/common.h b/common.h index 37475bd..8484e6d 100644 --- a/common.h +++ b/common.h @@ -343,11 +343,11 @@ const int buf_len=max_data_len+400; //const int max_address_len=512; -const int queue_len=2000; +const int queue_len=200; struct queue_t { - char data[queue_len][buf_len]; + char data[queue_len][huge_buf_len]; int data_len[queue_len]; int head=0; diff --git a/network.cpp b/network.cpp index daa07a8..ebaec76 100644 --- a/network.cpp +++ b/network.cpp @@ -539,7 +539,7 @@ int init_raw_socket() myexit(-1); } - assert( pcap_set_snaplen(pcap_handle, max_data_len) ==0); + assert( pcap_set_snaplen(pcap_handle, huge_data_len) ==0); assert( pcap_set_promisc(pcap_handle, 0) ==0); assert( pcap_set_timeout(pcap_handle, 1) ==0); assert( pcap_set_immediate_mode(pcap_handle,1) ==0);