fix(ns-ha): validate interface name against main VRRP interface#1669
Merged
Conversation
Prevent configuration corruption when adding a LAN interface by validating that the interface name does not conflict with the main VRRP interface name. When a non-lan VRRP interface is configured (e.g., trunk_ha), both the VRRP interface and any additional LAN interface use hardcoded lan_* identifiers in Keepalived configuration, causing corruption if a real 'lan' interface is later added. Changes: - Add get_main_vrrp_interface() to detect the primary VRRP interface from keepalived config by finding the section with name='lan_ha' and extracting the actual interface from ns_link field - Add validate_additional_ha_interface_name() to raise lan_interface_name_conflicts_with_main_vrrp_interface error when interface is 'lan' but main VRRP is different - Move validation into add_lan_interface() before device checks to catch conflicts early and prevent API callers from hitting remote execution - Reorder validation checks for better logical flow - Update API documentation (README.md and openapi.yml) to document the new validation constraint Closes #1664 Assisted-by: Copilot:claude-haiku-4.5
filippocarletti
approved these changes
May 14, 2026
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.
Summary
Prevent configuration corruption when adding a LAN interface by validating that the interface name does not conflict with the main VRRP interface name.
When a non-lan VRRP interface is configured (e.g., trunk_ha), both the VRRP interface and any additional LAN interface use hardcoded lan_* identifiers in Keepalived configuration, causing corruption if a real 'lan' interface is later added.
Related issue
#1664
How to test
error_code: lan_interface_name_conflicts_with_main_vrrp_interfaceChanges
get_main_vrrp_interface()to detect the primary VRRP interface from keepalived configvalidate_additional_ha_interface_name()to raise validation error when interface is 'lan' but main VRRP is differentadd_lan_interface()before device checks