diff --git a/common.h b/common.h index 1ddade8..7379098 100644 --- a/common.h +++ b/common.h @@ -347,12 +347,12 @@ struct not_copy_able_t } }; -const int single_max_data_len=1800; -const int max_data_len=single_max_data_len*10; -const int buf_len=max_data_len+800; +const int huge_data_len=65535+100; //a packet with link level header might be larger than 65535 +const int huge_buf_len=huge_data_len+100; + +const int max_data_len=1800; +const int buf_len=max_data_len+400; -//const int max_data_len_gro=max_data_len*10; -//const int buf_len_gro=max_data_len_gro+400; //const int max_address_len=512; u64_t get_current_time(); diff --git a/connection.cpp b/connection.cpp index f1a016e..3d4fb52 100644 --- a/connection.cpp +++ b/connection.cpp @@ -686,9 +686,10 @@ int recv_safer_multi(conn_info_t &conn_info,vector &type_arr,vector single_max_data_len ) + if(single_len> max_data_len ) { - mylog(log_warn,"single_len %d(%d) > %d, maybe you need to turn down mtu at upper level\n",single_len,single_len_no_xor,single_max_data_len); + mylog(log_warn,"single_len %d(%d) > %d, maybe you need to turn down mtu at upper level\n",single_len,single_len_no_xor,max_data_len); + break; } int ret = reserved_parse_safer(conn_info, recv_data, single_len, type, data, len); diff --git a/network.cpp b/network.cpp index f9a091c..8ca1112 100644 --- a/network.cpp +++ b/network.cpp @@ -43,7 +43,7 @@ const u32_t receive_window_lower_bound=40960; const u32_t receive_window_random_range=512; const unsigned char wscale=0x05; -char g_packet_buf[buf_len]; //looks dirty but works well +char g_packet_buf[huge_buf_len]; //looks dirty but works well int g_packet_buf_len=-1; int g_packet_buf_cnt=0; @@ -834,37 +834,37 @@ int pre_recv_raw_packet() assert(g_packet_buf_cnt==0); g_sockaddr_len=sizeof(g_sockaddr.ll); - g_packet_buf_len = recvfrom(raw_recv_fd, g_packet_buf, max_data_len+1, 0 ,(sockaddr*)&g_sockaddr , &g_sockaddr_len); + g_packet_buf_len = recvfrom(raw_recv_fd, g_packet_buf, huge_data_len+1, 0 ,(sockaddr*)&g_sockaddr , &g_sockaddr_len); //assert(g_sockaddr_len==sizeof(g_sockaddr.ll)); //g_sockaddr_len=18, sizeof(g_sockaddr.ll)=20, why its not equal? maybe its bc sll_halen is 6? //assert(g_addr_ll_size==sizeof(g_addr_ll)); - if(g_packet_buf_len==max_data_len+1) + if(g_packet_buf_len==huge_data_len+1) { if(g_fix_gro==0) { - mylog(log_warn,"huge packet, data_len %d > %d(max_data_len),dropped\n",g_packet_buf_len,max_data_len); + mylog(log_warn,"huge packet, data_len %d > %d,dropped\n",g_packet_buf_len,huge_data_len); return -1; } else { - mylog(log_debug,"huge packet, data_len %d > %d(max_data_len),not dropped\n",g_packet_buf_len,max_data_len); - g_packet_buf_len=max_data_len; + mylog(log_debug,"huge packet, data_len %d > %d,not dropped\n",g_packet_buf_len,huge_data_len); + g_packet_buf_len=huge_data_len; } } - if(g_packet_buf_len> single_max_data_len+1) + if(g_packet_buf_len> max_data_len+1) { if(g_fix_gro==0) { - mylog(log_warn, "huge packet, data_len %d > %d(single_max_data_len) dropped, maybe you need to turn down mtu at upper level, or you may take a look at --fix-gro\n", g_packet_buf_len, - single_max_data_len); + mylog(log_warn, "huge packet, data_len %d > %d(max_data_len) dropped, maybe you need to turn down mtu at upper level, or you may take a look at --fix-gro\n", g_packet_buf_len, + max_data_len); return -1; } else { - mylog(log_debug, "huge packet, data_len %d > %d(single_max_data_len) not dropped\n", g_packet_buf_len, - single_max_data_len); + mylog(log_debug, "huge packet, data_len %d > %d(max_data_len) not dropped\n", g_packet_buf_len, + max_data_len); //return -1; } diff --git a/network.h b/network.h index f2ea947..463bf67 100644 --- a/network.h +++ b/network.h @@ -27,7 +27,7 @@ extern int random_drop; extern int ifindex; -extern char g_packet_buf[buf_len]; +extern char g_packet_buf[huge_buf_len]; extern int g_packet_buf_len; extern int g_packet_buf_cnt;