Skip to content

Remove gr_ prefix from internal headers and symbols - #586

Merged
rjarry merged 7 commits into
DPDK:mainfrom
rjarry:internal-symbols
Apr 4, 2026
Merged

Remove gr_ prefix from internal headers and symbols#586
rjarry merged 7 commits into
DPDK:mainfrom
rjarry:internal-symbols

Conversation

@rjarry

@rjarry rjarry commented Apr 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

This pull request removes the gr_ prefix from internal headers and symbols throughout the codebase, transitioning from external-style includes (<gr_*.h>) to local project includes ("*.h") and renaming public API functions and types accordingly.

Scope of Changes

Header Includes:

  • Replace external-style includes (<gr_config.h>, <gr_event.h>, <gr_log.h>, <gr_metrics.h>, <gr_queue.h>, <gr_vec.h>, <gr_sort.h>, <gr_id_pool.h>, <gr_cmocka.h>) with local project headers ("config.h", "event.h", "log.h", "metrics.h", "sys_queue.h", "vec.h", "sort.h", "id_pool.h", "_cmocka.h")

API Renames:

Module registration:

  • gr_register_module(struct gr_module *)module_register(struct module *)
  • struct gr_modulestruct module

Logging:

  • GR_LOG_TYPE(name)LOG_TYPE(name)
  • struct gr_log_typestruct log_type
  • gr_log_typeslog_types

Events:

  • gr_event_subscribe()event_subscribe()
  • gr_event_push()event_push()
  • gr_event_serializer()event_serializer()
  • gr_event_serialize()event_serialize()
  • Type: gr_event_sub_cb_tevent_sub_cb_t
  • Type: gr_event_serializer_cb_tevent_serializer_cb_t

Metrics:

  • gr_metrics_register()metrics_register()
  • gr_metrics_ctx_init()metrics_ctx_init()
  • gr_metrics_labels_add()metrics_labels_add()
  • gr_metric_emit()metric_emit()
  • gr_metric_emit_histogram()metric_emit_histogram()
  • gr_metrics_set_affinity()metrics_set_affinity()
  • gr_metrics_start() / gr_metrics_stop()metrics_start() / metrics_stop()
  • Type: struct gr_metrics_ctxstruct metrics_ctx
  • Type: struct gr_metrics_writerstruct metrics_writer
  • Type: struct gr_metrics_collectorstruct metrics_collector
  • Enum: enum gr_metric_typeenum metric_type (values GR_METRIC_*METRIC_*)

ID Pool:

  • gr_id_pool_* functions → id_pool_* functions
  • struct gr_id_poolstruct id_pool

API Handlers:

  • gr_api_handler() macro → api_handler() macro
  • __gr_api_handler()__api_handler()
  • gr_api_handler_funcapi_handler_func

Files Modified

Core infrastructure: main/api.c, main/config.h, main/event.c, main/event.h, main/log.c, main/log.h, main/metrics.c, main/metrics.h, main/module.c, main/module.h, main/id_pool.h, main/id_pool_test.c

Data structures: main/sort.c, main/sort.h, main/control_queue.c, main/dpdk.c, main/main.c, main/signals.c, main/unix.c

Test files: api/printf_test.c, api/string_test.c, main/vec_test.c, modules/infra/control/port_test.c, modules/infra/control/worker_test.c, modules/ip/datapath/ip_input.c, modules/ip6/datapath/ip6_input.c

Module control and datapath: All modules/ subdirectories including dhcp, infra, ip, ip6, ipip, l2, l4, policy, and srv6

Documentation: devtools/ai-instructions.md

Alterations to Exported Entities

Changes are systematic across modules but notably affect:

  • All public event subscription and serialization APIs
  • All public metrics collection and registration APIs
  • Module registration and initialization framework
  • All logging type registration macros
  • Public struct types for metrics, modules, and events

