mirror of
https://github.com/wangyu-/udp2raw.git
synced 2025-01-19 14:29:34 +08:00
--fix-gro update
This commit is contained in:
parent
ee787e0d4a
commit
7e55b1e132
@ -500,7 +500,8 @@ int client_on_raw_recv(conn_info_t &conn_info) //called when raw fd received a p
|
||||
{
|
||||
vector<char> type_vec;
|
||||
vector<string> data_vec;
|
||||
if(recv_safer_multi(conn_info,type_vec,data_vec)!=0)
|
||||
recv_safer_multi(conn_info,type_vec,data_vec);
|
||||
if(data_vec.empty())
|
||||
{
|
||||
mylog(log_debug,"recv_safer failed!\n");
|
||||
return -1;
|
||||
|
@ -497,8 +497,8 @@ int send_safer(conn_info_t &conn_info,char type,const char* data,int len) //saf
|
||||
return -1;
|
||||
}
|
||||
write_u16(send_data_buf2,new_len);
|
||||
send_data_buf2[0]^=gro_xor[0];
|
||||
send_data_buf2[1]^=gro_xor[1];
|
||||
//send_data_buf2[0]^=gro_xor[0];
|
||||
//send_data_buf2[1]^=gro_xor[1];
|
||||
new_len+=2;
|
||||
}
|
||||
|
||||
@ -649,15 +649,17 @@ int recv_safer_multi(conn_info_t &conn_info,vector<char> &type_arr,vector<string
|
||||
data_arr.emplace_back(data,data+len);
|
||||
//std::copy(data,data+len,data_arr[0]);
|
||||
}
|
||||
return ret;
|
||||
return 0;
|
||||
} else
|
||||
{
|
||||
char *ori_recv_data=recv_data;
|
||||
mylog(log_debug,"recv_len:%d\n",recv_len);
|
||||
while(recv_len>2)
|
||||
{
|
||||
recv_len-=2;
|
||||
int single_len;
|
||||
recv_data[0]^=gro_xor[0];
|
||||
recv_data[1]^=gro_xor[1];
|
||||
//recv_data[0]^=gro_xor[0];
|
||||
//recv_data[1]^=gro_xor[1];
|
||||
single_len=read_u16(recv_data);
|
||||
recv_data+=2;
|
||||
if(single_len > recv_len)
|
||||
@ -674,7 +676,7 @@ int recv_safer_multi(conn_info_t &conn_info,vector<char> &type_arr,vector<string
|
||||
|
||||
if(ret!=0)
|
||||
{
|
||||
mylog(log_debug,"illegal single_len %d, recv_len %d left,dropped\n",single_len,recv_len);
|
||||
mylog(log_debug,"parse failed, offset= %d,single_len=%d\n",ori_recv_data-recv_data,single_len);
|
||||
} else{
|
||||
type_arr.push_back(type);
|
||||
data_arr.emplace_back(data,data+len);
|
||||
|
3
misc.cpp
3
misc.cpp
@ -741,7 +741,8 @@ void process_arg(int argc, char *argv[]) //process all options
|
||||
}
|
||||
else if(strcmp(long_options[option_index].name,"fix-gro")==0)
|
||||
{
|
||||
g_fix_gro=0;
|
||||
mylog(log_info,"--fix-gro enabled\n");
|
||||
g_fix_gro=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "log.h"
|
||||
#include "misc.h"
|
||||
|
||||
int g_fix_gro=1;
|
||||
int g_fix_gro=0;
|
||||
|
||||
int raw_recv_fd=-1;
|
||||
int raw_send_fd=-1;
|
||||
@ -855,9 +855,9 @@ int pre_recv_raw_packet()
|
||||
}
|
||||
else
|
||||
{
|
||||
mylog(log_debug, "huge packet, data_len %d > %d(single_max_data_len) dropped\n", g_packet_buf_len,
|
||||
mylog(log_debug, "huge packet, data_len %d > %d(single_max_data_len) not dropped\n", g_packet_buf_len,
|
||||
single_max_data_len);
|
||||
return -1;
|
||||
//return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -595,7 +595,8 @@ int server_on_raw_recv_multi() //called when server received an raw packet
|
||||
{
|
||||
vector<char> type_vec;
|
||||
vector<string> data_vec;
|
||||
if(recv_safer_multi(conn_info,type_vec,data_vec)!=0)
|
||||
recv_safer_multi(conn_info,type_vec,data_vec);
|
||||
if(data_vec.empty())
|
||||
{
|
||||
mylog(log_debug,"recv_safer failed!\n");
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user