diff options
author | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-07-30 10:15:36 +0000 |
---|---|---|
committer | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-07-30 10:15:36 +0000 |
commit | 72e6ad622b6c53695174a7eedf187617c68d9c36 (patch) | |
tree | d7038924c7bf1fd9980400f795b5025857c49ed9 | |
parent | 3c8d95df7cccbf10f10626a17bfec49f959ec083 (diff) |
Prevent a divide by zero panic if trunkproto loadbalance is
used w/out any trunkports. Patch from Dmitri Alenitchev.
OK reyk@
-rw-r--r-- | sys/net/if_trunk.c | 7 |
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); |