Skip to content

Commit

Permalink
PBB EVPN changes
Browse files Browse the repository at this point in the history
Issues fixed:
  1. Avoid generating multiple olist when multiple bridge domains are linked to
  b-comp vn
  2. Test to validate above fix.
  3. Path selection to take into account sticky and etree attribute
  4. Sandesh introspect display of etree community
  5. Sandesh introspect to display pbb mode on RI(both config and oper data)

Change-Id: I2858af0d1dfc280163da10379331a6bf1b58638a
Related-bug: #1645092
  • Loading branch information
bailkeri committed Feb 3, 2017
1 parent ae7449b commit 37edc22
Show file tree
Hide file tree
Showing 16 changed files with 582 additions and 95 deletions.
29 changes: 29 additions & 0 deletions src/bgp/bgp_attr.cc
Expand Up @@ -8,6 +8,7 @@
#include <string>

#include "bgp/bgp_server.h"
#include "bgp/extended-community/etree.h"
#include "bgp/extended-community/mac_mobility.h"
#include "bgp/extended-community/router_mac.h"
#include "net/bgp_af.h"
Expand Down Expand Up @@ -967,6 +968,34 @@ uint32_t BgpAttr::sequence_number() const {
return 0;
}

bool BgpAttr::sticky() const {
if (!ext_community_)
return 0;
for (ExtCommunity::ExtCommunityList::const_iterator it =
ext_community_->communities().begin();
it != ext_community_->communities().end(); ++it) {
if (ExtCommunity::is_mac_mobility(*it)) {
MacMobility mm(*it);
return mm.sticky();
}
}
return 0;
}

bool BgpAttr::leaf() const {
if (!ext_community_)
return 0;
for (ExtCommunity::ExtCommunityList::const_iterator it =
ext_community_->communities().begin();
it != ext_community_->communities().end(); ++it) {
if (ExtCommunity::is_etree(*it)) {
ETree etree(*it);
return etree.leaf();
}
}
return 0;
}

