summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordlg <dlg@openbsd.org>2015-09-27 05:23:50 +0000
committerdlg <dlg@openbsd.org>2015-09-27 05:23:50 +0000
commit3b3bd0e3bae23645f998450527471093a1b6853b (patch)
tree2aa4af1d7108b7c2a46ac132396e6c51fbcadd50
parentAnnotate funcs with __attribute__((printf(...))) and clean up the fallout: (diff)
downloadwireguard-openbsd-3b3bd0e3bae23645f998450527471093a1b6853b.tar.xz
wireguard-openbsd-3b3bd0e3bae23645f998450527471093a1b6853b.zip
pull the m_freem calls out of hfsc_enqueue by having IFQ_ENQUEUE free
the mbuf in both the hfsc and priq error paths. ok mikeb@ mpi@ claudio@ henning@
-rw-r--r--sys/net/hfsc.c7
-rw-r--r--sys/net/if_var.h7
2 files changed, 6 insertions, 8 deletions
diff --git a/sys/net/hfsc.c b/sys/net/hfsc.c
index 9fec9b322eb..0a66701d09a 100644
--- a/sys/net/hfsc.c
+++ b/sys/net/hfsc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hfsc.c,v 1.21 2015/04/18 11:12:33 dlg Exp $ */
+/* $OpenBSD: hfsc.c,v 1.22 2015/09/27 05:23:50 dlg Exp $ */
/*
* Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org>
@@ -646,17 +646,14 @@ hfsc_enqueue(struct ifqueue *ifq, struct mbuf *m)
if ((cl = hfsc_clh2cph(hif, m->m_pkthdr.pf.qid)) == NULL ||
cl->cl_children != NULL) {
cl = hif->hif_defaultclass;
- if (cl == NULL) {
- m_freem(m);
+ if (cl == NULL)
return (ENOBUFS);
- }
cl->cl_pktattr = NULL;
}
if (hfsc_addq(cl, m) != 0) {
/* drop occurred. mbuf needs to be freed */
PKTCNTR_INC(&cl->cl_stats.drop_cnt, m->m_pkthdr.len);
- m_freem(m);
return (ENOBUFS);
}
ifq->ifq_len++;
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 021a8c5e89b..8395a70ccd5 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_var.h,v 1.43 2015/09/13 17:53:44 mpi Exp $ */
+/* $OpenBSD: if_var.h,v 1.44 2015/09/27 05:23:50 dlg Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -330,15 +330,16 @@ do { \
(err) = hfsc_enqueue(((struct ifqueue *)(ifq)), m); \
else { \
if (IF_QFULL((ifq))) { \
- m_freem((m)); \
(err) = ENOBUFS; \
} else { \
IF_ENQUEUE((ifq), (m)); \
(err) = 0; \
} \
} \
- if ((err)) \
+ if ((err)) { \
+ m_freem((m)); \
(ifq)->ifq_drops++; \
+ } \
} while (/* CONSTCOND */0)
#define IFQ_DEQUEUE(ifq, m) \