pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/43156?usp=email )
Change subject: asp: Support setting timer xua beat 0 through VTY ......................................................................
asp: Support setting timer xua beat 0 through VTY
Previous VTY configured range for the set of tdefs in timer xua didn't allow to pass a 0 to it, which "timer xua beat 0" should be able to accept in order to disable heartbeat procedure on the ASP. In order to fix it: * Change VTY range to minimal accepted value to 0 for the whole tdef set. * Make sure the VTY command validates and rejects user trying to set a value outside the accepted range of the specific timer. * Set .min_val=1 in SS7_ASP_XUA_T_ACK, so it can't accept value 0. According to spec, T(ack) is always expected to be set, even if the resulting timeout may be handled by LM instead of simply retransmitting the packet. * Write vty tests to validate the restrictions are followed properly in the VTY.
Related: SYS#8156 Change-Id: Iadd7c6751ab09640fd2df214afa2ec87274a3210 --- M src/ss7_asp.c M src/ss7_asp_vty.c M tests/vty/osmo_stp_test.vty M tests/vty/ss7_asp_test.vty 4 files changed, 101 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/56/43156/1
diff --git a/src/ss7_asp.c b/src/ss7_asp.c index c47ee7c..5a47248 100644 --- a/src/ss7_asp.c +++ b/src/ss7_asp.c @@ -121,9 +121,10 @@
const struct osmo_tdef ss7_asp_xua_timer_defaults[SS7_ASP_XUA_TIMERS_LEN] = { { .T = SS7_ASP_XUA_T_ACK, .default_val = SS7_ASP_XUA_DEFAULT_T_ACK_SEC, .unit = OSMO_TDEF_S, - .desc = "Resend ASP Up/Down/Active/Inactive after timeout waiting for ASP Up/Down/Active/Inactive ACK (ASP role)(s)" }, + .desc = "T(ack): Resend ASP Up/Down/Active/Inactive after timeout waiting for ASP Up/Down/Active/Inactive ACK (ASP role) (s)", + .min_val = 1 }, { .T = SS7_ASP_XUA_T_BEAT, .default_val = SS7_ASP_XUA_DEFAULT_T_BEAT_SEC, .unit = OSMO_TDEF_S, - .desc = "Heartbeat Timer (0 = disabled) (s)" }, + .desc = "T(beat): Heartbeat Timer (0 = disabled) (s)" }, {} };
diff --git a/src/ss7_asp_vty.c b/src/ss7_asp_vty.c index c38b5b8..21d19d6 100644 --- a/src/ss7_asp_vty.c +++ b/src/ss7_asp_vty.c @@ -814,20 +814,34 @@ return CMD_SUCCESS; }
-/* timer xua <name> <1-999999> +/* timer xua <name> <0-999999> * (cmdstr and doc are dynamically generated from ss7_asp_xua_timer_names.) */ DEFUN_ATTR(asp_timer_xua, asp_timer_xua_cmd, NULL, NULL, CMD_ATTR_IMMEDIATE) { struct osmo_ss7_asp *asp = vty->index; enum ss7_asp_xua_timer timer = get_string_value(ss7_asp_xua_timer_names, argv[0]); + int rc; + unsigned long new_val = atoi(argv[1]);
if (timer <= 0 || timer >= SS7_ASP_XUA_TIMERS_LEN) { vty_out(vty, "%% Invalid timer: %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING; }
- osmo_tdef_set(asp->cfg.T_defs_xua, timer, atoi(argv[1]), OSMO_TDEF_S); + rc = osmo_tdef_set(asp->cfg.T_defs_xua, timer, new_val, OSMO_TDEF_S); + if (rc < 0) { + struct osmo_tdef *t = osmo_tdef_get_entry(asp->cfg.T_defs_xua, timer); + if (!t) + return CMD_WARNING; + if (!osmo_tdef_val_in_range(t, new_val)) { + char range_str[64]; + osmo_tdef_range_str_buf(range_str, sizeof(range_str), t); + vty_out(vty, "%% Timer %s value %lu is out of range %s%s", + argv[0], new_val, range_str, VTY_NEWLINE); + } + return CMD_WARNING; + } return CMD_SUCCESS; }
@@ -861,7 +875,7 @@ def->default_val); }
- osmo_talloc_asprintf(tall_vty_ctx, cmd_str, ") <1-999999>"); + osmo_talloc_asprintf(tall_vty_ctx, cmd_str, ") <0-999999>"); osmo_talloc_asprintf(tall_vty_ctx, doc_str, "Timer value, in seconds\n");
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty index 1b452c8..2dbd5b2 100644 --- a/tests/vty/osmo_stp_test.vty +++ b/tests/vty/osmo_stp_test.vty @@ -302,7 +302,7 @@ no destination-audit asp-active quirk (no_notify|daud_in_asp|snm_inactive) no quirk (no_notify|daud_in_asp|snm_inactive) - timer xua (ack|beat) <1-999999> + timer xua (ack|beat) <0-999999> timer lm (wait_asp_up|wait_notify|wait_notify_rkm|wait_rk_reg_resp) <1-999999> block no block @@ -386,6 +386,36 @@ ... end OsmoSTP(config-cs7-asp)# no shutdown + +OsmoSTP(config-cs7-asp)# ### Test ASP node timers +OsmoSTP(config-cs7-asp)# timer ? + xua Configure ASP default xua timer values + lm Configure ASP default lm timer values +OsmoSTP(config-cs7-asp)# timer xua ? + ack T(ack): Resend ASP Up/Down/Active/Inactive after timeout waiting for ASP Up/Down/Active/Inactive ACK (ASP role) (s) (default: 2) + beat T(beat): Heartbeat Timer (0 = disabled) (s) (default: 30) +OsmoSTP(config-cs7-asp)# timer xua beat 0 +OsmoSTP(config-cs7-asp)# show running-config +... + asp my-asp 12345 54321 m3ua +... + timer xua beat 0 +... +OsmoSTP(config-cs7-asp)# timer xua beat 5 +OsmoSTP(config-cs7-asp)# show running-config +... + asp my-asp 12345 54321 m3ua +... + timer xua beat 5 +... +OsmoSTP(config-cs7-asp)# timer xua beat 30 +OsmoSTP(config-cs7-asp)# show running-config +... + asp my-asp 12345 54321 m3ua +... !timer xua beat 30 +... + + OsmoSTP(config-cs7-asp)# exit % NOTE: Skipping automatic restart of ASP since an explicit '[no] shutdown' command was entered OsmoSTP(config-cs7)# as my-ass m3ua diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty index e93e037..f3193b6 100644 --- a/tests/vty/ss7_asp_test.vty +++ b/tests/vty/ss7_asp_test.vty @@ -298,7 +298,7 @@ no destination-audit asp-active quirk (no_notify|daud_in_asp|snm_inactive) no quirk (no_notify|daud_in_asp|snm_inactive) - timer xua (ack|beat) <1-999999> + timer xua (ack|beat) <0-999999> timer lm (wait_asp_up|wait_notify|wait_notify_rkm|wait_rk_reg_resp) <1-999999> block no block @@ -383,6 +383,55 @@ remote-ip 127.0.0.201 ... end + +ss7_asp_vty_test(config-cs7-asp)# ### Test ASP node timers +ss7_asp_vty_test(config-cs7-asp)# timer ? + xua Configure ASP default xua timer values + lm Configure ASP default lm timer values +ss7_asp_vty_test(config-cs7-asp)# timer xua ? + ack T(ack): Resend ASP Up/Down/Active/Inactive after timeout waiting for ASP Up/Down/Active/Inactive ACK (ASP role) (s) (default: 2) + beat T(beat): Heartbeat Timer (0 = disabled) (s) (default: 30) +ss7_asp_vty_test(config-cs7-asp)# timer xua ack 1 +ss7_asp_vty_test(config-cs7-asp)# show running-config +... + asp my-asp 12345 54321 m3ua +... + timer xua ack 1 +... +ss7_asp_vty_test(config-cs7-asp)# timer xua ack 2 +ss7_asp_vty_test(config-cs7-asp)# show running-config +... + asp my-asp 12345 54321 m3ua +... !timer xua ack 1 +... +ss7_asp_vty_test(config-cs7-asp)# timer xua ack 0 +% Timer ack value 0 is out of range [1 .. inf] +ss7_asp_vty_test(config-cs7-asp)# show running-config +... + asp my-asp 12345 54321 m3ua +... !timer xua ack 0 +... +ss7_asp_vty_test(config-cs7-asp)# timer xua beat 0 +ss7_asp_vty_test(config-cs7-asp)# show running-config +... + asp my-asp 12345 54321 m3ua +... + timer xua beat 0 +... +ss7_asp_vty_test(config-cs7-asp)# timer xua beat 5 +ss7_asp_vty_test(config-cs7-asp)# show running-config +... + asp my-asp 12345 54321 m3ua +... + timer xua beat 5 +... +ss7_asp_vty_test(config-cs7-asp)# timer xua beat 30 +ss7_asp_vty_test(config-cs7-asp)# show running-config +... + asp my-asp 12345 54321 m3ua +... !timer xua beat 30 +... + ss7_asp_vty_test(config-cs7-asp)# exit % NOTE: Make sure to use '[no] shutdown' command in 'asp' node in order to restart the ASP for new configs to be applied.