LCOV - code coverage report
Current view: top level - vnsw/agent/oper - ifmap_dependency_manager.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 418 490 85.3 %
Date: 2026-08-03 02:19:58 Functions: 27 33 81.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include <cmn/agent_cmn.h>
       6             : #include <vnc_cfg_types.h>
       7             : #include <agent_types.h>
       8             : 
       9             : #include "oper/oper_db.h"
      10             : #include "oper/ifmap_dependency_manager.h"
      11             : #include "oper/vn.h"
      12             : #include "oper/sg.h"
      13             : #include "oper/tag.h"
      14             : #include "oper/interface_common.h"
      15             : #include "oper/health_check.h"
      16             : #include "oper/vrf.h"
      17             : #include "oper/vm.h"
      18             : #include "oper/physical_device.h"
      19             : #include "filter/acl.h"
      20             : #include "oper/qos_queue.h"
      21             : #include "oper/forwarding_class.h"
      22             : #include "oper/qos_config.h"
      23             : #include "oper/config_manager.h"
      24             : #include "oper/vrouter.h"
      25             : #include "oper/bgp_router.h"
      26             : #include "oper/global_qos_config.h"
      27             : #include "oper/global_system_config.h"
      28             : #include "oper/global_vrouter.h"
      29             : #include "oper/bridge_domain.h"
      30             : #include "filter/policy_set.h"
      31             : #include "cfg/cfg_init.h"
      32             : #include "oper/security_logging_object.h"
      33             : #include "oper/multicast_policy.h"
      34             : 
      35             : #include <boost/assign/list_of.hpp>
      36             : #include <boost/bind/bind.hpp>
      37             : 
      38             : #include "base/task.h"
      39             : #include "base/task_trigger.h"
      40             : #include "db/db.h"
      41             : #include "db/db_table_partition.h"
      42             : #include "db/db_entry.h"
      43             : #include "ifmap/ifmap_agent_table.h"
      44             : #include "ifmap/ifmap_dependency_tracker.h"
      45             : #include "ifmap/ifmap_link.h"
      46             : #include "ifmap/ifmap_node.h"
      47             : #include "ifmap/ifmap_table.h"
      48             : 
      49             : using namespace boost::assign;
      50             : using namespace std;
      51             : using namespace boost::placeholders;
      52             : 
      53             : typedef IFMapDependencyTracker::ReactionMap ReactionMap;
      54             : typedef IFMapDependencyTracker::NodeEventPolicy NodeEventPolicy;
      55             : typedef IFMapDependencyTracker::PropagateList PropagateList;
      56             : 
      57        2026 : void intrusive_ptr_add_ref(IFMapNodeState *state) {
      58        2026 :     ++state->refcount_;
      59        2026 : }
      60             : 
      61        2026 : void intrusive_ptr_release(IFMapNodeState *state) {
      62        2026 :     if (--state->refcount_ ==  0) {
      63         113 :         assert(state->object_ == NULL);
      64         113 :         state->manager_->IFMapNodeReset(state->node_);
      65         113 :         delete state;
      66             :     }
      67        2026 : }
      68             : 
      69           3 : IFMapDependencyManager::IFMapDependencyManager(DB *database, DBGraph *graph)
      70           3 :         : database_(database),
      71           3 :           graph_(graph) {
      72           6 :     tracker_.reset(
      73             :         new IFMapDependencyTracker(
      74             :             database, graph,
      75           3 :             boost::bind(&IFMapDependencyManager::ChangeListAdd, this, _1)));
      76           3 :     int task_id = TaskScheduler::GetInstance()->GetTaskId("db::DBTable");
      77           6 :     trigger_.reset(
      78             :         new TaskTrigger(
      79             :             boost::bind(&IFMapDependencyManager::ProcessChangeList, this),
      80           3 :             task_id, 0));
      81           3 : }
      82             : 
      83           6 : IFMapDependencyManager::~IFMapDependencyManager() {
      84             :     // TODO: Unregister from all tables.
      85           6 : }
      86             : 
      87           3 : void IFMapDependencyManager::Initialize(Agent *agent) {
      88           3 :     agent_ = agent;
      89             :     static const char *ifmap_types[] = {
      90             :         "access-control-list",
      91             :         "address-group",
      92             :         "alias-ip",
      93             :         "alias-ip-pool",
      94             :         "application-policy-set",
      95             :         "application-policy-set-firewall-policy",
      96             :         "bgp-as-a-service",
      97             :         "bgpaas-control-node-zone",
      98             :         "bgp-router",
      99             :         "control-node-zone",
     100             :         "firewall-policy",
     101             :         "firewall-rule",
     102             :         "floating-ip",
     103             :         "floating-ip-pool",
     104             :         "forwarding-class",
     105             :         "global-qos-config",
     106             :         "global-system-config",
     107             :         "instance-ip",
     108             :         "logical-interface",
     109             :         "logical-router",
     110             :         "network-ipam",
     111             :         "physical-interface",
     112             :         "physical-router",
     113             :         "policy-management",
     114             :         "project",
     115             :         "qos-config",
     116             :         "qos-queue",
     117             :         "routing-instance",
     118             :         "security-group",
     119             :         "security-logging-object",
     120             :         "service-group",
     121             :         "service-health-check",
     122             :         "service-instance",
     123             :         "service-template",
     124             :         "subnet",
     125             :         "sub-cluster",
     126             :         "tag",
     127             :         "virtual-ip",
     128             :         "virtual-machine",
     129             :         "virtual-machine-interface",
     130             :         "virtual-machine-interface-routing-instance",
     131             :         "virtual-network",
     132             :         "virtual-network-network-ipam",
     133             :         "virtual-port-group",
     134             :         "virtual-port-group-physical-interface",
     135             :         "virtual-DNS",
     136             :         "global-vrouter-config",
     137             :         "virtual-router",
     138             :         "interface-route-table",
     139             :         "bridge-domain",
     140             :         "virtual-machine-interface-bridge-domain",
     141             :         "firewall-policy-firewall-rule",
     142             :         "port-tuple",
     143             :         "multicast-policy"
     144             :     };
     145             : 
     146             :     // Link table
     147             :     DBTable *link_table = static_cast<DBTable *>(
     148           3 :         database_->FindTable(IFMAP_AGENT_LINK_DB_NAME));
     149           3 :     assert(link_table != NULL);
     150             : 
     151           6 :     DBTable::ListenerId id = link_table->Register(
     152           3 :         boost::bind(&IFMapDependencyManager::LinkObserver, this, _1, _2));
     153           3 :     table_map_.insert(make_pair(link_table->name(), id));
     154             : 
     155             :     // Identifier tables
     156           3 :     const int n_types = sizeof(ifmap_types) / sizeof(const char *);
     157         165 :     for (int i = 0; i < n_types; i++) {
     158         162 :         const char *id_typename = ifmap_types[i];
     159         162 :         IFMapTable *table = IFMapTable::FindTable(database_, id_typename);
     160         162 :         assert(table);
     161         324 :         DBTable::ListenerId id = table->Register(
     162         162 :             boost::bind(&IFMapDependencyManager::NodeObserver, this, _1, _2));
     163         162 :         table_map_.insert(make_pair(table->name(), id));
     164             :     }
     165             : 
     166             :     // Policy definition
     167           3 :     IFMapDependencyTracker::NodeEventPolicy *policy = tracker_->policy_map();
     168             : 
     169             :     ReactionMap react_si = map_list_of<string, PropagateList>
     170           9 :             ("service-instance-service-template", list_of("self")
     171           6 :                 .convert_to_container<PropagateList>())
     172           9 :             ("virtual-machine-service-instance", list_of("self")
     173           6 :                 .convert_to_container<PropagateList>())
     174           6 :             ("self", list_of("self").convert_to_container<PropagateList>());
     175           3 :     policy->insert(make_pair("service-instance", react_si));
     176             : 
     177             :     ReactionMap react_tmpl = map_list_of<string, PropagateList>
     178           6 :             ("self", list_of("service-instance-service-template"));
     179           3 :     policy->insert(make_pair("service-template", react_tmpl));
     180             : 
     181             :     ReactionMap react_vm = map_list_of<string, PropagateList>
     182           9 :             ("self", list_of("virtual-machine-service-instance")
     183           6 :                 .convert_to_container<PropagateList>())
     184           3 :             ("virtual-machine-virtual-machine-interface",
     185           6 :              list_of("virtual-machine-service-instance")
     186           6 :                  .convert_to_container<PropagateList>())
     187           3 :             ("virtual-machine-interface-virtual-machine",
     188           6 :              list_of("virtual-machine-service-instance")
     189           9 :                  .convert_to_container<PropagateList>());
     190           3 :     policy->insert(make_pair("virtual-machine", react_vm));
     191             : 
     192             :     ReactionMap react_vmi = map_list_of<string, PropagateList>
     193           9 :             ("self", list_of("virtual-machine-interface-virtual-machine")
     194           3 :                             ("logical-interface-virtual-machine-interface")
     195           6 :                                 .convert_to_container<PropagateList>())
     196           3 :             ("instance-ip-virtual-machine-interface",
     197           6 :              list_of("virtual-machine-interface-virtual-machine")
     198           6 :                  .convert_to_container<PropagateList>())
     199           3 :             ("virtual-machine-interface-virtual-network",
     200           6 :              list_of("virtual-machine-interface-virtual-machine")
     201           3 :                     ("logical-interface-virtual-machine-interface")
     202           9 :                         .convert_to_container<PropagateList>());
     203           3 :     policy->insert(make_pair("virtual-machine-interface", react_vmi));
     204             : 
     205             :     ReactionMap react_ip = map_list_of<string, PropagateList>
     206           6 :             ("self", list_of("instance-ip-virtual-machine-interface"));
     207           3 :     policy->insert(make_pair("instance-ip", react_ip));
     208             : 
     209             :     ReactionMap react_subnet = map_list_of<string, PropagateList>
     210           9 :             ("self", list_of("virtual-network-network-ipam")
     211           6 :                 .convert_to_container<PropagateList>())
     212           9 :             ("virtual-network-network-ipam", list_of("nil")
     213           9 :                 .convert_to_container<PropagateList>());
     214           3 :     policy->insert(make_pair("virtual-network-network-ipam", react_subnet));
     215             : 
     216             :     ReactionMap react_ipam = map_list_of<string, PropagateList>
     217           6 :             ("virtual-network-network-ipam", list_of("nil"));
     218           3 :     policy->insert(make_pair("network-ipam", react_ipam));
     219             : 
     220             :     ReactionMap react_bgpaas = map_list_of<string, PropagateList>
     221           6 :             ("bgpaas-control-node-zone",
     222           6 :             list_of("bgpaas-virtual-machine-interface"));
     223           3 :     policy->insert(make_pair("bgp-as-a-service", react_bgpaas));
     224             : 
     225           3 :     InitializeDependencyRules(agent);
     226           3 : }
     227             : 
     228           0 : void IFMapDependencyManager::RegisterReactionMap
     229             : (const char *node_name, const IFMapDependencyTracker::ReactionMap &react) {
     230             :     // Register to the IFMap table
     231           0 :     IFMapTable *table = IFMapTable::FindTable(database_, node_name);
     232           0 :     assert(table);
     233             :     DBTable::ListenerId id = table->Register
     234           0 :         (boost::bind(&IFMapDependencyManager::NodeObserver, this, _1, _2));
     235           0 :     table_map_.insert(make_pair(table->name(), id));
     236             : 
     237             :     // Add Policy
     238           0 :     tracker_->policy_map()->insert(make_pair(node_name, react));
     239           0 : }
     240             : 
     241           3 : void IFMapDependencyManager::Terminate() {
     242           3 :     for (TableMap::iterator iter = table_map_.begin();
     243         168 :          iter != table_map_.end(); ++iter) {
     244             :         DBTable *table = static_cast<DBTable *>(
     245         165 :             database_->FindTable(iter->first));
     246         165 :         table->Unregister(iter->second);
     247             :     }
     248           3 :     table_map_.clear();
     249           3 :     event_map_.clear();
     250           3 : }
     251             : 
     252         210 : bool IFMapDependencyManager::ProcessChangeList() {
     253         210 :     tracker_->PropagateChanges();
     254         210 :     tracker_->Clear();
     255             : 
     256         210 :     for (ChangeList::iterator iter = change_list_.begin();
     257         758 :          iter != change_list_.end(); ++iter) {
     258         548 :         IFMapNodeState *state = iter->get();
     259         548 :         IFMapTable *table = state->node()->table();
     260         548 :         EventMap::iterator loc = event_map_.find(table->Typename());
     261         548 :         if (loc == event_map_.end()) {
     262          27 :             continue;
     263             :         }
     264             : 
     265         521 :         if (state->notify() == true) {
     266         521 :             loc->second(state->node(), state->object());
     267             :         }
     268             :     }
     269         210 :     change_list_.clear();
     270         210 :     return true;
     271             : }
     272             : 
     273         178 : void IFMapDependencyManager::NodeObserver(
     274             :     DBTablePartBase *root, DBEntryBase *db_entry) {
     275             : 
     276         178 :     IFMapNode *node = static_cast<IFMapNode *>(db_entry);
     277         178 :     tracker_->NodeEvent(node);
     278         178 :     trigger_->Set();
     279         178 : }
     280             : 
     281           7 : void IFMapDependencyManager::PropogateNodeChange(IFMapNode *node) {
     282           7 :     tracker_->NodeEvent(node, false);
     283           7 :     trigger_->Set();
     284           7 : }
     285             : 
     286           0 : void IFMapDependencyManager::PropogateNodeAndLinkChange(IFMapNode *node) {
     287             : 
     288           0 :     tracker_->NodeEvent(node);
     289             : 
     290           0 :     for (DBGraphVertex::edge_iterator iter = node->edge_list_begin(graph_);
     291           0 :                                 iter != node->edge_list_end(graph_); ++iter) {
     292           0 :         IFMapLink *link = static_cast<IFMapLink *>(iter.operator->());
     293           0 :         IFMapNode *target = static_cast<IFMapNode *>(iter.target());
     294           0 :         tracker_->LinkEvent(link->metadata(), node, target);
     295             :     }
     296             : 
     297           0 :     trigger_->Set();
     298           0 : }
     299             : 
     300         184 : void IFMapDependencyManager::LinkObserver(
     301             :     DBTablePartBase *root, DBEntryBase *db_entry) {
     302         184 :     IFMapLink *link = static_cast<IFMapLink *>(db_entry);
     303         184 :     IFMapNode *left = link->LeftNode(database_);
     304         184 :     IFMapNode *right = link->RightNode(database_);
     305         184 :     bool set = false;
     306         184 :     if (left) {
     307         184 :         EventMap::iterator loc = event_map_.find(left->table()->Typename());
     308         184 :         if (loc != event_map_.end()) {
     309         138 :             ChangeListAdd(left);
     310         138 :             set = true;
     311             :         }
     312             :     }
     313             : 
     314         184 :     if (right) {
     315         184 :         EventMap::iterator loc = event_map_.find(right->table()->Typename());
     316         184 :         if (loc != event_map_.end()) {
     317         134 :             ChangeListAdd(right);
     318         134 :             set = true;
     319             :         }
     320             :     }
     321             : 
     322         184 :     set |= tracker_->LinkEvent(link->metadata(), left, right);
     323         184 :     if (set) {
     324         184 :         trigger_->Set();
     325             :     }
     326         184 : }
     327             : 
     328         618 : void IFMapDependencyManager::ChangeListAdd(IFMapNode *node) {
     329         618 :     IFMapNodeState *state = IFMapNodeGet(node);
     330         618 :     if (state == NULL) {
     331         183 :         if (node->IsDeleted() == false)
     332         113 :             change_list_.push_back(SetState(node));
     333             :     } else {
     334         435 :         change_list_.push_back(IFMapNodePtr(state));
     335             :     }
     336         618 : }
     337             : 
     338             : IFMapNodeState *
     339        1882 : IFMapDependencyManager::IFMapNodeGet(IFMapNode *node) {
     340        1882 :     IFMapTable *table = node->table();
     341        1882 :     TableMap::const_iterator loc = table_map_.find(table->name());
     342        1882 :     if (loc == table_map_.end()) {
     343           0 :         return NULL;
     344             :     }
     345             :     IFMapNodeState *state =
     346        1882 :             static_cast<IFMapNodeState *>(node->GetState(table, loc->second));
     347        1882 :     return state;
     348             : }
     349             : 
     350         113 : void IFMapDependencyManager::IFMapNodeReset(IFMapNode *node) {
     351         113 :     IFMapTable *table = node->table();
     352         113 :     TableMap::const_iterator loc = table_map_.find(table->name());
     353         113 :     assert(loc != table_map_.end());
     354         113 :     node->ClearState(node->table(), loc->second);
     355         113 : }
     356             : 
     357             : /*
     358             :  * Associate an IFMapNode with an object in the operational database.
     359             :  *
     360             :  * IFMapNodes that do not have an object mapping do not receive notifications.
     361             :  * This method checks whether the DBState exists and delegates the
     362             :  * responsibility to create a new mapping to IFMapNodeSet (private).
     363             :  */
     364          94 : void IFMapDependencyManager::SetObject(IFMapNode *node, DBEntry *entry) {
     365             : 
     366          94 :     IFMapNodeState *state = IFMapNodeGet(node);
     367          94 :     assert(state);
     368             : 
     369          94 :     DBEntry *old_entry = state->object();
     370             : 
     371          94 :     if (old_entry)
     372          47 :         state->clear_object();
     373             : 
     374          94 :     if (entry) {
     375          47 :         state->set_object(entry);
     376          47 :         tracker_->NodeEvent(node);
     377          47 :         trigger_->Set();
     378             :     }
     379          94 : }
     380             : 
     381          12 : void IFMapDependencyManager::SetNotify(IFMapNode *node, bool notify_flag) {
     382             : 
     383          12 :     IFMapNodeState *state = IFMapNodeGet(node);
     384          12 :     assert(state);
     385             : 
     386          12 :     state->set_notify(notify_flag);
     387          12 : }
     388             : 
     389           0 : void IFMapDependencyManager::SetRequestEnqueued(IFMapNode *node,
     390             :         bool oper_db_request_enqueued) {
     391             : 
     392           0 :     IFMapNodeState *state = IFMapNodeGet(node);
     393           0 :     assert(state);
     394             : 
     395           0 :     state->set_oper_db_request_enqueued(oper_db_request_enqueued);
     396           0 : }
     397             : 
     398             : IFMapDependencyManager::IFMapNodePtr
     399         868 : IFMapDependencyManager::SetState(IFMapNode *node) {
     400         868 :     IFMapTable *table = node->table();
     401         868 :     TableMap::const_iterator loc = table_map_.find(table->name());
     402         868 :     if (loc == table_map_.end())
     403           0 :         return NULL;
     404             : 
     405             :     IFMapNodeState *state =
     406         868 :             static_cast<IFMapNodeState *>(node->GetState(table, loc->second));
     407             : 
     408         868 :     if (!state) {
     409         113 :         state = new IFMapNodeState(this, node);
     410         113 :         node->SetState(table, loc->second, state);
     411             :     }
     412         868 :     return IFMapNodePtr(state);
     413             : }
     414             : 
     415           0 : DBEntry *IFMapDependencyManager::GetObject(IFMapNode *node) {
     416           0 :     IFMapTable *table = node->table();
     417           0 :     TableMap::const_iterator loc = table_map_.find(table->name());
     418           0 :     if (loc == table_map_.end())
     419           0 :         return NULL;
     420             : 
     421             :     IFMapNodeState *state =
     422           0 :         static_cast<IFMapNodeState *>(node->GetState(table, loc->second));
     423           0 :     if (state == NULL)
     424           0 :         return NULL;
     425             : 
     426           0 :     return state->object();
     427             : }
     428             : 
     429             : /*
     430             :  * Register a notification callback.
     431             :  */
     432          81 : void IFMapDependencyManager::Register(
     433             :     const string &type, ChangeEventHandler handler) {
     434          81 :     event_map_.insert(std::make_pair(type, handler));
     435          81 : }
     436             : 
     437             : /*
     438             :  * Unregister a notification callback.
     439             :  */
     440           0 : void IFMapDependencyManager::Unregister(const string &type) {
     441           0 :     event_map_.erase(type);
     442           0 : }
     443             : 
     444             : // Check if a IFMapNode type is registerd with dependency manager
     445         687 : bool IFMapDependencyManager::IsRegistered(const IFMapNode *node) {
     446         687 :     EventMap::iterator it = event_map_.find(node->table()->Typename());
     447         687 :     return (it != event_map_.end());
     448             : }
     449             : 
     450         346 : bool IFMapDependencyManager::IsNodeIdentifiedByUuid(const IFMapNode *node) {
     451         346 :     return (strcmp(node->table()->Typename(), "routing-instance") != 0);
     452             : }
     453             : 
     454         180 : IFMapDependencyManager::Path MakePath
     455             : (const char *link1,        const char *node1,        bool interest1,
     456             :  const char *link2 = NULL, const char *node2 = NULL, bool interest2 = false,
     457             :  const char *link3 = NULL, const char *node3 = NULL, bool interest3 = false,
     458             :  const char *link4 = NULL, const char *node4 = NULL, bool interest4 = false,
     459             :  const char *link5 = NULL, const char *node5 = NULL, bool interest5 = false,
     460             :  const char *link6 = NULL, const char *node6 = NULL, bool interest6 = false) {
     461         180 :     if (link2) assert(node2);
     462         180 :     if (link3) assert(node3);
     463         180 :     if (link4) assert(node4);
     464         180 :     if (link5) assert(node5);
     465         180 :     if (link6) assert(node6);
     466             : 
     467         180 :     IFMapDependencyManager::Path path;
     468         180 :     path.push_back(IFMapDependencyManager::Link(link1, node1, interest1));
     469         180 :     if (link2)
     470         108 :         path.push_back(IFMapDependencyManager::Link(link2, node2, interest2));
     471         180 :     if (link3)
     472          54 :         path.push_back(IFMapDependencyManager::Link(link3, node3, interest3));
     473         180 :     if (link4)
     474          27 :         path.push_back(IFMapDependencyManager::Link(link4, node4, interest4));
     475         180 :     if (link5)
     476          15 :         path.push_back(IFMapDependencyManager::Link(link5, node5, interest5));
     477         180 :     if (link6)
     478           3 :         path.push_back(IFMapDependencyManager::Link(link6, node6, interest6));
     479         180 :     return path;
     480           0 : }
     481             : 
     482         567 : static NodeEventPolicy::iterator LocateNodeEventPolicy(NodeEventPolicy *policy,
     483             :                                                        const string &node) {
     484         567 :     NodeEventPolicy::iterator it = policy->find(node);
     485         567 :     if (it != policy->end()) {
     486         435 :         return it;
     487             :     }
     488             :     ReactionMap react = map_list_of<string, PropagateList>
     489         264 :         ("self", PropagateList());
     490         132 :     policy->insert(make_pair(node, react));
     491         132 :     return policy->find(node);
     492         132 : }
     493             : 
     494         909 : static ReactionMap::iterator LocateReactionMap(ReactionMap *react,
     495             :                                                const string &event) {
     496         909 :     ReactionMap::iterator it = react->find(event);
     497         909 :     if (it != react->end()) {
     498         582 :         return it;
     499             :     }
     500         327 :     react->insert(make_pair(event, PropagateList()));
     501         327 :     return react->find(event);
     502             : }
     503             : 
     504             : ////////////////////////////////////////////////////////////////////////
     505             : // The IFMap dependency tracker accepts rules in the form or "Reactor Map"
     506             : // Reactor map is not natural way of defining references between IFMap nodes
     507             : // in agent.
     508             : //
     509             : // When agent builds data for an oper-db entry, the IFNodeToReq API will keep
     510             : // the IFMapNode for oper-db entry as starting node and traverses the graph
     511             : // to build all realvent data for the entry. So, it is more natural in agent
     512             : // to specify relation between nodes in a way IFMapNodeToReq traverses the
     513             : // graph
     514             : //
     515             : // The routine AddDependencyPath takes the graph path between two vertices
     516             : // and then creates "Reactor Map" for them.
     517             : //
     518             : // The API takes IFMapNode for object being built as "node" and then a graph
     519             : // path to reach another IFMapNode of interest.
     520             : //
     521             : // Example: VMI refers to RI with following path to support floating-ip
     522             : //     VMI <----> FIP <----> FIP-POOL <----> VN <----> RI
     523             : //
     524             : //     node is specified as "virtual-machine-interface"
     525             : //     path is specified as,
     526             : //          <string(link-metadata), string(vertex), bool(vertex-attr-interest)>
     527             : //
     528             : //          vertex specifies name of the adjacent node in the path
     529             : //          link-metadata specifies metadata of the link connecting the vertex
     530             : //          vertex-attr-interest
     531             : //               If "node" is interested in any attribute of vertex, this value
     532             : //               is set to TRUE else its set to FALSE
     533             : //               When value is set to TRUE, it will generate an event of type
     534             : //               "self" in the reactor-map
     535             : //
     536             : //          The path from virtual-machine-interface to "routing-instance" above
     537             : //          is given as below,
     538             : //
     539             : //          <"virtual-machine-interface-floating-ip", "floating-ip", true>
     540             : //          <"floating-ip-floating-ip-pool", "floating-ip-pool", false>
     541             : //          <"floating-ip-pool-virtual-network", "virtual-network", true>
     542             : //          <"virtual-network-routing-instance", "routing-instance", true>
     543             : //
     544             : // AddDependencyPath will "APPEND" following Reactor rules,
     545             : //      node(virtual-machine-interface)
     546             : //             event(virtual-machine-floating-ip) => Rectors(self)
     547             : //
     548             : //      node(routing-instance)
     549             : //             event(self) => Reactors(virtual-network-routing-instance)
     550             : //
     551             : //      node(virtual-network)
     552             : //             event(virtual-network-routing-instance) => Reactors(floating-ip-pool-virtual-network)
     553             : //
     554             : //      node(floating-ip-pool)
     555             : //             event(self) => Reactors(virtual-machine-interface-virtual-network)
     556             : //             event(floating-ip-pool-virtual-network) => Reactors(floating-ip-floating-ip-pool)
     557             : //
     558             : //      node(floating-ip)
     559             : //             event(self) => Reactors(virtual-machine-interface-floating-ip)
     560             : //             event(floating-ip-floating-ip-pool) => Reactors(virtual-machine-interface-floating-ip)
     561             : //
     562             : ////////////////////////////////////////////////////////////////////////
     563         180 : void IFMapDependencyManager::AddDependencyPath(const std::string &node,
     564             :                                                Path path) {
     565         180 :     NodeEventPolicy *policy = tracker_->policy_map();
     566         180 :     assert(policy);
     567             : 
     568         180 :     NodeEventPolicy::iterator node_it;
     569         180 :     node_it = LocateNodeEventPolicy(policy, node);
     570         180 :     ReactionMap::iterator react_it = LocateReactionMap(&node_it->second,
     571         180 :                                                        path[0].edge_);
     572         180 :     LOG(DEBUG, "Updating dependency tacker rules for " << node);
     573         180 :     react_it->second.insert("self");
     574         180 :     LOG(DEBUG, "Adding ReactorMap " << node_it->first << " : " <<
     575             :                 react_it->first << " -> " << "self");
     576             : 
     577         567 :     for (size_t i = 0; i < path.size(); i++) {
     578         387 :         node_it = LocateNodeEventPolicy(policy, path[i].vertex_);
     579         387 :         if (path[i].vertex_interest_) {
     580         342 :             react_it = LocateReactionMap(&node_it->second, "self");
     581         342 :             react_it->second.insert(path[i].edge_);
     582         342 :             LOG(DEBUG, "Adding ReactorMap " << node_it->first << " : " <<
     583             :                 react_it->first << " -> " << path[i].edge_);
     584             :         }
     585             : 
     586         387 :         if (i < (path.size() - 1)) {
     587         207 :             react_it = LocateReactionMap(&node_it->second, path[i+1].edge_);
     588         207 :             react_it->second.insert(path[i].edge_);
     589         207 :             LOG(DEBUG, "Adding ReactorMap " << node_it->first << " : " <<
     590             :                 react_it->first << " -> " << path[i].edge_);
     591             :         } else {
     592         180 :             react_it = LocateReactionMap(&node_it->second, path[i].edge_);
     593         180 :             react_it->second.insert("nil");
     594         180 :             LOG(DEBUG, "Adding ReactorMap " << node_it->first << " : " <<
     595             :                 react_it->first << " -> " << "nil");
     596             :         }
     597             :     }
     598             : 
     599         360 :     return;
     600             : }
     601             : 
     602             : // Register callback for ifmap node not having corresponding oper-dbtable
     603          21 : static void RegisterConfigHandler(IFMapDependencyManager *dep,
     604             :                                   const char *name, OperIFMapTable *table) {
     605          21 :     if (table)
     606          21 :         dep->Register(name, boost::bind(&OperIFMapTable::ConfigEventHandler,
     607             :                                         table, _1, _2));
     608          21 : }
     609             : 
     610          57 : static void RegisterConfigHandler(IFMapDependencyManager *dep,
     611             :                                   const char *name, AgentOperDBTable *table) {
     612          57 :     if (table)
     613          57 :         dep->Register(name, boost::bind(&AgentOperDBTable::ConfigEventHandler,
     614             :                                         table, _1, _2));
     615          57 : }
     616             : 
     617           3 : void IFMapDependencyManager::InitializeDependencyRules(Agent *agent) {
     618             : 
     619           6 :     RegisterConfigHandler(this, "virtual-machine",
     620           3 :                           agent ? agent->vm_table() : NULL);
     621             : 
     622           6 :     RegisterConfigHandler(this, "access-control-list",
     623           3 :                           agent ? agent->acl_table() : NULL);
     624             : 
     625           6 :     RegisterConfigHandler(this, "multicast-policy",
     626           3 :                           agent ? agent->mp_table() : NULL);
     627             : 
     628             :     ////////////////////////////////////////////////////////////////////////
     629             :     // VN <----> RI
     630             :     //    <----> ACL
     631             :     //    <----> VN-IPAM <----> IPAM
     632             :     //    <----> SecurityLoggingObject
     633             :     //    <----> Multicast Policy
     634             :     ////////////////////////////////////////////////////////////////////////
     635           3 :     AddDependencyPath("virtual-network",
     636           6 :                       MakePath("virtual-network-routing-instance",
     637             :                                "routing-instance", true));
     638           3 :     AddDependencyPath("virtual-network",
     639           6 :                       MakePath("virtual-network-access-control-list",
     640             :                                "access-control-list", true));
     641           3 :     AddDependencyPath("virtual-network",
     642           6 :                       MakePath("virtual-network-network-ipam",
     643             :                                "virtual-network-network-ipam", true,
     644             :                                "virtual-network-network-ipam",
     645             :                                "network-ipam", false));
     646           3 :     AddDependencyPath("virtual-network",
     647           6 :                       MakePath("virtual-network-qos-config",
     648             :                                "qos-config", true));
     649           3 :     AddDependencyPath("virtual-network",
     650           6 :                       MakePath("virtual-network-security-logging-object",
     651             :                                "security-logging-object", true));
     652           3 :     AddDependencyPath("virtual-network",
     653           6 :                       MakePath("logical-router-virtual-network",
     654             :                                "logical-router-virtual-network", true,
     655             :                                "logical-router-virtual-network",
     656             :                                "logical-router", true));
     657           3 :     AddDependencyPath("virtual-network",
     658           6 :                       MakePath("virtual-network-multicast-policy",
     659             :                                "multicast-policy", true));
     660           6 :     RegisterConfigHandler(this, "virtual-network",
     661           3 :                           agent ? agent->vn_table() : NULL);
     662             : 
     663             :     ////////////////////////////////////////////////////////////////////////
     664             :     // RI <----> VN
     665             :     ////////////////////////////////////////////////////////////////////////
     666           3 :     AddDependencyPath("routing-instance",
     667           6 :                       MakePath("virtual-network-routing-instance",
     668             :                                "virtual-network", true,
     669             :                                "virtual-network-provider-network",
     670             :                                "virtual-network", true));
     671           6 :     RegisterConfigHandler(this, "routing-instance",
     672           3 :                           agent ? agent->vrf_table() : NULL);
     673             : 
     674             :     ////////////////////////////////////////////////////////////////////////
     675             :     // SG <----> ACL
     676             :     ////////////////////////////////////////////////////////////////////////
     677           3 :     AddDependencyPath("security-group",
     678           6 :                       MakePath("security-group-access-control-list",
     679             :                                "access-control-list", true));
     680           6 :     RegisterConfigHandler(this, "security-group",
     681           3 :                          agent ? agent->sg_table() : NULL);
     682             : 
     683           6 :     RegisterConfigHandler(this, "tag",
     684           3 :                          agent ? agent->tag_table() : NULL);
     685           3 :     AddDependencyPath("tag",
     686           6 :                       MakePath("application-policy-set-tag",
     687             :                                "application-policy-set", true,
     688             :                                "policy-management-application-policy-set",
     689             :                                "policy-management", false));
     690             :     ////////////////////////////////////////////////////////////////////////
     691             :     // VMI <----> VN
     692             :     //     <----> VM
     693             :     //     <----> VMI-RI <----> RI
     694             :     //     <----> SG
     695             :     //     //<----> FIP <----> FIP-POOL <----> VN <----> RI
     696             :     //     <----> FIP <----> FIP-POOL <----> VN
     697             :     //     <----> FIP <----> Instance-IP <----> VN
     698             :     //     <----> Instance-IP
     699             :     //     <----> interface-route-table
     700             :     //     <----> subnet
     701             :     //     //<----> vn <----> VN-IPAM <----> IPAM
     702             :     //     <----> LI <----> physical-interface <----> physical-router
     703             :     //     <----> SecurityLoggingObject
     704             :     ////////////////////////////////////////////////////////////////////////
     705           3 :     AddDependencyPath("virtual-machine-interface",
     706           6 :                       MakePath("virtual-machine-interface-virtual-network",
     707             :                                "virtual-network", true,
     708             :                                "virtual-network-network-ipam",
     709             :                                "virtual-network-network-ipam", true));
     710           3 :     AddDependencyPath("virtual-machine-interface",
     711           6 :                       MakePath("virtual-machine-interface-virtual-machine",
     712             :                                "virtual-machine", true));
     713           3 :     AddDependencyPath("virtual-machine-interface",
     714           6 :                       MakePath("virtual-machine-interface-sub-interface",
     715             :                                "virtual-machine-interface", true));
     716             : 
     717           3 :     AddDependencyPath("virtual-machine-interface",
     718           6 :                       MakePath("virtual-machine-interface-virtual-network",
     719             :                                "virtual-network", true,
     720             :                                "virtual-network-provider-network",
     721             :                                "virtual-network", true));
     722             : 
     723           3 :     AddDependencyPath("virtual-machine-interface",
     724           6 :                       MakePath("virtual-machine-interface-routing-instance",
     725             :                                "virtual-machine-interface-routing-instance",
     726             :                                true,
     727             :                                "virtual-machine-interface-routing-instance",
     728             :                                "routing-instance", true));
     729             : 
     730           3 :     AddDependencyPath("virtual-machine-interface",
     731           6 :                       MakePath("virtual-machine-interface-security-group",
     732             :                                "security-group", true));
     733           3 :     AddDependencyPath("virtual-machine-interface",
     734           6 :                       MakePath("alias-ip-virtual-machine-interface",
     735             :                                "alias-ip", true,
     736             :                                "alias-ip-pool-alias-ip",
     737             :                                "alias-ip-pool", false,
     738             :                                "virtual-network-alias-ip-pool",
     739             :                                "virtual-network", true));
     740           3 :     AddDependencyPath("virtual-machine-interface",
     741           6 :                       MakePath("floating-ip-virtual-machine-interface",
     742             :                                "floating-ip", true,
     743             :                                "floating-ip-pool-floating-ip",
     744             :                                "floating-ip-pool", false,
     745             :                                "virtual-network-floating-ip-pool",
     746             :                                "virtual-network", true,
     747             :                                "virtual-network-provider-network",
     748             :                                "virtual-network", true));
     749           3 :     AddDependencyPath("virtual-machine-interface",
     750           6 :                       MakePath("floating-ip-virtual-machine-interface",
     751             :                                "floating-ip", true,
     752             :                                "floating-ip-pool-floating-ip",
     753             :                                "floating-ip-pool", false,
     754             :                                "virtual-network-floating-ip-pool",
     755             :                                "virtual-network", true,
     756             :                                "virtual-network-routing-instance",
     757             :                                "routing-instance", true));
     758           3 :      AddDependencyPath("virtual-machine-interface",
     759           6 :                        MakePath("floating-ip-virtual-machine-interface",
     760             :                                 "floating-ip", true,
     761             :                                 "instance-ip-floating-ip",
     762             :                                 "instance-ip", false,
     763             :                                 "instance-ip-virtual-network",
     764             :                                 "virtual-network", true));
     765           3 :     AddDependencyPath("virtual-machine-interface",
     766           6 :                       MakePath("instance-ip-virtual-machine-interface",
     767             :                                "instance-ip", true));
     768           3 :     AddDependencyPath("virtual-machine-interface",
     769           6 :                       MakePath("virtual-machine-interface-route-table",
     770             :                                "interface-route-table", true));
     771           3 :     AddDependencyPath("virtual-machine-interface",
     772           6 :                       MakePath("subnet-virtual-machine-interface",
     773             :                                "subnet", true));
     774           3 :     AddDependencyPath("virtual-machine-interface",
     775           6 :                       MakePath("logical-interface-virtual-machine-interface",
     776             :                                "logical-interface", false,
     777             :                                "physical-interface-logical-interface",
     778             :                                "physical-interface", false,
     779             :                                "physical-router-physical-interface",
     780             :                                "physical-router", true));
     781           3 :     AddDependencyPath("virtual-machine-interface",
     782           6 :                       MakePath("virtual-port-group-virtual-machine-interface",
     783             :                                "virtual-port-group", false,
     784             :                                "virtual-port-group-physical-interface",
     785             :                                "physical-interface", false,
     786             :                                "physical-router-physical-interface",
     787             :                                "physical-router", true));
     788           3 :     AddDependencyPath("virtual-machine-interface",
     789           6 :                       MakePath("bgpaas-virtual-machine-interface",
     790             :                                "bgp-as-a-service", true,
     791             :                                "bgpaas-bgp-router",
     792             :                                "bgp-router", true,
     793             :                                "instance-bgp-router",
     794             :                                "routing-instance", true));
     795           3 :     AddDependencyPath("virtual-machine-interface",
     796           6 :                       MakePath("bgpaas-virtual-machine-interface",
     797             :                                "bgp-as-a-service", true,
     798             :                                "bgpaas-health-check",
     799             :                                "service-health-check", true));
     800           3 :     AddDependencyPath("virtual-machine-interface",
     801           6 :                       MakePath("virtual-machine-interface-qos-config",
     802             :                           "qos-config", true));
     803           3 :     AddDependencyPath("virtual-machine-interface",
     804           6 :                    MakePath("virtual-machine-interface-security-logging-object",
     805             :                             "security-logging-object", true));
     806             : 
     807           3 :     AddDependencyPath("virtual-machine-interface",
     808           6 :                       MakePath("virtual-machine-interface-bridge-domain",
     809             :                                "virtual-machine-interface-bridge-domain",
     810             :                                true,
     811             :                                "virtual-machine-interface-bridge-domain",
     812             :                                "bridge-domain", true,
     813             :                                "virtual-network-bridge-domain",
     814             :                                "virtual-network", true));
     815             :     //Above rule should suffice for VMI to act on bridge domain
     816             :     //"virtual-machine-interface-bridge-domain" link is used to
     817             :     //link both VMI and bridge domain, so this link could notify
     818             :     //bridge-domain which doesnt have any reaction list as bridge-domain
     819             :     //is not intererested in "virtual-machine-interface-bridge-domain".
     820             :     //VMI ---> VMI-BD Link ---> VMI-BD node ----> VMI-BD link ---> BD
     821             :     //Note that link name is same in above graph
     822             :     //Add the below dummy rule so that VMI-BD link triggers
     823             :     //bridge-domain evaluation its ignored and avoids assert
     824           3 :     AddDependencyPath("virtual-machine-interface",
     825           6 :                       MakePath("virtual-machine-interface-bridge-domain",
     826             :                                "virtual-machine-interface-bridge-domain",
     827             :                                true,
     828             :                                "virtual-machine-interface-bridge-domain",
     829             :                                "bridge-domain", true));
     830             : 
     831           3 :     AddDependencyPath("virtual-machine-interface",
     832           6 :                       MakePath("virtual-machine-interface-tag",
     833             :                                "tag", true,
     834             :                                "application-policy-set-tag",
     835             :                                "application-policy-set", true,
     836             :                                "application-policy-set-firewall-policy",
     837             :                                "application-policy-set-firewall-policy", true,
     838             :                                "application-policy-set-firewall-policy",
     839             :                                "firewall-policy", true));
     840             : 
     841           3 :     AddDependencyPath("virtual-machine-interface",
     842           6 :                       MakePath("virtual-machine-interface-virtual-network",
     843             :                                "virtual-network", true,
     844             :                                "virtual-network-tag", "tag", true,
     845             :                                "application-policy-set-tag",
     846             :                                "application-policy-set", true,
     847             :                                "application-policy-set-firewall-policy",
     848             :                                "application-policy-set-firewall-policy", true,
     849             :                                "application-policy-set-firewall-policy",
     850             :                                "firewall-policy", true));
     851             : 
     852             : 
     853           3 :     AddDependencyPath("virtual-machine-interface",
     854           6 :                       MakePath("virtual-machine-interface-virtual-machine",
     855             :                                "virtual-machine", true,
     856             :                                "virtual-machine-tag", "tag", true,
     857             :                                "application-policy-set-tag",
     858             :                                "application-policy-set", true,
     859             :                                "application-policy-set-firewall-policy",
     860             :                                "application-policy-set-firewall-policy", true,
     861             :                                "application-policy-set-firewall-policy",
     862             :                                "firewall-policy", true));
     863             : 
     864           3 :     AddDependencyPath("virtual-machine-interface",
     865           6 :                       MakePath("virtual-machine-interface-sub-interface",
     866             :                                "virtual-machine-interface", true,
     867             :                                "virtual-machine-interface-virtual-machine",
     868             :                                "virtual-machine", true,
     869             :                                "virtual-machine-tag", "tag", true,
     870             :                                "application-policy-set-tag",
     871             :                                "application-policy-set", true,
     872             :                                "application-policy-set-firewall-policy",
     873             :                                "application-policy-set-firewall-policy", true,
     874             :                                "application-policy-set-firewall-policy",
     875             :                                "firewall-policy", true));
     876             : 
     877           3 :     AddDependencyPath("virtual-machine-interface",
     878           6 :                       MakePath("project-virtual-machine-interface",
     879             :                                "project", true,
     880             :                                "project-tag", "tag", true,
     881             :                                "application-policy-set-tag",
     882             :                                "application-policy-set", true,
     883             :                                "application-policy-set-firewall-policy",
     884             :                                "application-policy-set-firewall-policy", true,
     885             :                                "application-policy-set-firewall-policy",
     886             :                                "firewall-policy", true));
     887             : 
     888             :     /* Trigger change on virtual-machine-interface, if there is change in
     889             :      * port-tuple configuration */
     890           3 :     AddDependencyPath("virtual-machine-interface",
     891           6 :                       MakePath("port-tuple-interface",
     892             :                                "port-tuple", true,
     893             :                                "port-tuple-interface",
     894             :                                "virtual-machine-interface", true));
     895           3 :     AddDependencyPath("virtual-machine-interface",
     896           6 :                       MakePath("logical-router-interface",
     897             :                                "logical-router", true));
     898             : 
     899           6 :     RegisterConfigHandler(this, "virtual-machine-interface",
     900           3 :                           agent ? agent->interface_table() : NULL);
     901             :     ////////////////////////////////////////////////////////////////////////
     902             :     // physical-interface <----> physical-router
     903             :     ////////////////////////////////////////////////////////////////////////
     904           3 :     AddDependencyPath("physical-interface",
     905           6 :                       MakePath("physical-router-physical-interface",
     906             :                                "physical-router", true));
     907             :     ////////////////////////////////////////////////////////////////////////
     908             :     // physical-interface <----> virtual-port-group
     909             :     ////////////////////////////////////////////////////////////////////////
     910           3 :     AddDependencyPath("physical-interface",
     911           6 :                     MakePath("virtual-port-group-physical-interface",
     912             :                              "virtual-port-group-physical-interface", true,
     913             :                              "virtual-port-group-physical-interface",
     914             :                              "virtual-port-group", true));
     915           6 :     RegisterConfigHandler(this, "physical-interface",
     916           3 :                           agent ? agent->interface_table() : NULL);
     917             : 
     918             :     ////////////////////////////////////////////////////////////////////////
     919             :     // logical-interface <----> physical-interface <----> physical-router
     920             :     //                   <----> virtual-machine-interface <---> virtual-network
     921             :     //
     922             :     ////////////////////////////////////////////////////////////////////////
     923           3 :     AddDependencyPath("logical-interface",
     924           6 :                       MakePath("physical-interface-logical-interface",
     925             :                                "physical-interface", true,
     926             :                                "physical-router-physical-interface",
     927             :                                "physical-router", true));
     928           3 :     AddDependencyPath("logical-interface",
     929           6 :                       MakePath("logical-interface-virtual-machine-interface",
     930             :                                "virtual-machine-interface", true));
     931           3 :     AddDependencyPath("logical-interface",
     932           6 :                       MakePath("physical-router-logical-interface",
     933             :                                "physical-router", true));
     934           6 :     RegisterConfigHandler(this, "logical-interface",
     935           3 :                           agent ? agent->interface_table() : NULL);
     936             : 
     937             :     ////////////////////////////////////////////////////////////////////////
     938             :     // physical-router <----> physical-interface
     939             :     ////////////////////////////////////////////////////////////////////////
     940           3 :     AddDependencyPath("physical-router",
     941           6 :                       MakePath("physical-router-physical-interface",
     942             :                                "physical-interface", true));
     943           6 :     RegisterConfigHandler(this, "physical-router",
     944           3 :                           agent ? agent->physical_device_table() : NULL);
     945             : 
     946             :     ////////////////////////////////////////////////////////////////////////
     947             :     // virtual-machine-interface <----> service-health-check
     948             :     ////////////////////////////////////////////////////////////////////////
     949           3 :     AddDependencyPath("service-health-check",
     950           6 :                       MakePath("service-port-health-check",
     951             :                                "virtual-machine-interface", true,
     952             :                                "virtual-machine-interface-virtual-network",
     953             :                                "virtual-network", false,
     954             :                                "virtual-network-network-ipam",
     955             :                                "virtual-network-network-ipam", true));
     956           3 :     AddDependencyPath("service-health-check",
     957           6 :                       MakePath("service-port-health-check",
     958             :                                "virtual-machine-interface", true,
     959             :                                "port-tuple-interface",
     960             :                                "port-tuple", true,
     961             :                                "port-tuple-interface",
     962             :                                "virtual-machine-interface", true,
     963             :                                "virtual-machine-interface-virtual-network",
     964             :                                "virtual-network", false,
     965             :                                "virtual-network-network-ipam",
     966             :                                "virtual-network-network-ipam", true));
     967           6 :     RegisterConfigHandler(this, "service-health-check",
     968           3 :                           agent ? agent->health_check_table() : NULL);
     969             : 
     970           3 :     AddDependencyPath("qos-config",
     971           6 :                        MakePath("global-qos-config-qos-config",
     972             :                                 "global-qos-config", false));
     973           6 :     RegisterConfigHandler(this, "qos-config",
     974           3 :                           agent ? agent->qos_config_table() : NULL);
     975             : 
     976           6 :     RegisterConfigHandler(this, "qos-queue",
     977           3 :                           agent ? agent->qos_queue_table() : NULL);
     978             : 
     979           3 :     AddDependencyPath("forwarding-class",
     980           6 :                        MakePath("forwarding-class-qos-queue",
     981             :                                 "qos-queue", true));
     982           6 :     RegisterConfigHandler(this, "forwarding-class",
     983           3 :                           agent ? agent->forwarding_class_table() : NULL);
     984             : 
     985             :     ////////////////////////////////////////////////////////////////////////
     986             :     // security-logging-object <----> network-policy
     987             :     //                         <----> security-group
     988             :     ////////////////////////////////////////////////////////////////////////
     989           3 :     AddDependencyPath("security-logging-object",
     990           6 :                        MakePath("security-logging-object-network-policy",
     991             :                                 "network-policy", true));
     992           3 :     AddDependencyPath("security-logging-object",
     993           6 :                        MakePath("security-logging-object-security-group",
     994             :                                 "security-group", true));
     995           3 :     AddDependencyPath("security-logging-object",
     996           6 :                       MakePath("firewall-policy-security-logging-object",
     997             :                                "firewall-policy-security-logging-object", true,
     998             :                                "firewall-policy-security-logging-object",
     999             :                                 "firewall-policy", false));
    1000           3 :     AddDependencyPath("security-logging-object",
    1001           6 :                        MakePath("firewall-rule-security-logging-object",
    1002             :                                 "firewall-rule-security-logging-object", true,
    1003             :                                 "firewall-rule-security-logging-object",
    1004             :                                 "firewall-rule", false));
    1005           6 :     RegisterConfigHandler(this, "security-logging-object",
    1006           3 :                           agent ? agent->slo_table() : NULL);
    1007             : 
    1008             :     ////////////////////////////////////////////////////////////////////////
    1009             :     // VR <----> Subcluster <----> bgp-router
    1010             :     ////////////////////////////////////////////////////////////////////////
    1011           3 :     AddDependencyPath("virtual-router",
    1012           6 :                        MakePath("virtual-router-sub-cluster",
    1013             :                                 "sub-cluster", true,
    1014             :                                 "bgp-router-sub-cluster",
    1015             :                                 "bgp-router", true));
    1016             : 
    1017             :     // Register callback for ifmap node not having corresponding oper-dbtable
    1018           3 :     RegisterConfigHandler(this, "virtual-router", agent->oper_db()->vrouter());
    1019           3 :     RegisterConfigHandler(this, "global-qos-config",
    1020           3 :                           agent->oper_db()->global_qos_config());
    1021           3 :     RegisterConfigHandler(this, "global-system-config",
    1022           3 :                           agent->oper_db()->global_system_config());
    1023           3 :     RegisterConfigHandler(this, "network-ipam",
    1024           3 :                           agent->oper_db()->network_ipam());
    1025           3 :     RegisterConfigHandler(this, "virtual-DNS",
    1026           3 :                           agent->oper_db()->virtual_dns());
    1027           3 :     RegisterConfigHandler(this, "global-vrouter-config",
    1028           3 :                           agent->oper_db()->global_vrouter());
    1029           3 :     RegisterConfigHandler(this, "bgp-router",
    1030           3 :                           agent->oper_db()->bgp_router_config());
    1031           3 :     AddDependencyPath("bridge-domain",
    1032           6 :                       MakePath("virtual-network-bridge-domain",
    1033             :                                "virtual-network", true,
    1034             :                                "virtual-network-routing-instance",
    1035             :                                "routing-instance", true));
    1036           3 :     AddDependencyPath("bridge-domain",
    1037           6 :                       MakePath("virtual-network-bridge-domain",
    1038             :                       "virtual-network", true));
    1039             : 
    1040           6 :     RegisterConfigHandler(this, "bridge-domain",
    1041           3 :                           agent ? agent->bridge_domain_table() : NULL);
    1042             : 
    1043           3 :     AddDependencyPath("application-policy-set",
    1044           6 :                       MakePath("application-policy-set-firewall-policy",
    1045             :                                "application-policy-set-firewall-policy", true,
    1046             :                                "application-policy-set-firewall-policy",
    1047             :                                "firewall-policy", true));
    1048           6 :     RegisterConfigHandler(this, "application-policy-set",
    1049           3 :                           agent ? agent->policy_set_table() : NULL);
    1050             : 
    1051           3 :     AddDependencyPath("firewall-policy",
    1052           6 :                       MakePath("firewall-policy-firewall-rule",
    1053             :                                "firewall-policy-firewall-rule", true,
    1054             :                                "firewall-policy-firewall-rule",
    1055             :                                "firewall-rule", true,
    1056             :                                "firewall-rule-service-group",
    1057             :                                "service-group", true));
    1058           3 :     AddDependencyPath("firewall-policy",
    1059           6 :                       MakePath("firewall-policy-firewall-rule",
    1060             :                                "firewall-policy-firewall-rule", true,
    1061             :                                "firewall-policy-firewall-rule",
    1062             :                                 "firewall-rule", true,
    1063             :                                 "firewall-rule-address-group",
    1064             :                                 "address-group", true,
    1065             :                                 "address-group-tag", "tag", "true"));
    1066             : 
    1067           3 :     AddDependencyPath("firewall-policy",
    1068           6 :                       MakePath("firewall-policy-firewall-rule",
    1069             :                                "firewall-policy-firewall-rule", true,
    1070             :                                "firewall-policy-firewall-rule",
    1071             :                                "firewall-rule", true,
    1072             :                                "firewall-rule-tag",
    1073             :                                "tag", true));
    1074             : 
    1075           3 :     AddDependencyPath("firewall-policy",
    1076           6 :                       MakePath("firewall-policy-firewall-rule",
    1077             :                                "firewall-policy-firewall-rule", true,
    1078             :                                "firewall-policy-firewall-rule",
    1079             :                                "firewall-rule", true));
    1080             : 
    1081           6 :     RegisterConfigHandler(this, "firewall-policy",
    1082           3 :                           agent ? agent->acl_table() : NULL);
    1083           3 : }
    1084             : 
    1085           0 : void IFMapNodePolicyReq::HandleRequest() const {
    1086           0 :     Agent *agent = Agent::GetInstance();
    1087           0 :     IFMapNodePolicyResp *resp = new IFMapNodePolicyResp();
    1088             : 
    1089             :     IFMapDependencyTracker::NodeEventPolicy *policy_list =
    1090           0 :         agent->oper_db()->dependency_manager()->tracker()->policy_map();
    1091           0 :     NodeEventPolicy::iterator it1 = policy_list->begin();
    1092           0 :     std::vector<IFMapNodePolicy> resp_policy_list;
    1093           0 :     while (it1 != policy_list->end()) {
    1094           0 :         if (it1->first.find(get_node()) == string::npos) {
    1095           0 :             it1++;
    1096           0 :             continue;
    1097             :         }
    1098             : 
    1099           0 :         ReactionMap::iterator it2 = it1->second.begin();
    1100           0 :         vector<IFMapReactEvent> resp_event_list;
    1101           0 :         while(it2 != it1->second.end()) {
    1102           0 :             IFMapReactEvent resp_event;
    1103           0 :             vector<string> resp_reactor_list;
    1104           0 :             PropagateList::iterator it3 = it2->second.begin();
    1105           0 :             while (it3 != it2->second.end()) {
    1106           0 :                 resp_reactor_list.push_back((*it3));
    1107           0 :                 it3++;
    1108             :             }
    1109           0 :             resp_event.set_event(it2->first);
    1110           0 :             resp_event.set_reactors(resp_reactor_list);
    1111           0 :             resp_event_list.push_back(resp_event);
    1112           0 :             it2++;
    1113           0 :         }
    1114             : 
    1115           0 :         IFMapNodePolicy policy;
    1116           0 :         policy.set_node(it1->first);
    1117           0 :         policy.set_events(resp_event_list);
    1118           0 :         resp_policy_list.push_back(policy);
    1119           0 :         it1++;
    1120           0 :     }
    1121             : 
    1122           0 :     resp->set_policies(resp_policy_list);
    1123           0 :     resp->set_context(context());
    1124           0 :     resp->set_more(false);
    1125           0 :     resp->Response();
    1126           0 :     return;
    1127           0 : }

Generated by: LCOV version 1.14