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.