Skip to content

Capture all routes from network namespace, not just interface#12724

Closed
p12tic wants to merge 1 commit intogoogle:masterfrom
p12tic:copy-routes
Closed

Capture all routes from network namespace, not just interface#12724
p12tic wants to merge 1 commit intogoogle:masterfrom
p12tic:copy-routes

Conversation

@p12tic
Copy link
Contributor

@p12tic p12tic commented Mar 12, 2026

Change routesForIface() to use netlink.RouteListFiltered() instead of netlink.RouteList() to capture all routes in the network namespace.

Previously, only routes directly associated with a specific interface were captured. This missed custom routes (e.g., from podman-network-create --route option).

Fixes #7168

Change routesForIface() to use netlink.RouteListFiltered() instead of
netlink.RouteList() to capture all routes in the network namespace.

Previously, only routes directly associated with a specific interface were
captured. This missed custom routes (e.g., from podman-network-create --route
option).

Fixes google#7168
@p12tic p12tic changed the title runsc: Capture all routes from network namespace, not just interface Capture all routes from network namespace, not just interface Mar 12, 2026
return nil, nil, nil, err
}
rs, err := netlink.RouteList(link, netlink.FAMILY_ALL)
// Get all routes in the namespace, not just routes for this specific link.
Copy link
Collaborator

Choose a reason for hiding this comment

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

In that case, isn't the iface parameter in this function meaningless? We should update this function signature and also inspect where this is being called.

cc @nybidari

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, managed to miss this :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will close the PR for the moment and bring back proper solution.

Copy link
Contributor Author

@p12tic p12tic Mar 12, 2026

Choose a reason for hiding this comment

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

@ayushr2 Turns out my mental model was wrong and the issue was that only routes to loopback were not copied. In my environment I used this as a poor man's alternative to blackhole routes.

The real fix is similarly simple as in this PR, though it was way more involved to make relevant code testable and the tests themselves are more verbose: #12725

@p12tic p12tic marked this pull request as draft March 12, 2026 15:45
@p12tic p12tic closed this Mar 12, 2026
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.

Adding firewall to /proc/{id}/... network namespace is not working

2 participants