From cb605f4bd1868c443799f4764e9400ada2c08eb8 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Mon, 23 Oct 2023 11:12:49 -0400 Subject: send triggered updates when any! entry in the table is created, updated, or deleted --- pkg/ipstack/ipstack.go | 11 +++++++++++ vhost | Bin 3104664 -> 3105056 bytes vrouter | Bin 3104672 -> 3105056 bytes 3 files changed, 11 insertions(+) diff --git a/pkg/ipstack/ipstack.go b/pkg/ipstack/ipstack.go index c8a4fe8..4556f0f 100644 --- a/pkg/ipstack/ipstack.go +++ b/pkg/ipstack/ipstack.go @@ -843,6 +843,7 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I destination := entry.prefix.Masked() // fmt.Println(prefix.String()) + triggeredEntries := make([]RIPEntry, 0) // check if the entry is already in the routing table and update if need be if hop, ok := routingTable[destination]; ok { // if the hop is the same as the incoming neighbor, @@ -853,8 +854,10 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I if entry.cost == INFINITY { // if we receive infinity from the same neighbor, then delete the route delete(routingTable, destination) + triggeredEntries = append(triggeredEntries, RIPEntry{destination, INFINITY}) } else { routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src} + triggeredEntries = append(triggeredEntries, RIPEntry{destination, entry.cost + 1}) } } @@ -863,8 +866,10 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I if entry.cost < hop.Cost { if entry.cost == INFINITY { routingTable[destination] = Hop{entry.cost, "R", src, hdr.Src} + triggeredEntries = append(triggeredEntries, RIPEntry{destination, entry.cost}) } else { routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src} + triggeredEntries = append(triggeredEntries, RIPEntry{destination, entry.cost + 1}) } } @@ -883,7 +888,13 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I // routingTable[destination] = Hop{0, "R", src, hdr.Src} //} else { routingTable[destination] = Hop{entry.cost + 1, "R", src, hdr.Src} + triggeredEntries = append(triggeredEntries, RIPEntry{destination, entry.cost + 1}) // } + + // send out triggered updates + if len(triggeredEntries) > 0 { + sendTriggeredUpdates(triggeredEntries) + } } } diff --git a/vhost b/vhost index 88948dc..66761c1 100755 Binary files a/vhost and b/vhost differ diff --git a/vrouter b/vrouter index 45624ed..e62754d 100755 Binary files a/vrouter and b/vrouter differ -- cgit v1.2.3-70-g09d2