← Back to Pull requests

control/utils: count a labelled IPv4 address toward its device and replace netifaces with pyroute2 #2236

Merged
tchaikov merged 5 files (274 lines) on Nov 18, 2026 03:59 UTC
View on GitHub
tchaikov tchaikov commented on Oct 23, 2026 05:07 UTC
Author

getifaddrs() names an IPv4 address that has a label, such as one added with "ip addr add ... label eth0:vip", after the label. NICS took "eth0:vip" for a device, so verify_ip_address() read /sys/class/net/eth0:vip/operstate, found nothing and treated the address as down. With verify_listener_ip set, a listener on that address failed with EADDRNOTAVAIL.

In this changeset,

1. we fold each label's addresses into the device named before the colon in label
2. switch from netifaces to pyroute2.

Diff: 274 lines (+207 / -67) across 5 files Reviewer: baum Review duration: 37372m
All Vouch review confidence checks passed
Residual risk 0.06 = Change Risk (0.42) × (1 − Review Confidence (0.85)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 274 lines diff across 5 files
0.42
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.86 · 5 substantive comment(s)
0.86
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
85%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.336
Real PR Conversation Timeline
17 items
copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 23, 2026 05:07 UTC
Reviewer

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 23, 2026 06:57 UTC
Reviewer

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 26, 2026 06:47 UTC
Reviewer

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Copilot Copilot commented on code on Nov 01, 2026 04:59 UTC
Code Review
control/utils.py:1
@@ -812,26 +817,39 @@ def __init__(self, logger=None, handle_all=False):
         self._build_adapter_info()
 
     def _build_adapter_info(self):
-        interfaces = netifaces.interfaces()
+        with IPRoute() as ipr:
+            links = ipr.get_links()
+            addrs = ipr.get_addr()
         if self.logger:
-            self.logger.debug(f"Network interfaces: {interfaces}")
-        for device_name in interfaces:
-            if device_name.startswith(self.ignored_device_prefixes):
+            self.logger.debug(f"Network interfaces: {[link.get('IFLA_IFNAME') for link in links]}")
+        # Netlink names an address's device by index, so a label such as
+        # "eth0:vip" never shows up as a device of its own.
+        nics = {}
+        for link in links:
+            device_name = link.get("IFLA_IFNAME")
+            if not device_name or device_name.startswith(self.ignored_device_prefixes):
                 continue
-            try:
-                nic = NIC(device_name)
-            except Exception:
-                if self.logger:
-                    self.logger.exception(f"Error in interface {device_name}")
+            nics[link["index"]] = NIC(device_name, link.get("IFLA_ADDRESS", ""))
+
+        for addr in addrs:
+            nic = nics.get(addr["index"])
+            # A link-local address cannot be listened on without a scope id
+            if nic is None or addr["scope"] == rt_scope["link"]:

This drops link-scoped addresses for both families, but IPv4 addresses configured with scope link (for example, a 169.254.x.x address) do not require a scope ID. Such addresses now disappear from the NIC inventory, causing listener creation with verify_listener_ip enabled to return EADDRNOTAVAIL and subnet-based auto-listeners to miss them. Restrict the scope exclusion to IPv6.

copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 01, 2026 04:59 UTC
Reviewer

<!-- ccr-overview-v2 -->

🟡 Changes recommended

The scope filter incorrectly excludes link-scoped IPv4 addresses from NIC inventory, causing verified listener creation to fail with EADDRNOTAVAIL and subnet-based auto-listeners to miss those addresses.

<details open>
<summary><strong>1 open issue</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> Preserve link-scoped IPv4 addresses in NIC inventory · New

  • </details>

    <sub>Review effort: Balanced</sub>

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 02, 2026 09:23 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🟢 Approval recommended

    No active review issues are identified for the listener IP validation changes.

    No open issues 🎉

    <details>
    <summary><strong>1 resolved since last review</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> Preserve link-scoped IPv4 addresses in NIC inventory

  • </details>

    <sub>Review effort: Balanced</sub>

    baum baum commented on code on Nov 04, 2026 04:40 UTC
    Code Review
    control/utils.py:1
    @@ -812,26 +817,41 @@ def __init__(self, logger=None, handle_all=False):
             self._build_adapter_info()
     
         def _build_adapter_info(self):
    -        interfaces = netifaces.interfaces()
    +        with IPRoute() as ipr:
    +            links = ipr.get_links()
    +            addrs = ipr.get_addr()
             if self.logger:
    -            self.logger.debug(f"Network interfaces: {interfaces}")
    -        for device_name in interfaces:
    -            if device_name.startswith(self.ignored_device_prefixes):
    +            self.logger.debug(f"Network interfaces: {[link.get('IFLA_IFNAME') for link in links]}")
    +        # Netlink names an address's device by index, so a label such as
    +        # "eth0:vip" never shows up as a device of its own.
    +        nics = {}
    +        for link in links:
    +            device_name = link.get("IFLA_IFNAME")
    +            if not device_name or device_name.startswith(self.ignored_device_prefixes):
                     continue
    -            try:
    -                nic = NIC(device_name)
    -            except Exception:
    -                if self.logger:
    -                    self.logger.exception(f"Error in interface {device_name}")
    +            nics[link["index"]] = NIC(device_name, link.get("IFLA_ADDRESS", ""))

    Kefu 🖖
    link.get("IFLA_ADDRESS", "") is not always a string. pyroute2 0.9 types IFLA_ADDRESS as l2addr, which only decodes a 6-byte MAC. On a shorter/longer hardware addresses that decode fails and get() returns the raw netlink bytes. See here

    fields = [('value', '=6s')]
    

    Those bytes are stored as NIC.mac_address (the annotation at line 922 says str) and later used as a Prometheus label in subsystem_listener_iface_info.
    Perhaps it is a good idea to normalize the raw netlink attribute get() returns when l2addr cannot decode it to string?
    def _link_address(raw) -> str:
        """Return a hardware address as colon-separated hex.
    
        pyroute2 0.9 decodes a 6-byte MAC to a string. A shorter/longer addresses
        fails that decode and get() returns the netlink attribute, header included.
        """
        ...
    
    nics[link["index"]] = NIC(device_name, _link_address(link.get("IFLA_ADDRESS", "")))
    

    baum baum approved these changes on Nov 04, 2026 06:16 UTC
    Approved Reviewer

    Approved these changes.

    tchaikov tchaikov commented on code on Nov 04, 2026 10:12 UTC
    Code Review
    control/utils.py:1
    @@ -812,26 +817,41 @@ def __init__(self, logger=None, handle_all=False):
             self._build_adapter_info()
     
         def _build_adapter_info(self):
    -        interfaces = netifaces.interfaces()
    +        with IPRoute() as ipr:
    +            links = ipr.get_links()
    +            addrs = ipr.get_addr()
             if self.logger:
    -            self.logger.debug(f"Network interfaces: {interfaces}")
    -        for device_name in interfaces:
    -            if device_name.startswith(self.ignored_device_prefixes):
    +            self.logger.debug(f"Network interfaces: {[link.get('IFLA_IFNAME') for link in links]}")
    +        # Netlink names an address's device by index, so a label such as
    +        # "eth0:vip" never shows up as a device of its own.
    +        nics = {}
    +        for link in links:
    +            device_name = link.get("IFLA_IFNAME")
    +            if not device_name or device_name.startswith(self.ignored_device_prefixes):
                     continue
    -            try:
    -                nic = NIC(device_name)
    -            except Exception:
    -                if self.logger:
    -                    self.logger.exception(f"Error in interface {device_name}")
    +            nics[link["index"]] = NIC(device_name, link.get("IFLA_ADDRESS", ""))

    @baum thanks for pointing this out. indeed. added the helper to normalize the addresses to str as suggested.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 04, 2026 10:14 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🔵 Needs a closer look

    The netlink backend affects listener validation, automatic selection, and metrics, requiring privileged-container testing with pyroute2 0.9.7, including gateway worker-thread use while the fatal SIGCHLD handler is installed.

    No open issues 🎉

    <sub>Review effort: Balanced</sub>

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 04, 2026 10:23 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🔵 Needs a closer look

    The netlink migration requires validation of the locked pyroute2 version in the unavailable Ceph/SPDK container, including gRPC-worker use and interaction with the gateway’s SIGCHLD handler.

    No open issues 🎉

    <sub>Review effort: Balanced</sub>

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 04, 2026 10:37 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    🟢 Approval recommended

    There are no active review issues for the listener IP validation change.

    No open issues 🎉

    <sub>Review effort: Balanced</sub>

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 17, 2026 02:54 UTC
    Reviewer

    Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

    An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

    tchaikov tchaikov commented on Nov 17, 2026 11:04 UTC
    Author

    @baum hello, do we need more testing before landing this PR?

    caroav caroav commented on Nov 17, 2026 12:56 UTC
    Contributor

    @baum hello, do we need more testing before landing this PR?

    @tchaikov it looks ok for merge

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Nov 17, 2026 13:16 UTC
    Reviewer

    Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

    An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

    Reviewers
    Assignees
    tchaikov tchaikov
    Labels
    risk: low confidence: 85.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.5% (MEDIUM) · Higher = larger blast radius
    42.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 85.4% · Lower = rushed or shallow review
    85.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 6.2% · Safe to merge
    6.2%