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

Generated by: LCOV version 1.14