Bug 2180 - It is possible to register several times the same route
It is possible to register several times the same route
Status: ASSIGNED
Product: ns-3
Classification: Unclassified
Component: internet
ns-3-dev
All All
: P5 minor
Assigned To: Tom Henderson
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-15 08:07 EDT by Matthieu Coudron
Modified: 2015-11-16 13:12 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthieu Coudron 2015-09-15 08:07:44 EDT
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.
Comment 1 Tommaso Pecorella 2015-09-19 11:01:07 EDT
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.
Comment 2 Tom Henderson 2015-11-16 13:12:35 EST
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.