Skip to content

cli: merge ping{,6} and traceroute{,6} commands#577

Open
rjarry wants to merge 1 commit intoDPDK:mainfrom
rjarry:ping
Open

cli: merge ping{,6} and traceroute{,6} commands#577
rjarry wants to merge 1 commit intoDPDK:mainfrom
rjarry:ping

Conversation

@rjarry
Copy link
Copy Markdown
Collaborator

@rjarry rjarry commented Mar 26, 2026

The IPv4 and IPv6 ping/traceroute commands share the same argument structure. Introduce a cli_icmp_ops dispatch table in the infra CLI so that a single "ping" and "traceroute" command handles both address families, selected automatically based on the destination address format.

Register per-family callbacks via cli_icmp_ops_register() instead of creating separate CLI contexts. Remove the ping6 and traceroute6 commands from the CLI and update smoke tests accordingly.

Command consolidation via dispatch table

Introduces a cli_icmp_ops dispatch table mechanism in the CLI infrastructure layer (modules/infra/cli/gr_cli_l3.h) with address-family-aware callbacks for ping and traceroute. A registration function cli_icmp_ops_register() allows per-family implementations to register their handlers without creating separate CLI command contexts.

Centralized ICMP CLI context

New modules/infra/cli/icmp.c implements a single icmp context with unified ping and traceroute subcommands. The dispatcher parses the destination argument as an IP address and selects the appropriate handler from the registered cli_icmp_ops queue based on address family match. Falls back to ENOPROTOOPT error if no handler supports the detected address family.

IPv4 and IPv6 implementation refactoring

  • modules/ip/cli/icmp.c: Removes ctx_init() function and direct cli_context registration. Introduces static cli_icmp_ops structure with af = GR_AF_IP4 and registers via cli_icmp_ops_register(). Changes argument name from "IP" to "DEST" for consistency with dispatcher expectations.
  • modules/ip6/cli/icmp6.c: Replaces ping6/traceroute6 CLI context registration with static cli_icmp_ops structure (af = GR_AF_IP6). Removes command schema and help metadata previously embedded in ctx_init(), delegating to centralized context.

Command removal and test updates

  • docs/meson.build: Removes ping6 and traceroute6 entries from hardcoded grcli_commands list for man page generation.
  • smoke/ip6_builtin_icmp_test.sh: Replaces grcli ping6 and grcli traceroute6 invocations with grcli ping and grcli traceroute on IPv6 destinations.
  • smoke/ospf6_frr_manualtest.sh: Replaces final connectivity check from grcli ping6 to grcli ping with same IPv6 target.

The IPv4 and IPv6 ping/traceroute commands share the same argument
structure. Introduce a cli_icmp_ops dispatch table in the infra CLI
so that a single "ping" and "traceroute" command handles both address
families, selected automatically based on the destination address
format.

Register per-family callbacks via cli_icmp_ops_register() instead of
creating separate CLI contexts. Remove the ping6 and traceroute6
commands from the CLI and update smoke tests accordingly.

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

coderabbitai bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 959397c0-3b12-4849-a8ad-868e4aa3f6cf

📥 Commits

Reviewing files that changed from the base of the PR and between a5520bf and b5aeacd.

📒 Files selected for processing (8)
  • docs/meson.build
  • modules/infra/cli/gr_cli_l3.h
  • modules/infra/cli/icmp.c
  • modules/infra/cli/meson.build
  • modules/ip/cli/icmp.c
  • modules/ip6/cli/icmp6.c
  • smoke/ip6_builtin_icmp_test.sh
  • smoke/ospf6_frr_manualtest.sh

📝 Walkthrough

Walkthrough

This pull request refactors ICMP CLI command handling from separate IPv4 and IPv6-specific subcommands (ping6, traceroute6) into unified ping and traceroute commands. A new generic ICMP context module is introduced in modules/infra/cli/icmp.c that maintains a registry of address-family-specific implementations via cli_icmp_ops structures. IPv4 and IPv6 implementations register their handlers through this registry rather than registering their own contexts directly. The command dispatcher selects the appropriate handler based on the destination IP address's address family. Build configuration and test scripts are updated accordingly to use the unified command names.


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.

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