arehbein has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/29903 )
Change subject: gb/vty: Show if NSVC is blocked locally by O&M/vty or by remote ......................................................................
gb/vty: Show if NSVC is blocked locally by O&M/vty or by remote
Related: OS#5085
Change-Id: I0e8a12c3e54b701c9e697d50de1c9cb0bcc817e0 --- M src/gb/gprs_ns2_internal.h M src/gb/gprs_ns2_vc_fsm.c M src/gb/gprs_ns2_vty.c M tests/gb/gprs_ns2_vty.vty 4 files changed, 27 insertions(+), 23 deletions(-)
Approvals: Jenkins Builder: Verified daniel: Looks good to me, but someone else must approve dexter: Looks good to me, but someone else must approve arehbein: Looks good to me, approved
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h index 0959d2b..93aaa99 100644 --- a/src/gb/gprs_ns2_internal.h +++ b/src/gb/gprs_ns2_internal.h @@ -271,6 +271,9 @@ /*! recursive anchor */ bool freed;
+ /*! if blocked by O&M/vty */ + bool om_blocked; + /*! when the NSVC became alive or dead */ struct timespec ts_alive_change; }; diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c index 1db2a8e..9cd83c4 100644 --- a/src/gb/gprs_ns2_vc_fsm.c +++ b/src/gb/gprs_ns2_vc_fsm.c @@ -58,8 +58,6 @@ bool initiator; bool initiate_block; bool initiate_reset; - /* if blocked by O&M/vty */ - bool om_blocked; /* if unitdata is forwarded to the user */ bool accept_unitdata;
@@ -268,7 +266,7 @@ struct gprs_ns2_inst *nsi = priv->nsvc->nse->nsi;
priv->initiate_reset = priv->initiate_block = priv->initiator; - priv->om_blocked = false; + priv->nsvc->om_blocked = false;
switch (event) { case GPRS_NS2_EV_REQ_START: @@ -345,7 +343,7 @@ }
ns2_nse_notify_unblocked(priv->nsvc, false); - if (priv->om_blocked) { + if (priv->nsvc->om_blocked) { /* we are already blocked after a RESET */ if (old_state == GPRS_NS2_ST_RESET) { osmo_timer_del(&fi->timer); @@ -363,7 +361,7 @@ { struct gprs_ns2_vc_priv *priv = fi->priv;
- if (priv->om_blocked) { + if (priv->nsvc->om_blocked) { switch (event) { case GPRS_NS2_EV_RX_BLOCK_ACK: priv->accept_unitdata = false; @@ -563,7 +561,7 @@ case GPRS_NS2_ST_BLOCKED: if (priv->initiate_block) { priv->N++; - if (priv->om_blocked) { + if (priv->nsvc->om_blocked) { if (priv->N <= nsi->timeout[NS_TOUT_TNS_BLOCK_RETRIES]) { osmo_fsm_inst_state_chg(fi, GPRS_NS2_ST_BLOCKED, nsi->timeout[NS_TOUT_TNS_BLOCK], 0); } else { @@ -717,14 +715,14 @@ case GPRS_NS2_EV_REQ_OM_BLOCK: /* vty cmd: block */ priv->initiate_block = true; - priv->om_blocked = true; + priv->nsvc->om_blocked = true; osmo_fsm_inst_state_chg(fi, GPRS_NS2_ST_BLOCKED, nsi->timeout[NS_TOUT_TNS_BLOCK], 0); break; case GPRS_NS2_EV_REQ_OM_UNBLOCK: /* vty cmd: unblock*/ - if (!priv->om_blocked) + if (!priv->nsvc->om_blocked) return; - priv->om_blocked = false; + priv->nsvc->om_blocked = false; if (fi->state == GPRS_NS2_ST_BLOCKED) osmo_fsm_inst_state_chg(fi, GPRS_NS2_ST_BLOCKED, nsi->timeout[NS_TOUT_TNS_BLOCK], 0); break; @@ -834,7 +832,7 @@ int ns2_vc_block(struct gprs_ns2_vc *nsvc) { struct gprs_ns2_vc_priv *priv = nsvc->fi->priv; - if (priv->om_blocked) + if (priv->nsvc->om_blocked) return -EALREADY;
return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_BLOCK, NULL); @@ -846,7 +844,7 @@ int ns2_vc_unblock(struct gprs_ns2_vc *nsvc) { struct gprs_ns2_vc_priv *priv = nsvc->fi->priv; - if (!priv->om_blocked) + if (!priv->nsvc->om_blocked) return -EALREADY;
return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_UNBLOCK, NULL); diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c index 016199d..3046fff 100644 --- a/src/gb/gprs_ns2_vty.c +++ b/src/gb/gprs_ns2_vty.c @@ -1875,18 +1875,21 @@ void ns2_vty_dump_nsvc(struct vty *vty, struct gprs_ns2_vc *nsvc, bool stats) { if (nsvc->nsvci_is_valid) - vty_out(vty, " NSVCI %05u: %s %s %s %s since ", nsvc->nsvci, + vty_out(vty, " NSVCI %05u: %s %s %s %s %ssince ", nsvc->nsvci, osmo_fsm_inst_state_name(nsvc->fi), nsvc->persistent ? "PERSIST" : "DYNAMIC", gprs_ns2_ll_str(nsvc), - ns2_vc_is_unblocked(nsvc) ? "ALIVE" : "DEAD"); + ns2_vc_is_unblocked(nsvc) ? "ALIVE" : "DEAD", + nsvc->om_blocked ? "(blocked by O&M/vty) " : + !ns2_vc_is_unblocked(nsvc) ? "(cause: remote) " : ""); else - vty_out(vty, " %s %s sig_weight=%u data_weight=%u %s %s since ", + vty_out(vty, " %s %s sig_weight=%u data_weight=%u %s %s %ssince ", osmo_fsm_inst_state_name(nsvc->fi), nsvc->persistent ? "PERSIST" : "DYNAMIC", nsvc->sig_weight, nsvc->data_weight, gprs_ns2_ll_str(nsvc), - ns2_vc_is_unblocked(nsvc) ? "ALIVE" : "DEAD"); + ns2_vc_is_unblocked(nsvc) ? "ALIVE" : "DEAD", + !ns2_vc_is_unblocked(nsvc) ? "(cause: remote) " : "");
vty_out_uptime(vty, &nsvc->ts_alive_change); vty_out_newline(vty); diff --git a/tests/gb/gprs_ns2_vty.vty b/tests/gb/gprs_ns2_vty.vty index 4be10d5..8db5fb5 100644 --- a/tests/gb/gprs_ns2_vty.vty +++ b/tests/gb/gprs_ns2_vty.vty @@ -40,11 +40,11 @@ OsmoNSdummy# show ns NSEI 01234: UDP, DEAD since 0d 0h 0m 0s 1 NS-VC: - RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD since 0d 0h 0m 0s + RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD (cause: remote) since 0d 0h 0m 0s UDP bind: 127.0.0.14:42999 DSCP: 0 Priority: 0 IP-SNS signalling weight: 1 data weight: 1 1 NS-VC: - RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD since 0d 0h 0m 0s + RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD (cause: remote) since 0d 0h 0m 0s OsmoNSdummy# configure terminal OsmoNSdummy(config)# ns OsmoNSdummy(config-ns)# nse 1234 @@ -54,15 +54,15 @@ OsmoNSdummy# show ns NSEI 01234: UDP, DEAD since 0d 0h 0m 0s 3 NS-VC: - RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD since 0d 0h 0m 0s - RECOVERING PERSIST sig_weight=0 data_weight=9 udp)[127.0.0.14]:42999<>[127.0.0.16]:9496 DEAD since 0d 0h 0m 0s - RECOVERING PERSIST sig_weight=0 data_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.17]:9496 DEAD since 0d 0h 0m 0s + RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD (cause: remote) since 0d 0h 0m 0s + RECOVERING PERSIST sig_weight=0 data_weight=9 udp)[127.0.0.14]:42999<>[127.0.0.16]:9496 DEAD (cause: remote) since 0d 0h 0m 0s + RECOVERING PERSIST sig_weight=0 data_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.17]:9496 DEAD (cause: remote) since 0d 0h 0m 0s UDP bind: 127.0.0.14:42999 DSCP: 0 Priority: 0 IP-SNS signalling weight: 1 data weight: 1 3 NS-VC: - RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD since 0d 0h 0m 0s - RECOVERING PERSIST sig_weight=0 data_weight=9 udp)[127.0.0.14]:42999<>[127.0.0.16]:9496 DEAD since 0d 0h 0m 0s - RECOVERING PERSIST sig_weight=0 data_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.17]:9496 DEAD since 0d 0h 0m 0s + RECOVERING PERSIST sig_weight=1 data_weight=1 udp)[127.0.0.14]:42999<>[127.0.0.15]:9496 DEAD (cause: remote) since 0d 0h 0m 0s + RECOVERING PERSIST sig_weight=0 data_weight=9 udp)[127.0.0.14]:42999<>[127.0.0.16]:9496 DEAD (cause: remote) since 0d 0h 0m 0s + RECOVERING PERSIST sig_weight=0 data_weight=0 udp)[127.0.0.14]:42999<>[127.0.0.17]:9496 DEAD (cause: remote) since 0d 0h 0m 0s OsmoNSdummy# configure terminal OsmoNSdummy(config)# ns OsmoNSdummy(config-ns)# nse 1234