summaryrefslogtreecommitdiff
path: root/sys/net/if_trunk.c
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2008-07-30 10:15:36 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2008-07-30 10:15:36 +0000
commit72e6ad622b6c53695174a7eedf187617c68d9c36 (patch)
treed7038924c7bf1fd9980400f795b5025857c49ed9 /sys/net/if_trunk.c
parent3c8d95df7cccbf10f10626a17bfec49f959ec083 (diff)
Prevent a divide by zero panic if trunkproto loadbalance is
used w/out any trunkports. Patch from Dmitri Alenitchev. OK reyk@
Diffstat (limited to 'sys/net/if_trunk.c')
-rw-r--r--sys/net/if_trunk.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c
index 0105cebdabc..e09648a8b58 100644
--- a/sys/net/if_trunk.c
+++ b/sys/net/if_trunk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_trunk.c,v 1.46 2008/06/15 06:56:09 mpf Exp $ */
+/* $OpenBSD: if_trunk.c,v 1.47 2008/07/30 10:15:35 mpf Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -1461,6 +1461,11 @@ trunk_lb_start(struct trunk_softc *tr, struct mbuf *m)
u_int32_t p = 0;
int idx;
+ if (tr->tr_count == 0) {
+ m_freem(m);
+ return (EINVAL);
+ }
+
p = trunk_hashmbuf(m, lb->lb_key);
if ((idx = p % tr->tr_count) >= TRUNK_MAX_PORTS) {
m_freem(m);