Try to catch a possible divide-by-zero as early as possible if "mtu" is 0

(also test for negative MTUs if checking it anyway).
An MTU of 0 is arguably a bug elsewhere, but this at least gives us some
more debugging hints.

Sponsored by:	ISPsystem (Early 2010)
MFC after:	1 week
This commit is contained in:
bz 2010-12-31 21:47:11 +00:00
parent 2a04b52e8a
commit 969f8f9046

View File

@ -323,6 +323,9 @@ again:
} else {
mtu = ifp->if_mtu;
}
/* Catch a possible divide by zero later. */
KASSERT(mtu > 0, ("%s: mtu %d <= 0, rte=%p (rt_flags=0x%08x) ifp=%p",
__func__, mtu, rte, (rte != NULL) ? rte->rt_flags : 0, ifp));
if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr))) {
m->m_flags |= M_MCAST;
/*