0

In the following code:

while (true)
{
    readfds = orig;
    activity = select(nfds, &readfds, NULL, NULL, NULL);
    if (activity == -1)  // sockets closed
        break;
    CHECK(activity > 0, "");
    for (int i = 0; i < numSocks; i++)  // numSocks is equal to 2
        if (FD_ISSET(_sock[i], &readfds))
        {
            int len = recv(_sock[i], buf, sizeof(buf), MSG_TRUNC);
            CHECK(len > 0, "");
            CHECK(len <= sizeof(buf), "small size buffer");
            printf("%10d %d %d\n", ++packetNumber, i, len);
            CHECK(send(_sock[!i], buf, len, 0) != -1, "%s", strerror(errno));
        }
}

I'm going to forward everything I get from one NIC to another for both interfaces. I recv I've no problem with large (eg. 2700 bytes long) packets, but I get Message too long error in send for the same packets. sizeof(buf) is large enough (64k). Both sockets are of type RAW. OS is Ubuntu 20.04.

What's the problem and how can I solve it?

Update

The following command:

sudo ethtool -K enp0s3 rx off tx off sg off tso off ufo off gso off gro off lro off rxvlan off txvlan off ntuple off rxhash off

resulted in the following output:

Cannot change udp-fragmentation-offload
Cannot change large-receive-offload
Cannot change tx-vlan-offload
Cannot change ntuple-filters
Cannot change receive-hashing
Actual changes:
tx-checksumming: off
    tx-checksum-ip-generic: off
scatter-gather: off
    tx-scatter-gather: off
rx-vlan-offload: off
tx-vlan-offload: off [fixed]

but solved the problem. :)

Now I'm going to find what options exactly should get turned off.

hamidi
  • 1,611
  • 1
  • 15
  • 28
  • Thanks for your suggestion. I'm reading it and will inform the result. – hamidi Mar 13 '21 at 14:25
  • Yeah, it could solve the problem. Although I got the result I mentioned in the update to my question. Thx – hamidi Mar 13 '21 at 14:45
  • Are these changes permanent? In another words, do I need to turn them off every time system reboots? – hamidi Mar 13 '21 at 14:50
  • I found that the configuration is reset by reboot. I also found that turning only `gro` off is sufficient. It was by trial and effort. Maybe I've not to count on it and turn other settings off too? – hamidi Mar 13 '21 at 16:15

0 Answers0