diff options
author | sotech117 <michael_foiani@brown.edu> | 2023-10-23 10:20:51 -0400 |
---|---|---|
committer | sotech117 <michael_foiani@brown.edu> | 2023-10-23 10:20:51 -0400 |
commit | c0bb904306866d31d0a2644c2b74989fa3c43261 (patch) | |
tree | 8c48981d439f970545c7f1433647363d8f856f49 | |
parent | 592a1f0d050147769ce0cb1d0d235150fbd5d8db (diff) |
fix 17 in table bug
-rw-r--r-- | pkg/ipstack/ipstack.go | 12 | ||||
-rwxr-xr-x | vhost | bin | 3104661 -> 3095810 bytes | |||
-rwxr-xr-x | 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 Binary files differBinary files differ |