From fb89f62a9e0e08cb7a995497d0d1f6cdc86e53fc Mon Sep 17 00:00:00 2001 From: Eric MacDonald Date: Wed, 22 May 2019 08:45:14 -0400 Subject: [PATCH] Fix hbsAgent mgmnt interface name corruption The hbsAgent socket initialization process is declaring a local string variable and then loading the management interface name into it and setting its static management interface config pointer to that variable. So, when that local variable falls out of scope and that local (stack) variable memory is recycled and changed by its new owner then the data the management interface config pointer points to changes and that leads to the reported error condition and log flooding. This update allocates a new memory pointer instead. Change-Id: I858bcc69455f1d915f2873c47a75dd1139cf8fcb Closes-Bug: 1829608 Signed-off-by: Eric MacDonald --- mtce/centos/build_srpm.data | 2 +- mtce/src/heartbeat/hbsAgent.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mtce/centos/build_srpm.data b/mtce/centos/build_srpm.data index c3dfc2e7..41f9cbb7 100644 --- a/mtce/centos/build_srpm.data +++ b/mtce/centos/build_srpm.data @@ -1,3 +1,3 @@ SRC_DIR="src" -TIS_PATCH_VER=151 +TIS_PATCH_VER=152 BUILD_IS_SLOW=5 diff --git a/mtce/src/heartbeat/hbsAgent.cpp b/mtce/src/heartbeat/hbsAgent.cpp index c0b16071..dc90df40 100644 --- a/mtce/src/heartbeat/hbsAgent.cpp +++ b/mtce/src/heartbeat/hbsAgent.cpp @@ -407,7 +407,7 @@ int daemon_configure ( void ) ilog("Failure Thld: %i misses\n", hbsInv.hbs_failure_threshold ); ilog("Multicast : %s\n", hbs_config.multicast ); - ilog("Mgmnt Name : %s\n", hbs_config.mgmnt_iface ); /* TODO: Remove me */ + ilog("Mgmnt Name : %s\n", hbs_config.mgmnt_iface ); hbs_config.mgmnt_iface = daemon_get_iface_master ( hbs_config.mgmnt_iface ); ilog("Mgmnt Master: %s\n", hbs_config.mgmnt_iface ); @@ -866,6 +866,8 @@ int hbs_socket_init ( void ) /* Setup the pulse messaging interfaces */ SETUP_PULSE_MESSAGING ( hbsInv.clstr_network_provisioned, rmem_max ) ; + /* Handle re-init case */ + close_netlink_socket ( hbs_sock.netlink_sock ); if (( hbs_sock.netlink_sock = open_netlink_socket ( RTMGRP_LINK )) <= 0 ) { elog ("Failed to create netlink listener socket"); @@ -1556,7 +1558,6 @@ void daemon_service_run ( void ) else // ( sockets_init == false ) { string mgmnt_iface = daemon_mgmnt_iface (); - hbs_config.mgmnt_iface = (char*)mgmnt_iface.data(); if ( mgmnt_iface.empty() || ( mgmnt_iface == "none" )) { ilog_throttled ( wait_log_throttle, 5, "MGMNT wait ..."); @@ -1564,6 +1565,14 @@ void daemon_service_run ( void ) continue ; } + /* update management interface name pointer with the master + * name if different from current config name */ + if ( hbs_config.mgmnt_iface != mgmnt_iface ) + { + if ( hbs_config.mgmnt_iface ) + free ( hbs_config.mgmnt_iface ); + hbs_config.mgmnt_iface = strdup((char*)mgmnt_iface.data()); + } if ( (rc = daemon_configure ( )) != PASS ) { elog ("Daemon service configuration failed (rc:%i)\n", rc );