laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bsc/+/35571?usp=email )

Change subject: Add vty commands "no gprs nsvc ..."
......................................................................

Add vty commands "no gprs nsvc ..."

A switch (bool) is used to enable or disable NSVC 0 or 1. It is enabled
via any "gprs nsvc 0|1" command and disabled via "no gprs nsvc 0|1"
command. If it is disabled, it is treated as unconfigured, similar when
no remote IP or port has been defined.

Related: OS#6006
Change-Id: Ia112e86aa35f6a245d98ef1b3720c18835faeda6
---
M include/osmocom/bsc/bts_sm.h
M src/osmo-bsc/bts_vty.c
M src/osmo-bsc/nm_gprs_nsvc_fsm.c
M tests/gprs_params.vty
4 files changed, 51 insertions(+), 7 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified




diff --git a/include/osmocom/bsc/bts_sm.h b/include/osmocom/bsc/bts_sm.h
index e25b8da..13be3d9 100644
--- a/include/osmocom/bsc/bts_sm.h
+++ b/include/osmocom/bsc/bts_sm.h
@@ -40,6 +40,7 @@
        /* data read via VTY config file, to configure the BTS
         * via OML from BSC */
        int id;
+       bool enabled;
        uint16_t nsvci;
        uint16_t local_port;    /* on the BTS */
        struct osmo_sockaddr remote;
diff --git a/src/osmo-bsc/bts_vty.c b/src/osmo-bsc/bts_vty.c
index e38ec94..24224f6 100644
--- a/src/osmo-bsc/bts_vty.c
+++ b/src/osmo-bsc/bts_vty.c
@@ -1564,6 +1564,22 @@
 #define NSVC_TEXT "Network Service Virtual Connection (NS-VC)\n" \
                "NSVC Logical Number\n"

+DEFUN_USRATTR(cfg_no_bts_gprs_nsvc,
+             cfg_no_bts_gprs_nsvc_cmd,
+             X(BSC_VTY_ATTR_RESTART_ABIS_OML_LINK),
+             "no gprs nsvc <0-1>",
+             NO_STR GPRS_TEXT NSVC_TEXT)
+{
+       struct gsm_bts *bts = vty->index;
+       int idx = atoi(argv[0]);
+
+       GPRS_CHECK_ENABLED(bts);
+
+       bts->site_mgr->gprs.nsvc[idx].enabled = false;
+
+       return CMD_SUCCESS;
+}
+
 DEFUN_USRATTR(cfg_bts_gprs_nsvci,
              cfg_bts_gprs_nsvci_cmd,
              X(BSC_VTY_ATTR_RESTART_ABIS_OML_LINK),
@@ -1578,6 +1594,7 @@
        GPRS_CHECK_ENABLED(bts);

        bts->site_mgr->gprs.nsvc[idx].nsvci = atoi(argv[1]);
+       bts->site_mgr->gprs.nsvc[idx].enabled = true;

        return CMD_SUCCESS;
 }
@@ -1598,6 +1615,7 @@
        GPRS_CHECK_ENABLED(bts);

        bts->site_mgr->gprs.nsvc[idx].local_port = atoi(argv[1]);
+       bts->site_mgr->gprs.nsvc[idx].enabled = true;

        return CMD_SUCCESS;
 }
@@ -1619,6 +1637,7 @@

        /* sockaddr_in and sockaddr_in6 have the port at the same position */
        bts->site_mgr->gprs.nsvc[idx].remote.u.sin.sin_port = 
htons(atoi(argv[1]));
+       bts->site_mgr->gprs.nsvc[idx].enabled = true;

        return CMD_SUCCESS;
 }
@@ -1651,9 +1670,11 @@
        switch (remote.af) {
        case AF_INET:
                osmo_sockaddr_str_to_in_addr(&remote, 
&bts->site_mgr->gprs.nsvc[idx].remote.u.sin.sin_addr);
+               bts->site_mgr->gprs.nsvc[idx].enabled = true;
                break;
        case AF_INET6:
                osmo_sockaddr_str_to_in6_addr(&remote, 
&bts->site_mgr->gprs.nsvc[idx].remote.u.sin6.sin6_addr);
+               bts->site_mgr->gprs.nsvc[idx].enabled = true;
                break;
        }

@@ -4251,6 +4272,11 @@
                const struct gsm_gprs_nsvc *nsvc = &bts_sm->gprs.nsvc[i];
                struct osmo_sockaddr_str remote;

+               if (!nsvc->enabled) {
+                       vty_out(vty, "  no gprs nsvc %u%s", i, VTY_NEWLINE);
+                       continue;
+               }
+
                vty_out(vty, "  gprs nsvc %u nsvci %u%s", i,
                        nsvc->nsvci, VTY_NEWLINE);

@@ -4951,6 +4977,7 @@
        install_element(BTS_NODE, &cfg_bts_gprs_bvci_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_cell_timer_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_nsei_cmd);
+       install_element(BTS_NODE, &cfg_no_bts_gprs_nsvc_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_nsvci_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_nsvc_lport_cmd);
        install_element(BTS_NODE, &cfg_bts_gprs_nsvc_rport_cmd);
diff --git a/src/osmo-bsc/nm_gprs_nsvc_fsm.c b/src/osmo-bsc/nm_gprs_nsvc_fsm.c
index a3555aa..beedcdd 100644
--- a/src/osmo-bsc/nm_gprs_nsvc_fsm.c
+++ b/src/osmo-bsc/nm_gprs_nsvc_fsm.c
@@ -96,6 +96,10 @@

 static bool has_valid_nsvc(const struct gsm_gprs_nsvc *nsvc)
 {
+       /* If not configured (enabled) at all. */
+       if (!nsvc->enabled)
+               return false;
+
        /* remote address must be valid */
        if (osmo_sockaddr_is_any(&nsvc->remote))
                return false;
diff --git a/tests/gprs_params.vty b/tests/gprs_params.vty
index e0c8b39..0f69a8c 100644
--- a/tests/gprs_params.vty
+++ b/tests/gprs_params.vty
@@ -41,10 +41,8 @@
   gprs ns timer tns-test 30
   gprs ns timer tns-alive 3
   gprs ns timer tns-alive-retries 10
-  gprs nsvc 0 nsvci 0
-  gprs nsvc 0 local udp port 0
-  gprs nsvc 1 nsvci 0
-  gprs nsvc 1 local udp port 0
+  no gprs nsvc 0
+  no gprs nsvc 1
 ...


@@ -104,13 +102,12 @@
 ...

 OsmoBSC(config-net-bts)# ### Disable secondary NSVC
-OsmoBSC(config-net-bts)# gprs nsvc 1 remote udp port 0
+OsmoBSC(config-net-bts)# no gprs nsvc 1
 OsmoBSC(config-net-bts)# show running-config
 ...
  bts 0
 ...
   gprs nsvc 0 nsvci 4242
   gprs nsvc 0 local udp port 0
-  gprs nsvc 1 nsvci 2424
-  gprs nsvc 1 local udp port 23023
+  no gprs nsvc 1
 ...

--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/35571?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ia112e86aa35f6a245d98ef1b3720c18835faeda6
Gerrit-Change-Number: 35571
Gerrit-PatchSet: 5
Gerrit-Owner: jolly <andr...@eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to