From 1f0625f214d912d23c9bd7a6805492d2ce4d230f Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Wed, 23 Sep 2020 18:22:20 +0200 Subject: ns2: vty: fix behavior of vtyvc_by_nsei when vtyvc isn't found Fixes the parsing of persistent nsvcs. Change-Id: I297409f557f17df680ac76018b4202eb99713021 --- src/gb/gprs_ns2_vty.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c index f204ff16..ab869c34 100644 --- a/src/gb/gprs_ns2_vty.c +++ b/src/gb/gprs_ns2_vty.c @@ -138,20 +138,21 @@ static void ns2_vc_free(struct ns2_vty_vc *vtyvc) { 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) -- cgit v1.2.3