Skip to content

feat(network): opt-in VIP detection (CARP/tunnel/loopback) with IP roles - #409

Open
eric-eisenhart wants to merge 2 commits into
Solvik:masterfrom
sonic-com:feat/vip-detection
Open

feat(network): opt-in VIP detection (CARP/tunnel/loopback) with IP roles#409
eric-eisenhart wants to merge 2 commits into
Solvik:masterfrom
sonic-com:feat/vip-detection

Conversation

@eric-eisenhart

Copy link
Copy Markdown

This is additional feature after #408 -- if you like that one and merge it, this should show just the features to detect VIPs.

Detect virtual IPs from runtime signals and set the matching NetBox IP role
so hosts sharing a VIP each keep their own record instead of stealing it.
Three independent detectors, each opt-in via config and all default off, so
default behavior is unchanged:

  • network.vip_carp: CARP VIPs (addresses carrying a vhid in ifconfig, *BSD)
    -> CARP role. Ifconfig now also collects carp_addresses.
  • network.vip_tunnel: a /32 or /128 on an IP-tunnel interface (IPIP/IP6IP6/
    SIT/GRE, via the /sys ARPHRD type) -> VIP role (e.g. LVS-TUN real servers).
  • network.vip_loopback: non-localhost addresses on a loopback interface -> VIP.

vip_roles() aggregates them to {address: role}. In
create_or_update_netbox_ip_on_interface a detected role is set when the IP is
created/adopted, and the multi-assignable branch now handles any such role,
not just Anycast.

Also fix that branch to use assigned_object_id instead of the .interface
attribute removed from the NetBox API, so Anycast handling works again. With
all detectors off, behavior is identical to before apart from that fix.

Adds the config options + example, and extends the ifconfig test to cover
CARP address extraction.

eric-eisenhart and others added 2 commits August 3, 2026 19:01
Network.scan() read interface facts exclusively from Linux sysfs
(/sys/class/net), so it could not run on *BSD. Abstract the OS-specific
bits behind small helpers that use sysfs when present and fall back to
parsing `ifconfig -a` otherwise:

- Add netbox_agent/ifconfig.py: parse `ifconfig -a` for per-interface MAC
  and MTU (the facts scan() reads from /sys on Linux).
- scan() enumerates interfaces and reads MAC/MTU/bonding/virtual via
  _use_sysfs()-guarded helpers; the Linux path is behaviorally unchanged.
- ethtool is already skipped when the binary is absent, so *BSD NICs get
  ethtool=None (interface type falls back to Other), which downstream
  already handles.
- Guard the MTU update so a missing (None) MTU never clears a known one.
- Add a fixture + test parsing real FreeBSD `ifconfig` output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Detect virtual IPs from runtime signals and set the matching NetBox IP role
so hosts sharing a VIP each keep their own record instead of stealing it.
Three independent detectors, each opt-in via config and all default off, so
default behavior is unchanged:

- network.vip_carp: CARP VIPs (addresses carrying a vhid in ifconfig, *BSD)
  -> CARP role. Ifconfig now also collects carp_addresses.
- network.vip_tunnel: a /32 or /128 on an IP-tunnel interface (IPIP/IP6IP6/
  SIT/GRE, via the /sys ARPHRD type) -> VIP role (e.g. LVS-TUN real servers).
- network.vip_loopback: non-localhost addresses on a loopback interface -> VIP.

vip_roles() aggregates them to {address: role}. In
create_or_update_netbox_ip_on_interface a detected role is set when the IP is
created/adopted, and the multi-assignable branch now handles any such role,
not just Anycast.

Also fix that branch to use assigned_object_id instead of the `.interface`
attribute removed from the NetBox API, so Anycast handling works again. With
all detectors off, behavior is identical to before apart from that fix.

Adds the config options + example, and extends the ifconfig test to cover
CARP address extraction.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant