Skip to content

Rename *_prefix_match to *_prefix_contains#22162

Open
donaldsharp wants to merge 2 commits into
FRRouting:masterfrom
donaldsharp:prefix_contains
Open

Rename *_prefix_match to *_prefix_contains#22162
donaldsharp wants to merge 2 commits into
FRRouting:masterfrom
donaldsharp:prefix_contains

Conversation

@donaldsharp
Copy link
Copy Markdown
Member

Rename:

a) prefix_match to prefix_contains. This better encapsulates what this function is doing. I have to look up what this function does every time because the name does not make 100% sense to me. Let's name it better
b) evpn_type5_prefix_match to evpn_type5_prefix_contains. Same reasoning.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Jun 2, 2026

Greptile Summary

This PR performs a global rename of prefix_matchprefix_contains and evpn_type5_prefix_matchevpn_type5_prefix_contains across 39 files, improving clarity by making it explicit that the function checks whether one prefix contains another rather than just "matching" in an ambiguous sense.

  • The rename is purely mechanical — function signatures, call sites, and the CONNECTED_ID macro in lib/if.h are all updated with no logic changes.
  • One inline comment in zebra/zebra_srv6.c (line 1333) still references the old name prefix_match and was missed by the rename sweep.

Confidence Score: 4/5

Safe to merge — the rename is purely cosmetic with no behavioural changes anywhere in the codebase.

Every call site and the function declarations were updated correctly. The only gap is a single stale comment in zebra_srv6.c that still says "prefix_match" instead of "prefix_contains", which has no runtime impact.

zebra/zebra_srv6.c — one comment at line 1333 still references the old name.

Important Files Changed

Filename Overview
lib/prefix.h Core header: renames prefix_match → prefix_contains and evpn_type5_prefix_match → evpn_type5_prefix_contains in declarations; also clarifies parameter names in the evpn variant.
lib/prefix.c Core implementation: function bodies renamed along with parameters; logic is unchanged.
lib/table.c Six call sites renamed; one blank line removed inside an if-block, otherwise purely mechanical.
lib/if.h CONNECTED_ID macro updated to use prefix_contains; trailing whitespace adjusted in the macro continuation lines.
bgpd/rfapi/rfapi_import.c Two call sites renamed; surrounding debug log strings also updated to reflect the new function name.
zebra/zebra_srv6.c Seven call sites renamed correctly, but one inline comment at line 1333 still references the old name "prefix_match" instead of "prefix_contains".
bgpd/bgp_debug.c Three call sites renamed with minor reformatting; logic unchanged.
bgpd/bgp_route.c Two sites renamed (one prefix_match, one evpn_type5_prefix_match); logic unchanged.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["prefix_contains(unetwork, uprefix)\nlib/prefix.c"] --> B["Returns 1 if unetwork contains uprefix\n(prefixlen check + byte mask compare)"]
    C["evpn_type5_prefix_contains(n, p)\nlib/prefix.c"] --> D["Returns 1 if n contains p\n(EVPN type-5 ip-prefix variant)"]

    E[Callers - bgpd] --> A
    F[Callers - zebra] --> A
    G[Callers - ospfd/ospf6d] --> A
    H[Callers - pimd/ripd/ldpd/nhrpd] --> A
    I[Callers - isisd/staticd] --> A
    J[Callers - lib filter/plist/table/if] --> A
    K[bgpd/bgp_route.c] --> C
Loading

Comments Outside Diff (1)

  1. zebra/zebra_srv6.c, line 1333-1334 (link)

    P2 This comment still references the old function name prefix_match after the rename. It should say prefix_contains to stay consistent with the code below it.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: zebra/zebra_srv6.c
    Line: 1333-1334
    
    Comment:
    This comment still references the old function name `prefix_match` after the rename. It should say `prefix_contains` to stay consistent with the code below it.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
zebra/zebra_srv6.c:1333-1334
This comment still references the old function name `prefix_match` after the rename. It should say `prefix_contains` to stay consistent with the code below it.

```suggestion
	 * This temporary prefix object is used below by the prefix_contains
	 * function to check if the SID belongs to a specific locator.
```

Reviews (1): Last reviewed commit: "lib, bgpd: Rename evpn_type5_prefix_matc..." | Re-trigger Greptile

prefix_match is not really a great name for what it is doing.
This function is actually checking that the first parameter contains
the second parameter as a prefix.  Let's name it something better
such that people will auto know what it is doing immediately.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This is a network check to see if the first parameter
contains the second parameter.  Let's name it better.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Copy link
Copy Markdown
Member

@riw777 riw777 left a comment

Choose a reason for hiding this comment

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

looks good ... the one ai comment seems valid

@riw777
Copy link
Copy Markdown
Member

riw777 commented Jun 2, 2026

This seems like it might need to be fixed?

< WARNING: braces {} are not necessary for single statement blocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants