← Back to Pull requests

apis: derive routing tables from a range of 10^9 IDs #407

Merged
NopeCharon merged 4 files (69 lines) on Oct 31, 2026 00:53 UTC
View on GitHub
NopeCharon NopeCharon commented on Oct 30, 2026 04:51 UTC
Author

What type of PR is this?

/kind bug

What this PR does / why we need it:

TableIDForName picked a routing table with fnv32a(name) % 1000 + 1000. The VRF default table, the GCE per-NIC tables (from the MAC) and the Alibaba per-bond tables all come from it, so two devices of one pod can get the same table. The second route to the same destination then fails with EEXIST, which the driver ignores, and traffic from the second device leaves through the first one. Some real names always clash, e.g. eth0/eth13 (1812) and vrf26/vrf39 (1777).

As suggested in the issue, this takes the hash modulo 2^30 (RouteTableRange) instead of 1000. Derived tables stay above RouteTableOffset (so away from the reserved tables 0 and 253-255) and below 2^31, so they fit in an int on every platform and in the kernel's u32 table ID. For 16 devices in one pod the chance of a clash goes from about 11% to about 10^-7.

The new TestTableIDForName checks the range, determinism, and that interface names, bond names, VRF names and GCE-style MACs that one pod can use together get different tables. It fails with the old modulus.

Which issue(s) this PR is related to:

Fixes #344

Special notes for your reviewer:

  • Tables of pods that are already running are not touched. Only devices configured after the upgrade get the new IDs, and claims that set vrf.table explicitly are unaffected.

  • I checked the kernel side in a privileged container with netlink: the eth0/eth13 setup from the issue now gets tables 739692812 and 402149812, ip route get 8.8.8.8 from <addr> resolves through each NIC's own gateway, and a VRF created with a derived table (356731777) reports that table back.

  • go test ./pkg/apis/... ./pkg/cloudprovider/... and golangci-lint v2.9.0 on the changed packages pass.

  • The OKE comment that cited the old 1000-1999 range is updated.
  • Does this PR introduce a user-facing change?

    ``release-note
    Routing table IDs that DRANET derives from names (the default VRF table, and the GCE and Alibaba per-device tables) now come from the range 1000 to 1073742823 instead of 1000 to 1999, so two devices of one pod no longer share a table by accident.
    ``

    Diff: 69 lines (+66 / -3) across 4 files Reviewer: aojea Review duration: 1202m
    All Vouch review confidence checks passed
    Residual risk 0.04 = Change Risk (0.33) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.33 · 69 lines diff across 4 files
    0.33
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.90 · 5 substantive comment(s)
    0.90
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    87%
    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.254
    Real PR Conversation Timeline
    9 items
    netlify[bot] netlify[bot] commented on Oct 30, 2026 04:51 UTC
    Bot

    <span aria-hidden="true">✅</span> Deploy Preview for dranet canceled.

    | Name | Link |
    |:-:|------------------------|
    |<span aria-hidden="true">🔨</span> Latest commit | 21d574cf4758dcf6d3c14e486be7e657063ddf5b |
    |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/dranet/deploys/6ae49e541bd7438a7765cd1b |

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Oct 30, 2026 04:51 UTC
    Bot

    Welcome @NopeCharon! <br><br>It looks like this is your first PR to <a href='https://github.com/kubernetes-sigs/dranet'>kubernetes-sigs/dranet</a> 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval. <br><br>You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation. <br><br>You can also check if kubernetes-sigs/dranet has its own contribution guidelines. <br><br>You may want to refer to our testing guide if you run into trouble with your tests not passing. <br><br>If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs! <br><br>Thank you, and welcome to Kubernetes. :smiley:

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Oct 30, 2026 04:51 UTC
    Bot

    Hi @NopeCharon. Thanks for your PR.

    I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

    Regular contributors should join the org to skip this step.

    Once the patch is verified, the new status will be reflected by the ok-to-test label.

    I understand the commands that are listed here.

    <details>

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
    </details>

    aojea aojea commented on code on Oct 30, 2026 13:25 UTC
    Code Review
    pkg/apis/constants.go:1
    @@ -35,6 +35,12 @@ const (
     	// tables (0, 253, 254, 255) and to identify DRANET managed tables.
     	RouteTableOffset = 1000
     
    +	// RouteTableRange is the number of routing table IDs, starting at
    +	// RouteTableOffset, that DRANET derives from names. The range is wide so
    +	// that two devices of one pod are unlikely to hash to the same table, and
    +	// small enough that every derived ID fits in an int32.
    +	RouteTableRange = 1_000_000_000

    	// RouteTableRange is the number of routing table IDs, starting at
    	// RouteTableOffset, that DRANET derives from names (1 << 30 = 1,073,741,824).
    	// By the birthday paradox, for k = 16 devices in one pod (C(16,2) = 120 pairs),
    	// the collision probability is ~120 / 2^30 ≈ 1.1e-7, while every derived ID
    	// (RouteTableOffset + [0, 2^30)) still fits in a signed int32.
    	RouteTableRange = 1 << 30
    

    aojea aojea commented on Oct 30, 2026 13:26 UTC
    Contributor

    /ok-to-test

    @NopeCharon please amend the change suggested and we are good to go, just one commit please

    NopeCharon NopeCharon commented on code on Oct 30, 2026 13:40 UTC
    Code Review
    pkg/apis/constants.go:1
    @@ -35,6 +35,12 @@ const (
     	// tables (0, 253, 254, 255) and to identify DRANET managed tables.
     	RouteTableOffset = 1000
     
    +	// RouteTableRange is the number of routing table IDs, starting at
    +	// RouteTableOffset, that DRANET derives from names. The range is wide so
    +	// that two devices of one pod are unlikely to hash to the same table, and
    +	// small enough that every derived ID fits in an int32.
    +	RouteTableRange = 1_000_000_000

    Applied the suggestion as is and squashed it into the single commit, so RouteTableRange is now 1 << 30.

    aojea aojea commented on Oct 31, 2026 00:39 UTC
    Contributor

    /ok-to-test
    /lgtm
    /approve

    kubernetes-prow[bot] kubernetes-prow[bot] commented on Oct 31, 2026 00:39 UTC
    Bot

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: <a href="https://github.com/kubernetes-sigs/dranet/pull/407#issuecomment-6536632027" title="Approved">aojea</a>, <a href="https://github.com/kubernetes-sigs/dranet/pull/407#" title="Author self-approved">NopeCharon</a>

    The full list of commands accepted by this bot can be found here.

    The pull request process is described here

    <details >
    Needs approval from an approver in each of these files:

  • ~~OWNERS~~ [aojea]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    Reviewers
    Assignees
    NopeCharon NopeCharon
    Labels
    risk: low confidence: 87.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: 32.8% (LOW) · Higher = larger blast radius
    32.8%
    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: 87.4% · Lower = rushed or shallow review
    87.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: 4.1% · Safe to merge
    4.1%