aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2024-01-15 17:20:27 +0100
committerlaforge <laforge@osmocom.org>2024-01-24 08:52:55 +0000
commit0c1ab7d82f5878d8a61de897c9bf360bf806e2b4 (patch)
treec5963b320a456d4d0273f1fc3a311a0de2471765
parent9a730ee2d497b041cdb6fff297d9f6cda97d0633 (diff)
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
-rw-r--r--include/osmocom/bsc/bts_sm.h1
-rw-r--r--src/osmo-bsc/bts_vty.c27
-rw-r--r--src/osmo-bsc/nm_gprs_nsvc_fsm.c4
-rw-r--r--tests/gprs_params.vty11
4 files changed, 36 insertions, 7 deletions
diff --git a/include/osmocom/bsc/bts_sm.h b/include/osmocom/bsc/bts_sm.h
index e25b8dac0..13be3d97e 100644
--- a/include/osmocom/bsc/bts_sm.h
+++ b/include/osmocom/bsc/bts_sm.h
@@ -40,6 +40,7 @@ struct gsm_gprs_nsvc {
/* 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 e38ec94b0..24224f64f 100644
--- a/src/osmo-bsc/bts_vty.c
+++ b/src/osmo-bsc/bts_vty.c
@@ -1564,6 +1564,22 @@ DEFUN_USRATTR(cfg_bts_gprs_nsei,
#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 @@ DEFUN_USRATTR(cfg_bts_gprs_nsvci,
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 @@ DEFUN_USRATTR(cfg_bts_gprs_nsvc_lport,
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 @@ DEFUN_USRATTR(cfg_bts_gprs_nsvc_rport,
/* 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 @@ DEFUN_USRATTR(cfg_bts_gprs_nsvc_rip,
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 @@ static void config_write_bts_gprs(struct vty *vty, struct gsm_bts *bts)
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 @@ int bts_vty_init(void)
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 a3555aa93..beedcdd7c 100644
--- a/src/osmo-bsc/nm_gprs_nsvc_fsm.c
+++ b/src/osmo-bsc/nm_gprs_nsvc_fsm.c
@@ -96,6 +96,10 @@ static void st_op_disabled_notinstalled(struct osmo_fsm_inst *fi, uint32_t event
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 e0c8b39e0..0f69a8cfb 100644
--- a/tests/gprs_params.vty
+++ b/tests/gprs_params.vty
@@ -41,10 +41,8 @@ OsmoBSC(config-net-bts)# show running-config
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)# show running-config
...
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
...