]> git.puffer.fish Git - mirror/frr.git/commit
ripd: fix race condition on input processing
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 11 Nov 2016 22:19:13 +0000 (20:19 -0200)
committerRenato Westphal <renato@opensourcerouting.org>
Fri, 25 Nov 2016 13:46:06 +0000 (11:46 -0200)
commitae735d2d0e13a6babd796ca171519b9db4feaf81
tree0a4e7d3c5e288d765c54696586a1d6eef3859575
parentb10ce841035275844cfe494d471865c8a1d4dda6
ripd: fix race condition on input processing

In the early days of ripd, we supported running RIP on secondary IP
addresses. To do that, everytime we needed to send a multicast packet,
we would create a new temporary socket for each of the interface's
addresses and call bind() to change the source IP of the outgoing packets.

The problem with these temporary sockets is that they are more specific
than the global RIP socket (bound to INADDR_ANY). Then, even though these
sockets only exist for a short amount of time, they can receive some RIP
packets that were supposed to be received on the global RIP socket. And
since we never read from the temporary sockets, these packets are dropped.

Since we don't support secondary addresses anymore, the simplest way to
fix this problem is to stop using temporary sockets for sending multicast
packets. We are already setting IP_MULTICAST_IF before sending each
multicast packet, and in this case the primary address of the selected
interface is used as the source IP of the outgoing packets, which is
exactly what we want.

If we decide to reintroduce support for secondary addresses in the future,
we should try one of the following:
* Use IP_SENDSRCADDR/IP_PKTINFO to set the source address of the outgoing
  multicast packets;
* Create one permanent UDP socket for each possible interface address,
  and enable reading on all sockets.

Fixes the following IxANVL RIP tests: 7.10 and 14.1.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
ripd/ripd.c