aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-01-30 22:01:28 +0100
committerHarald Welte <laforge@osmocom.org>2021-01-31 12:34:36 +0100
commitf22ae5af5f2df0e2e643c50f51978a4ca96d618a (patch)
tree4c4d0647f0f16f7d950ecf4489e08e1f4667fdce /src
parent5e0ef6f95858160a9a69633461d98d8aa11a9fb3 (diff)
ns2: count number of dropped packets / bytes on transmit
Differentiate between successfully transmitted packets/bytes, and pacets/bytes that were dropped (i.e. overflow of net-device) OsmoNSdummy# show ns nsvc 1001 stats NSVCI 01001: UNBLOCKED PERSIST data_weight=1 sig_weight=1 fr)netif: hdlc1 dlci: 1001 NSVC Peer Statistics: Packets at NS Level ( In): 36 (0/s 8/m 32/h 0/d) Packets at NS Level (Out): 23344 (170/s 20556/m 13119/h 0/d) Dropped Packets (Out): 30692 (230/s 27056/m 17221/h 0/d) Bytes at NS Level ( In): 262 (0/s 24/m 250/h 0/d) Bytes at NS Level (Out): 32741312 (238680/s 28849400/m 18391024/h 0/d) Dropped Bytes (Out): 43014628 (322920/s 37986624/m 24101344/h 0/d) Change-Id: If21906ff5379038f7be10cf48c68d1f756dd7c1e
Diffstat (limited to 'src')
-rw-r--r--src/gb/gprs_ns2.c2
-rw-r--r--src/gb/gprs_ns2_internal.h2
-rw-r--r--src/gb/gprs_ns2_message.c16
3 files changed, 17 insertions, 3 deletions
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index d3c1e699..0f65d37e 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -162,8 +162,10 @@ const struct value_string gprs_ns2_cause_strs[] = {
static const struct rate_ctr_desc nsvc_ctr_description[] = {
[NS_CTR_PKTS_IN] = { "packets:in", "Packets at NS Level ( In)" },
[NS_CTR_PKTS_OUT] = { "packets:out", "Packets at NS Level (Out)" },
+ [NS_CTR_PKTS_OUT_DROP] = { "packets:out:drop", "Dropped Packets (Out)" },
[NS_CTR_BYTES_IN] = { "bytes:in", "Bytes at NS Level ( In)" },
[NS_CTR_BYTES_OUT] = { "bytes:out", "Bytes at NS Level (Out)" },
+ [NS_CTR_BYTES_OUT_DROP] = { "bytes:out:drop", "Dropped Bytes (Out)" },
[NS_CTR_BLOCKED] = { "blocked", "NS-VC Block count " },
[NS_CTR_DEAD] = { "dead", "NS-VC gone dead count " },
[NS_CTR_REPLACED] = { "replaced", "NS-VC replaced other count" },
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h
index 68f28dba..98b3f294 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -88,8 +88,10 @@ enum ns2_cs {
enum ns_ctr {
NS_CTR_PKTS_IN,
NS_CTR_PKTS_OUT,
+ NS_CTR_PKTS_OUT_DROP,
NS_CTR_BYTES_IN,
NS_CTR_BYTES_OUT,
+ NS_CTR_BYTES_OUT_DROP,
NS_CTR_BLOCKED,
NS_CTR_DEAD,
NS_CTR_REPLACED,
diff --git a/src/gb/gprs_ns2_message.c b/src/gb/gprs_ns2_message.c
index cd498969..bfb8781d 100644
--- a/src/gb/gprs_ns2_message.c
+++ b/src/gb/gprs_ns2_message.c
@@ -168,10 +168,20 @@ int ns2_validate(struct gprs_ns2_vc *nsvc,
static int ns_vc_tx(struct gprs_ns2_vc *nsvc, struct msgb *msg)
{
- rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]);
- rate_ctr_add(&nsvc->ctrg->ctr[NS_CTR_BYTES_OUT], msgb_length(msg));
+ unsigned int bytes = msgb_length(msg);
+ int rc;
- return nsvc->bind->send_vc(nsvc, msg);
+
+ rc = nsvc->bind->send_vc(nsvc, msg);
+ if (rc < 0) {
+ rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT_DROP]);
+ rate_ctr_add(&nsvc->ctrg->ctr[NS_CTR_BYTES_OUT_DROP], bytes);
+ } else {
+ rate_ctr_inc(&nsvc->ctrg->ctr[NS_CTR_PKTS_OUT]);
+ rate_ctr_add(&nsvc->ctrg->ctr[NS_CTR_BYTES_OUT], bytes);
+ }
+
+ return rc;
}
/* transmit functions */