From 52779651904eba48c97af54b1f3924a38c1086ab Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Mon, 18 Mar 2024 17:19:49 +0700 Subject: e1line_dump_vty(): dump keepalive state and params There is currently no obvious way to know if the keepalive is enabled and which parameters are in use. Executing 'show running-config' command in the VTY would not always reveal the current configuration, because it tends to omit parameters with default values. Let's print the keepalive state and params in the output of the 'show e1_line' command. Below is a few examples: ! keepalive is disabled OsmoBSC# show e1_line E1 Line Number 0, Name , Driver ipa Keepalive: disabled IPA Keepalive: disabled ! TCP Keepalive is enabled (default) OsmoBSC# show e1_line E1 Line Number 0, Name , Driver ipa Keepalive: enabled Number of probes: (driver's default) Idle timeout: (driver's default) Probe interval: (driver's default) IPA Keepalive: disabled ! TCP and IPA keepalive enabled (custom params) OsmoBSC# show e1_line E1 Line Number 0, Name , Driver ipa Keepalive: enabled Number of probes: 2 Idle timeout: 1s Probe interval: 3s IPA Keepalive: enabled Interval: 2s Timeout: 10s Note that in the case of TCP keepalive with default parameters we cannot retrieve the actual defaults because that would be a layering violation. Thus we say "(driver's default)". Change-Id: I17bd991850333ee794ab216f474b5e045fb01fa3 Related: OS#6375, SYS#6801 --- src/e1_input_vty.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index ca45f93..b1898dd 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -457,12 +457,59 @@ DEFUN(show_e1drv, return CMD_SUCCESS; } +static void e1line_ka_dump_vty(struct vty *vty, const struct e1inp_line *line) +{ + if (line->keepalive_num_probes == 0) { + vty_out(vty, "Keepalive: disabled%s", VTY_NEWLINE); + return; + } + + vty_out(vty, "Keepalive: enabled%s", VTY_NEWLINE); + + vty_out(vty, " Number of probes: "); + if (line->keepalive_num_probes != E1INP_USE_DEFAULT) + vty_out(vty, "%d", line->keepalive_num_probes); + else + vty_out(vty, "(driver's default)"); + vty_out(vty, "%s", VTY_NEWLINE); + + vty_out(vty, " Idle timeout: "); + if (line->keepalive_idle_timeout != E1INP_USE_DEFAULT) + vty_out(vty, "%ds", line->keepalive_idle_timeout); + else + vty_out(vty, "(driver's default)"); + vty_out(vty, "%s", VTY_NEWLINE); + + vty_out(vty, " Probe interval: "); + if (line->keepalive_probe_interval != E1INP_USE_DEFAULT) + vty_out(vty, "%ds", line->keepalive_probe_interval); + else + vty_out(vty, "(driver's default)"); + vty_out(vty, "%s", VTY_NEWLINE); +} + +static void e1line_ipa_ka_dump_vty(struct vty *vty, const struct e1inp_line *line) +{ + if (line->ipa_kap == NULL) { + vty_out(vty, "IPA Keepalive: disabled%s", VTY_NEWLINE); + return; + } + + vty_out(vty, "IPA Keepalive: enabled%s", VTY_NEWLINE); + vty_out(vty, " Interval: %us%s", line->ipa_kap->interval, VTY_NEWLINE); + vty_out(vty, " Timeout: %us%s", line->ipa_kap->wait_for_resp, VTY_NEWLINE); +} + static void e1line_dump_vty(struct vty *vty, struct e1inp_line *line, int stats) { vty_out(vty, "E1 Line Number %u, Name %s, Driver %s%s", line->num, line->name ? line->name : "", line->driver->name, VTY_NEWLINE); + if (line->driver->has_keepalive) + e1line_ka_dump_vty(vty, line); + if (!strcmp(line->driver->name, "ipa")) + e1line_ipa_ka_dump_vty(vty, line); if (line->pcap_file) vty_out(vty, "PCAP %s%s", line->pcap_file, VTY_NEWLINE); if (line->driver->vty_show) -- cgit v1.2.3