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

fix(networkmonitor): false engine restarts #3355

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hurricanehrndz
Copy link
Contributor

Describe your changes

Network monitor should only trigger engine restarts when route get actually changes. There are many other instances when unspecified address get added to the system without actually affecting the real default route.

** change depends on **
netbirdio/go-netroute#5

Issue ticket number and link

fixes #3352

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

@hurricanehrndz
Copy link
Contributor Author

Please do not merge until go-netroute gets updated and merged.

Copy link
Contributor

@lixmal lixmal left a comment

Choose a reason for hiding this comment

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

https://github.com/netbirdio/netbird/pull/3355/files#diff-0f6b5bd1fd7206f0c6c1450e86746586e21d8a9bf4eda7d356e65d096893ac98R61

With this change RTM_CHANGE could also make sense. Would you mind testing that with route change ...?

Can you also add some comments why we're doing this differently on bsd (multiple 0.0.0.0/0 etc)

Network monitor should only trigger engine restarts when `route get`
actually changes. There are many other instances when unspecified
address get added to the system without actually affecting the real
default route.

fixes netbirdio#3352
@hurricanehrndz hurricanehrndz force-pushed the fix_networkmonitor_false_enginerestarts branch from a238f3e to 91dd571 Compare February 20, 2025 17:40
@hurricanehrndz
Copy link
Contributor Author

With the newest changes, this is the log when I pull out my usb-c wired connection

2025-02-20T12:23:52-07:00       info    client/internal/networkmonitor.checkChange      Network monitor: default route changed, v4GatewayChanged: true v4Gateway: "invalid IP", v6GatewayChanged: true, v6Gateway: "fe80::2d0:4cff:fe10:15d2%en0", IntfV4Changed: true, v4Intf: (*net.Interface)(nil),  v6IntfChanged: true, v6Intf: &net.Interface{Index:15, MTU:1500, Name:"en0", HardwareAddr:net.HardwareAddr{0x2e, 0xcf, 0x11, 0xd3, 0x8d, 0xc3}, Flags:0x33}
2025-02-20T12:23:52-07:00       info    client/internal.(*Engine).startNetworkMonitor.func1.1   Network monitor: detected network change, reset debounceTimer
2025-02-20T12:23:52-07:00       info    client/internal/networkmonitor.checkChange      Network monitor: failed to check next hop, assuming no network connection available: route not found
2025-02-20T12:23:52-07:00       info    client/internal/networkmonitor.checkChange      Network monitor: default route changed, v4GatewayChanged: true v4Gateway: "invalid IP", v6GatewayChanged: true, v6Gateway: "fe80::2d0:4cff:fe10:15d2%en0", IntfV4Changed: true, v4Intf: (*net.Interface)(nil),  v6IntfChanged: true, v6Intf: &net.Interface{Index:15, MTU:1500, Name:"en0", HardwareAddr:net.HardwareAddr{0x2e, 0xcf, 0x11, 0xd3, 0x8d, 0xc3}, Flags:0x33}
2025-02-20T12:23:52-07:00       info    client/internal.(*Engine).startNetworkMonitor.func1.1   Network monitor: detected network change, reset debounceTimer
2025-02-20T12:23:52-07:00       info    client/internal.(*Engine).startNetworkMonitor.func1.1   Network monitor: detected network change, reset debounceTimer
2025-02-20T12:23:52-07:00       info    client/internal/networkmonitor.checkChange      Network monitor: failed to check next hop, assuming no network connection available: route not found
2025-02-20T12:23:52-07:00       info    client/internal/networkmonitor.checkChange      Network monitor: default route changed, v4GatewayChanged: true v4Gateway: "invalid IP", v6GatewayChanged: true, v6Gateway: "fe80::2d0:4cff:fe10:15d2%en0", IntfV4Changed: true, v4Intf: (*net.Interface)(nil),  v6IntfChanged: true, v6Intf: &net.Interface{Index:15, MTU:1500, Name:"en0", HardwareAddr:net.HardwareAddr{0x2e, 0xcf, 0x11, 0xd3, 0x8d, 0xc3}, Flags:0x33}
2025-02-20T12:23:52-07:00       info    client/internal.(*Engine).startNetworkMonitor.func1.1   Network monitor: detected network change, reset debounceTimer
2025-02-20T12:23:52-07:00       info    client/internal.(*Engine).startNetworkMonitor.func1.1   Network monitor: detected network change, reset debounceTimer
2025-02-20T12:23:52-07:00       info    client/internal/networkmonitor.checkChange      Network monitor: default route changed, v4GatewayChanged: false v4Gateway: "172.28.250.1", v6GatewayChanged: true, v6Gateway: "fe80::2d0:4cff:fe10:15d2%en0", IntfV4Changed: true, v4Intf: &net.Interface{Index:15, MTU:1500, Name:"en0", HardwareAddr:net.HardwareAddr{0x2e, 0xcf, 0x11, 0xd3, 0x8d, 0xc3}, Flags:0x33},  v6IntfChanged: true, v6Intf: &net.Interface{Index:15, MTU:1500, Name:"en0", HardwareAddr:net.HardwareAddr{0x2e, 0xcf, 0x11, 0xd3, 0x8d, 0xc3}, Flags:0x33}
2025-02-20T12:23:52-07:00       info    client/internal/networkmonitor.checkChange      Network monitor: default route changed, v4GatewayChanged: false v4Gateway: "172.28.250.1", v6GatewayChanged: true, v6Gateway: "fe80::2d0:4cff:fe10:15d2%en0", IntfV4Changed: true, v4Intf: &net.Interface{Index:15, MTU:1500, Name:"en0", HardwareAddr:net.HardwareAddr{0x2e, 0xcf, 0x11, 0xd3, 0x8d, 0xc3}, Flags:0x33},  v6IntfChanged: true, v6Intf: &net.Interface{Index:15, MTU:1500, Name:"en0", HardwareAddr:net.HardwareAddr{0x2e, 0xcf, 0x11, 0xd3, 0x8d, 0xc3}, Flags:0x33}
2025-02-20T12:23:52-07:00       info    client/internal.(*Engine).startNetworkMonitor.func1.1   Network monitor: detected network change, reset debounceTimer
2025-02-20T12:23:52-07:00       info    client/internal.(*Engine).startNetworkMonitor.func1.1   Network monitor: detected network change, reset debounceTimer
2025-02-20T12:23:54-07:00       info    client/internal.(*Engine).startNetworkMonitor.func1.1.1 Network monitor: detected network change, restarting engine

@hurricanehrndz
Copy link
Contributor Author

Once the go-netroute PR is merge I can update the go.mod file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On macOS the route monitor triggers on non gw changes
2 participants