summaryrefslogtreecommitdiffstats
path: root/freebsd/sbin/dhclient/dispatch.c
diff options
context:
space:
mode:
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);
}