Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Jul 2018 09:41:50 +0000 (UTC)
From:      Eugene Grosbein <eugen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336195 - head/sbin/dhclient
Message-ID:  <201807110941.w6B9fogg097391@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eugen
Date: Wed Jul 11 09:41:50 2018
New Revision: 336195
URL: https://svnweb.freebsd.org/changeset/base/336195

Log:
  Make dhclient(8) verify if new MTU (option 26) differs from current one and skip unneeded MTU change.
  This check eliminates infinite loop of MTU change / link flap / lease verification / MTU change / link flap etc.
  in case of some NIC drivers like em(4) or igb(4).
  
  N.B.: obsolete u_int16_t is used in consistency with the rest of the file.
  
  PR:		229432
  Approved by:	mav (mentor)
  MFC after:	1 week

Modified:
  head/sbin/dhclient/dispatch.c

Modified: head/sbin/dhclient/dispatch.c
==============================================================================
--- head/sbin/dhclient/dispatch.c	Wed Jul 11 07:45:04 2018	(r336194)
+++ head/sbin/dhclient/dispatch.c	Wed Jul 11 09:41:50 2018	(r336195)
@@ -547,17 +547,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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807110941.w6B9fogg097391>