LCOV - code coverage report
Current view: top level - vnsw/agent/pkt/flow_mgmt - flow_mgmt_dbclient.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 27 28 96.4 %
Date: 2026-11-09 02:10:49 Functions: 21 22 95.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : #ifndef __AGENT_FLOW_MGMT_DBCLIENT_H__
       6             : #define __AGENT_FLOW_MGMT_DBCLIENT_H__
       7             : 
       8             : #include "pkt/flow_event.h"
       9             : 
      10             : class EcmpLoadBalance;
      11             : ////////////////////////////////////////////////////////////////////////////
      12             : // Request to the Flow Management module
      13             : ////////////////////////////////////////////////////////////////////////////
      14             : class FlowMgmtDbClient {
      15             : public:
      16             :     struct FlowMgmtState : public DBState {
      17        3327 :         FlowMgmtState() : gen_id_(0), deleted_(false) { }
      18        3327 :         virtual ~FlowMgmtState() { }
      19             : 
      20             :         void IncrementGenId() { gen_id_++; }
      21             :         uint32_t gen_id_;
      22             :         bool deleted_;
      23             :     };
      24             : 
      25             :     struct VnFlowHandlerState : public FlowMgmtState {
      26             :         AclDBEntryConstRef acl_;
      27             :         AclDBEntryConstRef macl_;
      28             :         AclDBEntryConstRef mcacl_;
      29             :         bool enable_rpf_;
      30             :         bool flood_unknown_unicast_;
      31          69 :         VnFlowHandlerState(const AclDBEntry *acl,
      32             :                            const AclDBEntry *macl,
      33             :                            const AclDBEntry *mcacl, bool enable_rpf,
      34          69 :                            bool flood_unknown_unicast) :
      35          69 :            acl_(acl), macl_(macl), mcacl_(mcacl), enable_rpf_(enable_rpf),
      36         138 :            flood_unknown_unicast_(flood_unknown_unicast){ }
      37         138 :         virtual ~VnFlowHandlerState() { }
      38             :     };
      39             : 
      40             :     struct VmIntfFlowHandlerState : public FlowMgmtState {
      41         338 :         VmIntfFlowHandlerState(const VnEntry *vn) : vn_(vn),
      42         169 :             vrf_assign_acl_(NULL), is_vn_qos_config_(false),
      43         338 :             forwarding_vrf_id_(VrfEntry::kInvalidIndex) { }
      44         338 :         virtual ~VmIntfFlowHandlerState() { }
      45             : 
      46             :         VnEntryConstRef vn_;
      47             :         bool policy_;
      48             :         VmInterface::SecurityGroupEntryList sg_l_;
      49             :         AclDBEntryConstRef vrf_assign_acl_;
      50             :         bool is_vn_qos_config_;
      51             :         AgentQosConfigConstRef qos_config_;
      52             :         FirewallPolicyList fw_policy_list_;
      53             :         FirewallPolicyList fwaas_fw_policy_list_;
      54             :         uint32_t forwarding_vrf_id_;
      55             :     };
      56             : 
      57             :     struct VrfFlowHandlerState : public FlowMgmtState {
      58          74 :         VrfFlowHandlerState() : deleted_(false) {}
      59         148 :         virtual ~VrfFlowHandlerState() {}
      60             : 
      61             :         // Register to all the route tables of intrest
      62             :         void Register(FlowMgmtDbClient *client, VrfEntry *vrf);
      63             :         void Unregister(FlowMgmtDbClient *client, VrfEntry *vrf);
      64             : 
      65             :         // Unregister from the route tables
      66             :         bool Unregister(VrfEntry *vrf);
      67             : 
      68        5641 :         DBTableBase::ListenerId GetListenerId(Agent::RouteTableType type) {
      69        5641 :             if (type == Agent::INET4_UNICAST)
      70        2007 :                 return inet_listener_id_;
      71        3634 :             if (type == Agent::INET6_UNICAST)
      72         936 :                 return inet6_listener_id_;
      73        2698 :             if (type == Agent::BRIDGE)
      74        2698 :                 return bridge_listener_id_;
      75             : 
      76           0 :             assert(0);
      77             :             return -1;
      78             :         }
      79             :         DBTableBase::ListenerId inet_listener_id_;
      80             :         DBTableBase::ListenerId inet6_listener_id_;
      81             :         DBTableBase::ListenerId bridge_listener_id_;
      82             :         bool deleted_;
      83             :     };
      84             : 
      85             :     struct RouteFlowHandlerState : public FlowMgmtState {
      86        4080 :         RouteFlowHandlerState() : sg_l_(), active_nh_(NULL), local_nh_(NULL),
      87        1360 :             ecmp_load_balance_(), tags_l_() {}
      88        2720 :         virtual ~RouteFlowHandlerState() { }
      89             :         typedef std::map<InterfaceConstRef, IpAddress> FixedIpMap;
      90             :         typedef std::pair<InterfaceConstRef, IpAddress> FixedIpEntry;
      91             : 
      92             :         SecurityGroupList sg_l_;
      93             :         const NextHop* active_nh_;
      94             :         const NextHop* local_nh_;
      95             :         FixedIpMap fixed_ip_map_;
      96             :         EcmpLoadBalance ecmp_load_balance_;
      97             :         TagList tags_l_;
      98             :         TunnelType::TypeBmap tunnel_bmap_;
      99             :     };
     100             : 
     101             :     struct NhFlowHandlerState : public FlowMgmtState {
     102        1650 :         NhFlowHandlerState(uint8_t valid_encap_size) : valid_encap_size_(valid_encap_size) { }
     103             :         uint8_t valid_encap_size_;
     104        3300 :         virtual ~NhFlowHandlerState() { }
     105             :     };
     106             : 
     107             :     struct AclFlowHandlerState : public FlowMgmtState {
     108           5 :         AclFlowHandlerState() { }
     109          10 :         virtual ~AclFlowHandlerState() { }
     110             :     };
     111             : 
     112             :     FlowMgmtDbClient(Agent *agent, FlowMgmtManager *mgr);
     113             :     virtual ~FlowMgmtDbClient();
     114             : 
     115             :     void Init();
     116             :     void Shutdown();
     117             :     bool FreeDBState(const DBEntry *entry, uint32_t gen_id);
     118             :     void FreeVrfState(VrfEntry *vrf, uint32_t gen_id);
     119             : 
     120             : private:
     121             :     friend class FlowMgmtRouteTest;
     122             :     void AddEvent(const DBEntry *entry, FlowMgmtState *state);
     123             :     void DeleteEvent(const DBEntry *entry, FlowMgmtState *state);
     124             :     void DeleteAllFlow(const DBEntry *entry, FlowMgmtState *state);
     125             :     void ChangeEvent(const DBEntry *entry, FlowMgmtState *state);
     126             :     void RouteNHChangeEvent(const DBEntry *entry, FlowMgmtState *state);
     127             : 
     128             :     void FreeInterfaceState(Interface *intf, uint32_t gen_id);
     129             :     void InterfaceNotify(DBTablePartBase *part, DBEntryBase *e);
     130             : 
     131             :     void FreeVnState(VnEntry *vn, uint32_t gen_id);
     132             :     void VnNotify(DBTablePartBase *part, DBEntryBase *e);
     133             : 
     134             :     void FreeAclState(AclDBEntry *acl, uint32_t gen_id);
     135             :     void AclNotify(DBTablePartBase *part, DBEntryBase *e);
     136             : 
     137             :     void FreeNhState(NextHop *nh, uint32_t gen_id);
     138             :     void NhNotify(DBTablePartBase *part, DBEntryBase *e);
     139             : 
     140             :     void VrfNotify(DBTablePartBase *part, DBEntryBase *e);
     141             : 
     142             :     void TraceMsg(AgentRoute *entry, const AgentPath *path,
     143             :                   const SecurityGroupList &sg_list, bool deleted);
     144             :     void FreeRouteState(AgentRoute *route, uint32_t gen_id);
     145             :     void RouteNotify(VrfFlowHandlerState *vrf_state, Agent::RouteTableType type,
     146             :                      DBTablePartBase *partition, DBEntryBase *e);
     147             :     bool HandleTrackingIpChange(const AgentRoute *rt,
     148             :                                 RouteFlowHandlerState *state);
     149             :     Agent *agent_;
     150             :     FlowMgmtManager *mgr_;
     151             : 
     152             :     DBTableBase::ListenerId acl_listener_id_;
     153             :     DBTableBase::ListenerId interface_listener_id_;
     154             :     DBTableBase::ListenerId vn_listener_id_;
     155             :     DBTableBase::ListenerId vm_listener_id_;
     156             :     DBTableBase::ListenerId vrf_listener_id_;
     157             :     DBTableBase::ListenerId nh_listener_id_;
     158             :     DISALLOW_COPY_AND_ASSIGN(FlowMgmtDbClient);
     159             : };
     160             : 
     161             : #endif //  __AGENT_FLOW_MGMT_DBCLIENT_H__

Generated by: LCOV version 1.14