Skip to content

zebra: Allow redistribution events to pass reserved ranges - #20599

Merged
riw777 merged 2 commits into
FRRouting:masterfrom
donaldsharp:allow_redistribution_to_pass_reserved_ranges
Feb 13, 2026
Merged

zebra: Allow redistribution events to pass reserved ranges#20599
riw777 merged 2 commits into
FRRouting:masterfrom
donaldsharp:allow_redistribution_to_pass_reserved_ranges

Conversation

@donaldsharp

Copy link
Copy Markdown
Member

If allow-reserved-ranges has been configured, allow the redistribution event to be passed up to the interested protocol.

I ran into this while playing with 224/4 flavors of static routes and was trying to get the static route into bgp. BGP was allowing network XXX statements for the routes. So I do not see much of a difference here.

@donaldsharp

Copy link
Copy Markdown
Member Author

before we pull the trigger here in any direction, let's make sure we discuss this in tomorrows tech meeting.

@greptile-apps

greptile-apps Bot commented Jan 26, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

Modified zebra_check_addr() to respect the allow-reserved-ranges configuration for loopback (127.0.0.0/8) and Class D multicast (224.0.0.0/4) address ranges during route redistribution.

Key Changes:

  • Split the validation logic to check allow-reserved-ranges config for 127.x.x.x and Class D addresses
  • When allow-reserved-ranges is enabled, these previously-blocked ranges can now be redistributed to routing protocols (BGP, OSPF, etc.)
  • Link-local addresses (169.254.0.0/16) remain blocked regardless of configuration
  • Aligns zebra redistribution behavior with BGP's existing support for reserved ranges via network statements

Impact:

  • Enables use cases like redistributing static routes in reserved ranges (e.g., 224/4) to BGP when allow-reserved-ranges is configured
  • Maintains backward compatibility: default behavior (config disabled) unchanged
  • Consistent with the documented purpose of allow-reserved-ranges feature

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - it's a small, focused change with clear intent
  • The change is straightforward and logically sound, properly gating reserved range support behind an existing configuration flag. The modification correctly splits the validation logic to allow 127.x.x.x and Class D addresses when allow-reserved-ranges is enabled while maintaining the block on link-local addresses. The implementation aligns with the documented purpose of the feature and maintains backward compatibility (default behavior unchanged). One minor consideration: the PR description mentions 224/4 and BGP network statements, and while the change is consistent with BGP's behavior, it would be valuable to verify Class D multicast redistribution is the intended use case, as the documentation doesn't explicitly mention enabling Class D ranges.
  • No files require special attention - the single modified function is clean and the logic is correct

Important Files Changed

Filename Overview
zebra/zebra_rib.c Modified zebra_check_addr() to respect allow-reserved-ranges config for 127.x.x.x and Class D (224.x.x.x) addresses, enabling redistribution when configured

Sequence Diagram

sequenceDiagram
    participant Client as Protocol Client (BGP/OSPF/etc)
    participant Redistribute as zebra_redistribute_update()
    participant CheckAddr as zebra_check_addr()
    participant Config as allow-reserved-ranges Config
    
    Note over Redistribute: Route update received
    Redistribute->>CheckAddr: Check if address is valid for redistribution
    
    alt Address is 127.x.x.x or 224.x.x.x (Class D)
        CheckAddr->>Config: cmd_allow_reserved_ranges_get()
        
        alt allow-reserved-ranges enabled
            Config-->>CheckAddr: true
            CheckAddr-->>Redistribute: return 1 (valid)
            Redistribute->>Client: Send route update
        else allow-reserved-ranges disabled (default)
            Config-->>CheckAddr: false
            CheckAddr-->>Redistribute: return 0 (invalid)
            Note over Redistribute: Route filtered, not sent to client
        end
    else Address is link-local (169.254.x.x, non-Class E)
        CheckAddr-->>Redistribute: return 0 (always invalid)
        Note over Redistribute: Route filtered regardless of config
    else Other valid address
        CheckAddr-->>Redistribute: return 1 (valid)
        Redistribute->>Client: Send route update
    end
Loading

@ton31337 ton31337 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.

LGTM, but can we have a topotest?

@riw777 riw777 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.

looks good

@donaldsharp
donaldsharp force-pushed the allow_redistribution_to_pass_reserved_ranges branch from 2af3509 to 0988ab1 Compare January 28, 2026 13:16
@frrbot frrbot Bot added the tests Topotests, make check, etc label Jan 28, 2026
@github-actions github-actions Bot added size/M and removed size/XS labels Jan 28, 2026
@donaldsharp

Copy link
Copy Markdown
Member Author

topotest added

If `allow-reserved-ranges` has been configured, allow the
redistribution event to be passed up to the interested protocol.

I ran into this while playing with 224/4 flavors of static routes
and was trying to get the static route into bgp.  BGP was allowing
network XXX statements for the routes.  So I do not see much
of a difference here.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
The previous commit added the ability for zebra to pass the reserved
ranges up to interested protocols.  BGP is the only one that currently
accepts these values as far as I can tell at the moment.  Test that
redistribute X works with reserved ranges.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
@donaldsharp
donaldsharp force-pushed the allow_redistribution_to_pass_reserved_ranges branch from 0988ab1 to 19d18c5 Compare February 10, 2026 14:32
@github-actions github-actions Bot added size/L and removed size/M labels Feb 10, 2026
@riw777
riw777 merged commit aa1d58e into FRRouting:master Feb 13, 2026
19 checks passed
@donaldsharp
donaldsharp deleted the allow_redistribution_to_pass_reserved_ranges branch April 30, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

master size/L tests Topotests, make check, etc zebra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants