LCOV - code coverage report
Current view: top level - bgp - bgp_rib_policy.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 99 99 100.0 %
Date: 2026-06-04 02:06:09 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include "bgp/bgp_rib_policy.h"
       6             : 
       7             : using std::string;
       8             : using std::vector;
       9             : 
      10      289049 : RibExportPolicy::RemovePrivatePolicy::RemovePrivatePolicy()
      11      289049 :     : enabled(false),
      12      289049 :       all(false),
      13      289049 :       replace(false),
      14      289049 :       peer_loop_check(false) {
      15      289049 : }
      16             : 
      17      264211 : RibExportPolicy::RibExportPolicy()
      18      264211 :     : type(BgpProto::IBGP),
      19      264211 :       encoding(BGP),
      20      264211 :       as_number(0),
      21      264211 :       local_as_number(0),
      22      264211 :       as_override(false),
      23      264210 :       affinity(-1),
      24      264210 :       llgr(false),
      25      264210 :       as4_supported(false),
      26      264211 :       cluster_id(0) {
      27      264210 : }
      28             : 
      29          83 : RibExportPolicy::RibExportPolicy(uint32_t cluster_id)
      30          83 :     : type(BgpProto::IBGP),
      31          83 :       encoding(BGP),
      32          83 :       as_number(0),
      33          83 :       local_as_number(0),
      34          83 :       as_override(false),
      35          83 :       affinity(-1),
      36          83 :       llgr(false),
      37          83 :       as4_supported(false),
      38          83 :       cluster_id(cluster_id) {
      39          83 : }
      40             : 
      41       11064 : RibExportPolicy::RibExportPolicy(BgpProto::BgpPeerType type, Encoding encoding,
      42       11064 :     int affinity, uint32_t cluster_id)
      43       11064 :     : type(type),
      44       11064 :       encoding(encoding),
      45       11064 :       as_number(0),
      46       11064 :       local_as_number(0),
      47       11064 :       as_override(false),
      48       11065 :       affinity(affinity),
      49       11065 :       llgr(false),
      50       11065 :       as4_supported(false),
      51       11064 :       cluster_id(cluster_id) {
      52       11065 :     if (encoding == XMPP)
      53       10873 :         assert(type == BgpProto::XMPP);
      54       11065 :     if (encoding == BGP)
      55         192 :         assert(type == BgpProto::IBGP || type == BgpProto::EBGP);
      56       11065 : }
      57             : 
      58         724 : RibExportPolicy::RibExportPolicy(BgpProto::BgpPeerType type, Encoding encoding,
      59             :     as_t as_number, bool as_override, bool llgr, bool as4, int affinity,
      60         724 :     uint32_t cluster_id, as_t local_as_number)
      61         724 :     : type(type),
      62         724 :       encoding(encoding),
      63         724 :       as_number(as_number),
      64         724 :       local_as_number(local_as_number),
      65         724 :       as_override(as_override),
      66         724 :       affinity(affinity),
      67         724 :       llgr(llgr),
      68         724 :       as4_supported(as4),
      69         724 :       cluster_id(cluster_id) {
      70         724 :     if (encoding == XMPP)
      71           8 :         assert(type == BgpProto::XMPP);
      72         724 :     if (encoding == BGP)
      73         716 :         assert(type == BgpProto::IBGP || type == BgpProto::EBGP);
      74         724 : }
      75             : 
      76             : 
      77       12969 : RibExportPolicy::RibExportPolicy(BgpProto::BgpPeerType type, Encoding encoding,
      78             :     as_t as_number, bool as_override, bool llgr, bool as4, IpAddress nexthop,
      79             :     int affinity, uint32_t cluster_id,
      80       12969 :     vector<string> &default_tunnel_encap_list, as_t local_as_number) :
      81       12969 :       type(type),
      82       12969 :       encoding(BGP),
      83       12969 :       as_number(as_number),
      84       12969 :       local_as_number(local_as_number),
      85       12969 :       as_override(as_override),
      86       12969 :       nexthop(nexthop),
      87       12968 :       affinity(affinity),
      88       12968 :       llgr(llgr),
      89       12968 :       as4_supported(as4),
      90       12968 :       cluster_id(cluster_id),
      91       12968 :       default_tunnel_encap_list(default_tunnel_encap_list) {
      92       12964 :     assert(type == BgpProto::IBGP || type == BgpProto::EBGP);
      93       12964 :     assert(encoding == BGP);
      94       12964 : }
      95             : 
      96         115 : void RibExportPolicy::SetRemovePrivatePolicy(bool all, bool replace,
      97             :     bool peer_loop_check) {
      98         115 :     remove_private.enabled = true;
      99         115 :     remove_private.all = all;
     100         115 :     remove_private.replace = replace;
     101         115 :     remove_private.peer_loop_check = peer_loop_check;
     102         115 : }
     103             : 
     104             : //
     105             : // Implement operator< for RibExportPolicy by comparing each of the fields.
     106             : //
     107      178425 : bool RibExportPolicy::operator<(const RibExportPolicy &rhs) const {
     108      178425 :     BOOL_KEY_COMPARE(encoding, rhs.encoding);
     109      177036 :     BOOL_KEY_COMPARE(type, rhs.type);
     110      176963 :     BOOL_KEY_COMPARE(as_number, rhs.as_number);
     111      166576 :     BOOL_KEY_COMPARE(local_as_number, rhs.local_as_number);
     112      166576 :     BOOL_KEY_COMPARE(as_override, rhs.as_override);
     113      166569 :     BOOL_KEY_COMPARE(nexthop, rhs.nexthop);
     114      166235 :     BOOL_KEY_COMPARE(affinity, rhs.affinity);
     115      166177 :     BOOL_KEY_COMPARE(llgr, rhs.llgr);
     116      166170 :     BOOL_KEY_COMPARE(as4_supported, rhs.as4_supported);
     117      166170 :     BOOL_KEY_COMPARE(cluster_id, rhs.cluster_id);
     118      165914 :     BOOL_KEY_COMPARE(remove_private.enabled, rhs.remove_private.enabled);
     119      165914 :     BOOL_KEY_COMPARE(remove_private.all, rhs.remove_private.all);
     120      165914 :     BOOL_KEY_COMPARE(remove_private.replace, rhs.remove_private.replace);
     121      165914 :     BOOL_KEY_COMPARE(
     122             :         remove_private.peer_loop_check, rhs.remove_private.peer_loop_check);
     123      165914 :     BOOL_KEY_COMPARE(default_tunnel_encap_list, rhs.default_tunnel_encap_list);
     124      165914 :     return false;
     125             : }

Generated by: LCOV version 1.14