diff --git a/exec/cfg.c b/exec/cfg.c index 743f213d..494b2773 100644 --- a/exec/cfg.c +++ b/exec/cfg.c @@ -736,6 +736,8 @@ static void message_handler_req_lib_cfg_ringstatusget ( unsigned int iface_count; char **status; const char *totem_ip_string; + char ifname[CFG_INTERFACE_NAME_MAX_LEN]; + unsigned int iface_ids[INTERFACE_MAX]; unsigned int i; cs_error_t res = CS_OK; @@ -746,6 +748,7 @@ static void message_handler_req_lib_cfg_ringstatusget ( api->totem_ifaces_get ( api->totem_nodeid_get(), + iface_ids, interfaces, INTERFACE_MAX, &status, @@ -763,11 +766,13 @@ static void message_handler_req_lib_cfg_ringstatusget ( totem_ip_string=""; } - if (strlen(totem_ip_string) >= CFG_INTERFACE_NAME_MAX_LEN) { + /* Allow for i/f number at the start */ + if (strlen(totem_ip_string) >= CFG_INTERFACE_NAME_MAX_LEN-3) { log_printf(LOGSYS_LEVEL_ERROR, "String representation of interface %u is too long", i); res = CS_ERR_NAME_TOO_LONG; goto send_response; } + snprintf(ifname, sizeof(ifname), "%d %s", iface_ids[i], totem_ip_string); if (strlen(status[i]) >= CFG_INTERFACE_STATUS_MAX_LEN) { log_printf(LOGSYS_LEVEL_ERROR, "Status string for interface %u is too long", i); @@ -778,7 +783,7 @@ static void message_handler_req_lib_cfg_ringstatusget ( strcpy ((char *)&res_lib_cfg_ringstatusget.interface_status[i], status[i]); strcpy ((char *)&res_lib_cfg_ringstatusget.interface_name[i], - totem_ip_string); + ifname); } send_response: @@ -999,6 +1004,7 @@ static void message_handler_req_lib_cfg_get_node_addrs (void *conn, const void *msg) { struct totem_ip_address node_ifs[INTERFACE_MAX]; + unsigned int iface_ids[INTERFACE_MAX]; char buf[PIPE_BUF]; char **status; unsigned int num_interfaces = 0; @@ -1014,7 +1020,7 @@ static void message_handler_req_lib_cfg_get_node_addrs (void *conn, if (nodeid == 0) nodeid = api->totem_nodeid_get(); - if (api->totem_ifaces_get(nodeid, node_ifs, INTERFACE_MAX, &status, &num_interfaces)) { + if (api->totem_ifaces_get(nodeid, iface_ids, node_ifs, INTERFACE_MAX, &status, &num_interfaces)) { ret = CS_ERR_EXIST; num_interfaces = 0; } diff --git a/exec/totemknet.c b/exec/totemknet.c index 388e7cb2..9886bbe6 100644 --- a/exec/totemknet.c +++ b/exec/totemknet.c @@ -834,7 +834,7 @@ int totemknet_initialize ( instance->totemknet_target_set_completed = target_set_completed; - instance->loopback_link = -1; + instance->loopback_link = 0; res = pipe(instance->logpipes); if (res == -1) { @@ -1145,12 +1145,10 @@ int totemknet_member_add ( knet_node_id_t host_ids[KNET_MAX_HOST]; size_t num_host_ids; - /* Only create 1 loopback link. - * NOTE: THis depends on member_remove being run before member_add when reconfiguring - * otherwise we could be left with no loopback. - */ - if (member->nodeid == instance->our_nodeid && instance->loopback_link > -1) { - return 0; + /* Only create 1 loopback link and use link 0 */ + if (member->nodeid == instance->our_nodeid && !instance->loopback_link) { + link_no = 0; + instance->loopback_link = 1; } knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: member_add: %d (%s), link=%d", member->nodeid, totemip_print(member), link_no); @@ -1195,7 +1193,6 @@ int totemknet_member_add ( if (member->nodeid == instance->our_nodeid) { knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: loopback link is %d\n", link_no); - instance->loopback_link = link_no; err = knet_link_set_config(instance->knet_handle, member->nodeid, link_no, KNET_TRANSPORT_LOOPBACK, &local_ss, &remote_ss, KNET_LINK_FLAG_TRAFFICHIPRIO); @@ -1255,9 +1252,9 @@ int totemknet_member_remove ( knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: member_remove: %d, link=%d", token_target->nodeid, link_no); - /* Removing link with the loopback on it */ - if (token_target->nodeid == instance->our_nodeid && link_no == instance->loopback_link) { - instance->loopback_link= -1; + /* Don't remove the link with the loopback on it until we shut down */ + if (token_target->nodeid == instance->our_nodeid) { + return 0; } /* Tidy stats */ diff --git a/exec/totempg.c b/exec/totempg.c index 15c9633d..e77ff105 100644 --- a/exec/totempg.c +++ b/exec/totempg.c @@ -1420,6 +1420,7 @@ int totempg_iface_set ( int totempg_ifaces_get ( unsigned int nodeid, + unsigned int *interface_id, struct totem_ip_address *interfaces, unsigned int interfaces_size, char ***status, @@ -1430,6 +1431,7 @@ int totempg_ifaces_get ( res = totemsrp_ifaces_get ( totemsrp_context, nodeid, + interface_id, interfaces, interfaces_size, status, @@ -1466,17 +1468,18 @@ const char *totempg_ifaces_print (unsigned int nodeid) char one_iface[ONE_IFACE_LEN+1]; struct totem_ip_address interfaces[INTERFACE_MAX]; unsigned int iface_count; + unsigned int iface_ids[INTERFACE_MAX]; unsigned int i; int res; iface_string[0] = '\0'; - res = totempg_ifaces_get (nodeid, interfaces, INTERFACE_MAX, NULL, &iface_count); + res = totempg_ifaces_get (nodeid, iface_ids, interfaces, INTERFACE_MAX, NULL, &iface_count); if (res == -1) { return ("no interface found for nodeid"); } - res = totempg_ifaces_get (nodeid, interfaces, INTERFACE_MAX, NULL, &iface_count); + res = totempg_ifaces_get (nodeid, iface_ids, interfaces, INTERFACE_MAX, NULL, &iface_count); for (i = 0; i < iface_count; i++) { if (!interfaces[i].family) { diff --git a/exec/totemsrp.c b/exec/totemsrp.c index 357c2e38..dba2dbca 100644 --- a/exec/totemsrp.c +++ b/exec/totemsrp.c @@ -1033,6 +1033,7 @@ void totemsrp_finalize ( int totemsrp_ifaces_get ( void *srp_context, unsigned int nodeid, + unsigned int *interface_id, struct totem_ip_address *interfaces, unsigned int interfaces_size, char ***status, @@ -1052,6 +1053,7 @@ int totemsrp_ifaces_get ( if (instance->totem_config->interfaces[i].configured && instance->totem_config->interfaces[i].member_list[n].nodeid == nodeid) { memcpy(iface_ptr, &instance->totem_config->interfaces[i].member_list[n], sizeof(struct totem_ip_address)); + interface_id[num_ifs] = i; iface_ptr++; if (++num_ifs > interfaces_size) { res = -2; diff --git a/exec/totemsrp.h b/exec/totemsrp.h index 1b80be89..54f7eb4c 100644 --- a/exec/totemsrp.h +++ b/exec/totemsrp.h @@ -104,6 +104,7 @@ extern void totemsrp_net_mtu_adjust (struct totem_config *totem_config); extern int totemsrp_ifaces_get ( void *srp_context, unsigned int nodeid, + unsigned int *interface_id, struct totem_ip_address *interfaces, unsigned int interfaces_size, char ***status, diff --git a/include/corosync/coroapi.h b/include/corosync/coroapi.h index cf259e69..9d14b7bd 100644 --- a/include/corosync/coroapi.h +++ b/include/corosync/coroapi.h @@ -281,6 +281,7 @@ struct corosync_api_v1 { int (*totem_ifaces_get) ( unsigned int nodeid, + unsigned int *interface_ids, struct totem_ip_address *interfaces, unsigned int interfaces_size, char ***status, diff --git a/include/corosync/totem/totempg.h b/include/corosync/totem/totempg.h index 20d1c70a..a735e973 100644 --- a/include/corosync/totem/totempg.h +++ b/include/corosync/totem/totempg.h @@ -140,6 +140,7 @@ extern int totempg_groups_send_ok_groups ( extern int totempg_ifaces_get ( unsigned int nodeid, + unsigned int *interface_id, struct totem_ip_address *interfaces, unsigned int interfaces_size, char ***status, diff --git a/tools/corosync-cfgtool.c b/tools/corosync-cfgtool.c index fe76aab7..b2a1440c 100644 --- a/tools/corosync-cfgtool.c +++ b/tools/corosync-cfgtool.c @@ -117,8 +117,8 @@ linkstatusget_do (char *interface_name, int brief) strcasecmp (interface_name, interface_names[i]) == 0)) || !interface_name ) { - printf ("LINK ID %d\n", i); - printf ("\tid\t= %s\n", interface_names[i]); + printf ("LINK ID %c\n", interface_names[i][0]); + printf ("\taddr\t= %s\n", interface_names[i]+1); if((!brief) && (strcmp(interface_status[i], "OK") != 0) && (!strstr(interface_status[i], "FAULTY"))) { len = strlen(interface_status[i]);