From c0bb904306866d31d0a2644c2b74989fa3c43261 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Mon, 23 Oct 2023 10:20:51 -0400 Subject: fix 17 in table bug --- pkg/ipstack/ipstack.go | 12 ++++++++++-- vhost | Bin 3104661 -> 3095810 bytes vrouter | Bin 3104653 -> 3095810 bytes 3 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 diff --git a/vhost b/vhost index 53dc4bc..e8e274b 100755 Binary files a/vhost and b/vhost differ diff --git a/vrouter b/vrouter index 14e6c0c..e9ade66 100755 Binary files a/vrouter and b/vrouter differ -- cgit v1.2.3-70-g09d2