osmux: Add negotiation state so race conditions can't disable osmux

Without this commit it is possible that osmux is disabled again on links with
high jitter. This happens when an MGCP response without X-Osmux header is
received before the NAT receives an Osmux dummy frame from the other side.

Ticket: SYS#2628, SYS#2627
Sponsored-by: On-Waves ehf
Change-Id: Id624b0279aee5e2412059a10296ce7896e2d4628
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index 9fd9967..4884786 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -590,7 +590,7 @@
 		 */
 		if (mgcp_endp->osmux.allocated_cid >= 0 &&
 		    mgcp_endp->osmux.state != OSMUX_STATE_ENABLED) {
-			mgcp_endp->osmux.state = OSMUX_STATE_ACTIVATING;
+			mgcp_endp->osmux.state = OSMUX_STATE_NEGOTIATING;
 			mgcp_endp->osmux.cid = mgcp_endp->osmux.allocated_cid;
 		}
 
@@ -680,6 +680,7 @@
 
 	LOGP(DMGCP, LOGL_NOTICE, "bsc accepted to use Osmux (cid=%u)\n",
 	     osmux_cid);
+	endp->osmux.state = OSMUX_STATE_ACTIVATING;
 	return;
 err:
 	osmux_release_cid(endp);
@@ -747,7 +748,7 @@
 		return;
 	}
 
-	if (endp->osmux.state == OSMUX_STATE_ACTIVATING)
+	if (endp->osmux.state == OSMUX_STATE_NEGOTIATING)
 		bsc_mgcp_osmux_confirm(endp, (const char *) msg->l2h);
 
 	/* If we require osmux and it is disabled.. fail */