cope with ndi->maxmtu == 0 case. sync w/kame

This commit is contained in:
itojun 2002-06-07 03:05:18 +00:00
parent fb6078474d
commit 88a8e0dd9e

View File

@ -1,4 +1,4 @@
/* $NetBSD: nd6_rtr.c,v 1.29 2002/05/29 07:53:42 itojun Exp $ */
/* $NetBSD: nd6_rtr.c,v 1.30 2002/06/07 03:05:18 itojun Exp $ */
/* $KAME: nd6_rtr.c,v 1.95 2001/02/07 08:09:47 itojun Exp $ */
/*
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.29 2002/05/29 07:53:42 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: nd6_rtr.c,v 1.30 2002/06/07 03:05:18 itojun Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -351,6 +351,7 @@ nd6_ra_input(m, off, icmp6len)
*/
if (ndopts.nd_opts_mtu && ndopts.nd_opts_mtu->nd_opt_mtu_len == 1) {
u_int32_t mtu = ntohl(ndopts.nd_opts_mtu->nd_opt_mtu_mtu);
u_long maxmtu;
/* lower bound */
if (mtu < IPV6_MMTU) {
@ -361,25 +362,19 @@ nd6_ra_input(m, off, icmp6len)
}
/* upper bound */
if (ndi->maxmtu) {
if (mtu <= ndi->maxmtu) {
int change = (ndi->linkmtu != mtu);
maxmtu = (ndi->maxmtu && ndi->maxmtu < ifp->if_mtu)
? ndi->maxmtu : ifp->if_mtu;
if (mtu <= maxmtu) {
int change = (ndi->linkmtu != mtu);
ndi->linkmtu = mtu;
if (change) /* in6_maxmtu may change */
in6_setmaxmtu();
} else {
nd6log((LOG_INFO, "nd6_ra_input: bogus mtu "
"mtu=%d sent from %s; "
"exceeds maxmtu %d, ignoring\n",
mtu, ip6_sprintf(&ip6->ip6_src),
ndi->maxmtu));
}
ndi->linkmtu = mtu;
if (change) /* in6_maxmtu may change */
in6_setmaxmtu();
} else {
nd6log((LOG_INFO, "nd6_ra_input: mtu option "
"mtu=%d sent from %s; maxmtu unknown, "
"ignoring\n",
mtu, ip6_sprintf(&ip6->ip6_src)));
nd6log((LOG_INFO, "nd6_ra_input: bogus mtu "
"mtu=%d sent from %s; "
"exceeds maxmtu %lu, ignoring\n",
mtu, ip6_sprintf(&ip6->ip6_src), maxmtu));
}
}
@ -400,8 +395,8 @@ nd6_ra_input(m, off, icmp6len)
if (lladdr && ((ifp->if_addrlen + 2 + 7) & ~7) != lladdrlen) {
nd6log((LOG_INFO,
"nd6_ra_input: lladdrlen mismatch for %s "
"(if %d, RA packet %d)\n",
ip6_sprintf(&saddr6), ifp->if_addrlen, lladdrlen - 2));
"(if %d, RA packet %d)\n", ip6_sprintf(&saddr6),
ifp->if_addrlen, lladdrlen - 2));
goto bad;
}