Fix default route replacement #1552
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/k8snetworkplumbingwg/multus-cni/pull/1552#gh-light-mode-only"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg" alt="Review Change Stack" width="202" height="32"></a><a href="https://app.coderabbit.ai/change-stack/k8snetworkplumbingwg/multus-cni/pull/1552#gh-dark-mode-only"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg" alt="Review Change Stack" width="202" height="32"></a>
<!-- review_stack_entry_end -->
<!-- recent_review_start -->
No actionable comments were generated in the recent review. 🎉
<details>
<summary>ℹ️ Recent review info</summary>
<details>
<summary>⚙️ Run configuration</summary>
Configuration used: Repository: k8snetworkplumbingwg/multus-cni/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID: 07e2275e-d425-4c16-b554-06c32f71e0f8
</details>
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between f68879000841714a83475c51590e501192e51abe and 26340cd64bf7cf4e051ec8d29e0f8c479c9101d9.
</details>
<details>
<summary>📒 Files selected for processing (2)</summary>
pkg/netutils/netutils.go
pkg/netutils/netutils_test.go
</details>
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.
</details>
---
<!-- recent_review_end -->
<!-- walkthrough_start -->
Walkthrough
DeleteDefaultGW now recognizes nil and zero-prefix IPv4 or IPv6 destinations. Tests cover helper behavior and verify that no zero-prefix route remains after deletion.
Changes
Default route detection
|Layer / File(s)|Summary|
|---|---|
|Route matching and validation <br> pkg/netutils/netutils.go, pkg/netutils/netutils_test.go|isIPNetZero identifies nil and zero-prefix destinations. DeleteDefaultGW uses the helper. Tests cover IPv4, IPv6, nil destinations, and post-deletion routes.|
<!-- change_assessment_start -->
Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
<!-- change_assessment_commit:"26340cd64bf7cf4e051ec8d29e0f8c479c9101d9" -->
Change: Bug fix
<!-- change_assessment_end -->
<!-- walkthrough_end -->
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary>
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
| :----------------: | :--------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
<details>
<summary>✅ Passed checks (4 passed)</summary>
| Check name | Status | Explanation |
| :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title, "Fix default route replacement," clearly and concisely describes the main change: correcting default-route detection before replacement. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
</details>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary>✨ Finishing Touches</summary>
<details open>
<summary>🧪 Generate unit tests (beta)</summary>
</details>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->
---
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.
<details>
<summary>❤️ Share</summary>
</details>
<sub>Comment @coderabbitai help to get the list of available commands.</sub>
<!-- tips_end -->
LGTM
🚀 Performance Test Results
Status: ✅ Completed
Workflow Run: #35542276439
Baseline: Run #36147853262
---
Workloads Tested: 2
---
<details>
<summary><strong>node-density-cni-0.4.0</strong></summary>
📊 Kubernetes Workload Metrics Report
node-density-cni-0.4.0 Performance Results
Generated on: 2026-10-04 05:00:43 UTC
📊 Baseline: Run from workflow
🎯 Pod Ready Latency (Main KPI)
| Metric | Current | Baseline | Change |
|--------|---------|----------|--------|
| Average Latency | 1648.4 ms | 6359.4 ms | -4710.9 (-74.1%) |
| Max Latency | 5000 ms | 10000 ms | -5000 (-50.0%) |
| Min Latency | 0 ms | 4000 ms | -4000 (-100.0%) |
| Total Pods | 128 | 128 | 0 |
---
Report generated by Multus performance testing
</details>
<details>
<summary><strong>node-density-cni-0.3.1</strong></summary>
📊 Kubernetes Workload Metrics Report
node-density-cni-0.3.1 Performance Results
Generated on: 2026-10-04 05:00:43 UTC
📊 Baseline: Run from workflow
🎯 Pod Ready Latency (Main KPI)
| Metric | Current | Baseline | Change |
|--------|---------|----------|--------|
| Average Latency | 4781.2 ms | 4320.3 ms | +460.9 (+10.7%) |
| Max Latency | 8000 ms | 8000 ms | 0 (0.0%) |
| Min Latency | 2000 ms | 2000 ms | 0 (0.0%) |
| Total Pods | 128 | 128 | 0 |
---
Report generated by Multus performance testing
</details>
---
Previous Run
<details>
<summary><strong>2026-09-25 14:59:05 UTC</strong></summary>
🚀 Performance Test Results
Status: ❌ Failed
Workflow Run: #35542276439
Baseline: Run #35069431027
---
Workloads Tested: 2
---
<details>
<summary><strong>node-density-cni-0.4.0</strong></summary>
📊 Kubernetes Workload Metrics Report
node-density-cni-0.4.0 Performance Results
Generated on: 2026-09-25 19:33:43 UTC
📊 Baseline: Run from workflow
🎯 Pod Ready Latency (Main KPI)
| Metric | Current | Baseline | Change |
|--------|---------|----------|--------|
| Average Latency | 1648.4 ms | 2453.1 ms | -804.7 (-32.8%) |
| Max Latency | 5000 ms | 6000 ms | -1000 (-16.7%) |
| Min Latency | 0 ms | 0 ms | N/A |
| Total Pods | 128 | 128 | 0 |
---
Report generated by Multus performance testing
</details>
<details>
<summary><strong>node-density-cni-0.3.1</strong></summary>
📊 Kubernetes Workload Metrics Report
node-density-cni-0.3.1 Performance Results
Generated on: 2026-09-25 19:33:43 UTC
📊 Baseline: Run from workflow
🎯 Pod Ready Latency (Main KPI)
⚠️ No pod latency data available
---
Report generated by Multus performance testing
</details>
</details>
---
🤖 Generated by performance-report workflow
I'm not sure that the failing e2e has anything to do with my changes, and I can't restart it to see if it's flaky
Anything else I have to do here to get this merged?
Hey, is there anything I can do to help this get merged?
@bpickard22 PTAL, CI lanes pass
Hey, any chance this could get looked at? Anything I can do to help?
wizhaoredhat
stek29
Multus was failing to detect existing Default routes in container and remove them before replacement, which causes later adding of default route to fail with EEXIST, which is ignored and not detected as a error.
This leads to container keeping existing default route in case of chained CNIs instead of getting new default route from Multus.
Fixes regression introduced by f18d96b648559d1b67d21eb8b772df51c7a493e7
There was a breaking change in that bump:
https://github.com/vishvananda/netlink/commit/acdc658b8613655ddb69f978e9fb4cf413e2b830 route.Dst is a zero IPNet instead of nil
Check for default route using isIPNetZero adopted from github.com/containernetworking/plugins/pkg/ip.IsIPNetZero. Avoid importing ip.IsIPNetZero to avoid brining more dependencies.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
- Improved default-route detection to recognize IPv4 and IPv6 zero-prefix routes, including routes with nil destinations.
- Deleting the default gateway now correctly removes these default route variants.
- Added coverage for IPv4, IPv6, and nil default-route destinations.
- Extended route deletion checks to confirm no default routes remain.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->