Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit a06aa6f

Browse files
committed
Add PersistentRoutes()
1 parent ac3edb6 commit a06aa6f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

cmd/neigh2route/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func main() {
3939
}()
4040

4141
go nm.SendPings()
42+
go nm.PersistentRoutes()
4243

4344
nm.MonitorNeighbors()
4445
}

internal/neighbor/manager.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,20 @@ func (nm *NeighborManager) SendPings() {
163163
}
164164
}
165165

166+
func (nm *NeighborManager) PersistentRoutes() {
167+
for {
168+
nm.mu.Lock()
169+
for _, n := range nm.reachableNeighbors {
170+
if err := netutils.AddRoute(n.ip, n.linkIndex); err != nil {
171+
log.Printf("Failed to add route for neighbor %s: %v", n.ip.String(), err)
172+
}
173+
}
174+
nm.mu.Unlock()
175+
176+
<-time.After(30 * time.Second)
177+
}
178+
}
179+
166180
func (nm *NeighborManager) Cleanup() {
167181
nm.mu.Lock()
168182
defer nm.mu.Unlock()

0 commit comments

Comments
 (0)