LAPDm: Add a flag to enable suppression of subsequent REJ frame

This behaviour was default in earlier versions of LAPDm/LAPD. Because it
is only required for osmocom-bb, a flag is added to enable it there.

Related: OS#5969
Change-Id: I93994dbbd1fc2c9edb8f3015c6b18ecd0fce0565
diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c
index 28644c2..fb892d2 100644
--- a/src/gsm/lapdm.c
+++ b/src/gsm/lapdm.c
@@ -1637,6 +1637,8 @@
 	/* Set flags at LAPD. */
 	if (le->flags & LAPDM_ENT_F_POLLING_ONLY)
 		dl_flags |= LAPD_F_RTS;
+	if (le->flags & LAPDM_ENT_F_DROP_2ND_REJ)
+		dl_flags |= LAPD_F_DROP_2ND_REJ;
 
 	for (i = 0; i < ARRAY_SIZE(le->datalink); i++) {
 		dl = &le->datalink[i];
diff --git a/src/isdn/lapd_core.c b/src/isdn/lapd_core.c
index 34748a4..d98edae 100644
--- a/src/isdn/lapd_core.c
+++ b/src/isdn/lapd_core.c
@@ -1633,9 +1633,8 @@
 		      ns, dl->v_recv, lapd_state_name(dl->state));
 		/* discard data */
 		msgb_free(msg);
-		if (dl->seq_err_cond != 1) {
-			/* FIXME: help me understand what exactly todo here
-			*/
+		/* Send reject, but suppress second reject if LAPD_F_DROP_2ND_REJ flag is set. */
+		if (dl->seq_err_cond != 1 || !(dl->lapd_flags & LAPD_F_DROP_2ND_REJ)) {
 			dl->seq_err_cond = 1;
 			lapd_send_rej(lctx, lctx->p_f);
 		} else {