LCOV - code coverage report
Current view: top level - vnsw/agent/mac_learning - mac_learning_db_client.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 4 5 80.0 %
Date: 2026-11-09 02:10:49 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : #ifndef SRC_VNSW_AGENT_MAC_LEARNING_MAC_LEARNING_DB_CLIENT_H_
       6             : #define SRC_VNSW_AGENT_MAC_LEARNING_MAC_LEARNING_DB_CLIENT_H_
       7             : #include "cmn/agent.h"
       8             : #include <oper/vn.h>
       9             : #include <oper/vm.h>
      10             : #include <oper/interface_common.h>
      11             : #include <oper/nexthop.h>
      12             : #include <oper/route_common.h>
      13             : #include <oper/sg.h>
      14             : #include <oper/vrf.h>
      15             : #include <filter/acl.h>
      16             : #include <oper/health_check.h>
      17             : 
      18             : //Mac learning mgmt DB client module listens for all notification from
      19             : //DB table and triggers change on the dependent MAC entries.
      20             : //Add or Change of DB entry:
      21             : //  Request to revaluate DB entries is enqueued to MAC mgmt module
      22             : //  which in turn RESYNC's all the mac entries
      23             : //
      24             : //Delete of DB entry:
      25             : //  Request to delete DB Entry gets queued to MAC mgmt table,
      26             : //  which in turn deletes all the mac entries dependent on this
      27             : //  DB entry.
      28             : //
      29             : //Free of DB State:
      30             : //  DB state should be release till the depedent mac entries
      31             : //  have been deleted. Hence once the mac entries are deleted
      32             : //  request to free DB state gets enqued from mac mgmt module
      33             : //  to learning module, so that it happens in exclusion to DB.
      34             : //
      35             : class MacLearningDBClient {
      36             : public:
      37             :     struct MacLearningDBState : public DBState {
      38         736 :         MacLearningDBState(): deleted_(false){}
      39             :        bool deleted_;
      40             :        uint32_t gen_id_;
      41             :     };
      42             : 
      43             :     struct MacLearningIntfState: public MacLearningDBState {
      44             :         uint32_t l2_label_;
      45             :         VmInterface::SecurityGroupEntryList sg_l_;
      46             :         bool learning_enabled_;
      47             :         bool policy_enabled_;
      48             :         bool l2_active_;
      49             :         bool mac_ip_learning_enable_;
      50             :     };
      51             : 
      52             :     struct MacLearningVrfState : public MacLearningDBState {
      53          74 :         MacLearningVrfState(): deleted_(false) {}
      54             :         void Register(MacLearningDBClient *client, VrfEntry *vrf);
      55             :         void Unregister(VrfEntry *vrf);
      56             :         bool deleted_;
      57             :         bool learning_enabled_;
      58             :         uint32_t isid_;
      59             :         DBTableBase::ListenerId bridge_listener_id_;
      60             :         DBTableBase::ListenerId evpn_listener_id_;
      61             :     };
      62             :     struct MacLearningVnState : public MacLearningDBState {
      63         138 :         MacLearningVnState(): deleted_(false), mac_ip_learning_enabled_(false),
      64          69 :                                 hc_uuid_() {}
      65             :         bool deleted_;
      66             :         bool mac_ip_learning_enabled_;
      67             :         boost::uuids::uuid hc_uuid_;
      68             :     };
      69             :     struct MacLearningHealthCheckState : public MacLearningDBState {
      70           0 :         MacLearningHealthCheckState(): deleted_(false) {}
      71             :         bool deleted_;
      72             :         uint32_t delay_;
      73             :         uint64_t delay_usecs_;
      74             :         uint32_t timeout_;
      75             :         uint64_t timeout_usecs_;
      76             :         uint32_t max_retries_;
      77             :         bool is_hc_enable_all_target_ips;
      78             :         std::set<IpAddress> hc_target_ip_list_;
      79             :     };
      80             : 
      81             :     struct MacLearningRouteState : public MacLearningDBState {
      82             :     };
      83             : 
      84             :     MacLearningDBClient(Agent *agent);
      85             :     virtual ~MacLearningDBClient();
      86             :     void Init();
      87             :     void Shutdown();
      88             :     void FreeDBState(const DBEntry *db_entry, uint32_t gen_id);
      89             : private:
      90             :     void AddEvent(const DBEntry *entry, MacLearningDBState *state);
      91             :     void DeleteEvent(const DBEntry *entry, MacLearningDBState *state);
      92             :     void DeleteNoOpEvent(const DBEntry *entry, MacLearningDBState *state);
      93             :     void ChangeEvent(const DBEntry *entry, MacLearningDBState *state);
      94             :     void ReleaseToken(const DBEntry *entry);
      95             :     void DeleteAllMac(const DBEntry *entry, MacLearningDBState *state);
      96             :     void InterfaceNotify(DBTablePartBase *part, DBEntryBase *e);
      97             :     void VrfNotify(DBTablePartBase *part, DBEntryBase *e);
      98             :     void RouteNotify(MacLearningVrfState *state,
      99             :                      Agent::RouteTableType type,
     100             :                      DBTablePartBase *partition,
     101             :                      DBEntryBase *e);
     102             :     void EvpnRouteNotify(MacLearningVrfState *state,
     103             :                      Agent::RouteTableType type,
     104             :                      DBTablePartBase *partition,
     105             :                      DBEntryBase *e);
     106             :     void VnNotify(DBTablePartBase *part, DBEntryBase *e);
     107             :     void HealthCheckNotify(DBTablePartBase *part, DBEntryBase *e);
     108             :     void FreeRouteState(const DBEntry *e, uint32_t gen_id);
     109             :     void EnqueueAgingTableDelete(const VrfEntry *vrf);
     110             :     Agent *agent_;
     111             :     DBTableBase::ListenerId interface_listener_id_;
     112             :     DBTableBase::ListenerId vrf_listener_id_;
     113             :     DBTableBase::ListenerId vn_listener_id_;
     114             :     DBTableBase::ListenerId hc_listener_id_;
     115             :     DISALLOW_COPY_AND_ASSIGN(MacLearningDBClient);
     116             : };
     117             : #endif

Generated by: LCOV version 1.14