Skip to contentSkip to conversation

netconfig: Add multiple levels to IWD_DHCP_DEBUG

PATCH Superseded Michael Johnson 1 participant 2 messages May 17, 2022

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Michael Johnson

author
#0 lore raw

PATCH 1/2 netconfig: Add multiple levels to IWD_DHCP_DEBUG

Allows granularly specifying the DHCP logging level. This allows the user to tailor the output to what they need. By default always display errors and warnings.

1 = INFO
2 = DEBUG

---
 src/netconfig.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
src/netconfig.c +14 -3
index 6694a0e9..7dd35b2f 100644
@@ -1621,6 +1621,8 @@ struct netconfig *netconfig_new(uint32_t ifindex)
 	struct netdev *netdev = netdev_find(ifindex);
 	struct netconfig *netconfig;
 	struct l_icmp6_client *icmp6;
+	const char *debug_level = NULL;
+	int dhcp_priority = L_LOG_WARNING;
 
 	if (!netconfig_list)
 		return NULL;
@@ -1640,9 +1642,18 @@ struct netconfig *netconfig_new(uint32_t ifindex)
 					netconfig_ipv4_dhcp_event_handler,
 					netconfig, NULL);
 
-	if (getenv("IWD_DHCP_DEBUG"))
-		l_dhcp_client_set_debug(netconfig->dhcp_client, do_debug,
-							"[DHCPv4] ", NULL);
+	debug_level = getenv("IWD_DHCP_DEBUG");
+	if (debug_level != NULL)
+	{
+		// Convert from user 1 or 2 to L_LOG_*
+		if (*debug_level == '1')
+			dhcp_priority = L_LOG_INFO;
+		else if (*debug_level == '2')
+			dhcp_priority = L_LOG_DEBUG;
+	}
+
+	l_dhcp_client_set_debug(netconfig->dhcp_client, do_debug,
+						"[DHCPv4] ", NULL, dhcp_priority);
 
 	netconfig->dhcp6_client = l_dhcp6_client_new(ifindex);
 	l_dhcp6_client_set_event_handler(netconfig->dhcp6_client,
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/2 docs: Update IWD_DHCP_DEBUG values

Use ``1`` and ``2`` for debug level to maintain compatibility with existing settings.

---
 src/iwd.debug.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/iwd.debug.rst +1 -1
index 5a805562..e218c4a8 100644
@@ -34,7 +34,7 @@ ENVIRONMENT
 
 *$IWD_GENL_DEBUG* set to ``1`` enables printing Generic Netlink communication with the kernel.
 
-*$IWD_DHCP_DEBUG* set to ``1`` enables DHCP debugging.
+*$IWD_DHCP_DEBUG* set to ``1`` (info) or ``2`` (debug) to enabled DHCP logging.
 
 *$IWD_TLS_DEBUG* set to ``1`` enables TLS debugging.
 
Signature · 1 line
2.25.1