mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 06:19:31 +08:00
introduce huge_buf_len and huge_data_len
This commit is contained in:
parent
b3e06de4cb
commit
79bb28fd12
10
common.h
10
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();
|
||||
|
@ -686,9 +686,10 @@ int recv_safer_multi(conn_info_t &conn_info,vector<char> &type_arr,vector<string
|
||||
mylog(log_debug,"illegal single_len %d(%d), recv_len %d left,dropped\n",single_len,single_len_no_xor,recv_len);
|
||||
break;
|
||||
}
|
||||
if(single_len> 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);
|
||||
|
22
network.cpp
22
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user