Bug 1528 - BindToNetDevice not working for IPv6 sockets
BindToNetDevice not working for IPv6 sockets
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: ipv6
ns-3-dev
All All
: P3 normal
Assigned To: Tommaso Pecorella
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-11 10:19 UTC by Tommaso Pecorella
Modified: 2012-11-28 15:38 UTC (History)
2 users (show)

See Also:


Attachments
IPv6 Sockets should now obey to BindToNetDevice (5.95 KB, patch)
2012-11-11 10:48 UTC, Tommaso Pecorella
Details | Diff
New patch, removed not needed functions (4.24 KB, patch)
2012-11-11 17:09 UTC, Tommaso Pecorella
Details | Diff
Test program for Raw v6 sockets (7.50 KB, application/octet-stream)
2012-11-15 15:58 UTC, Tommaso Pecorella
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tommaso Pecorella 2012-11-11 10:19:45 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.
Comment 1 Tommaso Pecorella 2012-11-11 10:48:05 UTC
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).
Comment 2 Tommaso Pecorella 2012-11-11 17:09:42 UTC
Created attachment 1465 [details]
New patch, removed not needed functions
Comment 3 Tommaso Pecorella 2012-11-15 15:58:57 UTC
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.
Comment 4 Tommaso Pecorella 2012-11-15 16:02:17 UTC
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.
Comment 5 Tom Henderson 2012-11-28 00:19:02 UTC
(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
Comment 6 Tommaso Pecorella 2012-11-28 15:38:51 UTC
Fixed in changeset 9148 - 9c37ec6053bd