Reputation: 41
I've created a packet socket
m_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
and attached a TX ring buffer. I fill out ethernet, ip and udp headers correctly and things work out great until the source and destination MACs happen to be equal. Then netcat (or any other utility/udp receivers) fails to receive the packet I sent. The packet is being sent according to tcpdump though.
I read somewhere that any network device would simply just ignore packets like this, but I still see this behavior on the loopback interface (why doesn't it loop back in this case?).
I only control the sender and due to performance reasons this is the way to go. However, one of the recipients may be located on the same computer and in this case either lo or eth0 will be used (depends on configuration).
How can I force the interface to not ignore these packets?
EDIT: Using a raw packet socket socket for receiving shows that I do get both outgoing (PACKET_OUTGOING) and incomming (PACKET_HOST). However, using a more 'regular' UDP socket for receiving does not catch anything at all.
Upvotes: 3
Views: 606
Reputation: 41
This seems to be to some odd behavior with raw sockets. See this related ticket on stackoverflow.
Upvotes: 1