From 539081d31548eb7a37bd2797c1cd06a5b94488ec Mon Sep 17 00:00:00 2001
From: viisauksena <viisauksena@users.noreply.github.com>
Date: Sun, 6 Nov 2016 00:01:49 +0100
Subject: [PATCH] gluon-mesh-vpn-fastd: make fastd syslog level configurable
 (#915)

---
 docs/site-example/site.conf                                   | 1 +
 docs/user/site.rst                                            | 3 +++
 package/gluon-mesh-vpn-fastd/check_site.lua                   | 1 +
 .../luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd               | 4 ++--
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/docs/site-example/site.conf b/docs/site-example/site.conf
index 7c5bbe254..8949ebb9f 100644
--- a/docs/site-example/site.conf
+++ b/docs/site-example/site.conf
@@ -102,6 +102,7 @@
     methods = {'salsa2012+umac'},
     -- enabled = true,
     -- configurable = true,
+    -- syslog_level = 'warn',
 
     mtu = 1280,
     groups = {
diff --git a/docs/user/site.rst b/docs/user/site.rst
index 0987a4445..21e2d5a4a 100644
--- a/docs/user/site.rst
+++ b/docs/user/site.rst
@@ -182,12 +182,15 @@ fastd_mesh_vpn
     In any case, the ``null`` method should always be the first method in the list
     if it is supported at all. You should only set `configurable` to `true` if the
     configured peers support both the ``null`` method and methods with encryption.
+    
+    You can set syslog_level from verbose (default) to warn to reduce syslog output.
     ::
 
       fastd_mesh_vpn = {
         methods = {'salsa2012+umac'},
       	-- enabled = true,
       	-- configurable = true,
+	-- syslog_level = 'warn',
         mtu = 1280,
         groups = {
           backbone = {
diff --git a/package/gluon-mesh-vpn-fastd/check_site.lua b/package/gluon-mesh-vpn-fastd/check_site.lua
index 30cca11d0..c1bf0ea13 100644
--- a/package/gluon-mesh-vpn-fastd/check_site.lua
+++ b/package/gluon-mesh-vpn-fastd/check_site.lua
@@ -3,6 +3,7 @@ need_number('fastd_mesh_vpn.mtu')
 need_boolean('fastd_mesh_vpn.enabled', false)
 need_boolean('fastd_mesh_vpn.configurable', false)
 
+need_one_of('fastd_mesh_vpn.syslog_level', {'error', 'warn', 'info', 'verbose', 'debug', 'debug2'}, false)
 
 local function check_peer(prefix)
   return function(k, _)
diff --git a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd
index 74ab4a419..102ae0b4e 100755
--- a/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd
+++ b/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/400-mesh-vpn-fastd
@@ -20,6 +20,7 @@ if not enabled then
   enabled = site.fastd_mesh_vpn.enabled and 1 or 0
 end
 
+local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose'
 
 local methods
 
@@ -31,7 +32,6 @@ if site.fastd_mesh_vpn.configurable then
     has_null = lutil.contains(old_methods, 'null')
   end
 
-
   methods = {}
   if has_null then
     table.insert(methods, 'null')
@@ -52,7 +52,7 @@ uci:section('fastd', 'fastd', 'mesh_vpn',
 	  {
 		  enabled = enabled,
 		  group = 'gluon-fastd',
-		  syslog_level = 'verbose',
+		  syslog_level = syslog_level,
 		  interface = 'mesh-vpn',
 		  mode = 'tap',
 		  mtu = site.fastd_mesh_vpn.mtu,
-- 
GitLab