Skip to content

lib: use MTYPEs for northbound in several places - #20733

Merged
donaldsharp merged 1 commit into
FRRouting:masterfrom
mjstapp:nb_use_mtypes
Feb 10, 2026
Merged

lib: use MTYPEs for northbound in several places#20733
donaldsharp merged 1 commit into
FRRouting:masterfrom
mjstapp:nb_use_mtypes

Conversation

@mjstapp

@mjstapp mjstapp commented Feb 9, 2026

Copy link
Copy Markdown
Contributor

Stop using MTYPE_TMP in several places; use NB-specific MTYPEs for visibility.

Stop using MTYPE_TMP in several places, use NB-specific
MTYPEs for visibility.

Signed-off-by: Mark Stapp <mjs@cisco.com>
@mjstapp mjstapp added the libfrr label Feb 9, 2026
@github-actions github-actions Bot added size/M master rebase PR needs rebase labels Feb 9, 2026
@greptile-apps

greptile-apps Bot commented Feb 9, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

This PR replaces several MTYPE_TMP allocations in the northbound core and northbound CLI/VTY integration with NB-specific MTYPEs to improve memory-accounting visibility. Specifically, northbound config-change/callback allocations now use MTYPE_NB_CONFIG, transaction allocations use a new MTYPE_NB_TRANS, and the VTY pending command buffer uses a new exported MTYPE_NB_CMDS (declared in northbound_cli.h and freed in vty.c).

I did not find any allocation/free mismatches or build-breaking issues in the changed hunks; the new MTYPE declarations/definitions are consistent with the existing DECLARE_MTYPE/DEFINE_MTYPE patterns and the cross-file free in vty.c now matches the allocator’s MTYPE.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Changes are limited to memory-type tagging for existing allocations/frees; the modified sites keep correct allocation/free pairing and the only cross-file MTYPE is properly declared/defined via existing macros.
  • No files require special attention

Important Files Changed

Filename Overview
lib/northbound.c Replaces several northbound allocations/frees from MTYPE_TMP to NB-specific MTYPEs (NB_CONFIG/NB_TRANS) and adds NB_TRANS memtype; no allocation/free mismatches found.
lib/northbound_cli.c Introduces exported MTYPE_NB_CMDS and switches pending_cmds_buf allocation/realloc/free to it; matches free sites in vty.c; no issues found.
lib/northbound_cli.h Adds DECLARE_MTYPE(NB_CMDS) so vty.c can use MTYPE_NB_CMDS; header/API change is consistent with existing memory.h patterns.
lib/vty.c Switches pending_cmds_buf free from MTYPE_TMP to MTYPE_NB_CMDS to match northbound_cli.c allocation; include visibility relies on northbound_cli.h; no functional issues found.

Sequence Diagram

sequenceDiagram
    participant CLI as northbound_cli
    participant VTY as vty
    participant NB as northbound

    CLI->>VTY: Append pending commands
    Note over CLI,VTY: pending_cmds_buf allocated/realloc'd with MTYPE_NB_CMDS
    VTY->>VTY: vty_close() cleanup
    VTY->>VTY: XFREE(MTYPE_NB_CMDS, pending_cmds_buf)
    NB->>NB: Create config change
    Note over NB: XCALLOC/XFREE with MTYPE_NB_CONFIG
    NB->>NB: Create transaction
    Note over NB: XCALLOC/XFREE with MTYPE_NB_TRANS
Loading

@donaldsharp

Copy link
Copy Markdown
Member

LGTM, I'll get in once CI finishes

@donaldsharp
donaldsharp merged commit fd70171 into FRRouting:master Feb 10, 2026
23 checks passed
@mjstapp
mjstapp deleted the nb_use_mtypes branch February 23, 2026 17:17
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.

3 participants