Bug 16601 - Multicast MAC when sending via gateway
Summary: Multicast MAC when sending via gateway
Status: RESOLVED WILL_NOT_FIX
Alias: None
Product: Networking
Classification: Unclassified
Component: IPV4 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Stephen Hemminger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-16 08:06 UTC by Nikita Rastegaev
Modified: 2012-10-30 16:05 UTC (History)
2 users (show)

See Also:
Kernel Version: 2.6.26
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Configuration and simple test for the issue (3.35 KB, application/zip)
2010-08-16 08:06 UTC, Nikita Rastegaev
Details

Description Nikita Rastegaev 2010-08-16 08:06:16 UTC
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
Comment 1 Alexandra Kossovsky 2010-09-13 06:35:28 UTC
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.
Comment 2 Nikita Rastegaev 2011-07-12 13:15:37 UTC
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.
Comment 3 Stephen Hemminger 2012-10-30 16:05:37 UTC
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.

Note You need to log in before you can comment on or make changes to this bug.