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:
Bjoern A. Zeeb 2010-12-31 21:47:11 +00:00
parent c9a2711a54
commit c744cde428
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=216857

View File

@ -323,6 +323,9 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
} 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;
/*