Bugzilla – Bug 1040
Olsr and multiple interfaces
Last modified: 2011-03-20 07:42:19 EDT
Created attachment 1021 [details] Patch to olsr module Olsr does not work with multiple interfaces which have both an IP address belonging to the same subnet. As in the real implementation the socket used to send UDP datagrams should be bind directly to a specific interface in order to skip the layer 3 routing lookup and have the hello messages broadcasted on all the interface and not only on the first one.
Created attachment 1048 [details] patch updated to ns-3-dev Sorry, I've only just seen this. Here's the patch updated to ns-3-dev. I ran the regression tests, and it does not seem to break anything.
For the record, a long time ago I ran OLSRD with two interfaces, albeit on different IP networks, and straced it to find out what socket calls it was making. The result is a little more complex, OLSRD uses two sockets per interface. But I think until we can figure out we really need the two sockets per interface, let's keep it simple. Here's my strace logs: Interface eth1: ============ [pid 5207] socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 7 [pid 5207] setsockopt(7, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0 [pid 5207] setsockopt(7, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 [pid 5207] setsockopt(7, SOL_SOCKET, SO_RCVBUF, [130048], 4) = 0 [pid 5207] setsockopt(7, SOL_SOCKET, SO_BINDTODEVICE, "eth1\0", 5) = 0 [pid 5207] bind(7, {sa_family=AF_INET, sin_port=htons(698), sin_addr=inet_addr("0.0.0.0")}, 16) = 0 [pid 5207] socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 8 [pid 5207] setsockopt(8, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0 [pid 5207] setsockopt(8, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 [pid 5207] setsockopt(8, SOL_SOCKET, SO_BINDTODEVICE, "eth1\0", 5) = 0 [pid 5207] bind(8, {sa_family=AF_INET, sin_port=htons(698), sin_addr=inet_addr("10.0.2.15")}, 16) = 0 [pid 5207] setsockopt(7, SOL_SOCKET, SO_PRIORITY, [0], 4) = 0 [pid 5207] setsockopt(7, SOL_IP, IP_TOS, [16], 4) = 0 Interface eth2: ============ [pid 5207] socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 9 [pid 5207] setsockopt(9, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0 [pid 5207] setsockopt(9, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 [pid 5207] setsockopt(9, SOL_SOCKET, SO_RCVBUF, [130048], 4) = 0 [pid 5207] setsockopt(9, SOL_SOCKET, SO_BINDTODEVICE, "eth2\0", 5) = 0 [pid 5207] bind(9, {sa_family=AF_INET, sin_port=htons(698), sin_addr=inet_addr("0.0.0.0")}, 16) = 0 [pid 5207] socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 10 [pid 5207] setsockopt(10, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0 [pid 5207] setsockopt(10, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 [pid 5207] setsockopt(10, SOL_SOCKET, SO_BINDTODEVICE, "eth2\0", 5) = 0 [pid 5207] bind(10, {sa_family=AF_INET, sin_port=htons(698), sin_addr=inet_addr("192.168.56.3")}, 16) = 0 [pid 5207] setsockopt(9, SOL_SOCKET, SO_PRIORITY, [0], 4) = 0 [pid 5207] setsockopt(9, SOL_IP, IP_TOS, [16], 4) = 0
Created attachment 1049 [details] simplified patch After reverting code style changes, the patch simplifies to this one. Basically just one line added: + socket->BindToNetDevice (m_ipv4->GetNetDevice (i)); Much easier to review, don't you think? ;-)
changeset: 6917:b19cd9a1d6f6 Sorry, I forgot to give you credit in the commit message, now it's too late. But anyway, it mentions the bug number, which has all the history.