summaryrefslogtreecommitdiffstats
path: root/freebsd/sbin/dhclient/dispatch.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-08-22 14:59:50 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-09-21 10:29:41 +0200
commit3489e3b6396ee9944a6a2e19e675ca54c36993b4 (patch)
treecd55cfac1c96ff4b888a9606fd6a0d8eb65bb446 /freebsd/sbin/dhclient/dispatch.c
parentck: Define CK_MD_PPC32_LWSYNC if available (diff)
downloadrtems-libbsd-3489e3b6396ee9944a6a2e19e675ca54c36993b4.tar.bz2
Update to FreeBSD head 2018-09-17
Git mirror commit 6c2192b1ef8c50788c751f878552526800b1e319. Update #3472.
Diffstat (limited to 'freebsd/sbin/dhclient/dispatch.c')
-rw-r--r--freebsd/sbin/dhclient/dispatch.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/freebsd/sbin/dhclient/dispatch.c b/freebsd/sbin/dhclient/dispatch.c
index a9cc65b7..b815e6b8 100644
--- a/freebsd/sbin/dhclient/dispatch.c
+++ b/freebsd/sbin/dhclient/dispatch.c
@@ -59,8 +59,8 @@ __FBSDID("$FreeBSD$");
/* Assert that pointer p is aligned to at least align bytes */
#define assert_aligned(p, align) assert((((uintptr_t)p) & ((align) - 1)) == 0)
-struct protocol *protocols;
-struct timeout *timeouts;
+static struct protocol *protocols;
+static struct timeout *timeouts;
static struct timeout *free_timeouts;
static int interfaces_invalidated;
void (*bootp_packet_handler)(struct interface_info *,
@@ -549,17 +549,29 @@ interface_set_mtu_priv(char *ifname, u_int16_t mtu)
{
struct ifreq ifr;
int sock;
+ u_int16_t old_mtu;
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
error("Can't create socket");
memset(&ifr, 0, sizeof(ifr));
+ old_mtu = 0;
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
- ifr.ifr_mtu = mtu;
- if (ioctl(sock, SIOCSIFMTU, &ifr) == -1)
- warning("SIOCSIFMTU failed (%d): %s", mtu,
+ if (ioctl(sock, SIOCGIFMTU, (caddr_t)&ifr) == -1)
+ warning("SIOCGIFMTU failed (%s): %s", ifname,
strerror(errno));
+ else
+ old_mtu = ifr.ifr_mtu;
+
+ if (mtu != old_mtu) {
+ ifr.ifr_mtu = mtu;
+
+ if (ioctl(sock, SIOCSIFMTU, &ifr) == -1)
+ warning("SIOCSIFMTU failed (%d): %s", mtu,
+ strerror(errno));
+ }
+
close(sock);
}