Don't choke on non-existent interface in route updates

This commit is contained in:
Viktor Liu
2024-11-21 15:37:06 +01:00
parent f66bbcc54c
commit 01a7c71586
2 changed files with 6 additions and 4 deletions

View File

@@ -1 +0,0 @@
package nftables

View File

@@ -230,10 +230,13 @@ func (rm *RouteMonitor) parseUpdate(row *MIB_IPFORWARD_ROW2, notificationType MI
if idx != 0 {
intf, err := net.InterfaceByIndex(idx)
if err != nil {
return update, fmt.Errorf("get interface name: %w", err)
log.Warnf("failed to get interface name for index %d: %v", idx, err)
update.Interface = &net.Interface{
Index: idx,
}
} else {
update.Interface = intf
}
update.Interface = intf
}
log.Tracef("Received route update with destination %v, next hop %v, interface %v", row.DestinationPrefix, row.NextHop, update.Interface)