From owner-svn-src-stable@freebsd.org Wed Jul 18 01:57:14 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 583E8102F224; Wed, 18 Jul 2018 01:57:14 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0C4EE82ABB; Wed, 18 Jul 2018 01:57:14 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DBDB013BDB; Wed, 18 Jul 2018 01:57:13 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6I1vDjS030922; Wed, 18 Jul 2018 01:57:13 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6I1vDLG030921; Wed, 18 Jul 2018 01:57:13 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201807180157.w6I1vDLG030921@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Wed, 18 Jul 2018 01:57:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r336440 - stable/11/sbin/dhclient X-SVN-Group: stable-11 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/11/sbin/dhclient X-SVN-Commit-Revision: 336440 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2018 01:57:14 -0000 Author: eugen Date: Wed Jul 18 01:57:13 2018 New Revision: 336440 URL: https://svnweb.freebsd.org/changeset/base/336440 Log: MFC r336195: unbreak dhclient(8) option 26 processing 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). PR: 229432 Approved by: mav (mentor) Modified: stable/11/sbin/dhclient/dispatch.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/dhclient/dispatch.c ============================================================================== --- stable/11/sbin/dhclient/dispatch.c Wed Jul 18 00:56:25 2018 (r336439) +++ stable/11/sbin/dhclient/dispatch.c Wed Jul 18 01:57:13 2018 (r336440) @@ -545,17 +545,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); }