diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2021-02-16 23:06:53 +0100 |
---|---|---|
committer | lynxis lazus <lynxis@fe80.eu> | 2021-02-19 10:41:50 +0000 |
commit | 7bb39e368d644e9d1029a210ea8a720674bd5185 (patch) | |
tree | e68e6989bda10b2de9704f3b7164b63735690e02 /src | |
parent | b2de546a5ca2e6ee76d342e66eda39afe4c08bbe (diff) |
gprs_ns2: ensure no duplicate UDP NSVC can be created
Change-Id: I58a95817e2730bbbaa851a43a5b072d1de2db037
Diffstat (limited to 'src')
-rw-r--r-- | src/gb/gprs_ns2_udp.c | 4 | ||||
-rw-r--r-- | src/gb/gprs_ns2_vty.c | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c index 36f6a97e..30816802 100644 --- a/src/gb/gprs_ns2_udp.c +++ b/src/gb/gprs_ns2_udp.c @@ -402,6 +402,10 @@ struct gprs_ns2_vc *ns2_ip_bind_connect(struct gprs_ns2_vc_bind *bind, return NULL; } + /* duplicate */ + if (gprs_ns2_nsvc_by_sockaddr_bind(bind, remote)) + return NULL; + sockaddr_str = (char *)osmo_sockaddr_to_str(remote); osmo_identifier_sanitize_buf(sockaddr_str, NULL, '_'); snprintf(idbuf, sizeof(idbuf), "%s-NSE%05u-remote-%s", gprs_ns2_lltype_str(nse->ll), diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c index 4bd7cdef..62149079 100644 --- a/src/gb/gprs_ns2_vty.c +++ b/src/gb/gprs_ns2_vty.c @@ -1093,6 +1093,15 @@ static int ns_nse_nsvc_udp_cmds(struct vty *vty, const char *bind_name, const ch goto err; } + nsvc = gprs_ns2_nsvc_by_sockaddr_bind(bind, &remote); + if (nsvc) { + if (nsvc->nse == nse) + vty_out(vty, "Specified NSVC is already present in this NSE.%s", VTY_NEWLINE); + else + vty_out(vty, "Specified NSVC is already present in another NSE%05u.%s", nsvc->nse->nsei, VTY_NEWLINE); + goto err; + } + nsvc = gprs_ns2_ip_connect(bind, &remote, nse, 0); if (!nsvc) { vty_out(vty, "Can not create NS-VC.%s", VTY_NEWLINE); |