From 8460e0d8fa27ba073e6d85e0ab683586b2e3e007 Mon Sep 17 00:00:00 2001
From: Boris Ranto <branto@redhat.com>
Date: Thu, 18 Feb 2016 16:10:42 +0100
Subject: [PATCH] Avoid assert on mismatched session ID
Move the logic that checks the session ID from read_session_data_v2x
function to the ipmi_lan_poll_single function in order to avoid calling
assert in this case. We can continue with the next packet if we detect
a session ID mismatch.
Signed-off-by: Boris Ranto <branto@redhat.com>
---
src/plugins/lanplus/lanplus.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/src/plugins/lanplus/lanplus.c b/src/plugins/lanplus/lanplus.c
index 998c1f9..7433337 100644
--- a/src/plugins/lanplus/lanplus.c
+++ b/src/plugins/lanplus/lanplus.c
@@ -664,6 +664,21 @@ ipmi_lan_poll_recv(struct ipmi_intf * intf)
read_session_data(rsp, &offset, intf->session);
+ /*
+ * Skip packets that are not intended for this session
+ */
+ if ((session->v2_data.session_state == LANPLUS_STATE_ACTIVE) &&
+ (rsp->session.authtype == IPMI_SESSION_AUTHTYPE_RMCP_PLUS) &&
+ (rsp->session.id != intf->session->v2_data.console_id))
+ {
+ lprintf(LOG_INFO, "packet session id 0x%x does not "
+ "match active session 0x%0x",
+ rsp->session.id, intf->session->v2_data.console_id);
+ lprintf(LOG_ERR, "ERROR: Received an Unexpected message ID");
+ /* read one more packet */
+ continue;
+ }
+
if (lanplus_has_valid_auth_code(rsp, intf->session) == 0)
{
lprintf(LOG_ERR, "ERROR: Received message with invalid authcode!");
@@ -1172,19 +1187,6 @@ read_session_data_v2x(
#endif
- /*
- * Verify that the session ID is what we think it should be
- */
- if ((s->v2_data.session_state == LANPLUS_STATE_ACTIVE) &&
- (rsp->session.id != s->v2_data.console_id))
- {
- lprintf(LOG_ERR, "packet session id 0x%x does not "
- "match active session 0x%0x",
- rsp->session.id, s->v2_data.console_id);
- assert(0);
- }
-
-
/* Ignored, so far */
memcpy(&rsp->session.seq, rsp->data + *offset, 4);
*offset += 4;
--
2.5.0