Skip to content

Commit

Permalink
Merge "Tor agent didnt unsubscribe for multicast route."
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jun 12, 2015
2 parents 0d505b3 + 89405e4 commit 1fec53c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 12 deletions.
19 changes: 17 additions & 2 deletions src/vnsw/agent/controller/controller_export.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <oper/nexthop.h>
#include <oper/peer.h>
#include <oper/mirror_table.h>
#include "oper/tunnel_nh.h"

#include <controller/controller_vrf_export.h>
#include <controller/controller_init.h>
Expand All @@ -20,7 +21,8 @@
RouteExport::State::State() :
DBState(), exported_(false), fabric_multicast_exported_(false),
force_chg_(false), label_(MplsTable::kInvalidLabel), vn_(""), sg_list_(),
tunnel_type_(TunnelType::INVALID), path_preference_() {
tunnel_type_(TunnelType::INVALID), path_preference_(),
destination_(), source_() {
}

bool RouteExport::State::Changed(const AgentRoute *route, const AgentPath *path) const {
Expand Down Expand Up @@ -255,6 +257,8 @@ void RouteExport::MulticastNotify(AgentXmppChannel *bgp_xmpp_peer,
route,
state->vn_,
state->label_,
state->destination_,
state->source_,
TunnelType::AllType());
state->fabric_multicast_exported_ = false;
}
Expand Down Expand Up @@ -324,6 +328,7 @@ void RouteExport::MulticastNotify(AgentXmppChannel *bgp_xmpp_peer,
if (withdraw) {
AgentXmppChannel::ControllerSendEvpnRouteDelete
(bgp_xmpp_peer, route, state->vn_, withdraw_label,
state->destination_, state->source_,
state->tunnel_type_);
state->fabric_multicast_exported_ = false;
}
Expand All @@ -346,20 +351,30 @@ void RouteExport::MulticastNotify(AgentXmppChannel *bgp_xmpp_peer,
state->label_ = active_path->GetActiveLabel();
state->vn_ = route->dest_vn_name();
if (associate) {
const TunnelNH *tnh =
dynamic_cast<const TunnelNH *>(active_path->nexthop());
if (tnh) {
state->destination_ = tnh->GetDip()->to_string();
state->source_ = tnh->GetSip()->to_string();
}

SecurityGroupList sg;
state->fabric_multicast_exported_ =
AgentXmppChannel::ControllerSendEvpnRouteAdd
(bgp_xmpp_peer, route,
active_path->NexthopIp(table->agent()),
route->dest_vn_name(), state->label_,
TunnelType::GetTunnelBmap(state->tunnel_type_),
&sg);
&sg, state->destination_,
state->source_);
} else {
state->fabric_multicast_exported_ =
AgentXmppChannel::ControllerSendEvpnRouteDelete(bgp_xmpp_peer,
route,
route->dest_vn_name(),
state->label_,
state->destination_,
state->source_,
TunnelType::AllType());
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/vnsw/agent/controller/controller_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class RouteExport {
SecurityGroupList sg_list_;
TunnelType::Type tunnel_type_;
PathPreference path_preference_;
//destination and source are valid for tunnel NH.
std::string destination_;
std::string source_;

bool Changed(const AgentRoute *route, const AgentPath *path) const;
void Update(const AgentRoute *route, const AgentPath *path);
Expand Down
31 changes: 22 additions & 9 deletions src/vnsw/agent/controller/controller_peer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1804,13 +1804,15 @@ bool AgentXmppChannel::BuildTorMulticastMessage(EnetItemType &item,
const SecurityGroupList *sg_list,
uint32_t label,
uint32_t tunnel_bmap,
const std::string &destination,
const std::string &source,
bool associate) {
assert(route->GetTableType() == Agent::BRIDGE);
const AgentPath *path = NULL;
BridgeRouteEntry *l2_route =
dynamic_cast<BridgeRouteEntry *>(route);
path = l2_route->FindOvsPath();
if (path == NULL) {
if ((path == NULL) && (associate)) {
CONTROLLER_TRACE(Trace, GetBgpPeerName(),
route->vrf()->GetName(),
"OVS path not found for ff:ff:ff:ff:ff:ff, skip send");
Expand All @@ -1819,9 +1821,7 @@ bool AgentXmppChannel::BuildTorMulticastMessage(EnetItemType &item,

item.entry.local_preference = PathPreference::LOW;
item.entry.sequence_number = 0;
const TunnelNH *tnh =
dynamic_cast<const TunnelNH *>(path->nexthop());
item.entry.replicator_address = tnh->GetSip()->to_string();
item.entry.replicator_address = source;
item.entry.nlri.af = BgpAf::L2Vpn;
item.entry.nlri.safi = BgpAf::Enet;
stringstream rstr;
Expand All @@ -1833,7 +1833,7 @@ bool AgentXmppChannel::BuildTorMulticastMessage(EnetItemType &item,
rstr.str("");
//TODO fix this when multicast moves to evpn
assert(l2_route->is_multicast());
rstr << tnh->GetDip()->to_string();
rstr << destination;
rstr << "/32";
item.entry.nlri.ethernet_tag = 0;
if (associate == false)
Expand All @@ -1844,7 +1844,7 @@ bool AgentXmppChannel::BuildTorMulticastMessage(EnetItemType &item,

autogen::EnetNextHopType nh;
nh.af = Address::INET;
nh.address = tnh->GetDip()->to_string();
nh.address = destination;
nh.label = label;

node_id << item.entry.nlri.af << "/" << item.entry.nlri.safi << "/"
Expand Down Expand Up @@ -2111,6 +2111,8 @@ bool AgentXmppChannel::ControllerSendEvpnRouteCommon(AgentRoute *route,
const SecurityGroupList *sg_list,
uint32_t label,
uint32_t tunnel_bmap,
const std::string &destination,
const std::string &source,
bool associate) {
EnetItemType item;
stringstream ss_node;
Expand All @@ -2135,6 +2137,7 @@ bool AgentXmppChannel::ControllerSendEvpnRouteCommon(AgentRoute *route,
} else if (agent_->tor_agent_enabled()) {
if (BuildTorMulticastMessage(item, ss_node, route, nh_ip,
vn, sg_list, label, tunnel_bmap,
destination, source,
associate) == false)
return false;;
ret = BuildAndSendEvpnDom(item, ss_node, route, associate);
Expand Down Expand Up @@ -2260,7 +2263,9 @@ bool AgentXmppChannel::ControllerSendEvpnRouteAdd(AgentXmppChannel *peer,
std::string vn,
uint32_t label,
uint32_t tunnel_bmap,
const SecurityGroupList *sg_list) {
const SecurityGroupList *sg_list,
const std::string &destination,
const std::string &source) {
if (!peer) return false;

CONTROLLER_TRACE(RouteExport, peer->GetBgpPeerName(),
Expand All @@ -2272,13 +2277,17 @@ bool AgentXmppChannel::ControllerSendEvpnRouteAdd(AgentXmppChannel *peer,
sg_list,
label,
tunnel_bmap,
destination,
source,
true));
}

bool AgentXmppChannel::ControllerSendEvpnRouteDelete(AgentXmppChannel *peer,
AgentRoute *route,
std::string vn,
uint32_t label,
const std::string &destination,
const std::string &source,
uint32_t tunnel_bmap) {
if (!peer) return false;

Expand All @@ -2292,6 +2301,8 @@ bool AgentXmppChannel::ControllerSendEvpnRouteDelete(AgentXmppChannel *peer,
NULL,
label,
tunnel_bmap,
destination,
source,
false));
}

Expand Down Expand Up @@ -2323,7 +2334,8 @@ bool AgentXmppChannel::ControllerSendRouteAdd(AgentXmppChannel *peer,
}
if (type == Agent::EVPN) {
ret = peer->ControllerSendEvpnRouteCommon(route, nexthop_ip, vn,
sg_list, label, bmap, true);
sg_list, label, bmap,
"", "", true);
}
return ret;
}
Expand Down Expand Up @@ -2358,7 +2370,8 @@ bool AgentXmppChannel::ControllerSendRouteDelete(AgentXmppChannel *peer,
if (type == Agent::EVPN) {
Ip4Address nh_ip(0);
ret = peer->ControllerSendEvpnRouteCommon(route, &nh_ip, vn, NULL,
label, bmap, false);
label, bmap, "", "",
false);
}
return ret;
}
Expand Down
10 changes: 9 additions & 1 deletion src/vnsw/agent/controller/controller_peer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ class AgentXmppChannel {
std::string vn,
uint32_t mpls_label,
uint32_t tunnel_bmap,
const SecurityGroupList *sg_list);
const SecurityGroupList *sg_list,
const std::string &destination,
const std::string &source);
static bool ControllerSendMcastRouteAdd(AgentXmppChannel *peer,
AgentRoute *route);
//Deletes to control node
Expand All @@ -94,6 +96,8 @@ class AgentXmppChannel {
AgentRoute *route,
std::string vn,
uint32_t mpls_label,
const std::string &destination,
const std::string &source,
uint32_t tunnel_bmap);
static bool ControllerSendMcastRouteDelete(AgentXmppChannel *peer,
AgentRoute *route);
Expand Down Expand Up @@ -130,6 +134,8 @@ class AgentXmppChannel {
const SecurityGroupList *sg_list,
uint32_t mpls_label,
uint32_t tunnel_bmap,
const std::string &destination,
const std::string &source,
bool associate);
bool ControllerSendMcastRouteCommon(AgentRoute *route,
bool associate);
Expand Down Expand Up @@ -167,6 +173,8 @@ class AgentXmppChannel {
const SecurityGroupList *sg_list,
uint32_t label,
uint32_t tunnel_bmap,
const std::string &destination,
const std::string &source,
bool associate);
bool BuildEvpnMulticastMessage(autogen::EnetItemType &item,
std::stringstream &node_id,
Expand Down

0 comments on commit 1fec53c

Please sign in to comment.