From: mpf Date: Wed, 30 Jul 2008 10:15:35 +0000 (+0000) Subject: Prevent a divide by zero panic if trunkproto loadbalance is X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9368cb083dfef01a6e4faad390becc38019ff235;p=openbsd Prevent a divide by zero panic if trunkproto loadbalance is used w/out any trunkports. Patch from Dmitri Alenitchev. OK reyk@ --- 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 @@ -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);