ns2: Properly report packet drops in FR code
When the FR code decides to drop a packet (ENOBUFS from the AF_PACKET
socket for non-signaling packet), let's report that back via the
frame_relay code into the generic NS2 code.
This way the generic NS2 code always knows if a packet was actually
successfully transmitted, or if it was dropped for some reason.
Change-Id: I4bb517fd04af69dbe6da628b132d57994ab3e5a4
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 4bd9ff1..9de2b06 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -340,7 +340,7 @@
#define LMI_Q933A_DLCI 0
/* enqueue to backlog (LMI, signaling) or drop (userdata msg) */
-static void backlog_enqueue_or_free(struct gprs_ns2_vc_bind *bind, struct msgb *msg)
+static int backlog_enqueue_or_free(struct gprs_ns2_vc_bind *bind, struct msgb *msg)
{
uint8_t dlci = msg->data[0];
uint8_t ns_pdu_type;
@@ -354,7 +354,7 @@
case LMI_Q933A_DLCI:
/* enqueue Q.933 LMI at head of queue */
enqueue_at_head(bind, msg);
- return;
+ return 0;
default:
if (msgb_length(msg) < 3)
break;
@@ -367,13 +367,13 @@
/* enqueue BVCI=0 traffic at tail of queue */
if (bvci == BVCI_SIGNALLING) {
enqueue_at_tail(bind, msg);
- return;
+ return 0;
}
break;
default:
/* enqueue NS signaling traffic at head of queue */
enqueue_at_head(bind, msg);
- return;
+ return 0;
}
break;
}
@@ -381,6 +381,7 @@
out_free:
/* drop everything that is not LMI, NS-signaling or BVCI-0 */
msgb_free(msg);
+ return -1;
}
static void fr_backlog_timer_cb(void *data)
@@ -420,11 +421,11 @@
rc = fr_netif_write_one(bind, msg);
if (rc < 0) {
/* enqueue to backlog in case it fails */
- backlog_enqueue_or_free(bind, msg);
+ return backlog_enqueue_or_free(bind, msg);
}
} else {
/* enqueue to backlog */
- backlog_enqueue_or_free(bind, msg);
+ return backlog_enqueue_or_free(bind, msg);
}
return 0;