From owner-svn-src-stable@freebsd.org  Thu Jul  4 13:20:33 2019
Return-Path: <owner-svn-src-stable@freebsd.org>
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 052A215D55D3;
 Thu,  4 Jul 2019 13:20:33 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 server-signature RSA-PSS (4096 bits)
 client-signature RSA-PSS (4096 bits) client-digest SHA256)
 (Client CN "mxrelay.nyi.freebsd.org",
 Issuer "Let's Encrypt Authority X3" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 99F1F91632;
 Thu,  4 Jul 2019 13:20:32 +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 6FCEA23703;
 Thu,  4 Jul 2019 13:20:32 +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 x64DKWUK026295;
 Thu, 4 Jul 2019 13:20:32 GMT (envelope-from eugen@FreeBSD.org)
Received: (from eugen@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id x64DKWhu026294;
 Thu, 4 Jul 2019 13:20:32 GMT (envelope-from eugen@FreeBSD.org)
Message-Id: <201907041320.x64DKWhu026294@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: eugen set sender to
 eugen@FreeBSD.org using -f
From: Eugene Grosbein <eugen@FreeBSD.org>
Date: Thu, 4 Jul 2019 13:20:32 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject: svn commit: r349725 - stable/12/libexec/rc
X-SVN-Group: stable-12
X-SVN-Commit-Author: eugen
X-SVN-Commit-Paths: stable/12/libexec/rc
X-SVN-Commit-Revision: 349725
X-SVN-Commit-Repository: base
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Rspamd-Queue-Id: 99F1F91632
X-Spamd-Bar: --
Authentication-Results: mx1.freebsd.org
X-Spamd-Result: default: False [-2.97 / 15.00];
 local_wl_from(0.00)[FreeBSD.org];
 NEURAL_HAM_MEDIUM(-1.00)[-0.998,0];
 NEURAL_HAM_LONG(-1.00)[-1.000,0];
 NEURAL_HAM_SHORT(-0.97)[-0.971,0];
 ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
 <svn-src-stable.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-stable>, 
 <mailto:svn-src-stable-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-stable/>
List-Post: <mailto:svn-src-stable@freebsd.org>
List-Help: <mailto:svn-src-stable-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-stable>,
 <mailto:svn-src-stable-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 04 Jul 2019 13:20:33 -0000

Author: eugen
Date: Thu Jul  4 13:20:32 2019
New Revision: 349725
URL: https://svnweb.freebsd.org/changeset/base/349725

Log:
  MFC r345970: network.subr: improve configuration of cloned gif(4) interfaces
  
  ifconfig(8) syntax allows to specify only single address_family,
  so we need additional invocation of ifconfig to support configuration
  of cloned gif interface that may use different address families
  for its internal and external addresses.
  
  Also, ifconfig(8) does not allow to omit "inet6" keyword for address family
  specifying IPv6 addresses as outer addresses of the interface.
  
  Also, address_family is not "parameter" and it has to go before parameters
  including "tunnel" keyword, so "ifconfig gif0 tunnel inet6 $oip1 $oip2" would be
  wrong syntax and only "ifconfig gif0 inet6 tunnel $oip1 $oip2" is right.
  
  With this change, the following works:
  
  gifconfig_gif0="inet6 2a00::1 2a01::1"
  ifconfig_gif0="inet 10.0.0.1 10.0.0.2 netmask 255.255.255.252"

Modified:
  stable/12/libexec/rc/network.subr
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rc/network.subr
==============================================================================
--- stable/12/libexec/rc/network.subr	Thu Jul  4 12:40:38 2019	(r349724)
+++ stable/12/libexec/rc/network.subr	Thu Jul  4 13:20:32 2019	(r349725)
@@ -1323,7 +1323,7 @@ wlan_down()
 #
 clone_up()
 {
-	local _list ifn ifopt _iflist _n tmpargs
+	local _list ifn ifopt _iflist _inet6 _n tmpargs
 	_list=
 	_iflist=$*
 
@@ -1389,9 +1389,21 @@ clone_up()
 		esac
 		if [ $? -eq 0 ]; then
 			_list="$_list $ifn"
+			tmpargs=$(get_if_var $ifn gifconfig_IF)
+			_inet6=''
+			case "$tmpargs" in
+			'')
+			;;
+			inet6[[:space:]]*)
+				tmpargs=${tmpargs#inet6}
+				_inet6=inet6
+				# FALLTHROUGH
+			;&
+			*)
+				${IFCONFIG_CMD} $ifn $_inet6 tunnel $tmpargs
+			;;
+			esac
 		fi
-		tmpargs=$(get_if_var $ifn gifconfig_IF)
-		eval ifconfig_${ifn}=\"\$ifconfig_${ifn} tunnel \$tmpargs\"
 	done
 	if [ -n "${_list# }" ]; then
 		echo "Created clone interfaces: ${_list# }."