LCOV - code coverage report
Current view: top level - vnsw/agent/oper - bridge_route.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 23 26 88.5 %
Date: 2026-11-09 02:10:49 Functions: 15 18 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef vnsw_bridge_route_hpp
       7             : #define vnsw_bridge_route_hpp
       8             : 
       9             : class MacVmBindingPath;
      10             : 
      11             : //////////////////////////////////////////////////////////////////
      12             : //  BRIDGE
      13             : /////////////////////////////////////////////////////////////////
      14             : class BridgeAgentRouteTable : public AgentRouteTable {
      15             : public:
      16          74 :     BridgeAgentRouteTable(DB *db, const std::string &name) :
      17          74 :         AgentRouteTable(db, name) {
      18          74 :     }
      19         148 :     virtual ~BridgeAgentRouteTable() { }
      20             : 
      21         148 :     virtual std::string GetTableName() const {return "BridgeAgentRouteTable";}
      22         628 :     virtual Agent::RouteTableType GetTableType() const {
      23         628 :         return Agent::BRIDGE;
      24             :     }
      25             :     virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args,
      26             :                                             const std::string &context);
      27             : 
      28             :     static DBTableBase *CreateTable(DB *db, const std::string &name);
      29             : 
      30             :     void AddMacVmBindingRoute(const Peer *peer,
      31             :                       const std::string &vrf_name,
      32             :                       const MacAddress &mac,
      33             :                       const VmInterface *vm_intf,
      34             :                       bool flood_dhcp);
      35             :     void AddBridgeRoute(const AgentRoute *rt);
      36             :     static AgentRouteData *BuildNonBgpPeerData(const string &vrf_name,
      37             :                                                const std::string &vn_name,
      38             :                                                uint32_t label,
      39             :                                                int vxlan_id,
      40             :                                                uint32_t tunnel_type,
      41             :                                                Composite::Type type,
      42             :                                                ComponentNHKeyList
      43             :                                                &component_nh_key_list,
      44             :                                                bool pbb_nh,
      45             :                                                bool learning_enabled);
      46             :     static AgentRouteData *BuildBgpPeerData(const Peer *peer,
      47             :                                             const string &vrf_name,
      48             :                                             const std::string &vn_name,
      49             :                                             uint32_t label,
      50             :                                             int vxlan_id,
      51             :                                             uint32_t ethernet_tag,
      52             :                                             uint32_t tunnel_type,
      53             :                                             Composite::Type type,
      54             :                                             ComponentNHKeyList
      55             :                                             &component_nh_key_list,
      56             :                                             bool pbb_nh,
      57             :                                             bool learning_enabled);
      58             :     static void AddBridgeRoute(const Peer *peer, const string &vrf_name,
      59             :                                             const MacAddress &mac,
      60             :                                             uint32_t ethernet_tag,
      61             :                                             AgentRouteData *data);
      62             :     static void AddBridgeBroadcastRoute(const Peer *peer,
      63             :                                         const string &vrf_name,
      64             :                                         uint32_t ethernet_tag,
      65             :                                         AgentRouteData *data);
      66             :     static void AddBridgeReceiveRoute(const Peer *peer,
      67             :                                       const std::string &vrf_name,
      68             :                                       const MacAddress &mac,
      69             :                                       const std::string &vn_name,
      70             :                                       const std::string &interface,
      71             :                                       bool policy);
      72             :     void AddBridgeReceiveRoute(const Peer *peer, const std::string &vrf_name,
      73             :                                uint32_t vxlan_id, const MacAddress &mac,
      74             :                                const std::string &vn_name);
      75             :     static void Delete(const Peer *peer, const std::string &vrf_name,
      76             :                        const MacAddress &mac, uint32_t ethernet_tag);
      77             :     static void DeleteBroadcastReq(const Peer *peer,
      78             :                                    const std::string &vrf_name,
      79             :                                    uint32_t ethernet_tag,
      80             :                                    COMPOSITETYPE type);
      81             :     void DeleteBridgeRoute(const AgentRoute *rt);
      82             :     static void DeleteBridgeRoute(const Peer *peer, const string &vrf_name,
      83             :                                    const MacAddress &mac,
      84             :                                    uint32_t ethernet_tag,
      85             :                                    COMPOSITETYPE type);
      86             :     void DeleteMacVmBindingRoute(const Peer *peer,
      87             :                          const std::string &vrf_name,
      88             :                          const MacAddress &mac,
      89             :                          const VmInterface *vm_intf);
      90             :     const VmInterface *FindVmFromDhcpBinding(const MacAddress &mac);
      91             :     BridgeRouteEntry *FindRoute(const MacAddress &mac);
      92             :     BridgeRouteEntry *FindRouteNoLock(const MacAddress &mac);
      93             :     BridgeRouteEntry *FindRoute(const MacAddress &mac, Peer::Type peer);
      94             : 
      95             : private:
      96             :     DBTableWalker::WalkId walkid_;
      97             :     DISALLOW_COPY_AND_ASSIGN(BridgeAgentRouteTable);
      98             : };
      99             : 
     100             : class BridgeRouteEntry : public AgentRoute,
     101             :     public AgentRoutePrefix<MacAddress> {
     102             : public:
     103        9147 :     BridgeRouteEntry(VrfEntry *vrf, const MacAddress &mac,
     104        9147 :                      Peer::Type type, bool is_multicast) :
     105        9147 :         AgentRoute(vrf, is_multicast), AgentRoutePrefix(mac,0) {
     106        9147 :     }
     107       16539 :     virtual ~BridgeRouteEntry() { }
     108             : 
     109             :     virtual int CompareTo(const Route &rhs) const;
     110             :     virtual std::string ToString() const;
     111           0 :     virtual void UpdateDependantRoutes() { }
     112           0 :     virtual void UpdateNH() { }
     113             :     virtual KeyPtr GetDBRequestKey() const;
     114             :     virtual void SetKey(const DBRequestKey *key);
     115             :     virtual const std::string GetAddressString() const;
     116             :     virtual const std::string GetSourceAddressString() const;
     117        2714 :     virtual Agent::RouteTableType GetTableType() const {
     118        2714 :         return Agent::BRIDGE;
     119             :     }
     120             :     virtual bool DBEntrySandesh(Sandesh *sresp, bool stale) const;
     121             :     virtual uint32_t GetActiveLabel() const;
     122             :     virtual bool ReComputePathDeletion(AgentPath *path);
     123             :     virtual bool ReComputePathAdd(AgentPath *path);
     124             :     virtual AgentPath *FindPathUsingKeyData(const AgentRouteKey *key,
     125             :                                             const AgentRouteData *data) const;
     126        2508 :     virtual bool ValidateMcastSrc() const {
     127        2508 :         return (prefix_address_ == MacAddress::BroadcastMac());
     128             :     }
     129             :     ///! @brief The length of L3 IP prefix (if present) associated with this
     130             :     /// L2 address.
     131        2917 :     uint8_t prefix_length() const {return prefix_length_;}
     132             :     const MacVmBindingPath *FindMacVmBindingPath() const;
     133             : 
     134             : private:
     135             :     AgentPath *FindEvpnPathUsingKeyData(const AgentRouteKey *key,
     136             :                                         const AgentRouteData *data) const;
     137             :     AgentPath *FindMulticastPathUsingKeyData(const AgentRouteKey *key,
     138             :                                              const AgentRouteData *data) const;
     139             : 
     140             :     DISALLOW_COPY_AND_ASSIGN(BridgeRouteEntry);
     141             : };
     142             : 
     143             : class BridgeRouteKey : public AgentRouteKey {
     144             : public:
     145        7343 :     BridgeRouteKey(const Peer *peer, const std::string &vrf_name,
     146        7343 :                    const MacAddress &mac, uint32_t ethernet_tag = 0) :
     147        7343 :         AgentRouteKey(peer, vrf_name), dmac_(mac), ethernet_tag_(ethernet_tag) {
     148        7343 :     }
     149             : 
     150       14686 :     virtual ~BridgeRouteKey() { }
     151             : 
     152             :     virtual AgentRoute *AllocRouteEntry(VrfEntry *vrf, bool is_multicast) const;
     153        8146 :     virtual Agent::RouteTableType GetRouteTableType() { return Agent::BRIDGE; }
     154             :     virtual std::string ToString() const;
     155             :     virtual BridgeRouteKey *Clone() const;
     156           0 :     const MacAddress &GetMac() const { return dmac_;}
     157             :     uint32_t ethernet_tag() const {return ethernet_tag_;}
     158             : 
     159             : private:
     160             :     MacAddress dmac_;
     161             :     //TODO retained only for multicast route. Once multicast route shift to
     162             :     //evpn table this will go off.
     163             :     uint32_t ethernet_tag_;
     164             :     DISALLOW_COPY_AND_ASSIGN(BridgeRouteKey);
     165             : };
     166             : 
     167             : #endif // vnsw_bridge_route_hpp

Generated by: LCOV version 1.14