From b956d323865da7958654bb12de84c24783174bfc Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 12 Jul 2018 18:37:33 +0200 Subject: nat: ctrl: Avoid sending back received ERROR msgs We only send back if we had an error parsing the message locally. If we receive an ERROR message from a bsc, we try to forward it if the ID is valid, otherwise only log the received error description locally. Related: OS#3394 Change-Id: I7b4d20aea7a16c4b4e5add7c274a4ed34a7f6b8d --- openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'openbsc/src') diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c index 7a5e9d0ca..152929ce2 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c @@ -111,13 +111,14 @@ static struct bsc_cmd_list *bsc_get_pending(struct bsc_connection *bsc, char *id int bsc_nat_handle_ctrlif_msg(struct bsc_connection *bsc, struct msgb *msg) { struct ctrl_cmd *cmd; + bool parse_failed; struct bsc_cmd_list *pending; char *var; - cmd = ctrl_cmd_parse2(bsc, msg); + cmd = ctrl_cmd_parse3(bsc, msg, &parse_failed); msgb_free(msg); - if (cmd->type == CTRL_TYPE_ERROR) + if (cmd->type == CTRL_TYPE_ERROR && parse_failed) goto err; if (bsc->cfg && !llist_empty(&bsc->cfg->lac_list)) { @@ -152,11 +153,14 @@ int bsc_nat_handle_ctrlif_msg(struct bsc_connection *bsc, struct msgb *msg) ctrl_cmd_send(&pending->cmd->ccon->write_queue, cmd); bsc_nat_ctrl_del_pending(pending); } else { - /* We need to handle TRAPS here */ - if ((cmd->type != CTRL_TYPE_ERROR) && - (cmd->type != CTRL_TYPE_TRAP)) { - LOGP(DNAT, LOGL_NOTICE, "Got control message " - "from BSC without pending entry\n"); + if ((cmd->type == CTRL_TYPE_ERROR)) { + LOGP(DNAT, LOGL_NOTICE, "Got ERROR CTRL message " + "from BSC without pending/valid ID %s: %s\n", + cmd->id, cmd->reply); + } else { + LOGP(DNAT, LOGL_NOTICE, "Got %s CTRL message " + "from BSC without pending entry\n", + get_value_string(ctrl_type_vals, cmd->type)); cmd->type = CTRL_TYPE_ERROR; cmd->reply = "No request outstanding"; goto err; -- cgit v1.2.3