frame_relay: Discard received messages for DLC not yet active

If we receive messages for a DLC which has not yet reported as being
available by Q.933 LMI, drop the incoming message.  Otherwise we would
dispatch it to the user, and the user wants to respond - but then
we reject the transmission due to the inactive DLC.

Change-Id: Ia4a045fdf165b526f429f4617e0fdc76036480bd
Related: OS#4999
diff --git a/src/gb/frame_relay.c b/src/gb/frame_relay.c
index a7e1da8..e9436fe 100644
--- a/src/gb/frame_relay.c
+++ b/src/gb/frame_relay.c
@@ -784,19 +784,22 @@
 		goto out;
 	}
 
-	llist_for_each_entry(dlc, &link->dlc_list, list) {
-		if (dlc->dlci == dlci) {
+	dlc = osmo_fr_dlc_by_dlci(link, dlci);
+	if (dlc) {
+		if (dlc->active) {
 			/* dispatch to handler of respective DLC */
 			msg->dst = dlc;
 			return dlc->rx_cb(dlc->cb_data, msg);
+		} else {
+			LOGPFRL(link, LOGL_NOTICE, "DLCI %u not yet active, discarding\n", dlci);
 		}
+	} else {
+		if (link->unknown_dlc_rx_cb)
+			return link->unknown_dlc_rx_cb(link->unknown_dlc_rx_cb_data, msg);
+		else
+			LOGPFRL(link, LOGL_NOTICE, "DLCI %u doesn't exist, discarding\n", dlci);
 	}
 
-	if (link->unknown_dlc_rx_cb)
-		return link->unknown_dlc_rx_cb(link->unknown_dlc_rx_cb_data, msg);
-	else
-		LOGPFRL(link, LOGL_NOTICE, "DLCI %u doesn't exist, discarding\n", dlci);
-
 out:
 	msgb_free(msg);