cli: merge ping{,6} and traceroute{,6} commands#577
Conversation
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>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThis pull request refactors ICMP CLI command handling from separate IPv4 and IPv6-specific subcommands ( 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. Comment |
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_opsdispatch table mechanism in the CLI infrastructure layer (modules/infra/cli/gr_cli_l3.h) with address-family-aware callbacks forpingandtraceroute. A registration functioncli_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.cimplements a singleicmpcontext with unifiedpingandtraceroutesubcommands. The dispatcher parses the destination argument as an IP address and selects the appropriate handler from the registeredcli_icmp_opsqueue based on address family match. Falls back toENOPROTOOPTerror if no handler supports the detected address family.IPv4 and IPv6 implementation refactoring
modules/ip/cli/icmp.c: Removesctx_init()function and directcli_contextregistration. Introduces staticcli_icmp_opsstructure withaf = GR_AF_IP4and registers viacli_icmp_ops_register(). Changes argument name from"IP"to"DEST"for consistency with dispatcher expectations.modules/ip6/cli/icmp6.c: Replacesping6/traceroute6CLI context registration with staticcli_icmp_opsstructure (af = GR_AF_IP6). Removes command schema and help metadata previously embedded inctx_init(), delegating to centralized context.Command removal and test updates
docs/meson.build: Removesping6andtraceroute6entries from hardcodedgrcli_commandslist for man page generation.smoke/ip6_builtin_icmp_test.sh: Replacesgrcli ping6andgrcli traceroute6invocations withgrcli pingandgrcli tracerouteon IPv6 destinations.smoke/ospf6_frr_manualtest.sh: Replaces final connectivity check fromgrcli ping6togrcli pingwith same IPv6 target.