pespin has uploaded this change for review.
asp: vty: Explicitly test timer lm value ranges
Validate the value to be set provided by user over VTY is actually
within the range of the specific tdef being set.
Mark all of them explicitly as min_val=1 in its tdef, since they are not
expected to be set to 0 (see also gen_asp_timer_lm_cmd_strs() defining a
VTY range <1..999999>).
Change-Id: I9b2c426a1eaceb6e7c5fbe35872ada324fef5733
---
M src/ss7_asp_vty.c
M src/xua_default_lm_fsm.c
M tests/vty/osmo_stp_test.vty
M tests/vty/ss7_asp_test.vty
4 files changed, 34 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/57/43157/1
diff --git a/src/ss7_asp_vty.c b/src/ss7_asp_vty.c
index 21d19d6..5136105 100644
--- a/src/ss7_asp_vty.c
+++ b/src/ss7_asp_vty.c
@@ -891,13 +891,27 @@
{
struct osmo_ss7_asp *asp = vty->index;
enum ss7_asp_lm_timer timer = get_string_value(ss7_asp_lm_timer_names, argv[0]);
+ int rc;
+ unsigned long new_val = atoi(argv[1]);
if (timer <= 0 || timer >= SS7_ASP_LM_TIMERS_LEN) {
vty_out(vty, "%% Invalid timer: %s%s", argv[0], VTY_NEWLINE);
return CMD_WARNING;
}
- osmo_tdef_set(asp->cfg.T_defs_lm, timer, atoi(argv[1]), OSMO_TDEF_S);
+ rc = osmo_tdef_set(asp->cfg.T_defs_lm, timer, new_val, OSMO_TDEF_S);
+ if (rc < 0) {
+ struct osmo_tdef *t = osmo_tdef_get_entry(asp->cfg.T_defs_lm, 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;
}
diff --git a/src/xua_default_lm_fsm.c b/src/xua_default_lm_fsm.c
index 73c4fdc..db84e6e 100644
--- a/src/xua_default_lm_fsm.c
+++ b/src/xua_default_lm_fsm.c
@@ -102,13 +102,17 @@
const struct osmo_tdef ss7_asp_lm_timer_defaults[SS7_ASP_LM_TIMERS_LEN] = {
{ .T = SS7_ASP_LM_T_WAIT_ASP_UP, .default_val = 20, .unit = OSMO_TDEF_S,
- .desc = "Restart ASP after timeout waiting for ASP UP (SG role) / ASP UP ACK (ASP role) (s)" },
+ .desc = "Restart ASP after timeout waiting for ASP UP (SG role) / ASP UP ACK (ASP role) (s)",
+ .min_val = 1 },
{ .T = SS7_ASP_LM_T_WAIT_NOTIFY, .default_val = 2, .unit = OSMO_TDEF_S,
- .desc = "Restart ASP after timeout waiting for NOTIFY (s)" },
+ .desc = "Restart ASP after timeout waiting for NOTIFY (s)",
+ .min_val = 1 },
{ .T = SS7_ASP_LM_T_WAIT_NOTIY_RKM, .default_val = 20, .unit = OSMO_TDEF_S,
- .desc = "Restart ASP after timeout waiting for NOTIFY after RKM registration (s)" },
+ .desc = "Restart ASP after timeout waiting for NOTIFY after RKM registration (s)",
+ .min_val = 1 },
{ .T = SS7_ASP_LM_T_WAIT_RK_REG_RESP, .default_val = 10, .unit = OSMO_TDEF_S,
- .desc = "Restart ASP after timeout waiting for RK_REG_RESP (s)" },
+ .desc = "Restart ASP after timeout waiting for RK_REG_RESP (s)",
+ .min_val = 1 },
{}
};
diff --git a/tests/vty/osmo_stp_test.vty b/tests/vty/osmo_stp_test.vty
index 2dbd5b2..d52ae5f 100644
--- a/tests/vty/osmo_stp_test.vty
+++ b/tests/vty/osmo_stp_test.vty
@@ -415,6 +415,11 @@
... !timer xua beat 30
...
+OsmoSTP(config-cs7-asp)# timer lm ?
+ wait_asp_up Restart ASP after timeout waiting for ASP UP (SG role) / ASP UP ACK (ASP role) (s) (default: 20)
+ wait_notify Restart ASP after timeout waiting for NOTIFY (s) (default: 2)
+ wait_notify_rkm Restart ASP after timeout waiting for NOTIFY after RKM registration (s) (default: 20)
+ wait_rk_reg_resp Restart ASP after timeout waiting for RK_REG_RESP (s) (default: 10)
OsmoSTP(config-cs7-asp)# exit
% NOTE: Skipping automatic restart of ASP since an explicit '[no] shutdown' command was entered
diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty
index f3193b6..5ea965b 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -432,6 +432,12 @@
... !timer xua beat 30
...
+ss7_asp_vty_test(config-cs7-asp)# timer lm ?
+ wait_asp_up Restart ASP after timeout waiting for ASP UP (SG role) / ASP UP ACK (ASP role) (s) (default: 20)
+ wait_notify Restart ASP after timeout waiting for NOTIFY (s) (default: 2)
+ wait_notify_rkm Restart ASP after timeout waiting for NOTIFY after RKM registration (s) (default: 20)
+ wait_rk_reg_resp Restart ASP after timeout waiting for RK_REG_RESP (s) (default: 10)
+
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.
To view, visit change 43157. To unsubscribe, or for help writing mail filters, visit settings.