LCOV - code coverage report
Current view: top level - vnsw/agent/oper - route_leak.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 11 12 91.7 %
Date: 2026-11-09 02:10:49 Functions: 5 6 83.3 %
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_OPER_ROUTE_LEAK_H__
       6             : #define SRC_VNSW_AGENT_OPER_ROUTE_LEAK_H__
       7             : 
       8             : struct RouteLeakState :  public DBState {
       9           4 :     RouteLeakState(Agent *agent, VrfEntry *vrf):
      10           4 :         agent_(agent), dest_vrf_(vrf) {}
      11             : 
      12             :     void AddRoute(const AgentRoute *route);
      13             :     void DeleteRoute(const AgentRoute *route,
      14             :                      const std::set<const Peer *> &peer_list);
      15             : 
      16           4 :     void set_dest_vrf(VrfEntry *vrf) {
      17           4 :         dest_vrf_ = vrf;
      18           4 :     }
      19             : 
      20          60 :     VrfEntry* dest_vrf() const {
      21          60 :         return dest_vrf_.get();
      22             :     }
      23             : 
      24           8 :     std::set<const Peer *>& peer_list() {
      25           8 :         return peer_list_;
      26             :     }
      27             : 
      28             : private:
      29             :     void AddIndirectRoute(const AgentRoute *route);
      30             :     void AddInterfaceRoute(const AgentRoute *route, const AgentPath *path);
      31             :     void AddReceiveRoute(const AgentRoute *route);
      32             :     void AddCompositeRoute(const AgentRoute *route);
      33             :     bool CanAdd(const InetUnicastRouteEntry *route);
      34             :     Agent *agent_;
      35             :     VrfEntryRef dest_vrf_;
      36             :     std::set<const Peer *> peer_list_;
      37             : };
      38             : 
      39             : class RouteLeakVrfState : public DBState {
      40             : public:
      41             :     RouteLeakVrfState(VrfEntry *source_vrf, VrfEntry *dest_vrf);
      42             :     ~RouteLeakVrfState();
      43             :     //Route Notify handler
      44             :     bool Notify(DBTablePartBase *partition, DBEntryBase *e);
      45             :     void Delete();
      46             :     void SetDestVrf(VrfEntry *dest_vrf);
      47             : 
      48           2 :     VrfEntry* dest_vrf() {
      49           2 :         return dest_vrf_.get();
      50             :     }
      51           0 :     bool deleted() const { return deleted_; }
      52             : 
      53             : private:
      54             :     void WalkDoneInternal(DBTableBase *part);
      55             :     bool WalkCallBack(DBTablePartBase *partition, DBEntryBase *entry);
      56             :     void AddDefaultRoute();
      57             :     void DeleteDefaultRoute();
      58             :     //VRF from which routes have to be sourced
      59             :     VrfEntryRef source_vrf_;
      60             :     //VRF to which routes have to be mirrored
      61             :     VrfEntryRef dest_vrf_;
      62             :     DBTableBase::ListenerId route_listener_id_;
      63             :     DBTable::DBTableWalkRef walk_ref_;
      64             :     bool deleted_;
      65             : };
      66             : 
      67             : //Base class registering to VRF table.
      68             : //If route have to be leaked from one VRF to another takes case of it.
      69             : class RouteLeakManager {
      70             : public:
      71             :     RouteLeakManager(Agent *agent);
      72             :     ~RouteLeakManager();
      73             : 
      74             :     Agent *agent() {
      75             :         return agent_;
      76             :     }
      77             : 
      78             :     //VRF notify handler
      79             :     void Notify(DBTablePartBase *partition, DBEntryBase *e);
      80             :     void ReEvaluateRouteExports();
      81             : 
      82             : private:
      83             :     bool VrfWalkNotify(DBTablePartBase *partition, DBEntryBase *e);
      84             :     void VrfWalkDone(DBTableBase *part);
      85             :     void StartRouteWalk(VrfEntry *vrf, RouteLeakVrfState *state);
      86             :     void RouteWalkDone(DBTableBase *part);
      87             : 
      88             :     Agent *agent_;
      89             :     DBTable::DBTableWalkRef vrf_walk_ref_;
      90             :     DBTableBase::ListenerId vrf_listener_id_;
      91             : };
      92             : #endif

Generated by: LCOV version 1.14