Skip to content

Commit

Permalink
pim: Deal better with fake VIFs.
Browse files Browse the repository at this point in the history
Let fea tell us the vif index, and make the change in
the vifs-updated logic.

Add some debug logic for pim shutdown paths.

Signed-off-by:  Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Jul 31, 2012
1 parent 28428ca commit cdbead1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
54 changes: 25 additions & 29 deletions xorp/pim/pim_node.cc
Expand Up @@ -449,6 +449,24 @@ PimNode::updates_made()
set_config_pif_index(ifmgr_vif_name,
ifmgr_vif.pif_index(),
error_msg);

if (node_vif->vif_index() != ifmgr_vif.vif_index()) {
XLOG_INFO("Vif-index changed, node-vif: %s ifmgr-vif: %s",
node_vif->str().c_str(), ifmgr_vif.toString().c_str());
// It went real..fix up underlying logic.
PimVif* fake_vif = vif_find_by_vif_index(ifmgr_vif.vif_index());
if (fake_vif) {
// Move any fake with our real ifindex out of the way.
adjust_fake_vif(fake_vif, ifmgr_vif.vif_index());
}

ProtoNode<PimVif>::delete_vif((PimVif*)(node_vif));
XLOG_INFO("Setting formerly fake node_vif: %s to real ifindex: %i",
node_vif->name().c_str(), ifmgr_vif.vif_index());
node_vif->set_vif_index(ifmgr_vif.vif_index());
node_vif->set_is_fake(false);
ProtoNode<PimVif>::add_vif((PimVif*)(node_vif));
}

//
// Update the vif flags
Expand Down Expand Up @@ -1184,39 +1202,11 @@ PimNode::enable_vif(const string& vif_name, string& error_msg)
PimVif*
PimNode::find_or_create_vif(const string& vif_name, string& error_msg) {
PimVif* mvif = vif_find_by_name(vif_name);
int if_index = 0;
errno = 0;

if (mvif == NULL) {
#ifdef HAVE_IF_NAMETOINDEX
if_index = if_nametoindex(vif_name.c_str());
#endif
add_vif(vif_name, if_index, error_msg);
add_vif(vif_name, 0, error_msg);
mvif = vif_find_by_name(vif_name);
}
else {
// If it's fake..then might need to fix things up.
if (mvif->is_fake()) {
#ifdef HAVE_IF_NAMETOINDEX
if_index = if_nametoindex(vif_name.c_str());
#endif
if (if_index > 0) {
// It went real..fix up underlying logic.
PimVif* fake_vif = vif_find_by_vif_index(if_index);
if (fake_vif) {
// Move any fake with our real ifindex out of the way.
adjust_fake_vif(fake_vif, if_index);
}

ProtoNode<PimVif>::delete_vif(mvif);
XLOG_INFO("Setting formerly fake mvif: %s to real ifindex: %i",
mvif->name().c_str(), if_index);
mvif->set_vif_index(if_index);
mvif->set_is_fake(false);
ProtoNode<PimVif>::add_vif(mvif);
}
}
}
return mvif;
}

Expand Down Expand Up @@ -1420,6 +1410,9 @@ PimNode::disable_all_vifs()
void
PimNode::delete_all_vifs()
{
XLOG_INFO("pim-node: %p start of delete-all vifs, size: %i\n",
this, (int)(proto_vifs().size()));

list<string> vif_names;
vector<PimVif *>::iterator iter;

Expand Down Expand Up @@ -1449,6 +1442,9 @@ PimNode::delete_all_vifs()
XLOG_ERROR("%s", error_msg.c_str());
}
}

XLOG_INFO("pim-node: %p end of delete-all vifs, size: %i\n",
this, (int)(proto_vifs().size()));
}

/**
Expand Down
11 changes: 11 additions & 0 deletions xorp/pim/xorp_pimsm4.cc
Expand Up @@ -139,6 +139,9 @@ static void pim_main(const string& finder_hostname, uint16_t finder_port) {
eventloop.run();
}

XLOG_INFO("Winding down pimsm, do-run: %i node.is_done: %i\n",
xorp_do_run, xrl_pimsm_node4.is_done());

while (xrl_pimsm_node4.xrl_router().pending()) {
eventloop.run();
}
Expand All @@ -147,9 +150,17 @@ static void pim_main(const string& finder_hostname, uint16_t finder_port) {
// will attempt the same, but that will cause some recursive cleanup
// that ends up calling a pure virtual on the xlr_pim_node logic,
// which throws an exception from deep in glibc and crashes us.
XLOG_INFO("Before delete-all-vifs, size: %i\n",
(int)(xrl_pimsm_node4.proto_vifs().size()));
xrl_pimsm_node4.delete_all_vifs();
XLOG_INFO("Before shutdown, size: %i\n",
(int)(xrl_pimsm_node4.proto_vifs().size()));
xrl_pimsm_node4.shutdown();
XLOG_INFO("Before destruct_me, size: %i\n",
(int)(xrl_pimsm_node4.proto_vifs().size()));
xrl_pimsm_node4.destruct_me();
XLOG_INFO("After destruct_me, size: %i\n",
(int)(xrl_pimsm_node4.proto_vifs().size()));
}

int
Expand Down

0 comments on commit cdbead1

Please sign in to comment.