incus/dhcp: default routes and multiple DHCP clients for OCI containers#2414
Merged
incus/dhcp: default routes and multiple DHCP clients for OCI containers#2414
Conversation
* Problem
When multiple DHCP clients attempt to install an IPv4 default route into the main table,
netlink.RouteAdd can fail with EEXIST. This leads to noisy errors and nondeterministic
behavior regarding which interface "owns" the default route.
* Summary of changes
1. internal/server/ip:
- Made Route.List device-optional: when DevName is empty or unresolved, the OIF filter
is cleared and routes across all devices are returned.
- Introduced a single builder netlinkRoute(mode) to construct netlink.Route for both
apply (add/replace/delete) and query (list) paths.
2. incus/dhcp (DHCPv4 path in main_forknet.go):
- Introduce a policy to keep a single default route in the main table, owned by the
lexicographically smallest interface name among candidates.
- Inspect current main table routes using ip.Route.List to find the current default
route owner.
- If the new interface name sorts before the current owner (or there is no owner),
install/replace the default route via ip.Route.Replace. Otherwise, skip installing
the default route for this interface.
- Mark installed routes with Proto="dhcp".
- Use Replace rather than Add to make route installation idempotent across renewals
and avoid EEXIST.
* Behavioral impact:
- Route.List now returns routes across all devices when DevName is empty (previously, it
always filtered by device).
- Add, Replace, Delete, and Flush continue to require a valid device and behave as before.
Signed-off-by: Andrey Mozharovsky <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When multiple DHCP clients attempt to install an IPv4 default route into the main table, netlink.RouteAdd can fail with EEXIST. This leads to noisy errors and nondeterministic behavior regarding which interface "owns" the default route.
Summary of changes
Behavioral impact
This PR resolves #2403