Created attachment 27461 [details] Configuration and simple test for the issue I observe some strange behavior when sending multicast datagrams via gateway. It appears that destination MAC in UDP packets differs when using connected and connectionless socket. In case of connectionless socket destination MAC field of UDP header is filled with MAC address of gateway, but in case we use connect() with multicast address, destination MAC is set to multicast MAC. I don't know, which behavior is right, but different behavior is unexpected. I run the attached test on thorin1 machine and use thorin2 as a gateway. thorin1 is running 2.6.26-2-686 kernel, thorin2 is 2.6.26-2-amd64. I also attach ifconfig and route output for this machines and tcpdump output on thorin2 when running test. There we can see the following: 16:02:30.567909 00:27:0e:09:01:2a > 00:27:0e:09:02:2a, ethertype IPv4 (0x0800), length 58: 10.54.10.1.40074 > 237.92.130.210.51721: UDP, length 16 16:02:30.567984 00:27:0e:09:01:2a > 01:00:5e:5c:82:d2, ethertype IPv4 (0x0800), length 74: 10.54.10.1.43360 > 237.92.130.210.51721: UDP, length 32
bind() to local address also changes the MAC of the outgoing multicast packet. I.e. if the socket is bound to local address or connected to this multicast address, then the outgoing packet has multicast dst MAC. When bound to INADDR_ANY and non-connected, sendto() sends a packet with dst MAC of gateway.
It also appears to depend on route destination prefix, specifically on whether it is greater than or equal to 4 or not, i.e. whether all destination addresses of the route are multicast. Thereby gateway mac is only used if the socket is not connected, not bound, and route destination address prefix is 4 or greater.
MAC is determined by routing. Connected socket is bound to one interface. Non-connected socket uses default multicast interface. Closing since changing will likely break existing applications.