MacAddress BgpAttr::mac_address() const {
if (!ext_community_)
return MacAddress::kZeroMac;
Expand Down
2 changes: 2 additions & 0 deletions src/bgp/bgp_attr.h
Expand Up @@ -853,6 +853,8 @@ class BgpAttr {
BgpOListPtr leaf_olist() const { return leaf_olist_; }
BgpAttrDB *attr_db() const { return attr_db_; }
uint32_t sequence_number() const;
bool sticky() const;
bool leaf() const;
MacAddress mac_address() const;

private:
Expand Down
2 changes: 2 additions & 0 deletions src/bgp/bgp_config.cc
Expand Up @@ -284,6 +284,7 @@ BgpInstanceConfig::BgpInstanceConfig(const string &name)
has_pnf_(false),
virtual_network_index_(0),
virtual_network_allow_transit_(false),
virtual_network_pbb_evpn_enable_(false),
vxlan_id_(0),
last_change_at_(UTCTimestampUsec()) {
}
Expand All @@ -298,6 +299,7 @@ void BgpInstanceConfig::Clear() {
virtual_network_.clear();
virtual_network_index_ = 0;
virtual_network_allow_transit_ = false;
virtual_network_pbb_evpn_enable_ = false;
vxlan_id_ = 0;
inet_static_routes_.clear();
inet6_static_routes_.clear();
Expand Down
9 changes: 9 additions & 0 deletions src/bgp/bgp_config.h
Expand Up @@ -429,6 +429,14 @@ class BgpInstanceConfig {
virtual_network_allow_transit_ = allow_transit;
}

bool virtual_network_pbb_evpn_enable() const {
return virtual_network_pbb_evpn_enable_;
}
void set_virtual_network_pbb_evpn_enable(bool pbb_evpn) {
virtual_network_pbb_evpn_enable_ = pbb_evpn;
}


int vxlan_id() const { return vxlan_id_; }
void set_vxlan_id(int vxlan_id) { vxlan_id_ = vxlan_id; }

Expand Down Expand Up @@ -469,6 +477,7 @@ class BgpInstanceConfig {
std::string virtual_network_;
int virtual_network_index_;
bool virtual_network_allow_transit_;
bool virtual_network_pbb_evpn_enable_;
int vxlan_id_;
mutable uint64_t last_change_at_;
StaticRouteList inet_static_routes_;
Expand Down
16 changes: 16 additions & 0 deletions src/bgp/bgp_config_ifmap.cc
Expand Up @@ -856,6 +856,20 @@ static bool GetVirtualNetworkAllowTransit(DBGraph *graph, IFMapNode *node) {
return false;
}


//
// Check if a virtual-network has pbb-evpn enabled.
// The input IFMapNode represents the virtual-network.
//
static bool GetVirtualNetworkPbbEvpnEnable(DBGraph *graph, IFMapNode *node) {
const autogen::VirtualNetwork *vn =
static_cast<autogen::VirtualNetwork *>(node->GetObject());
if (vn && vn->IsPropertySet(autogen::VirtualNetwork::PBB_EVPN_ENABLE))
return vn->pbb_evpn_enable();
return false;
}


//
// Get the vxlan id for a virtual-network. The input IFMapNode represents
// the virtual-network.
Expand Down Expand Up @@ -1088,6 +1102,8 @@ void BgpIfmapInstanceConfig::Update(BgpIfmapConfigManager *manager,
data_.set_virtual_network_allow_transit(
GetVirtualNetworkAllowTransit(graph, adj));
data_.set_vxlan_id(GetVirtualNetworkVxlanId(graph, adj));
data_.set_virtual_network_pbb_evpn_enable(
GetVirtualNetworkPbbEvpnEnable(graph, adj));
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/bgp/bgp_config_parser.cc
Expand Up @@ -557,16 +557,29 @@ bool BgpConfigParser::ParseVirtualNetwork(const xml_node &node,
string vn_name(node.attribute("name").value());
assert(!vn_name.empty());

auto_ptr<autogen::VirtualNetwork::OolProperty> pbb_property(
new autogen::VirtualNetwork::OolProperty);
pbb_property->data = false;

if (node.attribute("pbb-evpn-enable")) {
pbb_property->data =
(string(node.attribute("pbb-evpn-enable").value()) == "true");
}

auto_ptr<autogen::VirtualNetworkType> property(
new autogen::VirtualNetworkType());
assert(property->XmlParse(node));

if (add_change) {
MapObjectSetProperty("virtual-network", vn_name,
"virtual-network-properties", property.release(), requests);
MapObjectSetProperty("virtual-network", vn_name,
"pbb-evpn-enable", pbb_property.release(), requests);
} else {
MapObjectClearProperty("virtual-network", vn_name,
"virtual-network-properties", requests);
MapObjectClearProperty("virtual-network", vn_name,
"pbb-evpn-enable", requests);
}

return true;
Expand Down
10 changes: 10 additions & 0 deletions src/bgp/bgp_evpn.cc
Expand Up @@ -15,6 +15,7 @@
#include "bgp/bgp_server.h"
#include "bgp/bgp_update.h"
#include "bgp/evpn/evpn_table.h"
#include "bgp/routing-instance/routing_instance.h"

using std::sort;
using std::string;
Expand Down Expand Up @@ -232,16 +233,25 @@ UpdateInfo *EvpnLocalMcastNode::GetUpdateInfo() {
if (assisted_replication_leaf_)
return NULL;

const RoutingInstance *rti = partition_->table()->routing_instance();
bool pbb_evpn_enable = rti->virtual_network_pbb_evpn_enable();
uint32_t local_ethernet_tag = route_->GetPrefix().tag();

// Go through list of EvpnRemoteMcastNodes and build the BgpOList.
BgpOListSpec olist_spec(BgpAttribute::OList);
BOOST_FOREACH(EvpnMcastNode *node, partition_->remote_mcast_node_list()) {
uint32_t remote_ethernet_tag = node->route()->GetPrefix().tag();

if (node->address() == address_)
continue;
if (node->assisted_replication_leaf())
continue;
if (!edge_replication_not_supported_ &&
!node->edge_replication_not_supported())
continue;
if (pbb_evpn_enable && remote_ethernet_tag &&
(local_ethernet_tag != remote_ethernet_tag))
continue;

const ExtCommunity *extcomm = node->attr()->ext_community();
BgpOListElem elem(node->address(), node->label(),
Expand Down
6 changes: 6 additions & 0 deletions src/bgp/bgp_path.cc
Expand Up @@ -61,6 +61,12 @@ int BgpPath::PathCompare(const BgpPath &rhs, bool allow_ecmp) const {
// Compare local_pref in reverse order as larger is better.
KEY_COMPARE(rattr->local_pref(), attr_->local_pref());

// ETree Root path first [compare in reverse order]
BOOL_COMPARE(rattr->leaf(), attr_->leaf());

// Sticky paths first
BOOL_COMPARE(rattr->sticky(), attr_->sticky());

// Compare sequence_number in reverse order as larger is better.
KEY_COMPARE(rattr->sequence_number(), attr_->sequence_number());

Expand Down
2 changes: 2 additions & 0 deletions src/bgp/bgp_peer.sandesh
Expand Up @@ -326,6 +326,7 @@ struct ShowRoutingInstance {
5: list<string> export_target; // Export Route targets
10: bool always_subscribe; // Always subscribe for RTF
12: bool allow_transit; // Allow transit
13: bool pbb_evpn_enable; // PBB EVPN enabled
7: bool deleted; // Deletion in progress
9: string deleted_at; // Delete timestamp
2: optional list<ShowRoutingInstanceTable> tables;
Expand Down Expand Up @@ -575,6 +576,7 @@ struct ShowBgpInstanceConfig {
4: list<string> export_target;
10: bool has_pnf;
13: bool allow_transit;
14: bool pbb_evpn_enable;
9: string last_change_at;
5: list<ShowBgpServiceChainConfig> service_chain_infos;
6: list<ShowBgpStaticRouteConfig> static_routes;
Expand Down
6 changes: 5 additions & 1 deletion src/bgp/bgp_route.cc
Expand Up @@ -10,6 +10,7 @@
#include "bgp/extended-community/default_gateway.h"
#include "bgp/extended-community/es_import.h"
#include "bgp/extended-community/esi_label.h"
#include "bgp/extended-community/etree.h"
#include "bgp/extended-community/load_balance.h"
#include "bgp/extended-community/mac_mobility.h"
#include "bgp/extended-community/router_mac.h"
Expand Down Expand Up @@ -353,7 +354,10 @@ static void FillRoutePathExtCommunityInfo(const BgpTable *table,
} else if (ExtCommunity::is_mac_mobility(*it)) {
MacMobility mm(*it);
communities->push_back(mm.ToString());
show_path->set_sequence_no(mm.ToString());
show_path->set_sequence_no(integerToString(mm.sequence_number()));
} else if (ExtCommunity::is_etree(*it)) {
ETree etree(*it);
communities->push_back(etree.ToString());
} else if (ExtCommunity::is_router_mac(*it)) {
RouterMac router_mac(*it);
communities->push_back(router_mac.ToString());
Expand Down
1 change: 1 addition & 0 deletions src/bgp/bgp_show_config.cc
Expand Up @@ -38,6 +38,7 @@ static void FillBgpInstanceConfigInfo(ShowBgpInstanceConfig *sbic,
sbic->set_export_target(export_list);
sbic->set_has_pnf(instance->has_pnf());
sbic->set_allow_transit(instance->virtual_network_allow_transit());
sbic->set_pbb_evpn_enable(instance->virtual_network_pbb_evpn_enable());
sbic->set_last_change_at(UTCUsecToString(instance->last_change_at()));

vector<ShowBgpServiceChainConfig> sbscc_list;
Expand Down
1 change: 1 addition & 0 deletions src/bgp/bgp_show_routing_instance.cc
Expand Up @@ -65,6 +65,7 @@ static void FillRoutingInstanceInfo(ShowRoutingInstance *sri,
sri->set_export_target(export_rt);
sri->set_always_subscribe(rtinstance->always_subscribe());
sri->set_allow_transit(rtinstance->virtual_network_allow_transit());
sri->set_pbb_evpn_enable(rtinstance->virtual_network_pbb_evpn_enable());

if (!summary) {
const BgpMembershipManager *bmm = bsc->bgp_server->membership_mgr();
Expand Down
11 changes: 11 additions & 0 deletions src/bgp/routing-instance/routing_instance.cc
Expand Up @@ -767,6 +767,7 @@ RoutingInstance::RoutingInstance(string name, BgpServer *server,
: name_(name), index_(-1), server_(server), mgr_(mgr), config_(config),
is_master_(false), always_subscribe_(false), virtual_network_index_(0),
virtual_network_allow_transit_(false),
virtual_network_pbb_evpn_enable_(false),
vxlan_id_(0),
deleter_(new DeleteActor(server, this)),
manager_delete_ref_(this, NULL) {
Expand Down Expand Up @@ -940,6 +941,8 @@ void RoutingInstance::ProcessConfig() {
virtual_network_ = config_->virtual_network();
virtual_network_index_ = config_->virtual_network_index();
virtual_network_allow_transit_ = config_->virtual_network_allow_transit();
virtual_network_pbb_evpn_enable_ =
config_->virtual_network_pbb_evpn_enable();
vxlan_id_ = config_->vxlan_id();

// Always subscribe (using RTF) for RTs of PNF service chain instances.
Expand Down Expand Up @@ -1013,6 +1016,9 @@ void RoutingInstance::UpdateConfig(const BgpInstanceConfig *cfg) {
bool notify_routes = false;
if (virtual_network_allow_transit_ != cfg->virtual_network_allow_transit())
notify_routes = true;
if (virtual_network_pbb_evpn_enable_ !=
cfg->virtual_network_pbb_evpn_enable())
notify_routes = true;
if (virtual_network_ != cfg->virtual_network())
notify_routes = true;
if (virtual_network_index_ != cfg->virtual_network_index())
Expand Down Expand Up @@ -1043,6 +1049,7 @@ void RoutingInstance::UpdateConfig(const BgpInstanceConfig *cfg) {

virtual_network_index_ = cfg->virtual_network_index();
virtual_network_allow_transit_ = cfg->virtual_network_allow_transit();
virtual_network_pbb_evpn_enable_ = cfg->virtual_network_pbb_evpn_enable();
vxlan_id_ = cfg->vxlan_id();

// Master routing instance doesn't have import & export list
Expand Down Expand Up @@ -1155,6 +1162,10 @@ bool RoutingInstance::virtual_network_allow_transit() const {
return virtual_network_allow_transit_;
}

bool RoutingInstance::virtual_network_pbb_evpn_enable() const {
return virtual_network_pbb_evpn_enable_;
}

int RoutingInstance::vxlan_id() const {
return vxlan_id_;
}
Expand Down
2 changes: 2 additions & 0 deletions src/bgp/routing-instance/routing_instance.h
Expand Up @@ -120,6 +120,7 @@ class RoutingInstance {
const BgpInstanceConfig *config() const { return config_; }
int virtual_network_index() const;
bool virtual_network_allow_transit() const;
bool virtual_network_pbb_evpn_enable() const;
int vxlan_id() const;

const RoutingInstanceMgr *manager() const { return mgr_; }
Expand Down Expand Up @@ -219,6 +220,7 @@ class RoutingInstance {
std::string virtual_network_;
int virtual_network_index_;
bool virtual_network_allow_transit_;
bool virtual_network_pbb_evpn_enable_;
int vxlan_id_;
boost::scoped_ptr<DeleteActor> deleter_;
LifetimeRef<RoutingInstance> manager_delete_ref_;
Expand Down

0 comments on commit 37edc22

Please sign in to comment.