gprs_ns2_sns: reset the N of timeout when entering a new state

Otherwise retries are splitted between the states.

Related: OS#5355
Change-Id: Iefde0c89965f0be899d6d1f096480f6fc79a92be
diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index e84c79d..cd0a211 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -727,6 +727,9 @@
 	/* on a generic failure, the timer callback will recover */
 	if (old_state != GPRS_SNS_ST_UNCONFIGURED)
 		ns2_prim_status_ind(gss->nse, NULL, 0, GPRS_NS2_AFF_CAUSE_SNS_FAILURE);
+	if (old_state != GPRS_SNS_ST_SIZE)
+		gss->N = 0;
+
 
 	gss->alive = false;
 	ns2_clear_ipv46_entries(gss);
@@ -873,6 +876,10 @@
 static void ns2_sns_st_config_bss_onenter(struct osmo_fsm_inst *fi, uint32_t old_state)
 {
 	struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv;
+
+	if (old_state != GPRS_SNS_ST_CONFIG_BSS)
+		gss->N = 0;
+
 	/* Transmit SNS-CONFIG */
 	switch (gss->ip) {
 	case IPv4:
@@ -999,9 +1006,18 @@
 	} else {
 		/* just send CONFIG-ACK */
 		ns2_tx_sns_config_ack(gss->sns_nsvc, NULL);
+		osmo_timer_schedule(&fi->timer, nse->nsi->timeout[NS_TOUT_TSNS_PROV], 0);
 	}
 }
 
+static void ns2_sns_st_config_sgsn_onenter(struct osmo_fsm_inst *fi, uint32_t old_state)
+{
+	struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv;
+
+	if (old_state != GPRS_SNS_ST_CONFIG_SGSN)
+		gss->N = 0;
+}
+
 static void ns2_sns_st_config_sgsn(struct osmo_fsm_inst *fi, uint32_t event, void *data)
 {
 	struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv;
@@ -1334,6 +1350,7 @@
 				  S(GPRS_SNS_ST_SIZE),
 		.name = "CONFIG_SGSN",
 		.action = ns2_sns_st_config_sgsn,
+		.onenter = ns2_sns_st_config_sgsn_onenter,
 	},
 	[GPRS_SNS_ST_CONFIGURED] = {
 		.in_event_mask = S(GPRS_SNS_EV_ADD) |