gb: Create new NSVC object instead of patching the NSVCI

When a RESET is received on the same link with a different NSVCI from
a BSS on a dynamically created NS connection do not patch the nsvc
object but create a new one instead. Thus the NSVCI is never modified
at a nsvc object after the NS-VC has been established.

Sponsored-by: On-Waves ehf
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 043a66c..1754501 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -729,9 +729,6 @@
 
 	talloc_free(old_peer);
 
-	/* Do statistics */
-	rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_REPLACED]);
-
 	return 1;
 }
 
@@ -784,7 +781,16 @@
 		}
 
 		/* NS-VCI has changed */
-		gprs_nsvc_replace_if_found(nsvci, nsvc, &orig_nsvc);
+		if (!gprs_nsvc_replace_if_found(nsvci, nsvc, &orig_nsvc)) {
+			LOGP(DNS, LOGL_INFO, "Creating NS-VC %d replacing %d "
+			     "at %s\n",
+			     nsvci, (*nsvc)->nsvci,
+			     gprs_ns_ll_str(*nsvc));
+			orig_nsvc = *nsvc;
+			*nsvc = gprs_nsvc_create((*nsvc)->nsi, nsvci);
+			(*nsvc)->nsvci_is_valid = 1;
+			(*nsvc)->nsei  = nsei;
+		}
 	}
 
 	if ((*nsvc)->nsvci_is_valid && (*nsvc)->nsei != nsei) {
@@ -810,6 +816,7 @@
 	(*nsvc)->state = NSE_S_BLOCKED | NSE_S_ALIVE;
 
 	if (orig_nsvc) {
+		rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_REPLACED]);
 		ns_osmo_signal_dispatch_replaced(*nsvc, orig_nsvc);
 
 		/* Update the ll info fields */
@@ -916,6 +923,7 @@
 		}
 
 		/* Notify others */
+		rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_REPLACED]);
 		ns_osmo_signal_dispatch_replaced(*nsvc, orig_nsvc);
 
 		/* Update the ll info fields */