summaryrefslogtreecommitdiffstats
path: root/src/ipv6nd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2019-11-10 20:39:52 +0000
committerRoy Marples <roy@marples.name>2019-11-10 20:40:20 +0000
commit127863ec6d42807bd595515ad8a39f92c36030ec (patch)
tree47bfa4ae6057464eb59896f93d9444fbf11496b2 /src/ipv6nd.c
parent7857a08e7c28cb16368501da110ec6f2a8e36e46 (diff)
downloaddhcpcd-127863ec6d42807bd595515ad8a39f92c36030ec.tar.xz
RA: Warn if advertised MTU is greater than link MTU
Diffstat (limited to 'src/ipv6nd.c')
-rw-r--r--src/ipv6nd.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/ipv6nd.c b/src/ipv6nd.c
index 3cf69713..6033ee11 100644
--- a/src/ipv6nd.c
+++ b/src/ipv6nd.c
@@ -990,6 +990,7 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
struct dhcp_opt *dho;
bool new_rap, new_data, has_address;
uint32_t old_lifetime;
+ int ifmtu;
__printflike(1, 2) void (*logfunc)(const char *, ...);
#ifdef IPV6_MANAGETEMPADDR
uint8_t new_ap;
@@ -1274,22 +1275,30 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx,
case ND_OPT_MTU:
if (len < sizeof(mtu)) {
- logerrx("%s: short MTU option", ifp->name);
+ logfunc("%s: short MTU option", ifp->name);
break;
}
memcpy(&mtu, p, sizeof(mtu));
mtu.nd_opt_mtu_mtu = ntohl(mtu.nd_opt_mtu_mtu);
if (mtu.nd_opt_mtu_mtu < IPV6_MMTU) {
- logerrx("%s: invalid MTU %d",
+ logfunc("%s: invalid MTU %d",
ifp->name, mtu.nd_opt_mtu_mtu);
break;
}
- rap->mtu = mtu.nd_opt_mtu_mtu;
+ ifmtu = if_getmtu(ifp);
+ if (ifmtu == -1)
+ logerr("if_getmtu");
+ else if (mtu.nd_opt_mtu_mtu > (uint32_t)ifmtu) {
+ logfunc("%s: advertised MTU %d"
+ " is greater than link MTU %d",
+ ifp->name, mtu.nd_opt_mtu_mtu, ifmtu);
+ rap->mtu = (uint32_t)ifmtu;
+ } else
+ rap->mtu = mtu.nd_opt_mtu_mtu;
break;
-
case ND_OPT_RDNSS:
if (len < sizeof(rdnss)) {
- logerrx("%s: short RDNSS option", ifp->name);
+ logfunc("%s: short RDNSS option", ifp->name);
break;
}
memcpy(&rdnss, p, sizeof(rdnss));