Skip to content

Conversation

@troglobit
Copy link
Contributor

@troglobit troglobit commented Nov 14, 2025

Description

Resolve race condition between DHCP and configured hostname by introducing a priority-based hostname management system using a /etc/hostname.d/ directory pattern.

Checklist

Tick relevant boxes, this PR is-a or has-a:

  • Bugfix
    • Regression tests
    • ChangeLog updates (for next release)
  • Feature
    • YANG model change => revision updated?
    • Regression tests added?
    • ChangeLog updates (for next release)
    • Documentation added?
  • Test changes
    • Checked in changed Readme.adoc (make test-spec)
    • Added new test to group Readme.adoc and yaml file
  • Code style update (formatting, renaming)
  • Refactoring (please detail in commit messages)
  • Build related changes
  • Documentation content changes
    • ChangeLog updated (for major changes)
  • Other (please describe):

@troglobit troglobit linked an issue Nov 14, 2025 that may be closed by this pull request
@troglobit troglobit marked this pull request as ready for review November 14, 2025 12:17
@troglobit troglobit requested a review from mattiaswal November 14, 2025 12:17
@mattiaswal mattiaswal self-requested a review November 17, 2025 08:59
Copy link
Contributor

@mattiaswal mattiaswal left a comment

Choose a reason for hiding this comment

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

👍 Just one improvement for future testsystems

Resolve race condition between DHCP and configured hostname by introducing
priority-based hostname management using /etc/hostname.d/ directory pattern.

Priority order (highest wins):
  90-dhcp-<iface>  - DHCP assigned hostname
  50-configured    - YANG /system/hostname config
  10-default       - Bootstrap/factory default

The new /usr/libexec/infix/hostname helper reads all sources and applies the
highest priority hostname.  It exits early if hostname unchanged, preventing
unnecessary service restarts.

Fixes #1112

Signed-off-by: Joachim Wiberg <[email protected]>
Validate that DHCP options were requested in the parameter request
list before applying them. This prevents malicious or misconfigured
DHCP servers from forcing unwanted configuration changes.

Validates: hostname (12), DNS (6), domain (15), search (119),
router (3), static routes (121), and NTP (42).

Fail-safe behavior: rejects options if config file unavailable.

Signed-off-by: Joachim Wiberg <[email protected]>
This change exposes the macvlan mode to tests, unlocking support for running
certain types of tests on systems with only a single Ethernet port.

Signed-off-by: Joachim Wiberg <[email protected]>
Set PYTHONPYCACHEDIR=/tmp/__pycache__ in test/env to avoid permission issues
during git cleanup operations.  When tests run in Docker containers as root,
__pycache__ directories and .pyc files end up owned by root, preventing the
CI user from cleaning them up.

Signed-off-by: Joachim Wiberg <[email protected]>
Verify deterministic hostname management via /etc/hostname.d/, rules:

 1. Configured hostname takes precedence over default
 2. DHCP hostname takes precedence over configured
 3. Hostname reverts when DHCP lease ends

Signed-off-by: Joachim Wiberg <[email protected]>
@troglobit troglobit linked an issue Nov 17, 2025 that may be closed by this pull request
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.

Infix 25.10 GNS3 Image Takes Forever to Boot Hostname changes unexpectedly

3 participants