summaryrefslogtreecommitdiff
path: root/sys/net/hfsc.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2015-03-03 11:14:01 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2015-03-03 11:14:01 +0000
commitfe6c4f77f90a3e6acc376fce1e4ca69f069b1335 (patch)
tree911aa7ae479e308618a537287c06a2563cb5fbcc /sys/net/hfsc.c
parent7d86330d085bba0ff2d47c2fa727ba96101649af (diff)
make sure hfsc_attach, hfsc_detach, hfsc_addqueue, hfsc_delqueue and
hfsc_qstats cope with a NULL ifp. Can happen when refering to nonexistant interfaces from pf.conf. Problem noticed and fix tested by Kevin Chadwick <ma1l1ists at yahoo.co.uk>, ok phessler benno
Diffstat (limited to 'sys/net/hfsc.c')
-rw-r--r--sys/net/hfsc.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/sys/net/hfsc.c b/sys/net/hfsc.c
index 4d32e174b76..4036fe44db7 100644
--- a/sys/net/hfsc.c
+++ b/sys/net/hfsc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hfsc.c,v 1.15 2015/02/08 03:16:16 henning Exp $ */
+/* $OpenBSD: hfsc.c,v 1.16 2015/03/03 11:14:00 henning Exp $ */
/*
* Copyright (c) 2012-2013 Henning Brauer <henning@openbsd.org>
@@ -163,7 +163,7 @@ hfsc_attach(struct ifnet *ifp)
tblsize = HFSC_DEFAULT_CLASSES * sizeof(void *);
- if (ifp->if_snd.ifq_hfsc != NULL)
+ if (ifp == NULL || ifp->if_snd.ifq_hfsc != NULL)
return (0);
hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_WAITOK | M_ZERO);
@@ -184,8 +184,12 @@ hfsc_attach(struct ifnet *ifp)
int
hfsc_detach(struct ifnet *ifp)
{
- struct hfsc_if *hif = ifp->if_snd.ifq_hfsc;
+ struct hfsc_if *hif;
+
+ if (ifp == NULL)
+ return (0);
+ hif = ifp->if_snd.ifq_hfsc;
timeout_del(&hif->hif_defer);
ifp->if_snd.ifq_hfsc = NULL;
@@ -203,6 +207,9 @@ hfsc_addqueue(struct pf_queuespec *q)
struct hfsc_class *cl, *parent;
struct hfsc_sc rtsc, lssc, ulsc;
+ if (q->kif->pfik_ifp == NULL)
+ return (0);
+
if ((hif = q->kif->pfik_ifp->if_snd.ifq_hfsc) == NULL)
return (EINVAL);
@@ -242,6 +249,9 @@ hfsc_delqueue(struct pf_queuespec *q)
struct hfsc_if *hif;
struct hfsc_class *cl;
+ if (q->kif->pfik_ifp == NULL)
+ return (0);
+
if ((hif = q->kif->pfik_ifp->if_snd.ifq_hfsc) == NULL)
return (EINVAL);
@@ -259,6 +269,9 @@ hfsc_qstats(struct pf_queuespec *q, void *ubuf, int *nbytes)
struct hfsc_class_stats stats;
int error = 0;
+ if (q->kif->pfik_ifp == NULL)
+ return (EBADF);
+
if ((hif = q->kif->pfik_ifp->if_snd.ifq_hfsc) == NULL)
return (EBADF);