arehbein has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/29903 )


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

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

Related: OS#5085

Change-Id: I0e8a12c3e54b701c9e697d50de1c9cb0bcc817e0
---
M include/osmocom/core/fsm.h
M src/gb/gprs_ns2_vc_fsm.c
M src/gb/gprs_ns2_vty.c
3 files changed, 21 insertions(+), 19 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/03/29903/1

diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h
index 5e5b091..fc63378 100644
--- a/include/osmocom/core/fsm.h
+++ b/include/osmocom/core/fsm.h
@@ -99,6 +99,8 @@
        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;
diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index 1db2a8e..a094aba 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;
+       fi->om_blocked = false;

        switch (event) {
        case GPRS_NS2_EV_REQ_START:
@@ -338,14 +336,13 @@
 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 @@
 {
        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 @@
        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 @@
        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 @@
  *  \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 @@
  *  \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);
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index 016199d..14beea8 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -1875,18 +1875,23 @@
 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 %s since ",
                        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);

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/29903
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I0e8a12c3e54b701c9e697d50de1c9cb0bcc817e0
Gerrit-Change-Number: 29903
Gerrit-PatchSet: 1
Gerrit-Owner: arehbein <[email protected]>
Gerrit-MessageType: newchange

Reply via email to