Skip to content

fix(ns-ha): validate interface name against main VRRP interface#1669

Merged
gsanchietti merged 1 commit into
mainfrom
issue1664
May 14, 2026
Merged

fix(ns-ha): validate interface name against main VRRP interface#1669
gsanchietti merged 1 commit into
mainfrom
issue1664

Conversation

@gsanchietti
Copy link
Copy Markdown
Member

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

  1. Set up HA with a non-lan interface (e.g., trunk_ha)
  2. Attempt to add a new lan interface using:
    ns-ha-config add-lan-interface <primary_ip> <backup_ip> <virtual_ip>
  3. Verify the API returns validation error:
    error_code: lan_interface_name_conflicts_with_main_vrrp_interface

Changes

  • Add get_main_vrrp_interface() to detect the primary VRRP interface from keepalived config
  • Add validate_additional_ha_interface_name() to raise validation error when interface is 'lan' but main VRRP is different
  • Move validation into add_lan_interface() before device checks
  • Update API documentation (README.md and openapi.yml)

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
@gsanchietti gsanchietti self-assigned this May 14, 2026
@gsanchietti gsanchietti merged commit 73f1c8c into main May 14, 2026
2 checks passed
@gsanchietti gsanchietti deleted the issue1664 branch May 14, 2026 10:03
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.

2 participants