-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TAP interface misses packets ,I found the reason。 #10
Comments
@Z-J-X it's for multiple-queue. no problem from my using experience. what's your use-case ?
|
@sequoiar I wrote a demo program,like this: #include <viface/viface.hpp>
#include <iostream>
#include <iomanip>
#include <unistd.h>
#include <algorithm>
using namespace std;
int main()
{
viface::VIface iface("viface%d");
// Configure interface
iface.setIPv4Netmask("255.255.255.0");
iface.setIPv4("192.168.100.11");
// Bring-up interface
iface.up();
std::set<string> stats_set = iface.listStats();
while (1)
{
auto data = iface.receive();
if (data.size() == 0)
{
sleep(1);
continue;
}
std::cout << "receive:" << std::dec << data.size() << std::endl;
for (int a : data)
{
std::cout << std::setiosflags(std::ios::uppercase) << std::hex << std::setw(2) << std::setfill('0') << a << " ";
}
std::cout << std::endl;
}
} The results may be different on different machines Tcpdump shows that the data has reached the Tun / tap device i use ping to test this program, I found that half of the data could not be received. Then I looked at the source code and found that Tun / tap would be opened twice, I think the data not received will be received by another FD. Therefore, I modified the source code to test, read the data of two FD, and everything is normal. you can see issue#6,They have the same problems as me |
Can confirm that applying this fix solves the issue with missing pings and many other IP packets. |
/Dev/net/Tun should not be opened twice. If it is opened twice, the data will be allocated to two FDS
![1640587162(1)](https://user-images.githubusercontent.com/49222032/147442437-326edd5b-c049-4ee1-8adf-7561f812f0c9.jpg)
Temporary solution:you can change like this:
The text was updated successfully, but these errors were encountered: