LCOV - code coverage report
Current view: top level - bgp - bgp_xmpp_peer_close.cc (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 0 76 0.0 %
Date: 2026-09-28 02:13:17 Functions: 0 24 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  */
       4             : 
       5             : #include <boost/foreach.hpp>
       6             : #include <boost/scoped_ptr.hpp>
       7             : 
       8             : #include "base/task_annotations.h"
       9             : #include "bgp/bgp_factory.h"
      10             : #include "bgp/bgp_path.h"
      11             : #include "bgp/bgp_xmpp_peer_close.h"
      12             : #include "bgp/bgp_xmpp_rtarget_manager.h"
      13             : #include "bgp/peer_close_manager.h"
      14             : #include "bgp/bgp_xmpp_channel.h"
      15             : #include "xmpp/xmpp_connection.h"
      16             : #include "xmpp/xmpp_server.h"
      17             : 
      18             : using std::string;
      19             : using std::vector;
      20             : 
      21           0 : BgpXmppPeerClose::BgpXmppPeerClose(BgpXmppChannel *channel) :
      22           0 :         channel_(channel) {
      23           0 : }
      24             : 
      25           0 : BgpXmppPeerClose::~BgpXmppPeerClose() {
      26           0 : }
      27             : 
      28           0 : PeerCloseManager *BgpXmppPeerClose::GetManager() const {
      29           0 :     return channel_->close_manager();
      30             : }
      31             : 
      32           0 : void BgpXmppPeerClose::UpdateRouteStats(Address::Family family,
      33             :                                         const BgpPath *old_path,
      34             :                                         uint32_t path_flags) const {
      35           0 :     GetManager()->UpdateRouteStats(family, old_path, path_flags);
      36           0 : }
      37             : 
      38           0 : bool BgpXmppPeerClose::IsReady() const {
      39           0 :     return channel_->Peer()->IsReady();
      40             : }
      41             : 
      42           0 : IPeer *BgpXmppPeerClose::peer() const {
      43           0 :     return channel_->Peer();
      44             : }
      45             : 
      46           0 : int BgpXmppPeerClose::GetGracefulRestartTime() const {
      47           0 :     return channel_->manager()->xmpp_server()->GetGracefulRestartTime();
      48             : }
      49             : 
      50           0 : int BgpXmppPeerClose::GetLongLivedGracefulRestartTime() const {
      51           0 :     return channel_->manager()->xmpp_server()->
      52           0 :         GetLongLivedGracefulRestartTime();
      53             : }
      54             : 
      55             : // Mark all current subscription as 'stale'
      56             : // Concurrency: Protected with a mutex from peer close manager
      57           0 : void BgpXmppPeerClose::GracefulRestartStale() {
      58           0 :     channel_->StaleCurrentSubscriptions();
      59           0 : }
      60             : 
      61             : // Mark all current subscriptions as 'llgr_stale'
      62             : // Concurrency: Protected with a mutex from peer close manager
      63           0 : void BgpXmppPeerClose::LongLivedGracefulRestartStale() {
      64           0 :     channel_->LlgrStaleCurrentSubscriptions();
      65           0 : }
      66             : 
      67             : // Delete all current subscriptions which are still stale.
      68             : // Concurrency: Protected with a mutex from peer close manager
      69           0 : void BgpXmppPeerClose::GracefulRestartSweep() {
      70           0 :     channel_->SweepCurrentSubscriptions();
      71           0 : }
      72             : 
      73           0 : bool BgpXmppPeerClose::IsCloseGraceful() const {
      74             :     // Do not close gracefully if connection is already marked for deletion.
      75           0 :     if (channel_->channel()->connection()->IsDeleted())
      76           0 :         return false;
      77           0 :     return channel_->manager()->xmpp_server()->IsPeerCloseGraceful();
      78             : }
      79             : 
      80           0 : bool BgpXmppPeerClose::IsCloseLongLivedGraceful() const {
      81           0 :     return IsCloseGraceful() && GetLongLivedGracefulRestartTime() != 0;
      82             : }
      83             : 
      84             : // EoR from xmpp is afi independent at the moment.
      85           0 : void BgpXmppPeerClose::GetGracefulRestartFamilies(Families *families) const {
      86           0 :     families->insert(Address::UNSPEC);
      87           0 : }
      88             : 
      89           0 : void BgpXmppPeerClose::GetLongLivedGracefulRestartFamilies(Families *families) const {
      90           0 :     families->insert(Address::UNSPEC);
      91           0 : }
      92             : 
      93           0 : void BgpXmppPeerClose::ReceiveEndOfRIB(Address::Family family) {
      94           0 :     channel_->ReceiveEndOfRIB(family);
      95           0 : }
      96             : 
      97             : // Process any pending subscriptions as close manager is now no longer
      98             : // using membership manager.
      99           0 : void BgpXmppPeerClose::MembershipRequestCallbackComplete() {
     100           0 :     CHECK_CONCURRENCY(GetTaskName());
     101           0 :     if (channel_) {
     102           0 :         assert(!GetManager()->IsMembershipInUse());
     103           0 :         channel_->ProcessPendingSubscriptions();
     104             :     }
     105           0 : }
     106             : 
     107           0 : const char *BgpXmppPeerClose::GetTaskName() const {
     108           0 :     return "bgp::Config";
     109             : }
     110             : 
     111           0 : int BgpXmppPeerClose::GetTaskInstance() const {
     112           0 :     return 0;
     113             : }
     114             : 
     115           0 : void BgpXmppPeerClose::CustomClose() {
     116           0 :     channel_->rtarget_manager()->Close();
     117           0 :     channel_->ClearSubscriptions();
     118           0 : }
     119             : 
     120           0 : void BgpXmppPeerClose::CloseComplete() {
     121           0 :     assert(!channel_->channel()->connection()->IsDeleted());
     122           0 :     channel_->set_peer_closed(false);
     123           0 :     channel_->channel()->UnRegisterReceive(xmps::BGP);
     124           0 : }
     125             : 
     126           0 : void BgpXmppPeerClose::Delete() {
     127           0 :     channel_->set_delete_in_progress(true);
     128           0 :     channel_->set_peer_closed(true);
     129           0 :     channel_->manager()->increment_deleting_count();
     130           0 :     channel_->manager()->Enqueue(channel_);
     131           0 :     channel_ = NULL;
     132           0 : }
     133             : 
     134           0 : void BgpXmppPeerClose::Close(bool graceful) {
     135           0 :     if (channel_) {
     136           0 :         assert(channel_->peer_deleted());
     137           0 :         if (!IsCloseGraceful())
     138           0 :             graceful = false;
     139           0 :         GetManager()->Close(graceful);
     140             :     }
     141           0 : }

Generated by: LCOV version 1.14