From f8d40a5b25b47f145f20ca83d5581428cb6a4e2c Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Mon, 15 May 2017 17:40:37 +0200 Subject: router: fix interface mtu read error Use integer type for mtu variable as odhcpd_get_interface_config returns -1 when it fails to read the interface mtu. This allows to set the mtu to a meaningfull value of 1280 in case of interface mtu read failure. Signed-off-by: Hans Dedecker --- src/odhcpd.h | 2 +- src/router.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/odhcpd.h b/src/odhcpd.h index bb4702e..ecb7d9a 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -165,7 +165,7 @@ struct interface { uint32_t ra_reachabletime; uint32_t ra_retranstime; uint32_t ra_hoplimit; - uint32_t ra_mtu; + int ra_mtu; // DHCPv4 struct in_addr dhcpv4_start; diff --git a/src/router.c b/src/router.c index 8a2f816..f08a7b0 100644 --- a/src/router.c +++ b/src/router.c @@ -259,11 +259,11 @@ static uint16_t calc_ra_lifetime(struct interface *iface, uint32_t maxival) static uint64_t send_router_advert(struct interface *iface, const struct in6_addr *from) { time_t now = odhcpd_time(); - uint32_t mtu = iface->ra_mtu; + int mtu = iface->ra_mtu; int hlim = iface->ra_hoplimit; if (mtu == 0) - mtu = odhcpd_get_interface_config(iface->ifname, "mtu"); + mtu = odhcpd_get_interface_config(iface->ifname, "mtu"); if (mtu < 1280) mtu = 1280; -- cgit v1.2.3