Skip to content

Commit

Permalink
Merge "Add more info to output of ShowMulticastManagerDetailReq"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Feb 1, 2016
2 parents 19041a8 + 7cab43d commit 731710e
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 32 deletions.
11 changes: 10 additions & 1 deletion src/base/label_block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

#include "base/label_block.h"

#include <stdio.h>

#include <cassert>
#include <string>

using namespace std;
using std::string;

LabelBlockManager::LabelBlockManager() {
refcount_ = 0;
Expand Down Expand Up @@ -99,3 +102,9 @@ void LabelBlock::ReleaseLabel(uint32_t value) {
size_t pos = value - first_;
used_bitset_.reset(pos);
}

string LabelBlock::ToString() const {
char repr[32];
snprintf(repr, sizeof(repr), "%u-%u", first_, last_);
return repr;
}
1 change: 1 addition & 0 deletions src/base/label_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class LabelBlock {

uint32_t AllocateLabel();
void ReleaseLabel(uint32_t value);
std::string ToString() const;
uint32_t first() { return first_; }
uint32_t last() { return last_; }
LabelBlockManagerPtr block_manager() { return block_manager_; }
Expand Down
14 changes: 10 additions & 4 deletions src/bgp/bgp_multicast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,12 @@ void McastSGEntry::UpdateRoutes(uint8_t level) {
//
// Implement tree builder election.
//
bool McastSGEntry::IsTreeBuilder(uint8_t level) {
bool McastSGEntry::IsTreeBuilder(uint8_t level) const {
if (level == McastTreeManager::LevelNative)
return true;

ForwarderSet *forwarders = forwarder_sets_[level];
ForwarderSet::iterator it = forwarders->begin();
const ForwarderSet *forwarders = forwarder_sets_[level];
ForwarderSet::const_iterator it = forwarders->begin();
if (it == forwarders->end())
return false;

Expand Down Expand Up @@ -787,11 +787,17 @@ BgpServer *McastManagerPartition::server() {
return tree_manager_->table()->server();
}

const BgpServer *McastManagerPartition::server() const {
return tree_manager_->table()->server();
}

//
// Constructor for McastTreeManager.
//
McastTreeManager::McastTreeManager(ErmVpnTable *table)
: table_(table), table_delete_ref_(this, table->deleter()) {
: table_(table),
listener_id_(DBTable::kInvalidId),
table_delete_ref_(this, table->deleter()) {
deleter_.reset(new DeleteActor(this));
}

Expand Down
5 changes: 4 additions & 1 deletion src/bgp/bgp_multicast.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class McastForwarder : public DBState {

uint8_t level() const { return level_; }
uint32_t label() const { return label_; }
const LabelBlock *label_block() const { return label_block_.get(); }
Ip4Address address() const { return address_; }
std::vector<std::string> encap() const { return encap_; }
ErmVpnRoute *route() { return route_; }
Expand Down Expand Up @@ -239,7 +240,7 @@ class McastSGEntry : public DBState {

typedef std::set<McastForwarder *, McastForwarderCompare> ForwarderSet;

bool IsTreeBuilder(uint8_t level);
bool IsTreeBuilder(uint8_t level) const;
void UpdateTree(uint8_t level);
void UpdateRoutes(uint8_t level);

Expand Down Expand Up @@ -310,6 +311,7 @@ class McastManagerPartition {
DBTablePartBase *GetTablePartition();
const RoutingInstance *routing_instance() const;
BgpServer *server();
const BgpServer *server() const;
McastTreeManager *tree_manager() const { return tree_manager_; }

bool empty() const { return sg_list_.empty(); }
Expand Down Expand Up @@ -394,6 +396,7 @@ class McastTreeManager {
virtual UpdateInfo *GetUpdateInfo(ErmVpnRoute *route);
DBTablePartBase *GetTablePartition(size_t part_id);
ErmVpnTable *table() { return table_; }
const ErmVpnTable *table() const { return table_; }

void ManagedDelete();
void Shutdown();
Expand Down
4 changes: 3 additions & 1 deletion src/bgp/bgp_peer.sandesh
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,15 @@ struct ShowMulticastForwarder {
1: string address;
2: string label_block;
3: u32 label;
5: string router_id;
4: list<ShowMulticastTreeLink> links;
}

struct ShowMulticastTree {
1: string group;
2: string source;
3: list<ShowMulticastForwarder> forwarders;
3: list<ShowMulticastForwarder> level0_forwarders;
4: list<ShowMulticastForwarder> level1_forwarders;
}

struct ShowBgpServiceChainConfig {
Expand Down
61 changes: 36 additions & 25 deletions src/bgp/bgp_sandesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,38 +153,47 @@ class ShowMulticastManagerDetailHandler {
return (new MulticastManagerDetailData);
}

static void FillMulticastLinkInfo(ShowMulticastForwarder *fwd,
const McastForwarder *forwarder) {
ShowMulticastTreeLink link;
link.set_address(forwarder->address().to_string());
link.set_label(forwarder->label());
fwd->links.push_back(link);
static void FillMulticastLinkInfo(const McastForwarder *forwarder,
ShowMulticastTreeLink *smtl) {
smtl->set_address(forwarder->address().to_string());
smtl->set_label(forwarder->label());
}

static void FillMulticastForwarderInfo(ShowMulticastTree *tree,
const McastForwarder *forwarder) {
ShowMulticastForwarder fwd;
fwd.set_address(forwarder->address().to_string());
fwd.set_label(forwarder->label());
static void FillMulticastForwarderInfo(const McastForwarder *forwarder,
ShowMulticastForwarder *smf) {
smf->set_address(forwarder->address().to_string());
smf->set_label(forwarder->label());
smf->set_label_block(forwarder->label_block()->ToString());
smf->set_router_id(forwarder->router_id().to_string());
for (McastForwarderList::const_iterator it =
forwarder->tree_links_.begin();
it != forwarder->tree_links_.end(); it++) {
FillMulticastLinkInfo(&fwd, *it);
it != forwarder->tree_links_.end(); ++it) {
ShowMulticastTreeLink smtl;
FillMulticastLinkInfo(*it, &smtl);
smf->links.push_back(smtl);
}
tree->forwarders.push_back(fwd);
}

static void FillMulticastTreeInfo(MulticastManagerDetailData *data,
const McastSGEntry *sg) {
ShowMulticastTree tree;
tree.set_group(sg->group().to_string());
tree.set_source(sg->source().to_string());
for (McastSGEntry::ForwarderSet::const_iterator it =
sg->forwarder_sets_[0]->begin();
it != sg->forwarder_sets_[0]->end(); it++) {
FillMulticastForwarderInfo(&tree, *it);
static void FillMulticastTreeInfo(const McastSGEntry *sg,
ShowMulticastTree *smt) {
smt->set_group(sg->group().to_string());
smt->set_source(sg->source().to_string());
for (uint8_t level = McastTreeManager::LevelFirst;
level < McastTreeManager::LevelCount; ++level) {
if (!sg->IsTreeBuilder(level))
continue;
for (McastSGEntry::ForwarderSet::const_iterator it =
sg->forwarder_sets_[level]->begin();
it != sg->forwarder_sets_[level]->end(); ++it) {
ShowMulticastForwarder smf;
FillMulticastForwarderInfo(*it, &smf);
if (level == McastTreeManager::LevelNative) {
smt->level0_forwarders.push_back(smf);
} else {
smt->level1_forwarders.push_back(smf);
}
}
}
data->tree_list.push_back(tree);
}

static void FillMulticastPartitionInfo(MulticastManagerDetailData *data,
Expand All @@ -194,7 +203,9 @@ class ShowMulticastManagerDetailHandler {
for (McastManagerPartition::SGList::const_iterator it =
partition->sg_list_.begin();
it != partition->sg_list_.end(); it++) {
FillMulticastTreeInfo(data, *it);
ShowMulticastTree smt;
FillMulticastTreeInfo(*it, &smt);
data->tree_list.push_back(smt);
}
}

Expand Down

0 comments on commit 731710e

Please sign in to comment.