gb/vty: Show if an NSVC is locally blocked or blocked by remote

Related: OS#5085

Change-Id: I0e8a12c3e54b701c9e697d50de1c9cb0bcc817e0
This commit is contained in:
Alexander Rehbein 2022-10-27 15:34:04 +02:00 committed by arehbein
parent 19bd12e919
commit d00b272a67
4 changed files with 29 additions and 27 deletions

View File

@ -99,6 +99,8 @@ struct osmo_fsm_inst {
int log_level;
/*! current state of the FSM */
uint32_t state;
/*! if blocked by O&M/vty */
bool om_blocked;
/*! timer number for states with time-out */
int T;

View File

@ -58,8 +58,6 @@ struct gprs_ns2_vc_priv {
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 @@ static void ns2_st_unconfigured(struct osmo_fsm_inst *fi, uint32_t event, void *
struct gprs_ns2_inst *nsi = priv->nsvc->nse->nsi;
priv->initiate_reset = priv->initiate_block = priv->initiator;
priv->om_blocked = false;
fi->om_blocked = false;
switch (event) {
case GPRS_NS2_EV_REQ_START:
@ -338,14 +336,13 @@ static void ns2_st_reset(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static void ns2_st_blocked_onenter(struct osmo_fsm_inst *fi, uint32_t old_state)
{
struct gprs_ns2_vc_priv *priv = fi->priv;
if (old_state != GPRS_NS2_ST_BLOCKED) {
priv->N = 0;
RATE_CTR_INC_NS(priv->nsvc, NS_CTR_BLOCKED);
}
ns2_nse_notify_unblocked(priv->nsvc, false);
if (priv->om_blocked) {
if (fi->om_blocked) {
/* we are already blocked after a RESET */
if (old_state == GPRS_NS2_ST_RESET) {
osmo_timer_del(&fi->timer);
@ -363,7 +360,7 @@ static void ns2_st_blocked(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct gprs_ns2_vc_priv *priv = fi->priv;
if (priv->om_blocked) {
if (fi->om_blocked) {
switch (event) {
case GPRS_NS2_EV_RX_BLOCK_ACK:
priv->accept_unitdata = false;
@ -563,7 +560,7 @@ static int ns2_vc_fsm_timer_cb(struct osmo_fsm_inst *fi)
case GPRS_NS2_ST_BLOCKED:
if (priv->initiate_block) {
priv->N++;
if (priv->om_blocked) {
if (fi->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 +714,14 @@ static void ns2_vc_fsm_allstate_action(struct osmo_fsm_inst *fi,
case GPRS_NS2_EV_REQ_OM_BLOCK:
/* vty cmd: block */
priv->initiate_block = true;
priv->om_blocked = true;
fi->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)
/* vty cmd: unblock */
if (!fi->om_blocked)
return;
priv->om_blocked = false;
fi->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;
@ -833,8 +830,7 @@ int ns2_vc_force_unconfigured(struct gprs_ns2_vc *nsvc)
* \return 0 on success; negative on error */
int ns2_vc_block(struct gprs_ns2_vc *nsvc)
{
struct gprs_ns2_vc_priv *priv = nsvc->fi->priv;
if (priv->om_blocked)
if (nsvc->fi->om_blocked)
return -EALREADY;
return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_BLOCK, NULL);
@ -845,8 +841,7 @@ int ns2_vc_block(struct gprs_ns2_vc *nsvc)
* \return 0 on success; negative on error */
int ns2_vc_unblock(struct gprs_ns2_vc *nsvc)
{
struct gprs_ns2_vc_priv *priv = nsvc->fi->priv;
if (!priv->om_blocked)
if (!nsvc->fi->om_blocked)
return -EALREADY;
return osmo_fsm_inst_dispatch(nsvc->fi, GPRS_NS2_EV_REQ_OM_UNBLOCK, NULL);

View File

@ -1875,18 +1875,23 @@ DEFUN(cfg_no_ns_nse_ip_sns_bind, cfg_no_ns_nse_ip_sns_bind_cmd,
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->fi->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",
nsvc->fi->om_blocked ? "(blocked by O&M/vty) " :
!ns2_vc_is_unblocked(nsvc) ? "(cause: remote) " : "");
vty_out_uptime(vty, &nsvc->ts_alive_change);
vty_out_newline(vty);

View File

@ -40,11 +40,11 @@ OsmoNSdummy(config-ns-nse)# end
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(config-ns-nse)# end
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