pespin submitted this change.
Fix combined linkset lookup when inserting route
The early loop termiantion logic was wrong, which meant
ss7_route_table_find_combined_linkset() may return earlier than expected
and hence a new combined linkset may have been created when adding a
route instead of adding it to a previous existing matching one.
The fix can be spotted by the fact that now "show cs7 instance 0 route"
shows the 3 3.2.0/11 prio=1 routes properly in the same combined linkset
in osmo_stp_route_prio.vty.
Change-Id: I44d7545a3c6a3ea4839e983104112f8afa6b981a
---
M src/ss7_route_table.c
M tests/vty/osmo_stp_route_prio.vty
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/ss7_route_table.c b/src/ss7_route_table.c
index fb10df4..c816e36 100644
--- a/src/ss7_route_table.c
+++ b/src/ss7_route_table.c
@@ -184,12 +184,13 @@
/* we assume the combined_links are sorted by mask length, i.e. more
* specific routes first, and less specific routes with shorter
- * mask later */
+ * mask later. Finally, ordered based on priority (lower prio value means higher prio).
+ */
llist_for_each_entry(clset, &rtbl->combined_linksets, list) {
- if (mask < clset->cfg.mask)
+ if (mask > clset->cfg.mask)
break;
if (dpc == clset->cfg.pc && mask == clset->cfg.mask) {
- if (prio > clset->cfg.priority)
+ if (prio < clset->cfg.priority)
break;
if (prio == clset->cfg.priority)
return clset;
diff --git a/tests/vty/osmo_stp_route_prio.vty b/tests/vty/osmo_stp_route_prio.vty
index fe89e44..f2bfd1e 100644
--- a/tests/vty/osmo_stp_route_prio.vty
+++ b/tests/vty/osmo_stp_route_prio.vty
@@ -97,9 +97,11 @@
3.2.1/14 INACC 7 6 as1 UNAVAIL ? UNAVAIL
OsmoSTP(config-cs7-rt)# ! NOW ADD MORE GENERIC ROUTES (SMALLER BITMASK LENGTH)
+OsmoSTP(config-cs7-rt)# update route 3.2.0 7.255.0 linkset as3 priority 3
OsmoSTP(config-cs7-rt)# update route 3.2.0 7.255.0 linkset as1 priority 1
OsmoSTP(config-cs7-rt)# update route 3.2.0 7.255.0 linkset as2 priority 1
OsmoSTP(config-cs7-rt)# update route 3.2.0 7.255.0 linkset as3 priority 1
+OsmoSTP(config-cs7-rt)# update route 3.2.0 7.255.0 linkset as3 priority 2
OsmoSTP(config-cs7-rt)# show running-config
...
cs7 instance 0
@@ -111,6 +113,8 @@
update route 3.2.0 7.255.0 linkset as1 priority 1
update route 3.2.0 7.255.0 linkset as2 priority 1
update route 3.2.0 7.255.0 linkset as3 priority 1
+ update route 3.2.0 7.255.0 linkset as3 priority 2
+ update route 3.2.0 7.255.0 linkset as3 priority 3
...
OsmoSTP(config-cs7-rt)# do show cs7 instance 0 route
Routing table = system
@@ -122,8 +126,10 @@
3.2.1/14 INACC 0 5 as2 UNAVAIL ? UNAVAIL
3.2.1/14 INACC 7 6 as1 UNAVAIL ? UNAVAIL
3.2.0/11 INACC 0 1 as1 UNAVAIL ? UNAVAIL
-3.2.0/11 INACC 0 1 as2 UNAVAIL ? UNAVAIL
-3.2.0/11 INACC 0 1 as3 UNAVAIL ? UNAVAIL
+ INACC 0 1 as2 UNAVAIL ? UNAVAIL
+ INACC 0 1 as3 UNAVAIL ? UNAVAIL
+3.2.0/11 INACC 0 2 as3 UNAVAIL ? UNAVAIL
+3.2.0/11 INACC 0 3 as3 UNAVAIL ? UNAVAIL
OsmoSTP(config-cs7-rt)# do show cs7 instance 0 route binding-table 3.2.1
To view, visit change 40551. To unsubscribe, or for help writing mail filters, visit settings.