OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
bgp_xmpp_peer_close.cc
Go to the documentation of this file.
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 
9 #include "bgp/bgp_factory.h"
10 #include "bgp/bgp_path.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 
22  channel_(channel) {
23 }
24 
26 }
27 
29  return channel_->close_manager();
30 }
31 
33  const BgpPath *old_path,
34  uint32_t path_flags) const {
35  GetManager()->UpdateRouteStats(family, old_path, path_flags);
36 }
37 
39  return channel_->Peer()->IsReady();
40 }
41 
43  return channel_->Peer();
44 }
45 
48 }
49 
51  return channel_->manager()->xmpp_server()->
53 }
54 
55 // Mark all current subscription as 'stale'
56 // Concurrency: Protected with a mutex from peer close manager
59 }
60 
61 // Mark all current subscriptions as 'llgr_stale'
62 // Concurrency: Protected with a mutex from peer close manager
65 }
66 
67 // Delete all current subscriptions which are still stale.
68 // Concurrency: Protected with a mutex from peer close manager
71 }
72 
74  // Do not close gracefully if connection is already marked for deletion.
75  if (channel_->channel()->connection()->IsDeleted())
76  return false;
78 }
79 
82 }
83 
84 // EoR from xmpp is afi independent at the moment.
86  families->insert(Address::UNSPEC);
87 }
88 
90  families->insert(Address::UNSPEC);
91 }
92 
94  channel_->ReceiveEndOfRIB(family);
95 }
96 
97 // Process any pending subscriptions as close manager is now no longer
98 // using membership manager.
101  if (channel_) {
102  assert(!GetManager()->IsMembershipInUse());
104  }
105 }
106 
107 const char *BgpXmppPeerClose::GetTaskName() const {
108  return "bgp::Config";
109 }
110 
112  return 0;
113 }
114 
118 }
119 
121  assert(!channel_->channel()->connection()->IsDeleted());
122  channel_->set_peer_closed(false);
124 }
125 
128  channel_->set_peer_closed(true);
131  channel_ = NULL;
132 }
133 
134 void BgpXmppPeerClose::Close(bool graceful) {
135  if (channel_) {
136  assert(channel_->peer_deleted());
137  if (!IsCloseGraceful())
138  graceful = false;
139  GetManager()->Close(graceful);
140  }
141 }
virtual void CloseComplete()
virtual const XmppConnection * connection() const =0
void Enqueue(BgpXmppChannel *bx_channel)
virtual const char * GetTaskName() const
Family
Definition: address.h:24
virtual bool IsPeerCloseGraceful() const
Definition: xmpp_server.cc:280
void set_peer_closed(bool flag)
virtual bool IsReady() const
virtual int GetTaskInstance() const
XmppServer * xmpp_server()
virtual void GracefulRestartSweep()
virtual bool IsReady() const =0
Definition: ipeer.h:186
virtual bool IsCloseGraceful() const
virtual void CustomClose()
BgpXmppPeerClose(BgpXmppChannel *channel)
virtual void GetGracefulRestartFamilies(Families *families) const
virtual bool IsCloseLongLivedGraceful() const
bool IsDeleted() const
BgpXmppChannel * channel_
virtual PeerCloseManager * GetManager() const
virtual void UpdateRouteStats(Address::Family family, const BgpPath *old_path, uint32_t path_flags) const
std::set< Address::Family > Families
void set_delete_in_progress(bool flag)
#define CHECK_CONCURRENCY(...)
virtual void LongLivedGracefulRestartStale()
virtual void Close(bool graceful)
const BgpXmppChannelManager * manager() const
void UpdateRouteStats(Address::Family family, const BgpPath *old_path, uint32_t path_flags) const
virtual void UnRegisterReceive(xmps::PeerId)=0
void ProcessPendingSubscriptions()
void ReceiveEndOfRIB(Address::Family family)
bool peer_deleted() const
virtual void GracefulRestartStale()
uint16_t GetGracefulRestartTime() const
Definition: xmpp_server.cc:238
virtual IPeer * peer() const
void Close(bool graceful)
PeerCloseManager * close_manager()
void StaleCurrentSubscriptions()
BgpXmppRTargetManager * rtarget_manager()
virtual int GetGracefulRestartTime() const
virtual void MembershipRequestCallbackComplete()
virtual void ReceiveEndOfRIB(Address::Family family)
void LlgrStaleCurrentSubscriptions()
virtual int GetLongLivedGracefulRestartTime() const
const XmppChannel * channel() const
void SweepCurrentSubscriptions()
virtual void GetLongLivedGracefulRestartFamilies(Families *families) const