Skip to content

More routing sanities - #1675

Merged
Fredi-raspall merged 5 commits into
mainfrom
pr/fredi/routing_sanities2
Jul 31, 2026
Merged

More routing sanities#1675
Fredi-raspall merged 5 commits into
mainfrom
pr/fredi/routing_sanities2

Conversation

@Fredi-raspall

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 30, 2026 14:42
@Fredi-raspall
Fredi-raspall requested a review from a team as a code owner July 30, 2026 14:42
@Fredi-raspall
Fredi-raspall requested review from daniel-noland and removed request for a team July 30, 2026 14:42
@Fredi-raspall Fredi-raspall added the ci:+vlab Enable VLAB tests label Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f3a5e8dd-bcd3-4b62-82b2-65bc793910a1

📥 Commits

Reviewing files that changed from the base of the PR and between 1e6642a and 92e31ee.

📒 Files selected for processing (1)
  • pipeline/src/sample_nfs.rs

📝 Walkthrough

Walkthrough

Changes

The routing path validates FIB entries before group insertion and supports egress creation from resolved addresses. RMAC updates report changes and trigger VNI-specific FIB refreshes only when needed. Packet egress metadata and packet dump logging use updated handling.

Routing and egress resolution

Layer / File(s) Summary
FIB accessors and entry validation
routing/src/fib/fibobjects.rs, routing/src/fib/fibgroupstore.rs
FibGroup entries use accessors, and FibEntry::is_valid() validates instruction sequences before storage.
Next-hop instruction and fibgroup construction
routing/src/rib/rib2fib.rs, routing/src/rib/nexthop.rs
Non-local nexthops emit Egress instructions when an interface or address exists. Invalid recursive entries are omitted, with Drop insertion for empty groups.
Packet egress metadata handling
dataplane/src/packet_processor/ipforward.rs
Egress execution assigns optional interface and address metadata and logs whether an outgoing interface is present.

RMAC refresh handling

Layer / File(s) Summary
RMAC update result and FIB refresh wiring
routing/src/evpn/rmac.rs, routing/src/router/cpi.rs
add_rmac_entry reports insertion or MAC replacement. Rmac::add refreshes FIBs for the entry VNI only when the store reports a change.

Packet dump logging

Layer / File(s) Summary
Packet dump target configuration
pipeline/src/sample_nfs.rs
PKT_DUMP_TARGET no longer inherits the pipeline target filter.

Possibly related PRs

Suggested reviewers: daniel-noland, copilot

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided, so its relevance to the changeset cannot be assessed. Add a concise description of the routing validation, next-hop handling, RMAC refresh, and related logging changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies routing sanity improvements, which match the primary changes in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@routing/src/rib/nexthop.rs`:
- Around line 919-962: Update test_nhop_instruction_build_and_fibroup so both
fibgroup entries are validated: collect the egress (ifindex, address) pair from
e1 and e2, then compare the resulting set or list against the two expected
interface/address pairs, preserving order independence and ensuring neither
entry can be incorrect.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ce183423-b6a4-44da-83c6-f79e5b6f13ca

📥 Commits

Reviewing files that changed from the base of the PR and between ce05789 and f4b99e1.

📒 Files selected for processing (5)
  • dataplane/src/packet_processor/ipforward.rs
  • routing/src/fib/fibgroupstore.rs
  • routing/src/fib/fibobjects.rs
  • routing/src/rib/nexthop.rs
  • routing/src/rib/rib2fib.rs

Comment thread routing/src/rib/nexthop.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens routing/FIB “sanity” behavior by ensuring unresolved or invalid next-hop resolution results don’t accidentally get committed as usable forwarding entries, and by making egress-resolution intent clearer through both code and tests.

Changes:

  • Emit Egress instructions for next-hops that have an address even when they don’t yet have an ifindex, enabling correct recursive resolution behavior.
  • Add FibEntry::is_valid() and use it during next-hop → fibgroup construction to ignore invalid leaf entries and only inject a DROP when the resulting group is empty.
  • Encapsulate FibGroup internals (private entries) and add safe accessors; update call sites and add new unit tests.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
routing/src/rib/rib2fib.rs Improves next-hop instruction generation and validates/sanitizes leaf fib entries before committing to groups.
routing/src/rib/nexthop.rs Adds new sanity/unit tests around instruction building and DROP insertion behavior.
routing/src/fib/fibobjects.rs Makes FibGroup.entries private, adds entries_mut(), and introduces FibEntry::is_valid().
routing/src/fib/fibgroupstore.rs Updates indexing and test helpers to use the new FibGroup accessors.
dataplane/src/packet_processor/ipforward.rs Simplifies egress metadata assignment and logs when an egress object lacks an outgoing interface.

Comment thread routing/src/rib/nexthop.rs Outdated
Comment thread routing/src/rib/nexthop.rs
Comment thread routing/src/fib/fibobjects.rs Outdated

@qmonnet qmonnet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd appreciate a comment to explain why a FIB entry is valid or not, but that's not blocking. Looks good otherwise, thanks!

Comment thread routing/src/fib/fibobjects.rs
Copilot AI review requested due to automatic review settings July 30, 2026 17:07
@Fredi-raspall
Fredi-raspall force-pushed the pr/fredi/routing_sanities2 branch from f4b99e1 to ba8a2e7 Compare July 30, 2026 17:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

routing/src/fib/fibobjects.rs:132

confidence: 8
tags: [style]

`FibGroup::entries_mut()` is only used from `#[cfg(test)]` code right now, but it’s exposed as a public API. This widens the public surface and lets callers arbitrarily mutate the internal `Vec`, undermining the intent of making `entries` private.

