ns2: vty: fix behavior of vtyvc_by_nsei when vtyvc isn't found
Fixes the parsing of persistent nsvcs.
Change-Id: I297409f557f17df680ac76018b4202eb99713021
diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c
index f204ff1..ab869c3 100644
--- a/src/gb/gprs_ns2_vty.c
+++ b/src/gb/gprs_ns2_vty.c
@@ -138,20 +138,21 @@
static struct ns2_vty_vc *vtyvc_by_nsei(uint16_t nsei, bool alloc_missing) {
struct ns2_vty_vc *vtyvc;
+
llist_for_each_entry(vtyvc, &priv.vtyvc, list) {
if (vtyvc->nsei == nsei)
return vtyvc;
}
- if (alloc_missing) {
- vtyvc = vtyvc_alloc(nsei);
- if (!vtyvc)
- return vtyvc;
+ if (!alloc_missing)
+ return NULL;
- vtyvc->nsei = nsei;
- }
+ vtyvc = vtyvc_alloc(nsei);
+ if (!vtyvc)
+ return vtyvc;
- return NULL;
+ vtyvc->nsei = nsei;
+ return vtyvc;
}
static int config_write_ns(struct vty *vty)