[draft] Handle route update as add instead of replace - #41391
[draft] Handle route update as add instead of replace#41391FetoiuCatalin wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This draft PR changes Linux route “Update” handling in netlinkutil to avoid inadvertently replacing another interface’s route when multiple routes share the same destination/metric key, and adds a Windows networking test to validate the new behavior.
Changes:
- Update route modification logic to omit
NLM_F_REPLACEfor Update operations (treat Update as “ensure exists” / add-only). - Add a regression test that creates two same-metric default routes on different interfaces and verifies both persist after an Update.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/linux/netlinkutil/RoutingTable.cpp |
Changes Update route flags to avoid NLM_F_REPLACE overwriting another interface’s route. |
test/windows/NetworkTests.cpp |
Adds a WSL2 test validating that updating eth0’s default route does not remove another interface’s same-metric default route. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/linux/netlinkutil/RoutingTable.cpp:103
- Remove the leftover commented-out assignment (
// flags = NLM_F_CREATE;). It’s redundant with the next line and makes it look like the code is mid-edit.
// Note: The EEXIST error is already treated as non-fatal.
// flags = NLM_F_CREATE;
flags = NLM_F_CREATE;
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/windows/service/exe/WslMirroredNetworking.cpp:1415
- In the refresh-all-routes retry path, the code sets
SyncStatus = PendingUpdate, but this PR now treatsPendingUpdateidentically toPendingAdd(both sendModifyRequestType::Add). SettingPendingAddhere would better reflect the actual retry operation and avoid future confusion when debugging route-sync state transitions.
hr = SendRouteRequestToGns(endpoint, trackedRoute, hns::ModifyRequestType::Add);
if (FAILED(hr.value()))
{
trackedRoute.SyncStatus = PendingUpdate;
trackedRoute.SyncRetryCount = TrackedRoute::MaxSyncRetryCount;
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/windows/service/exe/WslMirroredNetworking.cpp:1416
- In the refresh-all-routes retry path, the code now only ever sends
ModifyRequestType::Add, but on failure it setsSyncStatus = PendingUpdate. SincePendingUpdateno longer results in an Update request (it’s handled identically toPendingAdd), keeping the status asPendingUpdateis misleading and makes future debugging harder. Consider usingPendingAddhere (or renaming the enum more broadly) to match the actual behavior.
hr = SendRouteRequestToGns(endpoint, trackedRoute, hns::ModifyRequestType::Add);
if (FAILED(hr.value()))
{
trackedRoute.SyncStatus = PendingUpdate;
trackedRoute.SyncRetryCount = TrackedRoute::MaxSyncRetryCount;
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/windows/service/exe/WslMirroredNetworking.cpp:1403
- Grammar: use "A" (not "An") before "ModifyRequestType::Add".
// An ModifyRequestType::Add plumbs a new route or leaves an existing one in place (EEXIST is ignored),
Summary of the Pull Request
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed