Comment 4 for bug 1434342

Revision history for this message
Tapan Karwa (tkarwa) wrote :

We will have to change this function to include the node's table name too i.e. use node->ToString() instead of name().

std::string IFMapLinkTable::LinkKey(const string &metadata,
                                       IFMapNode *left, IFMapNode *right) {
   ostringstream oss;
   if (left->IsLess(*right)) {
       oss << metadata << "," << left->name() << "," << right->name();
   } else {
       oss << metadata << "," << right->name() << "," << left->name();
   }
   return oss.str();
}

EG:

We are actually trying to add a link between midnode and second (which is left and right below).

(gdb) p left->name_
"attr(default-domain:admin:6060,default-domain:admin:6060)" <<<< note the 2 strings inside the (). they are the same.
(gdb) p right->name_
"default-domain:admin:6060"

But, we use IsLess() and so it returns the link between first and midnode i.e. the left_node_ and right_node_ in the link.

(gdb) p link->left_node_->name_
"default-domain:admin:6060"
(gdb) p link->right_node_->name_
"attr(default-domain:admin:6060,default-domain:admin:6060)"

1.
(gdb) p link->left_node_->table_->name_
"__ifmap__.virtual_network.0"
2.
(gdb) p link->right_node_->table_->name_
"__ifmap__.virtual_network_network_ipam.0"
3.
(gdb) p left->table_->name_
"__ifmap__.virtual_network_network_ipam.0"
4.
(gdb) p right->table_->name_
"__ifmap__.network_ipam.0"

So, #1 and #4 belong to different tables.
But, they have the same name and we use IsLess() to decide on the sequence of the string. Thats the problem.