aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Doan <daviddoan@Davids-MacBook-Pro-70.local>2023-10-23 15:26:45 -0400
committerDavid Doan <daviddoan@Davids-MacBook-Pro-70.local>2023-10-23 15:26:45 -0400
commitaaa3e0e5279c534bb07856bbce867e4cde2ed255 (patch)
tree44cfe6a0d344a07e2c94d2e69726b2130de7eebb
parent766ee3654c3ccca3b9a80d26736bfcbb9e37d708 (diff)
parent4dff16be71e58c8669ddfdcd5bcee90061b2cf51 (diff)
comments and refactoring
-rw-r--r--pkg/ipstack/ipstack.go24
-rwxr-xr-xvhostbin3110259 -> 0 bytes
-rwxr-xr-xvrouterbin3110267 -> 0 bytes
3 files changed, 19 insertions, 5 deletions
diff --git a/pkg/ipstack/ipstack.go b/pkg/ipstack/ipstack.go
index 038a2d4..e3d9ca2 100644
--- a/pkg/ipstack/ipstack.go
+++ b/pkg/ipstack/ipstack.go
@@ -192,8 +192,11 @@ func InterfaceListenerRoutine(i *Interface) {
if closed { // stop this go routine if channel is closed
return
}
-
- time.Sleep(1 * time.Millisecond)
+ //if !isUp { // don't call the listeners if interface is down
+ // continue
+ //}
+ // TODO: remove these "training wheels"
+ // time.Sleep(1 * time.Millisecond)
err := RecvIP(i, &isUp)
if err != nil {
continue
@@ -232,7 +235,18 @@ func InterfaceUp(iface *Interface) {
ripEntries := make([]RIPEntry, 0)
ripEntries = append(ripEntries, RIPEntry{iface.IpPrefix.Masked(), LOCAL_COST})
sendTriggeredUpdates(ripEntries)
+
+ // send a request to all neighbors of this iface to get info ASAP
+ for _, neighbor := range myNeighbors[iface.Name] {
+ message := makeRipMessage(1, nil)
+ addr := iface.IpPrefix.Addr()
+ _, err := SendIP(&addr, neighbor, RIP_PROTOCOL, message, neighbor.VipAddr.String(), nil)
+ if err != nil {
+ fmt.Println("Error sending RIP request to neighbor on interfaceup", err)
+ }
+ }
}
+
}
func InterfaceUpREPL(ifaceName string) {
@@ -375,7 +389,7 @@ func SendIP(src *netip.Addr, dest *Neighbor, protocolNum int, message []byte, de
// check if the interface is up
iface, err := GetInterfaceByName(dest.Name)
if !iface.State {
- return -1, errors.New("error: interface is down")
+ return -1, errors.Errorf("error SEND: %s is down", iface.Name)
}
// if the header is nil, create a new one
if hdr == nil {
@@ -462,7 +476,7 @@ func RecvIP(iface *Interface, isOpen *bool) error {
// check if the interface is up
if !*isOpen {
- return errors.New("interface is down")
+ return errors.Errorf("error RECV: %s is down", iface.Name)
}
// Marshal the received byte array into a UDP header
@@ -886,7 +900,7 @@ func handleRIP(src *Interface, dest *Neighbor, message []byte, hdr *ipv4header.I
if entry.cost == INFINITY {
// remove after GC time if the COST is still INFINITY
go func() {
- time.Sleep(12 * time.Second)
+ time.Sleep(time.Second * time.Duration(MAX_TIMEOUT))
if routingTable[destination].Cost == INFINITY {
delete(routingTable, destination)
mu.Lock()
diff --git a/vhost b/vhost
deleted file mode 100755
index 06cd653..0000000
--- a/vhost
+++ /dev/null
Binary files differ
diff --git a/vrouter b/vrouter
deleted file mode 100755
index 230afe9..0000000
--- a/vrouter
+++ /dev/null
Binary files differ