Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[client] Don't choke on non-existent interface in route updates #2922

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion client/firewall/nftables/state.go

This file was deleted.

9 changes: 6 additions & 3 deletions client/internal/routemanager/systemops/systemops_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the description of the PR, it was to help debug things only. But if you remove the return the logic will be different. Or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is slightly different, we won't error out here, instead, we will return the interface info we have (index). Index is sufficient for the current checks we have in the network monitor for Windows.

This case where we cannot lookup the interface only happens if we get a route update notification from the OS at the same time as the interface is removed (e.g. the interface is removed and all routes that point to it are removed as well, like in the linked issue).

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)
Expand Down
Loading