diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-05-17 20:42:45 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2019-05-17 20:42:45 +0000 |
commit | 14a3e7c3d0ad3653f1c91caa63f42f7276fd3a3e (patch) | |
tree | 1ef126adcc573aee7bd17e0c34288e270f254bba /sbin/dhclient/kroute.c | |
parent | 15db974524ee5b192ae4142ac4c3fd2c82928660 (diff) |
Don't put dhclient into a loop when interface-mtu is present
in a lease.
dhclient.c r1.634 made every RTM_IFINFO restart the DHCP protocol
and obtain a new/renewed lease. If the lease contained
interface-mtu the interface MTU was set. An RTM_IFINFO is
generated every time an interface MTU is set.
So only set the interface MTU if it is different from the
existing MTU. Fix using %d to print an unsigned value in passing.
Noticed and fix inmproved & tested by Bj??rn Ketelaars while
usihg the wifi on Dutch Railways.
Diffstat (limited to 'sbin/dhclient/kroute.c')
-rw-r--r-- | sbin/dhclient/kroute.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index 79e7436151a..d543f5c7aeb 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.162 2019/05/10 16:51:13 benno Exp $ */ +/* $OpenBSD: kroute.c,v 1.163 2019/05/17 20:42:44 krw Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -792,12 +792,18 @@ set_mtu(char *name, int ioctlfd, uint16_t mtu) struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - ifr.ifr_mtu = mtu; + if (ioctl(ioctlfd, SIOCGIFMTU, &ifr) == -1) { + log_warn("%s: SIOCGIFMTU", log_procname); + return; + } + if (ifr.ifr_mtu == mtu) + return; /* Avoid unnecessary RTM_IFINFO! */ + + ifr.ifr_mtu = mtu; if (ioctl(ioctlfd, SIOCSIFMTU, &ifr) == -1) - log_warn("%s: SIOCSIFMTU %d", log_procname, mtu); + log_warn("%s: SIOCSIFMTU %u", log_procname, mtu); } /* |