[PATCH] ctrl: Fix handling of missing replies

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Thu May 15 11:04:14 UTC 2014


Currently, if a CTRL method does not set the reply, an error is
logged ("cmd->reply has not been set"). It even complains when the
function implementing the command returns CTRL_CMD_HANDLED, where
a reply text is not needed.

This patch changes the logging level from ERROR to NOTICE. The logging
is now only done, when the retry has not been set and the
implementation returns either CTRL_CMD_ERROR or CTRL_CMD_REPLY. So
in these cases the reply field must be set.

This fixes the generation of log messages when doing NAT ctrl command
forwarding.

Ticket: OW#1177
Sponsored-by: On-Waves ehf
---
 openbsc/src/libbsc/bsc_ctrl_lookup.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/openbsc/src/libbsc/bsc_ctrl_lookup.c b/openbsc/src/libbsc/bsc_ctrl_lookup.c
index 338fb11..3a3df9c 100644
--- a/openbsc/src/libbsc/bsc_ctrl_lookup.c
+++ b/openbsc/src/libbsc/bsc_ctrl_lookup.c
@@ -150,11 +150,19 @@ int bsc_ctrl_cmd_handle(struct ctrl_cmd *cmd, void *data)
 
 err:
 	if (!cmd->reply) {
-		LOGP(DCTRL, LOGL_ERROR, "cmd->reply has not been set.\n");
-		if (ret == CTRL_CMD_ERROR)
+		if (ret == CTRL_CMD_ERROR) {
 			cmd->reply = "An error has occured.";
-		else
+			LOGP(DCTRL, LOGL_NOTICE,
+			     "%s: cmd->reply has not been set (ERROR).\n",
+			     cmd->variable);
+		} else if (ret == CTRL_CMD_REPLY) {
+			LOGP(DCTRL, LOGL_NOTICE,
+			     "%s: cmd->reply has not been set (type = %d).\n",
+			     cmd->variable, cmd->type);
+			cmd->reply = "";
+		} else {
 			cmd->reply = "Command has been handled.";
+		}
 	}
 
 	if (ret == CTRL_CMD_ERROR)
-- 
1.7.9.5





More information about the OpenBSC mailing list