mirror of
https://github.com/wangyu-/UDPspeeder.git
synced 2025-01-18 22:09:35 +08:00
add warning when packet is truncated
This commit is contained in:
parent
6dcc97155b
commit
af607e4bfa
@ -44,12 +44,18 @@ void data_from_local_or_fec_timeout(conn_info_t & conn_info,int is_time_out)
|
|||||||
mylog(log_trace,"events[idx].data.u64 == (u64_t)local_listen_fd\n");
|
mylog(log_trace,"events[idx].data.u64 == (u64_t)local_listen_fd\n");
|
||||||
address_t::storage_t udp_new_addr_in={0};
|
address_t::storage_t udp_new_addr_in={0};
|
||||||
socklen_t udp_new_addr_len = sizeof(address_t::storage_t);
|
socklen_t udp_new_addr_len = sizeof(address_t::storage_t);
|
||||||
if ((data_len = recvfrom(local_listen_fd, data, max_data_len, 0,
|
if ((data_len = recvfrom(local_listen_fd, data, max_data_len+1, 0,
|
||||||
(struct sockaddr *) &udp_new_addr_in, &udp_new_addr_len)) == -1) {
|
(struct sockaddr *) &udp_new_addr_in, &udp_new_addr_len)) == -1) {
|
||||||
mylog(log_debug,"recv_from error,this shouldnt happen,err=%s,but we can try to continue\n",get_sock_error());
|
mylog(log_debug,"recv_from error,this shouldnt happen,err=%s,but we can try to continue\n",get_sock_error());
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(data_len==max_data_len+1)
|
||||||
|
{
|
||||||
|
mylog(log_warn,"huge packet, data_len > %d, packet truncated, dropped\n",max_data_len);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
if(!disable_mtu_warn&&data_len>=mtu_warn)
|
if(!disable_mtu_warn&&data_len>=mtu_warn)
|
||||||
{
|
{
|
||||||
mylog(log_warn,"huge packet,data len=%d (>=%d).strongly suggested to set a smaller mtu at upper level,to get rid of this warn\n ",data_len,mtu_warn);
|
mylog(log_warn,"huge packet,data len=%d (>=%d).strongly suggested to set a smaller mtu at upper level,to get rid of this warn\n ",data_len,mtu_warn);
|
||||||
@ -122,7 +128,15 @@ static void remote_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
|
|||||||
|
|
||||||
int fd=fd_manager.to_fd(remote_fd64);
|
int fd=fd_manager.to_fd(remote_fd64);
|
||||||
|
|
||||||
int data_len =recv(fd,data,max_data_len,0);
|
int data_len =recv(fd,data,max_data_len+1,0);
|
||||||
|
|
||||||
|
if(data_len==max_data_len+1)
|
||||||
|
{
|
||||||
|
mylog(log_warn,"huge packet, data_len > %d, packet truncated, dropped\n",max_data_len);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mylog(log_trace, "received data from udp fd %d, len=%d\n", remote_fd,data_len);
|
mylog(log_trace, "received data from udp fd %d, len=%d\n", remote_fd,data_len);
|
||||||
if(data_len<0)
|
if(data_len<0)
|
||||||
{
|
{
|
||||||
|
@ -89,7 +89,13 @@ void data_from_remote_or_fec_timeout_or_conn_timer(conn_info_t & conn_info,fd64_
|
|||||||
conn_info.update_active_time();
|
conn_info.update_active_time();
|
||||||
|
|
||||||
int fd=fd_manager.to_fd(fd64);
|
int fd=fd_manager.to_fd(fd64);
|
||||||
data_len=recv(fd,data,max_data_len,0);
|
data_len=recv(fd,data,max_data_len+1,0);
|
||||||
|
|
||||||
|
if(data_len==max_data_len+1)
|
||||||
|
{
|
||||||
|
mylog(log_warn,"huge packet, data_len > %d, packet truncated, dropped\n",max_data_len);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
mylog(log_trace,"received a packet from udp_fd,len:%d,conv=%d\n",data_len,conv);
|
mylog(log_trace,"received a packet from udp_fd,len:%d,conv=%d\n",data_len,conv);
|
||||||
|
|
||||||
@ -135,12 +141,18 @@ static void local_listen_cb(struct ev_loop *loop, struct ev_io *watcher, int rev
|
|||||||
int data_len;
|
int data_len;
|
||||||
address_t::storage_t udp_new_addr_in={0};
|
address_t::storage_t udp_new_addr_in={0};
|
||||||
socklen_t udp_new_addr_len = sizeof(address_t::storage_t);
|
socklen_t udp_new_addr_len = sizeof(address_t::storage_t);
|
||||||
if ((data_len = recvfrom(local_listen_fd, data, max_data_len, 0,
|
if ((data_len = recvfrom(local_listen_fd, data, max_data_len+1, 0,
|
||||||
(struct sockaddr *) &udp_new_addr_in, &udp_new_addr_len)) == -1) {
|
(struct sockaddr *) &udp_new_addr_in, &udp_new_addr_len)) == -1) {
|
||||||
mylog(log_error,"recv_from error,this shouldnt happen,err=%s,but we can try to continue\n",get_sock_error());
|
mylog(log_error,"recv_from error,this shouldnt happen,err=%s,but we can try to continue\n",get_sock_error());
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(data_len==max_data_len+1)
|
||||||
|
{
|
||||||
|
mylog(log_warn,"huge packet, data_len > %d, packet truncated, dropped\n",max_data_len);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
address_t addr;
|
address_t addr;
|
||||||
addr.from_sockaddr((struct sockaddr *) &udp_new_addr_in,udp_new_addr_len);
|
addr.from_sockaddr((struct sockaddr *) &udp_new_addr_in,udp_new_addr_len);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user