Bugzilla – Bug 1528
BindToNetDevice not working for IPv6 sockets
Last modified: 2012-11-28 15:38:51 UTC
BindToNetDevice does nothing for IPv6 sockets (any kind of). This is particularly harmful, as IPv6 sockets are often used with multicast addresses. The proof is: grab a node with two interfaces. Open two sockets with the same address and bind them to the respective NetDevices. Now watch the node receive the packets on *both* sockets. The same packet too... This applies to all kind of sockets, UDP, TCP and RawIPv6. Patch incoming. T.
Created attachment 1464 [details] IPv6 Sockets should now obey to BindToNetDevice Half-drycoded patch. The IPv6RawSockets one has been tested and it works. The TCP and UDP Sockets should work as the new code mimics the Ipv4 approach (i.e., do it in the EndPoint demux).
Created attachment 1465 [details] New patch, removed not needed functions
Created attachment 1470 [details] Test program for Raw v6 sockets Without the patch: 21:40:32:~/Development/workspace/ns-3-dev pecos$ ./waf --run scratch/BindTestv6 Waf: Entering directory `/Users/pecos/Development/workspace/ns-3-dev/build' Waf: Leaving directory `/Users/pecos/Development/workspace/ns-3-dev/build' 'build' finished successfully (2.781s) Socket 0x7ff891c7a740 - Received a packet from 2001:0001:0000:0000:0200:00ff:fe00:0001, pointer 0x7ff891c75cb0, size 192, content ns3::Ipv6Header ((Version 6 Traffic class 0x0 Flow Label 0x0 Payload Length 136 Next Header 17 Hop Limit 64 )2001:0001:0000:0000:0200:00ff:fe00:0001 > ff01:0000:0000:0000:0000:0000:0000:0001) ns3::UdpHeader (length: 136 49153 > 9) Payload (size=128) Socket 0x7ff891c7a830 - Received a packet from 2001:0001:0000:0000:0200:00ff:fe00:0001, pointer 0x7ff891c75cb0, size 192, content ns3::Ipv6Header ((Version 6 Traffic class 0x0 Flow Label 0x0 Payload Length 136 Next Header 17 Hop Limit 64 )2001:0001:0000:0000:0200:00ff:fe00:0001 > ff01:0000:0000:0000:0000:0000:0000:0001) ns3::UdpHeader (length: 136 49153 > 9) Payload (size=128) Socket 0x7ff891c7a940 - Received a packet from 2001:0001:0000:0000:0200:00ff:fe00:0001, pointer 0x7ff891c75cb0, size 192, content ns3::Ipv6Header ((Version 6 Traffic class 0x0 Flow Label 0x0 Payload Length 136 Next Header 17 Hop Limit 64 )2001:0001:0000:0000:0200:00ff:fe00:0001 > ff01:0000:0000:0000:0000:0000:0000:0001) ns3::UdpHeader (length: 136 49153 > 9) Payload (size=128) Socket 0x7ff891c7a740 - Received a packet from 2001:0001:0000:0000:0200:00ff:fe00:0001, pointer 0x7ff891c7eff0, size 192, content ns3::Ipv6Header ((Version 6 Traffic class 0x0 Flow Label 0x0 Payload Length 136 Next Header 17 Hop Limit 64 )2001:0001:0000:0000:0200:00ff:fe00:0001 > ff01:0000:0000:0000:0000:0000:0000:0001) ns3::UdpHeader (length: 136 49153 > 9) Payload (size=128) Socket 0x7ff891c7a830 - Received a packet from 2001:0001:0000:0000:0200:00ff:fe00:0001, pointer 0x7ff891c7eff0, size 192, content ns3::Ipv6Header ((Version 6 Traffic class 0x0 Flow Label 0x0 Payload Length 136 Next Header 17 Hop Limit 64 )2001:0001:0000:0000:0200:00ff:fe00:0001 > ff01:0000:0000:0000:0000:0000:0000:0001) ns3::UdpHeader (length: 136 49153 > 9) Payload (size=128) Socket 0x7ff891c7a940 - Received a packet from 2001:0001:0000:0000:0200:00ff:fe00:0001, pointer 0x7ff891c7eff0, size 192, content ns3::Ipv6Header ((Version 6 Traffic class 0x0 Flow Label 0x0 Payload Length 136 Next Header 17 Hop Limit 64 )2001:0001:0000:0000:0200:00ff:fe00:0001 > ff01:0000:0000:0000:0000:0000:0000:0001) ns3::UdpHeader (length: 136 49153 > 9) Payload (size=128) 21:55:32:~/Development/workspace/ns-3-dev pecos$ 6 packets, bad. 21:56:07:~/Development/workspace/ns-3-dev pecos$ ./waf --run scratch/BindTestv6 Waf: Entering directory `/Users/pecos/Development/workspace/ns-3-dev/build' Waf: Leaving directory `/Users/pecos/Development/workspace/ns-3-dev/build' 'build' finished successfully (2.793s) Socket 0x7fb7d847a830 - Received a packet from 2001:0001:0000:0000:0200:00ff:fe00:0001, pointer 0x7fb7d8475cb0, size 192, content ns3::Ipv6Header ((Version 6 Traffic class 0x0 Flow Label 0x0 Payload Length 136 Next Header 17 Hop Limit 64 )2001:0001:0000:0000:0200:00ff:fe00:0001 > ff01:0000:0000:0000:0000:0000:0000:0001) ns3::UdpHeader (length: 136 49153 > 9) Payload (size=128) Socket 0x7fb7d847a830 - Received a packet from 2001:0001:0000:0000:0200:00ff:fe00:0001, pointer 0x7fb7d8475cb0, size 192, content ns3::Ipv6Header ((Version 6 Traffic class 0x0 Flow Label 0x0 Payload Length 136 Next Header 17 Hop Limit 64 )2001:0001:0000:0000:0200:00ff:fe00:0001 > ff01:0000:0000:0000:0000:0000:0000:0001) ns3::UdpHeader (length: 136 49153 > 9) Payload (size=128) 21:56:23:~/Development/workspace/ns-3-dev pecos$ 2 packets, better.
Since I'm the Ipv6 maintainer I could auto-approve the patch, however I'll wait for comments since this patch goes hand-in-hand with bug #1527 and I feel like they should be both applied at the same time. T.
(In reply to comment #4) > Since I'm the Ipv6 maintainer I could auto-approve the patch, however I'll > wait for comments since this patch goes hand-in-hand with bug #1527 and I > feel like they should be both applied at the same time. > > T. +1 to both
Fixed in changeset 9148 - 9c37ec6053bd