summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelikan <pelikan@openbsd.org>2014-06-30 12:47:23 +0000
committerpelikan <pelikan@openbsd.org>2014-06-30 12:47:23 +0000
commit144d81a93716096bc72bffed6d4287ddd8cbf700 (patch)
treef4527dba139b148e42dd6fa12b8cfd58a94b95a9
parentKill dead code, what does a negative number of addresses on a carp(4) (diff)
downloadwireguard-openbsd-144d81a93716096bc72bffed6d4287ddd8cbf700.tar.xz
wireguard-openbsd-144d81a93716096bc72bffed6d4287ddd8cbf700.zip
Attach HFSC after it's been completely initialized.
This fixes the "integer divide fault trap" bug caused by the second malloc skipping a beat and leaving the amount of allocated queues equal to zero. tested by me, ok henning mikeb
-rw-r--r--sys/net/hfsc.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/net/hfsc.c b/sys/net/hfsc.c
index 7cd6633e79c..2a5b755cf84 100644
--- a/sys/net/hfsc.c
+++ b/sys/net/hfsc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hfsc.c,v 1.9 2014/04/19 15:58:12 henning Exp $ */
+/* $OpenBSD: hfsc.c,v 1.10 2014/06/30 12:47:23 pelikan Exp $ */
/*
* Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org>
@@ -164,14 +164,14 @@ hfsc_attach(struct ifnet *ifp)
if (ifp->if_snd.ifq_hfsc != NULL)
return (0);
- hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_WAITOK|M_ZERO);
+ hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_WAITOK | M_ZERO);
hif->hif_eligible = hfsc_ellist_alloc();
- hif->hif_ifq = &ifp->if_snd;
- ifp->if_snd.ifq_hfsc = hif;
-
hif->hif_class_tbl = malloc(tblsize, M_DEVBUF, M_WAITOK | M_ZERO);
hif->hif_allocated = HFSC_DEFAULT_CLASSES;
+ hif->hif_ifq = &ifp->if_snd;
+ ifp->if_snd.ifq_hfsc = hif;
+
timeout_set(&hif->hif_defer, hfsc_deferred, ifp);
/* XXX HRTIMER don't schedule it yet, only when some packets wait. */
timeout_add(&hif->hif_defer, 1);