Skip to content

Conversation

@ressys1978
Copy link
Contributor

@ressys1978 ressys1978 commented Jan 22, 2026

Describe your changes

Changed the Soft Interface detection on Windows to include looking at the Interface Description as well as the Name. Also added support to detect a PANGP (Palo Alto Networks GlobalProtect) as a Soft Interface.

Issue ticket number and link

This fixes #5077 on Windows

Stack

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)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

No changes to anything that's configurable.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

Summary by CodeRabbit

  • Bug Fixes

    • Improved network monitoring to better detect and ignore virtual/soft Windows adapters (including GlobalProtect), reducing false change notifications.
  • Tests

    • Added/updated tests to cover virtual adapter detection and ensure consistent filtering behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

Adds a Windows-specific soft interface checker that enumerates adapters via GetAdaptersAddresses, flags "soft" adapters (e.g., GlobalProtect/PANGP), and uses that checker in route change handling to ignore route changes originating from soft interfaces.

Changes

Cohort / File(s) Summary
Soft Interface Checker Implementation
client/internal/networkmonitor/check_change_windows.go
New softInterfaceChecker type and newSoftInterfaceChecker constructor using Windows API (GetAdaptersAddresses) to build an index of soft interfaces. Adds IsSoft method, extends routeChanged to accept a checker parameter, updates checkChange to instantiate/pass the checker, and adds "pangp" keyword detection.
Unit Tests
client/internal/networkmonitor/check_change_windows_test.go
Updated routeChanged call-site to pass the new checker parameter (nil in tests) and added a test case asserting "PANGP Virtual Ethernet Adapter" is detected as soft.

Sequence Diagram

sequenceDiagram
    participant RM as Route Monitor
    participant CH as Route Change Handler
    participant SC as softInterfaceChecker
    participant WinAPI as Windows API

    RM->>CH: notify route change
    CH->>SC: newSoftInterfaceChecker()
    SC->>WinAPI: GetAdaptersAddresses()
    WinAPI-->>SC: adapter list
    SC->>SC: build softByIndex map
    SC-->>CH: checker ready
    CH->>SC: IsSoft(route.NextHop)
    SC-->>CH: true / false
    alt soft interface
        CH->>CH: log debug and ignore route change
    else not soft
        CH->>CH: process route change
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I sniffed adapters, paws soft on the log,
Found PANGP footprints in foggy Windows bog.
I mapped each index with a twitch and a hop,
Now false alarms pause and the tunnels won't drop.
Hooray — no more restarts! — said the rabbit, on top.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: extending soft interface detection on Windows to include interface descriptions and adding PANGP support.
Description check ✅ Passed The description covers all required template sections: changes explained, linked issue cited, checklist completed, and documentation decision justified.
Linked Issues check ✅ Passed The code changes directly address issue #5077 by implementing soft interface detection for GlobalProtect (PANGP), preventing unnecessary WireGuard interface recreation.
Out of Scope Changes check ✅ Passed All code changes are focused on soft interface detection and directly support the objective of preventing GlobalProtect-triggered interface teardowns.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@client/internal/networkmonitor/check_change_windows.go`:
- Around line 47-56: The nil-check on checker in routeChanged causes
soft-interface filtering to be skipped when the checker is nil; remove the
conditional guard so you always call checker.IsSoft and instead make
softInterfaceChecker.IsSoft tolerate a nil receiver (handle nil inside IsSoft
and return false when no match), and apply the same change to the other similar
call site (the block at 151-157) so name-based soft-interface detection remains
active even if GetAdaptersAddresses or the caller yields a nil checker.
🧹 Nitpick comments (1)
client/internal/networkmonitor/check_change_windows.go (1)

35-40: Consider caching the soft-interface checker outside the loop.

Line 35 rebuilds the adapter index on every default-route update; GetAdaptersAddresses can be relatively expensive and may stall the monitor during bursts. Building once and refreshing on error/interval keeps the hot path lighter.

♻️ Suggested refactor
-	for {
+	checker, err := newSoftInterfaceChecker()
+	if err != nil {
+		log.Warnf("Network monitor: failed to build soft interface checker: %v", err)
+	}
+
+	for {
 		select {
 		case <-ctx.Done():
 			return ctx.Err()
 		case route := <-routeMonitor.RouteUpdates():
 			if route.Destination.Bits() != 0 {
 				continue
 			}
 
-			checker, err := newSoftInterfaceChecker()
-			if err != nil {
-				log.Warnf("Network monitor: failed to build soft interface checker: %v", err)
-			}
+			if checker == nil {
+				checker, err = newSoftInterfaceChecker()
+				if err != nil {
+					log.Warnf("Network monitor: failed to build soft interface checker: %v", err)
+				}
+			}
 
 			if routeChanged(route, nexthopv4, nexthopv6, checker) {
 				return nil
 			}
 		}
 	}

@sonarqubecloud
Copy link

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.

Unexpected WireGuard interface restart during GlobalProtect connection

1 participant