summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2017-11-14 04:08:12 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2017-11-14 04:08:12 +0000
commita26648ea0606f1d4ef584942defdb1a5f98805d4 (patch)
treea1fda0d0d0005513181f1fdc2f71f2263fe4eaaf
parentd9df466280f91005c30f78b55ff4b39cba7c8aac (diff)
move the adding of an ifqs counters in if_getdata to ifq.c
this keeps the knowledge of ifq locking in ifq.c ok visa@
-rw-r--r--sys/net/if.c28
-rw-r--r--sys/net/ifq.c14
-rw-r--r--sys/net/ifq.h3
3 files changed, 21 insertions, 24 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index df43465d00d..00d81d94894 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.526 2017/11/12 14:11:15 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.527 2017/11/14 04:08:11 dlg Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -2277,30 +2277,14 @@ void
if_getdata(struct ifnet *ifp, struct if_data *data)
{
unsigned int i;
- struct ifqueue *ifq;
- uint64_t opackets = 0;
- uint64_t obytes = 0;
- uint64_t omcasts = 0;
- uint64_t oqdrops = 0;
+
+ *data = ifp->if_data;
for (i = 0; i < ifp->if_nifqs; i++) {
- ifq = ifp->if_ifqs[i];
-
- mtx_enter(&ifq->ifq_mtx);
- opackets += ifq->ifq_packets;
- obytes += ifq->ifq_bytes;
- oqdrops += ifq->ifq_qdrops;
- omcasts += ifq->ifq_mcasts;
- mtx_leave(&ifq->ifq_mtx);
- /* ifq->ifq_errors */
- }
+ struct ifqueue *ifq = ifp->if_ifqs[i];
- *data = ifp->if_data;
- data->ifi_opackets += opackets;
- data->ifi_obytes += obytes;
- data->ifi_oqdrops += oqdrops;
- data->ifi_omcasts += omcasts;
- /* ifp->if_data.ifi_oerrors */
+ ifq_add_data(ifq, data);
+ }
}
/*
diff --git a/sys/net/ifq.c b/sys/net/ifq.c
index d460d764488..2090704a8c7 100644
--- a/sys/net/ifq.c
+++ b/sys/net/ifq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifq.c,v 1.13 2017/11/14 00:00:35 dlg Exp $ */
+/* $OpenBSD: ifq.c,v 1.14 2017/11/14 04:08:11 dlg Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
@@ -289,6 +289,18 @@ ifq_destroy(struct ifqueue *ifq)
ml_purge(&ml);
}
+void
+ifq_add_data(struct ifqueue *ifq, struct if_data *data)
+{
+ mtx_enter(&ifq->ifq_mtx);
+ data->ifi_opackets += ifq->ifq_packets;
+ data->ifi_obytes += ifq->ifq_bytes;
+ data->ifi_oqdrops += ifq->ifq_qdrops;
+ data->ifi_omcasts += ifq->ifq_mcasts;
+ /* ifp->if_data.ifi_oerrors */
+ mtx_leave(&ifq->ifq_mtx);
+}
+
int
ifq_enqueue(struct ifqueue *ifq, struct mbuf *m)
{
diff --git a/sys/net/ifq.h b/sys/net/ifq.h
index b76a6d82b77..d9b40a328db 100644
--- a/sys/net/ifq.h
+++ b/sys/net/ifq.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifq.h,v 1.14 2017/11/14 00:00:35 dlg Exp $ */
+/* $OpenBSD: ifq.h,v 1.15 2017/11/14 04:08:11 dlg Exp $ */
/*
* Copyright (c) 2015 David Gwynne <dlg@openbsd.org>
@@ -379,6 +379,7 @@ struct ifq_ops {
void ifq_init(struct ifqueue *, struct ifnet *, unsigned int);
void ifq_attach(struct ifqueue *, const struct ifq_ops *, void *);
void ifq_destroy(struct ifqueue *);
+void ifq_add_data(struct ifqueue *, struct if_data *);
int ifq_enqueue(struct ifqueue *, struct mbuf *);
void ifq_start(struct ifqueue *);
struct mbuf *ifq_deq_begin(struct ifqueue *);