[From nobody Thu Jun 25 05:55:12 2020
Received: from mail.sgstbr.de ([2a01:4f8:160:14d5:e20b::21])
 by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux))
 id 1hUqFl-0002Tp-Jx
 for openwrt-devel@lists.openwrt.org; Sun, 26 May 2019 10:19:47 +0000
Received: from fbl-desktop.lan (unknown
 [IPv6:2a02:810d:98c0:4a00:6791:2d02:f640:b309])
 (Authenticated sender: fabian@blaese.de)
 by mail.sgstbr.de (Postfix) with ESMTPSA id 0AAA52C00D2;
 Sun, 26 May 2019 12:19:41 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blaese.de; s=201803;
 t=1558865981; bh=mfF5H4/bMdVbotXOIFHsxcJDjN++IstH4wLM0VsdGa4=;
 h=From:To:Subject:Date:From;
 b=VNzINyPJmX9bnYMX0DXaEhxyyjk3rQEQqmtG4H+5fnOWjyYUZh2JVWJ+soiq9qszg
 Xte/JKqQdsdElGuvdG8+tasTHwiwdQi6fFDslnkWg5jTmxBZN78r9TcWQsPoyJy01g
 03ljFi+zwQnTVq1oT6VDyka37HZyUtKyfvWS0vMkj5rC/U1F+Op0Q1Ulf8CSVkiEdu
 LphiK71AOb63/WrvYpHpgNyXtJwVRSl856CCHKLZMY4lXN+ReRU1TQlgVIjop0wk7B
 pgFxfoWkhZXoUkNDYzB3LXL9GcthFw9NodGCjK3M4lhUw6fi+Pu6zQBB6T1EvCJ6sg
 jCxTO4rgG6o2w==
From: =?UTF-8?q?Fabian=20Bl=C3=A4se?= &lt;fabian@blaese.de&gt;
To: openwrt-devel@lists.openwrt.org
Cc: =?UTF-8?q?Fabian=20Bl=C3=A4se?= &lt;fabian@blaese.de&gt;
Subject: [PATCH] gre: introduce 'nohostroute' option
Date: Sun, 26 May 2019 12:19:05 +0200
Message-Id: &lt;20190526101905.6764-1-fabian@blaese.de&gt;
X-Mailer: git-send-email 2.21.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 
X-CRM114-CacheID: sfid-20190526_031946_258669_AF0F1A36 
X-CRM114-Status: UNSURE (   7.90  )
X-CRM114-Notice: Please train this message.
X-Spam-Score: -0.2 (/)
X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary:
 Content analysis details:   (-0.2 points)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from
 envelope-from domain
 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
 -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from
 author's domain
 0.1 DKIM_SIGNED            Message has a DKIM or DK signature, not necessarily
 valid

It is not always necessary to add a host route for the gre peer address.

This introduces a new config option 'nohostroute' (similar to the
option introduced for wireguard in d8e2e19) to allow to disable
the creation of those routes explicitely.

Signed-off-by: Fabian Bläse &lt;fabian@blaese.de&gt;
---
 package/network/config/gre/files/gre.sh | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/package/network/config/gre/files/gre.sh b/package/network/config/gre/files/gre.sh
index 2bb1010b76..3414ed3047 100755
--- a/package/network/config/gre/files/gre.sh
+++ b/package/network/config/gre/files/gre.sh
@@ -56,7 +56,7 @@ gre_setup() {
 	local remoteip
 
 	local ipaddr peeraddr
-	json_get_vars df ipaddr peeraddr tunlink
+	json_get_vars df ipaddr peeraddr tunlink nohostroute
 
 	[ -z &quot;$peeraddr&quot; ] &amp;&amp; {
 		proto_notify_error &quot;$cfg&quot; &quot;MISSING_PEER_ADDRESS&quot;
@@ -76,7 +76,9 @@ gre_setup() {
 		break
 	done
 
-	( proto_add_host_dependency &quot;$cfg&quot; &quot;$peeraddr&quot; &quot;$tunlink&quot; )
+	if [ &quot;${nohostroute}&quot; != &quot;1&quot; ]; then
+		( proto_add_host_dependency &quot;$cfg&quot; &quot;$peeraddr&quot; &quot;$tunlink&quot; )
+	fi
 
 	[ -z &quot;$ipaddr&quot; ] &amp;&amp; {
 		local wanif=&quot;$tunlink&quot;
@@ -133,7 +135,7 @@ grev6_setup() {
 	local remoteip6
 
 	local ip6addr peer6addr weakif
-	json_get_vars ip6addr peer6addr tunlink weakif encaplimit
+	json_get_vars ip6addr peer6addr tunlink weakif encaplimit nohostroute
 
 	[ -z &quot;$peer6addr&quot; ] &amp;&amp; {
 		proto_notify_error &quot;$cfg&quot; &quot;MISSING_PEER_ADDRESS&quot;
@@ -153,7 +155,9 @@ grev6_setup() {
 		break
 	done
 
-	( proto_add_host_dependency &quot;$cfg&quot; &quot;$peer6addr&quot; &quot;$tunlink&quot; )
+	if [ &quot;${nohostroute}&quot; != &quot;1&quot; ]; then
+		( proto_add_host_dependency &quot;$cfg&quot; &quot;$peer6addr&quot; &quot;$tunlink&quot; )
+	fi
 
 	[ -z &quot;$ip6addr&quot; ] &amp;&amp; {
 		local wanif=&quot;$tunlink&quot;
@@ -262,6 +266,7 @@ proto_gre_init_config() {
 	proto_config_add_string &quot;ipaddr&quot;
 	proto_config_add_string &quot;peeraddr&quot;
 	proto_config_add_boolean &quot;df&quot;
+	proto_config_add_boolean &quot;nohostroute&quot;
 }
 
 proto_gretap_init_config() {
@@ -275,6 +280,7 @@ proto_grev6_init_config() {
 	proto_config_add_string &quot;peer6addr&quot;
 	proto_config_add_string &quot;weakif&quot;
 	proto_config_add_string &quot;encaplimit&quot;
+	proto_config_add_boolean &quot;nohostroute&quot;
 }
 
 proto_grev6tap_init_config() {
-- 
2.21.0


]