aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2023-10-23 10:20:51 -0400
committersotech117 <michael_foiani@brown.edu>2023-10-23 10:20:51 -0400
commitc0bb904306866d31d0a2644c2b74989fa3c43261 (patch)
tree8c48981d439f970545c7f1433647363d8f856f49
parent592a1f0d050147769ce0cb1d0d235150fbd5d8db (diff)
fix 17 in table bug
-rw-r--r--pkg/ipstack/ipstack.go12
-rwxr-xr-xvhostbin3104661 -> 3095810 bytes
-rwxr-xr-xvrouterbin3104653 -> 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
--- a/vhost
+++ b/vhost
Binary files differ
diff --git a/vrouter b/vrouter
index 14e6c0c..e9ade66 100755
--- a/vrouter
+++ b/vrouter
Binary files differ