rjarry added 7 commits April 4, 2026 12:04
The gr_ prefix on symbols is meant to denote public API. The daemon
private headers in main/ are not part of the public API so the prefix
is misleading. Rename them to plain names and switch all includes
accordingly. Also rename gr_queue.h to sys_queue.h since queue.h would
be too generic.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
The metrics types and functions (gr_metrics_writer, gr_metrics_collector,
gr_metrics_register, gr_metric_emit, etc.) are internal to the daemon,
not part of the public API. Remove the gr_ prefix from all of them.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
The event subscription and notification functions (gr_event_subscribe,
gr_event_push, gr_event_serialize, etc.) and their associated types are
internal to the daemon. Remove the gr_ prefix from all of them.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
Rename gr_module to module, and gr_register_module() to
module_register(). These are internal to the daemon and do not belong
in the public API namespace.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
Rename gr_api_handler() to api_handler() and gr_api_handler_func to
api_handler_func. The handler registration mechanism is internal to the
daemon and not exposed in the public API.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
Rename GR_LOG_TYPE() to LOG_TYPE(), gr_log_type to log_type, and
gr_log_types to log_types. These are daemon-internal logging helpers
and not part of the public API.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
Rename gr_id_pool and all its functions (gr_id_pool_create,
gr_id_pool_destroy, gr_id_pool_get, gr_id_pool_put, etc.) to drop the
gr_ prefix. The ID pool is a daemon-internal utility, not part of the
public API.

Signed-off-by: Robin Jarry <rjarry@redhat.com>
@coderabbitai

coderabbitai Bot commented Apr 4, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request systematically refactors the codebase to decouple internal APIs from the gr_* namespace convention. The changes replace gr_-prefixed function names, type names, and macros with non-prefixed equivalents across logging, event dispatch, metrics, module registration, ID pooling, and related infrastructure. Include directives are updated from angle-bracket style (<gr_*.h>) to quote style ("*.h") for local headers. Affected modules include logging, event system, metrics collection, module initialization, control plane infrastructure, and datapath components. API handler registration, event serialization, and metrics collection callbacks are renamed accordingly. These changes propagate through main infrastructure, networking modules (DHCP, IPv4, IPv6, L2, L4, SRv6, policy), and their associated test files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
modules/ip/datapath/icmp_input.c (1)

25-25: ⚠️ Potential issue | 🔴 Critical

Critical: Buffer overflow vulnerability (pre-existing).

The array icmp_cb[UINT8_MAX] has size 255, with valid indices 0-254. However, icmp_type is a uint8_t that can be 255, causing out-of-bounds access at lines 57, 58, 77, and 80. A malformed ICMP packet with type 255 would trigger a buffer overflow.

🛡️ Proposed fix
-static control_queue_cb_t icmp_cb[UINT8_MAX];
+static control_queue_cb_t icmp_cb[UINT8_MAX + 1];

Note: This is a pre-existing issue, not introduced by this PR.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@modules/ip/datapath/icmp_input.c` at line 25, The icmp_cb array is sized as
UINT8_MAX (255) but is indexed by an uint8_t icmp_type which can be 255, causing
out-of-bounds access; fix by either allocating icmp_cb with space for all 256
values (use UINT8_MAX + 1 / 256 entries) or add an explicit bounds check before
any access using icmp_type (e.g., in the places that reference icmp_cb with
icmp_type) to reject/handle icmp_type == 255 safely; update the declaration of
icmp_cb and/or the indexing sites (references to icmp_cb and the icmp_type
usages) accordingly to prevent overflow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@modules/ip/datapath/icmp_input.c`:
- Line 25: The icmp_cb array is sized as UINT8_MAX (255) but is indexed by an
uint8_t icmp_type which can be 255, causing out-of-bounds access; fix by either
allocating icmp_cb with space for all 256 values (use UINT8_MAX + 1 / 256
entries) or add an explicit bounds check before any access using icmp_type
(e.g., in the places that reference icmp_cb with icmp_type) to reject/handle
icmp_type == 255 safely; update the declaration of icmp_cb and/or the indexing
sites (references to icmp_cb and the icmp_type usages) accordingly to prevent
overflow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9179bd97-cb7f-433d-a6e9-c892497e8fb6

📥 Commits

Reviewing files that changed from the base of the PR and between fd79ce9 and a848c71.

