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-11-09 02:10:49 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             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #include "bgp/bgp_rib_policy.h"
       7             : 
       8             : using std::string;
       9             : using std::vector;
      10             : 
      11      289051 : RibExportPolicy::RemovePrivatePolicy::RemovePrivatePolicy()
      12      289051 :     : enabled(false),
      13      289051 :       all(false),
      14      289051 :       replace(false),
      15      289051 :       peer_loop_check(false) {
      16      289051 : }
      17             : 
      18      264212 : RibExportPolicy::RibExportPolicy()
      19      264212 :     : type(BgpProto::IBGP),
      20      264212 :       encoding(BGP),
      21      264212 :       as_number(0),
      22      264212 :       local_as_number(0),
      23      264212 :       as_override(false),
      24      264214 :       affinity(-1),
      25      264214 :       llgr(false),
      26      264214 :       as4_supported(false),
      27      264212 :       cluster_id(0) {
      28      264216 : }
      29             : 
      30          83 : RibExportPolicy::RibExportPolicy(uint32_t cluster_id)
      31          83 :     : type(BgpProto::IBGP),
      32          83 :       encoding(BGP),
      33          83 :       as_number(0),
      34          83 :       local_as_number(0),
      35          83 :       as_override(false),
      36          83 :       affinity(-1),
      37          83 :       llgr(false),
      38          83 :       as4_supported(false),
      39          83 :       cluster_id(cluster_id) {
      40          83 : }
      41             : 
      42       11057 : RibExportPolicy::RibExportPolicy(BgpProto::BgpPeerType type, Encoding encoding,
      43       11057 :     int affinity, uint32_t cluster_id)
      44       11057 :     : type(type),
      45       11057 :       encoding(encoding),
      46       11057 :       as_number(0),
      47       11057 :       local_as_number(0),
      48       11057 :       as_override(false),
      49       11057 :       affinity(affinity),
      50       11057 :       llgr(false),
      51       11057 :       as4_supported(false),
      52       11057 :       cluster_id(cluster_id) {
      53       11057 :     if (encoding == XMPP)
      54       10865 :         assert(type == BgpProto::XMPP);
      55       11057 :     if (encoding == BGP)
      56         192 :         assert(type == BgpProto::IBGP || type == BgpProto::EBGP);
      57       11057 : }
      58             : 
      59         724 : RibExportPolicy::RibExportPolicy(BgpProto::BgpPeerType type, Encoding encoding,
      60             :     as_t as_number, bool as_override, bool llgr, bool as4, int affinity,
      61         724 :     uint32_t cluster_id, as_t local_as_number)
      62         724 :     : type(type),
      63         724 :       encoding(encoding),
      64         724 :       as_number(as_number),
      65         724 :       local_as_number(local_as_number),
      66         724 :       as_override(as_override),
      67         724 :       affinity(affinity),
      68         724 :       llgr(llgr),
      69         724 :       as4_supported(as4),
      70         724 :       cluster_id(cluster_id) {
      71         724 :     if (encoding == XMPP)
      72           8 :         assert(type == BgpProto::XMPP);
      73         724 :     if (encoding == BGP)
      74         716 :         assert(type == BgpProto::IBGP || type == BgpProto::EBGP);
      75         724 : }
      76             : 
      77             : 
      78       12972 : RibExportPolicy::RibExportPolicy(BgpProto::BgpPeerType type, Encoding encoding,
      79             :     as_t as_number, bool as_override, bool llgr, bool as4, IpAddress nexthop,
      80             :     int affinity, uint32_t cluster_id,
      81       12972 :     vector<string> &default_tunnel_encap_list, as_t local_as_number) :
      82       12972 :       type(type),
      83       12972 :       encoding(BGP),
      84       12972 :       as_number(as_number),
      85       12972 :       local_as_number(local_as_number),
      86       12972 :       as_override(as_override),
      87       12972 :       nexthop(nexthop),
      88       12972 :       affinity(affinity),
      89       12972 :       llgr(llgr),
      90       12972 :       as4_supported(as4),
      91       12972 :       cluster_id(cluster_id),
      92       12972 :       default_tunnel_encap_list(default_tunnel_encap_list) {
      93       12968 :     assert(type == BgpProto::IBGP || type == BgpProto::EBGP);
      94       12968 :     assert(encoding == BGP);
      95       12968 : }
      96             : 
      97         115 : void RibExportPolicy::SetRemovePrivatePolicy(bool all, bool replace,
      98             :     bool peer_loop_check) {
      99         115 :     remove_private.enabled = true;
     100         115 :     remove_private.all = all;
     101         115 :     remove_private.replace = replace;
     102         115 :     remove_private.peer_loop_check = peer_loop_check;
     103         115 : }
     104             : 
     105             : //
     106             : // Implement operator< for RibExportPolicy by comparing each of the fields.
     107             : //
     108      178497 : bool RibExportPolicy::operator<(const RibExportPolicy &rhs) const {
     109      178497 :     BOOL_KEY_COMPARE(encoding, rhs.encoding);
     110      177110 :     BOOL_KEY_COMPARE(type, rhs.type);
     111      177039 :     BOOL_KEY_COMPARE(as_number, rhs.as_number);
     112      166574 :     BOOL_KEY_COMPARE(local_as_number, rhs.local_as_number);
     113      166574 :     BOOL_KEY_COMPARE(as_override, rhs.as_override);
     114      166567 :     BOOL_KEY_COMPARE(nexthop, rhs.nexthop);
     115      166233 :     BOOL_KEY_COMPARE(affinity, rhs.affinity);
     116      166175 :     BOOL_KEY_COMPARE(llgr, rhs.llgr);
     117      166168 :     BOOL_KEY_COMPARE(as4_supported, rhs.as4_supported);
     118      166168 :     BOOL_KEY_COMPARE(cluster_id, rhs.cluster_id);
     119      165912 :     BOOL_KEY_COMPARE(remove_private.enabled, rhs.remove_private.enabled);
     120      165912 :     BOOL_KEY_COMPARE(remove_private.all, rhs.remove_private.all);
     121      165912 :     BOOL_KEY_COMPARE(remove_private.replace, rhs.remove_private.replace);
     122      165912 :     BOOL_KEY_COMPARE(
     123             :         remove_private.peer_loop_check, rhs.remove_private.peer_loop_check);
     124      165912 :     BOOL_KEY_COMPARE(default_tunnel_encap_list, rhs.default_tunnel_encap_list);
     125      165912 :     return false;
     126             : }

Generated by: LCOV version 1.14