[PATCH] netifd: add debug options to uci

Florian Eckert fe at dev.tdt.de
Tue Jan 10 00:13:15 PST 2023


To simplify netifd development, the logging and debugging options should
be configured via uci, so we could set this also during boot.

New uci config options in '/etc/config/network':

config globals 'globals'
	option mask '1'
	option level '3'

The following options are available for the individual uci options and are
given when the service is started.

Option 'mask':
This option  specifies which messages are output on the stderr.
* SYSTEM = 0
* DEVICE = 1
* INTERFACE = 2
* WIRELESS = 3

In order for the log messages to also appear in the syslog, the output
of the stderr must be redirected by the netifd.

Option 'level':
* L_CRIT = 0
* L_WARNING = 1
* L_NOTICE = 2
* L_INFO = 3
* L_DEBUG = 4

With this option the loglevel of the netifd can be changed. If nothing
is specified, the level is set to 'notice'.

Signed-off-by: Florian Eckert <fe at dev.tdt.de>
---
 .../network/config/netifd/files/etc/init.d/network    | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/package/network/config/netifd/files/etc/init.d/network b/package/network/config/netifd/files/etc/init.d/network
index dc208c4ce0..ffdf470e10 100755
--- a/package/network/config/netifd/files/etc/init.d/network
+++ b/package/network/config/netifd/files/etc/init.d/network
@@ -15,8 +15,19 @@ init_switch() {
 start_service() {
 	init_switch
 
+	local mask level debug
+
+	config_load network
+	config_get level "globals" level
+	config_get mask "globals" mask
+
 	procd_open_instance
 	procd_set_param command /sbin/netifd
+	[ -z "${level}" ] || procd_append_param command -l "$level"
+	[ -z "${mask}" ] || {
+		procd_append_param command -d "$mask"
+		procd_set_param stderr 1
+	}
 	procd_set_param respawn
 	procd_set_param watch network.interface
 	[ -e /proc/sys/kernel/core_pattern ] && {
-- 
2.30.2




More information about the openwrt-devel mailing list