Support mgmt and infra network on an interface

Currently, management interface can be shared with infrastructure only over
an VLAN. This update supports both management and infrastructure network
sharing a single interface.

Story: 2003087
Task: 23171
Depends-On: https://review.openstack.org/#/c/601156

Change-Id: Ie97dbd1260f5c98d7401b0e48361ebd87f060f65
Signed-off-by: Teresa Ho <teresa.ho@windriver.com>
This commit is contained in:
Teresa Ho 2018-09-11 14:02:12 -04:00
parent a2dc830d33
commit eb7559f335
5 changed files with 77 additions and 54 deletions

View File

@ -268,8 +268,14 @@ int msgClassAddr::getAddressFromInterface(const char* interface, char* address,
get_infra_iface(&infra_iface_name);
if (infra_iface_name && strlen(infra_iface_name)) {
if (!strcmp(interface, infra_iface_name)) {
// requesting address for the infra interface
interface_type = INFRA_IFACE;
if (!strcmp(infra_iface_name, daemon_mgmnt_iface().data())) {
// infra and mgmt interface name are the same
interface_type = MGMNT_IFACE;
}
else {
// requesting address for the infra interface
interface_type = INFRA_IFACE;
}
}
free (infra_iface_name);
}

11
mtce-common/cgts-mtce-common-1.0/heartbeat/hbsAgent.cpp Executable file → Normal file
View File

@ -393,8 +393,15 @@ int daemon_configure ( void )
get_infra_iface (&hbs_config.infra_iface );
if ( strlen(hbs_config.infra_iface) )
{
hbsInv.infra_network_provisioned = true ;
ilog ("Infra iface : %s\n", hbs_config.infra_iface );
if (!strcmp(hbs_config.infra_iface, hbs_config.mgmnt_iface))
{
hbsInv.infra_network_provisioned = false ;
}
else
{
hbsInv.infra_network_provisioned = true ;
ilog ("Infra iface : %s\n", hbs_config.infra_iface );
}
}
ilog("Infra RxPort: %d\n", hbs_config.hbs_agent_infra_port );

View File

@ -418,8 +418,11 @@ int daemon_configure ( void )
get_infra_iface (&hbs_config.infra_iface );
if ( strlen(hbs_config.infra_iface) )
{
infra_network_provisioned = true ;
ilog ("Infra iface : %s\n", hbs_config.infra_iface );
if (strcmp(hbs_config.infra_iface, hbs_config.mgmnt_iface))
{
infra_network_provisioned = true ;
ilog ("Infra iface : %s\n", hbs_config.infra_iface );
}
}
ilog("Infra RxPort: %d\n", hbs_config.hbs_client_infra_port );
ilog("Infra TxPort: %d\n", hbs_config.hbs_agent_infra_port );

View File

@ -333,6 +333,11 @@ void setup_mgmnt_rx_socket ( void )
void setup_infra_rx_socket ( void )
{
if ( ctrl.infra_iface_provisioned == false )
{
return ;
}
dlog ("setup of infra RX\n");
/* Fetch the infrastructure interface name.
* calls daemon_get_iface_master inside so the
@ -343,7 +348,6 @@ void setup_infra_rx_socket ( void )
/* Only get the infrastructure network address if it is provisioned */
if ( get_iface_address ( mtc_config.infra_iface, ctrl.address_infra, false ) == PASS )
{
ctrl.infra_iface_provisioned = true ;
ilog ("Infra iface : %s\n", mtc_config.infra_iface );
ilog ("Infra addr : %s\n", ctrl.address_infra.c_str());
}
@ -352,7 +356,7 @@ void setup_infra_rx_socket ( void )
{
_close_infra_rx_socket ();
/* Only set up the socket if an infra interface is provisioned */
/* Only set up the socket if an infra interface is provisioned */
mtc_sock.mtc_client_infra_rx_socket = new msgClassRx(ctrl.address_infra.c_str(),mtc_sock.mtc_cmd_port, IPPROTO_UDP, ctrl.infra_iface.data(), false );
/* update health of socket */
@ -403,12 +407,12 @@ void setup_mgmnt_tx_socket ( void )
void setup_infra_tx_socket ( void )
{
ilog ("setup of infra TX\n");
if ( ctrl.infra_iface_provisioned == false )
{
return ;
}
dlog ("setup of infra TX\n");
_close_infra_tx_socket ();
mtc_sock.mtc_client_infra_tx_socket = new msgClassTx(CONTROLLER_NFS,mtc_sock.mtc_agent_port, IPPROTO_UDP, mtc_config.infra_iface);
@ -522,20 +526,30 @@ int mtc_socket_init ( void )
/************************************************************/
setup_mgmnt_rx_socket ();
/************************************************************/
/* Setup the Infra Interface Receive Socket */
/************************************************************/
setup_infra_rx_socket () ;
/************************************************************/
/* Setup the Mgmnt Interface Transmit messaging to mtcAgent */
/************************************************************/
setup_mgmnt_tx_socket ();
/*************************************************************/
/* Setup the Infra Interface Transmit Messaging to mtcAgent */
/*************************************************************/
setup_infra_tx_socket () ;
/* Manage Infrastructure network setup */
string infra_iface_name = daemon_infra_iface();
string mgmnt_iface_name = daemon_mgmnt_iface();
if ( !infra_iface_name.empty() )
{
if ( infra_iface_name != mgmnt_iface_name )
{
ctrl.infra_iface_provisioned = true ;
/************************************************************/
/* Setup the Infra Interface Receive Socket */
/************************************************************/
setup_infra_rx_socket () ;
/*************************************************************/
/* Setup the Infra Interface Transmit Messaging to mtcAgent */
/*************************************************************/
setup_infra_tx_socket () ;
}
}
/*************************************************************/
/* Setup and Open the active monitoring socket */
@ -1048,7 +1062,6 @@ void daemon_service_run ( void )
string resource_name;
int rc = PASS ;
int infra_retry_count = 0 ;
int file_not_present_count = 0 ;
/* Start mtcAlive message timer */
@ -1074,13 +1087,12 @@ void daemon_service_run ( void )
FD_SET(mtc_sock.mtc_client_rx_socket->getFD(), &mtc_sock.readfds);
}
if ( !ctrl.address_infra.empty() )
if (( ctrl.infra_iface_provisioned == true ) &&
( mtc_sock.mtc_client_infra_rx_socket ) &&
( mtc_sock.mtc_client_infra_rx_socket->return_status==PASS ))
{
if ( mtc_sock.mtc_client_infra_rx_socket && mtc_sock.mtc_client_infra_rx_socket->return_status==PASS )
{
socks.push_front (mtc_sock.mtc_client_infra_rx_socket->getFD());
FD_SET(mtc_sock.mtc_client_infra_rx_socket->getFD(), &mtc_sock.readfds);
}
socks.push_front (mtc_sock.mtc_client_infra_rx_socket->getFD());
FD_SET(mtc_sock.mtc_client_infra_rx_socket->getFD(), &mtc_sock.readfds);
}
mtc_sock.amon_socket = active_monitor_get_sel_obj ();
@ -1100,7 +1112,7 @@ void daemon_service_run ( void )
/* Initialize the timeval struct to wait for 50 mSec */
mtc_sock.waitd.tv_sec = 0;
mtc_sock.waitd.tv_usec = SOCKET_WAIT;
/* Call select() and wait only up to SOCKET_WAIT */
socks.sort();
@ -1114,7 +1126,7 @@ void daemon_service_run ( void )
#endif
rc = select( socks.back()+1,
&mtc_sock.readfds, NULL, NULL,
&mtc_sock.readfds, NULL, NULL,
&mtc_sock.waitd);
/* If the select time out expired then */
@ -1133,12 +1145,13 @@ void daemon_service_run ( void )
{
mtc_service_command ( sock_ptr, MGMNT_INTERFACE );
}
if ((mtc_sock.mtc_client_infra_rx_socket && mtc_sock.mtc_client_infra_rx_socket->return_status==PASS) && FD_ISSET(mtc_sock.mtc_client_infra_rx_socket->getFD(), &mtc_sock.readfds))
if (( ctrl.infra_iface_provisioned == true ) &&
( !ctrl.address_infra.empty() ) &&
( mtc_sock.mtc_client_infra_rx_socket ) &&
( mtc_sock.mtc_client_infra_rx_socket->return_status==PASS) &&
( FD_ISSET(mtc_sock.mtc_client_infra_rx_socket->getFD(), &mtc_sock.readfds)))
{
if ( !ctrl.address_infra.empty() )
{
mtc_service_command ( sock_ptr, INFRA_INTERFACE );
}
mtc_service_command ( sock_ptr, INFRA_INTERFACE );
}
if ( FD_ISSET(mtc_sock.amon_socket, &mtc_sock.readfds))
{
@ -1181,26 +1194,6 @@ void daemon_service_run ( void )
}
}
/* retry getting the infra ip address if its not already provisioned */
if ( ctrl.infra_iface_provisioned == false )
{
if ( infra_retry_count++ > 100 )
{
if ( strlen(mtc_config.infra_iface) )
{
ilog ("Retrying Interface %s\n", mtc_config.infra_iface )
/* Only get the infrastructure network address if it is provisioned */
rc = get_iface_address ( mtc_config.infra_iface, ctrl.address_infra, false );
if ( rc == PASS )
{
ctrl.infra_iface_provisioned = true ;
}
}
infra_retry_count = 0 ;
}
}
if (( ctrl.active_script_set == GOENABLED_MAIN_SCRIPTS ) ||
( ctrl.active_script_set == GOENABLED_SUBF_SCRIPTS ))
{
@ -1385,11 +1378,18 @@ void daemon_service_run ( void )
}
send_mtcAlive_msg ( sock_ptr, ctrl.who_i_am, MGMNT_INTERFACE );
send_mtcAlive_msg ( sock_ptr, ctrl.who_i_am, INFRA_INTERFACE );
if (( ctrl.infra_iface_provisioned == true ) &&
( mtc_sock.mtc_client_infra_rx_socket != NULL ) &&
( mtc_sock.mtc_client_infra_rx_socket->sock_ok() == true ))
{
send_mtcAlive_msg ( sock_ptr, ctrl.who_i_am, INFRA_INTERFACE );
}
/* Re-Start mtcAlive message timer */
mtcTimer_start ( ctrl.timer, timer_handler, MTC_ALIVE_TIMER );
dlog3 ("Infra is %senabled", ctrl.infra_iface_provisioned ? "" : "NOT ");
if ( daemon_is_file_present ( MTC_CMD_FIT__DIR ) )
{
/* fault insertion testing */

View File

@ -610,7 +610,14 @@ int daemon_configure ( void )
ilog ("Infra iface : %s\n", mtc_config.infra_iface );
ilog ("Infra addr : %s\n", infra_ip.c_str());
}
mtcInv.infra_network_provisioned = true ;
if (!strcmp(mtc_config.infra_iface, mtc_config.mgmnt_iface))
{
mtcInv.infra_network_provisioned = false ;
}
else
{
mtcInv.infra_network_provisioned = true ;
}
}
/* Log the startup settings */