Skip to content
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

Closed
Z-J-X opened this issue Dec 27, 2021 · 3 comments
Closed

TAP interface misses packets ,I found the reason。 #10

Z-J-X opened this issue Dec 27, 2021 · 3 comments

Comments

@Z-J-X
Copy link

Z-J-X commented Dec 27, 2021

/Dev/net/Tun should not be opened twice. If it is opened twice, the data will be allocated to two FDS
Temporary solution:you can change like this:
1640587162(1)

@sequoiar
Copy link

@Z-J-X it's for multiple-queue. no problem from my using experience. what's your use-case ?

ifr.ifr_flags = IFF_NO_PI | IFF_MULTI_QUEUE;

@Z-J-X
Copy link
Author

Z-J-X commented Dec 31, 2021

@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
ping 192.168.100.1 receive
ping 192.168.100.2 not receive
ping 192.168.100.3 receive

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.
ps: After modifying the source code, I only carried out the reading test.

you can see issue#6,They have the same problems as me

@Matheus-Garbelini
Copy link

Can confirm that applying this fix solves the issue with missing pings and many other IP packets.

@Z-J-X Z-J-X closed this as completed Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants