ip: improve primary address selection to account for address flags #2295
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.
Description
This change uses known IFA_F flags that are attached to interface addresses by the linux kernel to differentiate between the usability of multiple addresses.
Primarily, this deprioritizes temporary and completely excludes deprecated addresses that have been assigned to a node through RFC7217 address generation techniques. It also explicitly prioritizes addresses that are marked as "manually assigned" by the kernel.
This improves routing stability for all backends that require an address to reach a node.
Closes #2293 but generally speaking in any case where a node has multiple addresses to choose from, flannel should consciously choose the most useful and less likely to suddenly change.
Performed Testing
I have already patches this change into my own three-node linux k3s setup and have run manual end-to-end tests there. The change has the intended outcome in that temporary addresses are no longer chosen as primary addresses.
Todos
Release Note
I do think a release note is required since this changes the way flannel chooses primary addresses which has potential impact in user deployments.
There should be no action required by a user during updates but they should be aware that after restarting flannel, the primary address chosen by it might be a different one than before the restart.
I have trouble finding a fitting formulation though.