[PATCH] ctrliface: add the debug log, print out the source address of the Ctrl iface when recv command

xinpeng wang wangxinpeng at uniontech.com
Wed Jan 5 00:54:59 PST 2022


sometimes there is a program error to send a large number of commands to the
WPA, and the source address can help quickly find the program that sends
commands.

Signed-off-by: xinpeng wang <wangxinpeng at uniontech.com>
---
 wpa_supplicant/ctrl_iface.c      | 2 +-
 wpa_supplicant/ctrl_iface.h      | 6 ++++++
 wpa_supplicant/ctrl_iface_udp.c  | 2 ++
 wpa_supplicant/ctrl_iface_unix.c | 2 ++
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index bcd67fca3..df917b757 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -10685,7 +10685,7 @@ fail:
 #endif /* CONFIG_FILS */
 
 
-static int wpas_ctrl_cmd_debug_level(const char *cmd)
+int wpas_ctrl_cmd_debug_level(const char *cmd)
 {
 	if (os_strcmp(cmd, "PING") == 0 ||
 	    os_strncmp(cmd, "BSS ", 4) == 0 ||
diff --git a/wpa_supplicant/ctrl_iface.h b/wpa_supplicant/ctrl_iface.h
index dfbd25a03..2a5c0e712 100644
--- a/wpa_supplicant/ctrl_iface.h
+++ b/wpa_supplicant/ctrl_iface.h
@@ -122,6 +122,8 @@ void wpa_supplicant_global_ctrl_iface_deinit(
 
 void wpas_ctrl_radio_work_flush(struct wpa_supplicant *wpa_s);
 
+int wpas_ctrl_cmd_debug_level(const char *cmd);
+
 #else /* CONFIG_CTRL_IFACE */
 
 static inline struct ctrl_iface_priv *
@@ -162,6 +164,10 @@ static inline void wpas_ctrl_radio_work_flush(struct wpa_supplicant *wpa_s)
 {
 }
 
+static inline int wpas_ctrl_cmd_debug_level(const char *cmd)
+{
+}
+
 #endif /* CONFIG_CTRL_IFACE */
 
 #endif /* CTRL_IFACE_H */
diff --git a/wpa_supplicant/ctrl_iface_udp.c b/wpa_supplicant/ctrl_iface_udp.c
index 1cbf7fa28..e2a94ffa8 100644
--- a/wpa_supplicant/ctrl_iface_udp.c
+++ b/wpa_supplicant/ctrl_iface_udp.c
@@ -337,6 +337,8 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
 		else
 			reply_len = 2;
 	} else {
+		int level = wpas_ctrl_cmd_debug_level(buf);
+		sockaddr_print(level, "Control interface recv command from:", &from, fromlen);
 		reply = wpa_supplicant_ctrl_iface_process(wpa_s, pos,
 							  &reply_len);
 	}
diff --git a/wpa_supplicant/ctrl_iface_unix.c b/wpa_supplicant/ctrl_iface_unix.c
index 639573dae..6890f3d52 100644
--- a/wpa_supplicant/ctrl_iface_unix.c
+++ b/wpa_supplicant/ctrl_iface_unix.c
@@ -178,6 +178,8 @@ static void wpa_supplicant_ctrl_iface_receive(int sock, void *eloop_ctx,
 		else
 			reply_len = 2;
 	} else {
+		int level = wpas_ctrl_cmd_debug_level(buf);
+		sockaddr_print(level, "Control interface recv command from:", &from, fromlen);
 		reply_buf = wpa_supplicant_ctrl_iface_process(wpa_s, buf,
 							      &reply_len);
 		reply = reply_buf;
-- 
2.20.1






More information about the Hostap mailing list