📒 Files selected for processing (101)
  • api/printf_test.c
  • api/string_test.c
  • devtools/ai-instructions.md
  • main/_cmocka.h
  • main/api.c
  • main/config.h
  • main/control_queue.c
  • main/dpdk.c
  • main/event.c
  • main/event.h
  • main/id_pool.h
  • main/id_pool_test.c
  • main/log.c
  • main/log.h
  • main/main.c
  • main/metrics.c
  • main/metrics.h
  • main/module.c
  • main/module.h
  • main/signals.c
  • main/sort.c
  • main/sort.h
  • main/sys_queue.h
  • main/unix.c
  • main/vec.h
  • main/vec_test.c
  • modules/dhcp/control/client.c
  • modules/dhcp/control/options.c
  • modules/dhcp/control/packet.c
  • modules/infra/api/affinity.c
  • modules/infra/api/iface.c
  • modules/infra/api/nexthop.c
  • modules/infra/api/stats.c
  • modules/infra/api/trace.c
  • modules/infra/control/bond.c
  • modules/infra/control/bond.h
  • modules/infra/control/ctlplane.c
  • modules/infra/control/graph.c
  • modules/infra/control/graph.h
  • modules/infra/control/group_nexthop.c
  • modules/infra/control/iface.c
  • modules/infra/control/iface.h
  • modules/infra/control/l3_nexthop.c
  • modules/infra/control/lacp.c
  • modules/infra/control/loopback.c
  • modules/infra/control/mempool.c
  • modules/infra/control/netlink.c
  • modules/infra/control/nexthop.c
  • modules/infra/control/nexthop.h
  • modules/infra/control/port.c
  • modules/infra/control/port_test.c
  • modules/infra/control/vlan.c
  • modules/infra/control/vrf.c
  • modules/infra/control/worker.c
  • modules/infra/control/worker.h
  • modules/infra/control/worker_test.c
  • modules/infra/datapath/control_input.c
  • modules/infra/datapath/control_output.c
  • modules/infra/datapath/drop.c
  • modules/infra/datapath/eth_input.c
  • modules/infra/datapath/iface_input.c
  • modules/infra/datapath/iface_output.c
  • modules/infra/datapath/loop_input.c
  • modules/infra/datapath/main_loop.c
  • modules/infra/datapath/port_rx.c
  • modules/infra/datapath/port_tx.c
  • modules/infra/datapath/snap_input.c
  • modules/infra/datapath/trace.c
  • modules/ip/control/address.c
  • modules/ip/control/icmp.c
  • modules/ip/control/nexthop.c
  • modules/ip/control/route.c
  • modules/ip/datapath/icmp_input.c
  • modules/ip/datapath/ip_input.c
  • modules/ip/datapath/ip_local.c
  • modules/ip/datapath/ip_output.c
  • modules/ip6/control/address.c
  • modules/ip6/control/icmp6.c
  • modules/ip6/control/nexthop.c
  • modules/ip6/control/route.c
  • modules/ip6/control/router_advert.c
  • modules/ip6/datapath/icmp6_input.c
  • modules/ip6/datapath/ip6_error.c
  • modules/ip6/datapath/ip6_input.c
  • modules/ip6/datapath/ip6_local.c
  • modules/ip6/datapath/ip6_output.c
  • modules/ip6/datapath/ndp_na_input.c
  • modules/ipip/control.c
  • modules/l2/control/bridge.c
  • modules/l2/control/fdb.c
  • modules/l2/control/flood.c
  • modules/l2/control/vxlan.c
  • modules/l4/l4_input_local.c
  • modules/policy/api/dnat44.c
  • modules/policy/api/snat44.c
  • modules/policy/control/conntrack.c
  • modules/policy/control/nat.h
  • modules/policy/control/snat44_dynamic.c
  • modules/policy/control/snat44_static.c
  • modules/srv6/control/route.c
  • modules/srv6/datapath/srv6_local.c

@rjarry
rjarry merged commit 2a482b2 into DPDK:main Apr 4, 2026
12 checks passed
@rjarry
rjarry deleted the internal-symbols branch April 4, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant