LCOV - code coverage report
Current view: top level - bgp/rtarget - rtarget_table.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 35 37 94.6 %
Date: 2026-11-09 02:10:49 Functions: 10 11 90.9 %
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             : #include "bgp/rtarget/rtarget_table.h"
       7             : 
       8             : #include "bgp/bgp_update.h"
       9             : #include "db/db.h"
      10             : 
      11             : using std::unique_ptr;
      12             : using std::string;
      13             : 
      14        8228 : RTargetTable::RTargetTable(DB *db, const string &name)
      15        8228 :         : BgpTable(db, name) {
      16        8228 : }
      17             : 
      18       77648 : unique_ptr<DBEntry> RTargetTable::AllocEntry(const DBRequestKey *key) const {
      19       77648 :     const RequestKey *pfxkey = static_cast<const RequestKey *>(key);
      20       77648 :     return unique_ptr<DBEntry> (new RTargetRoute(pfxkey->prefix));
      21             : }
      22             : 
      23         245 : unique_ptr<DBEntry> RTargetTable::AllocEntryStr(const string &key_str) const {
      24         245 :     RTargetPrefix prefix = RTargetPrefix::FromString(key_str);
      25         490 :     return unique_ptr<DBEntry> (new RTargetRoute(prefix));
      26             : }
      27             : 
      28      809303 : size_t RTargetTable::Hash(const DBEntry *entry) const {
      29      809303 :     return 0;
      30             : }
      31             : 
      32      123095 : size_t RTargetTable::Hash(const DBRequestKey *key) const {
      33      123095 :     return 0;
      34             : }
      35             : 
      36      109786 : BgpRoute *RTargetTable::TableFind(DBTablePartition *rtp,
      37             :                                   const DBRequestKey *prefix) {
      38      109786 :     const RequestKey *pfxkey = static_cast<const RequestKey *>(prefix);
      39      109786 :     RTargetRoute rt_key(pfxkey->prefix);
      40      219572 :     return static_cast<BgpRoute *>(rtp->Find(&rt_key));
      41      109786 : }
      42             : 
      43        8228 : DBTableBase *RTargetTable::CreateTable(DB *db, const string &name) {
      44        8228 :     RTargetTable *table = new RTargetTable(db, name);
      45        8228 :     table->Init();
      46        8228 :     return table;
      47             : }
      48             : 
      49           0 : BgpRoute *RTargetTable::RouteReplicate(BgpServer *server,
      50             :         BgpTable *src_table, BgpRoute *src_rt, const BgpPath *src_path,
      51             :         ExtCommunityPtr community) {
      52           0 :     return NULL;
      53             : }
      54             : 
      55       85967 : bool RTargetTable::Export(RibOut *ribout, Route *route,
      56             :         const RibPeerSet &peerset, UpdateInfoSList &uinfo_slist) {
      57       85967 :     BgpRoute *bgp_route = static_cast<BgpRoute *> (route);
      58       85967 :     UpdateInfo *uinfo = GetUpdateInfo(ribout, bgp_route, peerset);
      59       85967 :     if (!uinfo) return false;
      60       54352 :     uinfo_slist->push_front(*uinfo);
      61             : 
      62       54352 :     return true;
      63             : }
      64             : 
      65       86652 : void RTargetTable::AddRemoveCallback(const DBEntryBase *entry, bool add) const {
      66       86652 :     if (add)
      67       43326 :         last_updated_ = UTCTimestamp();
      68       86652 : }
      69             : 
      70         159 : static void RegisterFactory() {
      71         159 :     DB::RegisterFactory("bgp.rtarget.0", &RTargetTable::CreateTable);
      72         159 : }
      73             : MODULE_INITIALIZER(RegisterFactory);

Generated by: LCOV version 1.14