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/bgp_ribout.h"
7 :
8 : #include <boost/bind/bind.hpp>
9 :
10 : #include <algorithm>
11 :
12 : #include "sandesh/sandesh_trace.h"
13 : #include "base/string_util.h"
14 : #include "bgp/bgp_peer_types.h"
15 : #include "bgp/bgp_ribout_updates.h"
16 : #include "bgp/bgp_export.h"
17 : #include "bgp/bgp_factory.h"
18 : #include "bgp/bgp_route.h"
19 : #include "bgp/bgp_server.h"
20 : #include "bgp/bgp_table.h"
21 : #include "bgp/bgp_update.h"
22 : #include "bgp/bgp_update_sender.h"
23 : #include "bgp/ipeer.h"
24 : #include "bgp/routing-instance/routing_instance.h"
25 : #include "db/db.h"
26 :
27 : using std::find;
28 : using namespace boost::placeholders;
29 :
30 28637 : RibOutAttr::NextHop::NextHop(const BgpTable *table, IpAddress address,
31 : const MacAddress &mac, uint32_t label, uint32_t l3_label,
32 : const ExtCommunity *ext_community, const LargeCommunity *large_community,
33 28637 : bool vrf_originated)
34 28637 : : address_(address),
35 28641 : mac_(mac),
36 28640 : label_(label),
37 28640 : l3_label_(l3_label),
38 28640 : origin_vn_index_(-1) {
39 28633 : as_t asn = table ? table->server()->autonomous_system() : 0;
40 57257 : bool all = table ?
41 28630 : table->server()->global_config()->all_tags_are_global() : false;
42 28627 : if (large_community != nullptr) {
43 28435 : tag_list_ = large_community->GetTagList(all ? 0 : asn);
44 : }
45 28609 : if (ext_community != nullptr) {
46 28417 : encap_ = ext_community->GetTunnelEncap();
47 28427 : origin_vn_index_ = ext_community->GetOriginVnIndex();
48 : }
49 :
50 28622 : if (origin_vn_index_ < 0 && vrf_originated) {
51 1344 : origin_vn_index_ =
52 1344 : table ? table->routing_instance()->virtual_network_index() : 0;
53 : }
54 28622 : }
55 :
56 13126 : int RibOutAttr::NextHop::CompareTo(const NextHop &rhs) const {
57 13126 : KEY_COMPARE(address_, rhs.address_);
58 13116 : KEY_COMPARE(mac_, rhs.mac_) ;
59 13120 : KEY_COMPARE(label_, rhs.label_);
60 13120 : KEY_COMPARE(l3_label_, rhs.l3_label_);
61 13120 : KEY_COMPARE(source_address_, rhs.source_address_);
62 13115 : KEY_COMPARE(origin_vn_index_, rhs.origin_vn_index_);
63 13115 : KEY_COMPARE(encap_.size(), rhs.encap_.size());
64 26082 : for (size_t idx = 0; idx < encap_.size(); ++idx) {
65 12978 : KEY_COMPARE(encap_[idx], rhs.encap_[idx]);
66 : }
67 13074 : KEY_COMPARE(tag_list_.size(), rhs.tag_list_.size());
68 13099 : for (size_t idx = 0; idx < tag_list_.size(); ++idx) {
69 0 : KEY_COMPARE(tag_list_[idx], rhs.tag_list_[idx]);
70 : }
71 13099 : return 0;
72 : }
73 :
74 0 : bool RibOutAttr::NextHop::operator==(const NextHop &rhs) const {
75 0 : return CompareTo(rhs) == 0;
76 : }
77 :
78 0 : bool RibOutAttr::NextHop::operator!=(const NextHop &rhs) const {
79 0 : return CompareTo(rhs) != 0;
80 : }
81 :
82 13124 : bool RibOutAttr::NextHop::operator<(const NextHop &rhs) const {
83 13124 : return CompareTo(rhs) < 0;
84 : }
85 :
86 67915 : RibOutAttr::RibOutAttr()
87 67903 : : label_(0),
88 67903 : l3_label_(0),
89 67895 : is_xmpp_(false),
90 67915 : vrf_originated_(false) {
91 67893 : }
92 :
93 : //
94 : // Copy constructor.
95 : // Do not copy the string representation;
96 : //
97 37501 : RibOutAttr::RibOutAttr(const RibOutAttr &rhs) {
98 37499 : attr_out_ = rhs.attr_out_;
99 37538 : nexthop_list_ = rhs.nexthop_list_;
100 37501 : label_ = rhs.label_;
101 37501 : l3_label_ = rhs.l3_label_;
102 37501 : source_address_ = rhs.source_address_;
103 37505 : is_xmpp_ = rhs.is_xmpp_;
104 37505 : vrf_originated_ = rhs.vrf_originated_;
105 37505 : }
106 :
107 0 : RibOutAttr::RibOutAttr(const BgpTable *table, const BgpAttr *attr,
108 0 : uint32_t label, uint32_t l3_label, bool is_xmpp)
109 0 : : attr_out_(attr),
110 0 : label_(label),
111 0 : l3_label_(l3_label),
112 0 : is_xmpp_(is_xmpp),
113 0 : vrf_originated_(false) {
114 0 : if (attr && is_xmpp) {
115 0 : nexthop_list_.push_back(NextHop(table, attr->nexthop(),
116 0 : attr->mac_address(), label, l3_label, attr->ext_community(),
117 : attr->large_community(), false));
118 : }
119 0 : }
120 :
121 0 : RibOutAttr::RibOutAttr(const BgpTable *table, const BgpRoute *route,
122 0 : const BgpAttr *attr, uint32_t label, bool include_nh, bool is_xmpp)
123 0 : : attr_out_(attr),
124 0 : label_(0),
125 0 : l3_label_(0),
126 0 : is_xmpp_(is_xmpp),
127 0 : vrf_originated_(route->BestPath()->IsVrfOriginated()) {
128 0 : if (attr && include_nh) {
129 0 : if (is_xmpp) {
130 0 : nexthop_list_.push_back(NextHop(table, attr->nexthop(),
131 0 : attr->mac_address(), label, 0, attr->ext_community(),
132 0 : attr->large_community(), vrf_originated_));
133 : } else {
134 0 : label_ = label;
135 0 : l3_label_ = 0;
136 : }
137 : }
138 0 : }
139 :
140 41088 : RibOutAttr::RibOutAttr(const BgpRoute *route, const BgpAttr *attr,
141 41088 : bool is_xmpp) :
142 41088 : label_(0), l3_label_(0), is_xmpp_(is_xmpp), vrf_originated_(false) {
143 : // Attribute should not be set already
144 41083 : assert(!attr_out_);
145 :
146 41085 : const BgpTable *table = static_cast<const BgpTable *>(route->get_table());
147 :
148 : // Always encode best path's attributes (including it's nexthop) and label.
149 41084 : if (!is_xmpp) {
150 12428 : set_attr(table, attr, route->BestPath()->GetLabel(),
151 : route->BestPath()->GetL3Label(), false, is_xmpp);
152 12428 : return;
153 : }
154 :
155 : // Encode ECMP nexthops only for XMPP peers.
156 : // Vrf Origination matters only for XMPP peers.
157 28665 : set_attr(table, attr, route->BestPath()->GetLabel(),
158 28656 : route->BestPath()->GetL3Label(), route->BestPath()->IsVrfOriginated(),
159 : is_xmpp);
160 :
161 28730 : for (Route::PathList::const_iterator it = route->GetPathList().begin();
162 114723 : it != route->GetPathList().end(); ++it) {
163 28679 : const BgpPath *path = static_cast<const BgpPath *>(it.operator->());
164 :
165 : // Skip the best path.
166 28679 : if (path == route->BestPath())
167 28684 : continue;
168 :
169 : // Check if the path is ECMP eligible. If not, bail out, as the paths
170 : // are sorted in cost order anyways.
171 0 : if (route->BestPath()->PathCompare(*path, true))
172 0 : break;
173 :
174 : // We have an eligible ECMP path.
175 : // Remember if the path was originated in the VRF. This is used to
176 : // determine if VRF's VN name can be used as the origin VN for the
177 : // nexthop.
178 0 : NextHop nexthop(table, path->GetAttr()->nexthop(),
179 0 : path->GetAttr()->mac_address(), path->GetLabel(),
180 : path->GetL3Label(), path->GetAttr()->ext_community(),
181 0 : path->GetAttr()->large_community(), path->IsVrfOriginated());
182 :
183 : // Skip if we have already encoded this next-hop
184 0 : if (find(nexthop_list_.begin(), nexthop_list_.end(), nexthop) !=
185 0 : nexthop_list_.end()) {
186 0 : continue;
187 : }
188 0 : nexthop_list_.push_back(nexthop);
189 0 : }
190 0 : }
191 :
192 : //
193 : // Assignment operator.
194 : // Do not copy the string representation;
195 : //
196 41108 : RibOutAttr &RibOutAttr::operator=(const RibOutAttr &rhs) {
197 41108 : attr_out_ = rhs.attr_out_;
198 41152 : nexthop_list_ = rhs.nexthop_list_;
199 41091 : label_ = rhs.label_;
200 41091 : l3_label_ = rhs.l3_label_;
201 41091 : source_address_ = rhs.source_address_;
202 41101 : is_xmpp_ = rhs.is_xmpp_;
203 41101 : vrf_originated_ = rhs.vrf_originated_;
204 41101 : return *this;
205 : }
206 :
207 : //
208 : // Comparator for RibOutAttr.
209 : // First compare the BgpAttr and then the nexthops.
210 : //
211 60793 : int RibOutAttr::CompareTo(const RibOutAttr &rhs) const {
212 60793 : KEY_COMPARE(attr_out_.get(), rhs.attr_out_.get());
213 10115 : KEY_COMPARE(nexthop_list_.size(), rhs.nexthop_list_.size());
214 16673 : for (size_t idx = 0; idx < nexthop_list_.size(); ++idx) {
215 6570 : KEY_COMPARE(nexthop_list_[idx], rhs.nexthop_list_[idx]);
216 : }
217 10096 : KEY_COMPARE(label_, rhs.label());
218 3612 : KEY_COMPARE(l3_label_, rhs.l3_label());
219 3613 : KEY_COMPARE(source_address_, rhs.source_address());
220 3613 : KEY_COMPARE(is_xmpp_, rhs.is_xmpp());
221 3613 : KEY_COMPARE(vrf_originated_, rhs.vrf_originated());
222 3613 : return 0;
223 : }
224 :
225 41153 : void RibOutAttr::set_attr(const BgpTable *table, const BgpAttrPtr &attrp,
226 : uint32_t label, uint32_t l3_label, bool vrf_originated, bool is_xmpp) {
227 41153 : if (!attr_out_) {
228 41148 : attr_out_ = attrp;
229 41144 : assert(nexthop_list_.empty());
230 41119 : if (is_xmpp) {
231 28669 : NextHop nexthop(table, attrp->nexthop(), attrp->mac_address(),
232 : label, l3_label, attrp->ext_community(),
233 57325 : attrp->large_community(), vrf_originated);
234 28622 : nexthop_list_.push_back(nexthop);
235 28642 : } else {
236 12428 : label_ = label;
237 12428 : l3_label_ = l3_label;
238 : }
239 41075 : return;
240 : }
241 :
242 0 : if (!attrp) {
243 0 : clear();
244 0 : return;
245 : }
246 :
247 0 : assert(attr_out_->nexthop() == attrp->nexthop());
248 0 : attr_out_ = attrp;
249 : }
250 :
251 37496 : RouteState::RouteState() {
252 37492 : }
253 :
254 : //
255 : // Move history from RouteState to RouteUpdate.
256 : //
257 28638 : void RouteState::MoveHistory(RouteUpdate *rt_update) {
258 28638 : AdvertiseSList adv_slist;
259 28631 : SwapHistory(adv_slist);
260 28612 : rt_update->SwapHistory(adv_slist);
261 28607 : }
262 :
263 : //
264 : // Find the AdvertiseInfo element with matching RibOutAttr.
265 : //
266 5787 : const AdvertiseInfo *RouteState::FindHistory(
267 : const RibOutAttr &roattr) const {
268 7953 : for (AdvertiseSList::List::const_iterator iter = advertised_->begin();
269 15901 : iter != advertised_->end(); iter++) {
270 9399 : if (iter->roattr == roattr) return iter.operator->();
271 : }
272 2162 : return NULL;
273 : }
274 :
275 : //
276 : // Compare AdevrtiseInfos in this RouteState with the UpdateInfo elements
277 : // in the given list.
278 : //
279 : // Uses brute force since the UpdateInfo and AdvertiseInfo lists typically
280 : // contain just a single element.
281 : //
282 : // Return true if the information in the RouteState is same as that in the
283 : // UpdateInfoSList.
284 : //
285 32328 : bool RouteState::CompareUpdateInfo(const UpdateInfoSList &uinfo_slist) const {
286 : // Both lists must have the same number of elements.
287 32328 : if (uinfo_slist->size() != advertised_->size())
288 26520 : return false;
289 :
290 : // Compare the peerset for each UpdateInfo in the UpdateInfoSList to
291 : // the peerset for the corresponding AdvertiseInfo in the advertised
292 : // list.
293 5795 : for (UpdateInfoSList::List::const_iterator iter = uinfo_slist->begin();
294 18798 : iter != uinfo_slist->end(); ++iter) {
295 5787 : const AdvertiseInfo *ainfo = FindHistory(iter->roattr);
296 9388 : if (!ainfo || iter->target != ainfo->bitset)
297 2166 : return false;
298 : }
299 :
300 3610 : return true;
301 : }
302 :
303 : //
304 : // Create a new RibOut based on the BgpTable and RibExportPolicy.
305 : //
306 804 : RibOut::RibOut(BgpTable *table, BgpUpdateSender *sender,
307 804 : const RibExportPolicy &policy)
308 804 : : table_(table),
309 804 : sender_(sender),
310 804 : policy_(policy),
311 804 : listener_id_(DBTableBase::kInvalidId),
312 804 : bgp_export_(BgpStaticObjectFactory::Create<BgpExport>(this)) {
313 804 : name_ = "RibOut";
314 804 : if (policy_.type == BgpProto::XMPP) {
315 460 : name_ += " Type: XMPP";
316 344 : } else if (policy_.type == BgpProto::IBGP) {
317 0 : name_ += " Type: IBGP";
318 : } else {
319 344 : name_ += " Type: EBGP";
320 344 : name_ += " (AS " + integerToString(policy_.as_number);
321 344 : if (!policy_.nexthop.is_unspecified())
322 0 : name_ += " Nexthop " + policy_.nexthop.to_string();
323 344 : if (policy_.as_override)
324 0 : name_ += " ASOverride";
325 344 : name_ += ")";
326 : }
327 4020 : for (int idx = 0; idx < DB::PartitionCount(); ++idx) {
328 3216 : updates_.push_back(BgpStaticObjectFactory::Create<RibOutUpdates>(this, idx));
329 : }
330 804 : }
331 :
332 : //
333 : // Destructor for RibOut. Takes care of unregistering the RibOut from
334 : // the DBTableBase.
335 : //
336 804 : RibOut::~RibOut() {
337 804 : if (listener_id_ != DBTableBase::kInvalidId) {
338 804 : table_->Unregister(listener_id_);
339 804 : listener_id_ = DBTableBase::kInvalidId;
340 : }
341 804 : STLDeleteValues(&updates_);
342 804 : }
343 :
344 : //
345 : // Register the RibOut as a listener with the underlying DBTableBase. This
346 : // is separated out from the constructor to let the unit testing code work
347 : // using the bare bones RibOut functionality.
348 : //
349 : // Note that the corresponding unregister from the DBTableBase will happen
350 : // implicitly from the destructor.
351 : //
352 2184 : void RibOut::RegisterListener() {
353 2184 : if (listener_id_ != DBTableBase::kInvalidId)
354 1380 : return;
355 804 : listener_id_ = table_->Register(
356 : boost::bind(&BgpExport::Export, bgp_export_.get(), _1, _2),
357 : ToString());
358 : }
359 :
360 : //
361 : // Register a new peer to the RibOut. If the peer is not present in the
362 : // PeerStateMap, create a new PeerState and add it to the map.
363 : // Join the IPeerUpdate to the UPDATE and BULK queues for all RibOutUpdates
364 : // associated with the RibOut.
365 : //
366 2184 : void RibOut::Register(IPeerUpdate *peer) {
367 2184 : PeerState *ps = state_map_.Locate(peer);
368 2184 : assert(ps != NULL);
369 2184 : active_peerset_.set(ps->index);
370 2184 : sender_->Join(this, peer);
371 10920 : for (int idx = 0; idx < DB::PartitionCount(); ++idx) {
372 8736 : if (updates_[idx]->QueueJoin(RibOutUpdates::QUPDATE, ps->index))
373 0 : sender_->RibOutActive(idx, this, RibOutUpdates::QUPDATE);
374 8736 : if (updates_[idx]->QueueJoin(RibOutUpdates::QBULK, ps->index))
375 0 : sender_->RibOutActive(idx, this, RibOutUpdates::QBULK);
376 : }
377 2184 : }
378 :
379 : //
380 : // Unregister a IPeerUpdate from the RibOut.
381 : // Leave the IPeerUpdate from the UPDATE and BULK queues for all RibOutUpdates
382 : // associated with the RibOut.
383 : // Removes the IPeerUpdate from the PeerStateMap.
384 : // If this was the last IPeerUpdate in the RibOut, remove the RibOut from the
385 : // BgpTable. That will cause this RibOut itself to get destroyed.
386 : //
387 2184 : void RibOut::Unregister(IPeerUpdate *peer) {
388 2184 : PeerState *ps = state_map_.Find(peer);
389 2184 : assert(ps != NULL);
390 2184 : assert(!active_peerset_.test(ps->index));
391 :
392 10920 : for (int idx = 0; idx < DB::PartitionCount(); ++idx) {
393 8736 : updates_[idx]->QueueLeave(RibOutUpdates::QUPDATE, ps->index);
394 8736 : updates_[idx]->QueueLeave(RibOutUpdates::QBULK, ps->index);
395 : }
396 2184 : sender_->Leave(this, peer);
397 2184 : state_map_.Remove(peer, ps->index);
398 :
399 2184 : if (state_map_.empty()) {
400 804 : table_->RibOutDelete(policy_);
401 : }
402 2184 : }
403 :
404 : //
405 : // Return true if the IPeerUpdate is registered to this RibOut.
406 : //
407 0 : bool RibOut::IsRegistered(IPeerUpdate *peer) {
408 0 : PeerState *ps = state_map_.Find(peer);
409 0 : return (ps != NULL);
410 : }
411 :
412 : //
413 : // Deactivate a IPeerUpdate from the RibOut. Removes it from the RibPeerSet of
414 : // active peers without removing it from the PeerStateMap.
415 : //
416 : // This must be called when the peer starts the process of leaving the RibOut
417 : // in order to prevent any new or existing routes from getting exported while
418 : // the route table walk for the leave processing is in progress.
419 : //
420 2184 : void RibOut::Deactivate(IPeerUpdate *peer) {
421 2184 : PeerState *ps = state_map_.Find(peer);
422 2184 : assert(ps != NULL);
423 2184 : assert(active_peerset_.test(ps->index));
424 2184 : active_peerset_.reset(ps->index);
425 2184 : }
426 :
427 0 : bool RibOut::IsActive(IPeerUpdate *peer) const {
428 0 : int index = GetPeerIndex(peer);
429 0 : return (index < 0 ? false : active_peerset_.test(index));
430 : }
431 :
432 : //
433 : // Build the subset of given RibPeerSet in this RibOut that are send ready.
434 : //
435 0 : void RibOut::BuildSendReadyBitSet(const RibPeerSet &peerset,
436 : RibPeerSet *mready) const {
437 0 : for (size_t bit = peerset.find_first(); bit != RibPeerSet::npos;
438 0 : bit = peerset.find_next(bit)) {
439 0 : IPeerUpdate *peer = GetPeer(bit);
440 0 : if (peer->send_ready()) {
441 0 : mready->set(bit);
442 : }
443 : }
444 0 : }
445 :
446 : //
447 : // Return the number of peers this route has been advertised to.
448 : //
449 0 : int RibOut::RouteAdvertiseCount(const BgpRoute *rt) const {
450 0 : const DBState *dbstate = rt->GetState(table_, listener_id_);
451 0 : if (dbstate == NULL) {
452 0 : return 0;
453 : }
454 :
455 0 : const RouteState *rstate = dynamic_cast<const RouteState *>(dbstate);
456 0 : if (rstate != NULL) {
457 0 : int count = 0;
458 0 : for (AdvertiseSList::List::const_iterator iter =
459 0 : rstate->Advertised()->begin();
460 0 : iter != rstate->Advertised()->end(); ++iter) {
461 0 : count += iter->bitset.count();
462 : }
463 0 : return count;
464 : }
465 :
466 0 : const RouteUpdate *rt_update = dynamic_cast<const RouteUpdate *>(dbstate);
467 0 : if (rt_update != NULL) {
468 0 : int count = 0;
469 0 : for (AdvertiseSList::List::const_iterator iter =
470 0 : rt_update->History()->begin();
471 0 : iter != rt_update->History()->end(); ++iter) {
472 0 : count += iter->bitset.count();
473 : }
474 0 : return count;
475 : }
476 :
477 0 : const UpdateList *uplist = dynamic_cast<const UpdateList *>(dbstate);
478 0 : if (uplist != NULL) {
479 0 : int count = 0;
480 0 : for (AdvertiseSList::List::const_iterator iter =
481 0 : uplist->History()->begin();
482 0 : iter != uplist->History()->end(); ++iter) {
483 0 : count += iter->bitset.count();
484 : }
485 0 : return count;
486 : }
487 :
488 0 : return 0;
489 : }
490 :
491 : //
492 : // Return the total queue size across all RibOutUpdates and UpdateQueues.
493 : //
494 0 : uint32_t RibOut::GetQueueSize() const {
495 0 : uint32_t queue_size = 0;
496 0 : for (int idx = 0; idx < DB::PartitionCount(); ++idx) {
497 0 : const RibOutUpdates *updates = updates_[idx];
498 0 : for (int qid = RibOutUpdates::QFIRST; qid < RibOutUpdates::QCOUNT;
499 : ++qid) {
500 0 : queue_size += updates->queue_size(qid);
501 : }
502 : }
503 0 : return queue_size;
504 : }
505 :
506 : //
507 : // Return the active RibPeerSet for this RibOut. We keep track of the active
508 : // peers via the calls to Register and Deactivate.
509 : //
510 : // The active RibPeerSet is always a subset of the registered RibPeerSet that
511 : // is in the PeerStateMap.
512 : //
513 112459 : const RibPeerSet &RibOut::PeerSet() const {
514 112459 : return active_peerset_;
515 : }
516 :
517 : //
518 : // Clear the bit index corresponding to the specified peer.
519 : // Used to implement split horizon within an EBGP Ribout.
520 : //
521 0 : void RibOut::GetSubsetPeerSet(RibPeerSet *peerset,
522 : const IPeerUpdate *cpeer) const {
523 0 : assert(policy_.type == BgpProto::EBGP);
524 0 : IPeerUpdate *peer = const_cast<IPeerUpdate *>(cpeer);
525 0 : int index = GetPeerIndex(peer);
526 0 : if (index < 0)
527 0 : return;
528 0 : peerset->reset(index);
529 : }
530 :
531 : //
532 : // Return the peer corresponding to the specified bit index.
533 : //
534 160462 : IPeerUpdate *RibOut::GetPeer(int index) const {
535 160462 : PeerState *ps = state_map_.At(index);
536 160464 : if (ps != NULL) {
537 160467 : return ps->peer;
538 : }
539 0 : return NULL;
540 : }
541 :
542 : //
543 : // Return the bit index corresponding to the specified peer.
544 : //
545 131925 : int RibOut::GetPeerIndex(IPeerUpdate *peer) const {
546 131925 : PeerState *ps = state_map_.Find(peer);
547 131843 : return (ps ? ps->index : -1);
548 : }
549 :
550 : //
551 : // Fill introspect information.
552 : // Accumulate counters from all RibOutUpdates.
553 : //
554 0 : void RibOut::FillStatisticsInfo(vector<ShowRibOutStatistics> *sros_list) const {
555 0 : for (int qid = RibOutUpdates::QFIRST; qid < RibOutUpdates::QCOUNT; ++qid) {
556 : RibOutUpdates::Stats stats;
557 0 : memset(&stats, 0, sizeof(stats));
558 0 : size_t queue_size = 0;
559 0 : size_t queue_marker_count = 0;
560 0 : for (int idx = 0; idx < DB::PartitionCount(); ++idx) {
561 0 : const RibOutUpdates *updates = updates_[idx];
562 0 : updates->AddStatisticsInfo(qid, &stats);
563 0 : queue_size += updates->queue_size(qid);
564 0 : queue_marker_count += updates->queue_marker_count(qid);
565 : }
566 :
567 0 : ShowRibOutStatistics sros;
568 0 : sros.set_table(table_->name());
569 0 : sros.set_encoding(EncodingString());
570 0 : sros.set_peer_type(BgpProto::BgpPeerTypeString(peer_type()));
571 0 : sros.set_peer_as(peer_as());
572 0 : sros.set_peers(state_map_.size());
573 0 : sros.set_queue(qid == RibOutUpdates::QBULK ? "BULK" : "UPDATE");
574 0 : sros.set_pending_updates(queue_size);
575 0 : sros.set_markers(queue_marker_count);
576 0 : sros.set_messages_built(stats.messages_built_count_);
577 0 : sros.set_messages_sent(stats.messages_sent_count_);
578 0 : sros.set_reach(stats.reach_count_);
579 0 : sros.set_unreach(stats.unreach_count_);
580 0 : sros.set_tail_dequeues(stats.tail_dequeue_count_);
581 0 : sros.set_peer_dequeues(stats.peer_dequeue_count_);
582 0 : sros.set_marker_splits(stats.marker_split_count_);
583 0 : sros.set_marker_merges(stats.marker_merge_count_);
584 0 : sros.set_marker_moves(stats.marker_move_count_);
585 0 : sros_list->push_back(sros);
586 0 : }
587 0 : }
|