Bugzilla – Bug 2180
It is possible to register several times the same route
Last modified: 2015-11-16 13:12:35 EST
For instance here is a printed routing table with several times the same route: === Destination Gateway Genmask Flags Metric Ref Use Iface 9 127.0.0.0 0.0.0.0 255.0.0.0 U 0 - - 0 10 10.2.0.0 0.0.0.0 255.255.255.0 U 0 - - 1 11 10.2.0.0 0.0.0.0 255.255.255.0 U 0 - - 1 12 0.0.0.0 10.2.0.2 0.0.0.0 UGS 0 - - 1 13 10.2.0.0 10.2.0.2 255.255.255.0 UGS 0 - - 1 === Hence someone who removed a route may think the route was removed but may end up with a duplicate.
The behaviour is not limited to GlobalRouting. Also Ipv[4,6]StaticRouting has the same behaviour. basically all the Add[Host,Network]Route functions are assuming that the caller is doing the appropriate checks. The question is: what is the right behaviour ? Shall we change all the code and point in the docs that any successive call will overwrite the old route or shall we point out that it's the caller responsibility to not add duplicate routes ? As a side note, removing a route requires that you knows its index or the *exact* parameters of the route. In the second case, if two identical routes exist, the first will be removed.
I would like to propose that the behavior be for IPv4/v6 static routing, and global routing, that any attempt to add multiple routes lead to a NS_LOG_WARN() that the route already exists, and prevent adding duplicate entries. I can work on a patch.