aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/ipstack/ipstack.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/ipstack/ipstack.go b/pkg/ipstack/ipstack.go
index 8a451f8..019d97b 100644
--- a/pkg/ipstack/ipstack.go
+++ b/pkg/ipstack/ipstack.go
@@ -844,13 +844,21 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I
// then we can increase the cost by that new value
if hop.VIP == hdr.Src &&
entry.cost > hop.Cost {
- routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src}
+ if entry.cost == INFINITY {
+ routingTable[destination] = Hop{entry.cost, "R", src, hdr.Src}
+ } else {
+ routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src}
+ }
}
// if there is a shorter route for this destination on a different (or same) neighbor
// then update to use that one
if entry.cost < hop.Cost {
- routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src}
+ if entry.cost == INFINITY {
+ routingTable[destination] = Hop{entry.cost, "R", src, hdr.Src}
+ } else {
+ routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src}
+ }
}
// upon an update from this prefix, reset its timeout