Consider restricting it to `pub(crate)` (or gating it under `#[cfg(test)]`) unless there’s a concrete external consumer that needs mutable access.
pub fn entries_mut(&mut self) -> &mut Vec<FibEntry> {
</details>

Copilot AI review requested due to automatic review settings July 31, 2026 11:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Suppressed comments (3)

routing/src/fib/fibobjects.rs:205

confidence: 10
tags: [logic]

`FibEntry::is_valid()` takes an extra reference to `self.instructions.last()`, making `inst` a `&&PktInstruction`. This is easy to miss and can lead to a compile error / incorrect matching; also `unwrap_or_else(|| unreachable!())` is redundant because this branch is only hit when `len() >= 2`.

Remove the extra `&` and simplify the branch to avoid the double-reference.
        _ => {
            let inst = &self.instructions.last().unwrap_or_else(|| unreachable!());
            match inst {
                PktInstruction::Egress(e) => e.ifindex().is_some(),
                _ => false,
**routing/src/fib/fibobjects.rs:132**
* ```yaml
confidence: 8
tags: [style]

FibGroup::entries_mut() is declared pub, which expands the public API to allow any downstream crate to mutate the internal Vec<FibEntry>. Since the only current use is within this crate’s tests, this should be pub(crate) to keep the encapsulation benefits of making entries private.

    pub fn entries_mut(&mut self) -> &mut Vec<FibEntry> {

routing/src/evpn/rmac.rs:90

confidence: 8
tags: [logic]

`RmacStore::add_rmac_entry()` documents “newly inserted or updated”, and it also decrements the stale counter when replacing a stale entry. However it currently returns `false` when the MAC is unchanged even if the previous entry was stale (i.e. the store state did change). Since callers (e.g. `router/cpi.rs`) use this boolean to decide whether to refresh VRF FIBs, stale→fresh replacements should return `true` as well.
        if let Some(stale_t) = &old.stale_t {
            debug!("The rmac was stale for {}s", stale_t.elapsed().as_secs());
            self.stale = self.stale.saturating_sub(1);
        }
        was_updated
</details>

Add method to validate a fib entries and replace by a drop if
the entry is not correct.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Let add_rmac_entry() report if the rmac added created a new entry
or updated one.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Force a vrf/fib refresh when we learn a new rmac or it changes.
FRR sends first rmacs and then the routes that depend on it, but
protecting dataplane against reordering is good.

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Copilot AI review requested due to automatic review settings July 31, 2026 13:10
@Fredi-raspall
Fredi-raspall force-pushed the pr/fredi/routing_sanities2 branch from 9e61422 to 1e6642a Compare July 31, 2026 13:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Suppressed comments (3)

routing/src/fib/fibobjects.rs:126

confidence: 10
tags: [docs]

Doc comment uses the incorrect pluralization "[`FibEntry`]ies"; it should be "[`FibEntry`]s".
pub fn entries(&self) -> &Vec<FibEntry> {
**routing/src/evpn/rmac.rs:70**
* ```yaml
confidence: 9
tags: [docs]

add_rmac_entry()’s doc says it returns true when an entry is “newly inserted or updated”, but the implementation returns false when the entry already exists and the MAC is unchanged (even though other fields like stale_t may differ). This makes the API contract ambiguous for callers (e.g., deciding whether to refresh dependent FIBs).

Consider tightening the doc to match the actual behavior (inserted or MAC-changed), or adjust the boolean computation if broader “updated” semantics are intended.

    /// Add a `RmacEntry` to the rmac store. This method never fails.
    /// Returns true if a `RmacEntry` was newly inserted or updated.
    //////////////////////////////////////////////////////////////////
    #[must_use]
    pub fn add_rmac_entry(&mut self, entry: RmacEntry) -> bool {

routing/src/rib/nexthop.rs:993

confidence: 8
tags: [docs]

This test comment attributes the DROP fib entry to the resulting `FibEntry` being “not valid”, but in this setup the resolver chain ends in an unresolved next-hop (`must_be_resolved()`), so the recursive builder returns early and `build_nhop_fibgroup()` injects a DROP because the fibgroup is empty. Updating the comment would make the test intent clearer.
    // check: the fibgroup for nh1 contains 1 fib entry drop, in spite of the egress instruction, since
    // the resulting fibentry would not be valid.
</details>

Signed-off-by: Fredi Raspall <fredi@githedgehog.com>
Copilot AI review requested due to automatic review settings July 31, 2026 16:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Suppressed comments (4)

routing/src/rib/nexthop.rs:963

confidence: 9
tags: [logic]

Same compilation issue here: `IpAddr::from_str(...)` requires the `FromStr` trait to be in scope in this module. Switching to `parse::<std::net::IpAddr>()` avoids the missing-import problem.
    assert!(matches!(&e1.instructions[0], PktInstruction::Egress(e)
            if e.ifindex().unwrap().to_u32() == 1 && e.address().unwrap() == IpAddr::from_str("10.0.0.1").unwrap()
            || e.ifindex().unwrap().to_u32() == 2 && e.address().unwrap() == IpAddr::from_str("10.0.1.1").unwrap()));
**routing/src/rib/nexthop.rs:966**
* ```yaml
confidence: 9
tags: [logic]

Same compilation issue here as well (IpAddr::from_str without importing FromStr into the tests module).

        assert!(matches!(&e2.instructions[0], PktInstruction::Egress(e)
                if e.ifindex().unwrap().to_u32() == 1 && e.address().unwrap() == IpAddr::from_str("10.0.0.1").unwrap()
                || e.ifindex().unwrap().to_u32() == 2 && e.address().unwrap() == IpAddr::from_str("10.0.1.1").unwrap()));

routing/src/rib/nexthop.rs:990

confidence: 9
tags: [logic]

`IpAddr::from_str(...)` here has the same missing-import issue inside the `tests` module; using `parse::<std::net::IpAddr>()` keeps it compiling without adding new `use` statements elsewhere.
    assert!(
        matches!(inst, PktInstruction::Egress(e) if e.address().unwrap() == IpAddr::from_str("7.0.0.1").unwrap())
    );
**routing/src/fib/fibobjects.rs:128**
* ```yaml
confidence: 10
tags: [docs]

Same pluralization typo in this doc comment ("[FibEntry]ies").

    /// Provide a reference to the vector of [`FibEntry`]ies in a [`FibGroup`]
    #[must_use]
    pub fn entries(&self) -> &Vec<FibEntry> {
        &self.entries
    }

Comment thread routing/src/rib/nexthop.rs
@Fredi-raspall
Fredi-raspall added this pull request to the merge queue Jul 31, 2026
Merged via the queue into main with commit e7c4e76 Jul 31, 2026
28 checks passed
@Fredi-raspall
Fredi-raspall deleted the pr/fredi/routing_sanities2 branch July 31, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:+vlab Enable VLAB tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants