Skip to content

Commit

Permalink
Agent support for Community attribute to avoid re-orignating the routes
Browse files Browse the repository at this point in the history
Refer to https://bugs.launchpad.net/juniperopenstack/+bug/1500698

1. Add community attribute to AgentPath
2. Static routes added with community attribute as per RouteType config object
3. send community in xmpp message for ip v4 & v6 routes
4. UT for the same

Change-Id: Ibb928f535e8fbc0c6b26db1ff6ee6e3f5087e53f
Related-bug:#1500698
  • Loading branch information
bailkeri committed Nov 16, 2015
1 parent ab5f2c9 commit bcefae6
Show file tree
Hide file tree
Showing 27 changed files with 324 additions and 78 deletions.
1 change: 1 addition & 0 deletions src/vnsw/agent/cmn/agent.h
Expand Up @@ -125,6 +125,7 @@ void intrusive_ptr_add_ref(const PhysicalDeviceVn *p);

//class SecurityGroup;
typedef std::vector<int> SecurityGroupList;
typedef std::vector<std::string> CommunityList;

class AgentDBTable;
class InterfaceTable;
Expand Down
11 changes: 8 additions & 3 deletions src/vnsw/agent/controller/controller_export.cc
Expand Up @@ -45,6 +45,9 @@ bool RouteExport::State::Changed(const AgentRoute *route, const AgentPath *path)
if (sg_list_ != path->sg_list())
return true;

if (communities_ != path->communities())
return true;

if (path_preference_ != path->path_preference())
return true;

Expand All @@ -56,6 +59,7 @@ void RouteExport::State::Update(const AgentRoute *route, const AgentPath *path)
label_ = path->GetActiveLabel();
vn_ = path->dest_vn_name();
sg_list_ = path->sg_list();
communities_ = path->communities();
tunnel_type_ = path->tunnel_type();
path_preference_ = path->path_preference();
}
Expand Down Expand Up @@ -172,7 +176,8 @@ void RouteExport::UnicastNotify(AgentXmppChannel *bgp_xmpp_peer,
AgentXmppChannel::ControllerSendRouteAdd(bgp_xmpp_peer,
static_cast<AgentRoute * >(route),
path->NexthopIp(table->agent()), state->vn_,
state->label_, path->GetTunnelBmap(), &path->sg_list(),
state->label_, path->GetTunnelBmap(),
&path->sg_list(), &path->communities(),
type, state->path_preference_);
}
} else {
Expand All @@ -181,7 +186,7 @@ void RouteExport::UnicastNotify(AgentXmppChannel *bgp_xmpp_peer,
static_cast<AgentRoute *>(route), state->vn_,
(state->tunnel_type_ == TunnelType::VXLAN ?
state->label_ : 0),
TunnelType::AllType(), NULL,
TunnelType::AllType(), NULL, NULL,
type, state->path_preference_);
state->exported_ = false;
}
Expand Down Expand Up @@ -406,7 +411,7 @@ void RouteExport::SubscribeIngressReplication(Agent *agent,
active_path->NexthopIp(agent),
route->dest_vn_name(), state->label_,
TunnelType::GetTunnelBmap(state->tunnel_type_),
&sg, state->destination_,
&sg, NULL, state->destination_,
state->source_, PathPreference());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/controller/controller_export.h
Expand Up @@ -26,6 +26,7 @@ class RouteExport {
uint32_t label_;
std::string vn_;
SecurityGroupList sg_list_;
CommunityList communities_;
TunnelType::Type tunnel_type_;
PathPreference path_preference_;
//destination and source are valid for tunnel NH.
Expand Down
47 changes: 31 additions & 16 deletions src/vnsw/agent/controller/controller_peer.cc
Expand Up @@ -1720,6 +1720,7 @@ bool AgentXmppChannel::ControllerSendSubscribe(AgentXmppChannel *peer,
bool AgentXmppChannel::ControllerSendV4V6UnicastRouteCommon(AgentRoute *route,
const std::string &vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t mpls_label,
TunnelType::TypeBmap bmap,
const PathPreference &path_preference,
Expand Down Expand Up @@ -1763,6 +1764,10 @@ bool AgentXmppChannel::ControllerSendV4V6UnicastRouteCommon(AgentRoute *route,
item.entry.security_group_list.security_group = *sg_list;
}

if (communities && !communities->empty()) {
item.entry.community_tag_list.community_tag = *communities;
}

item.entry.version = 1; //TODO
item.entry.virtual_network = vn;

Expand Down Expand Up @@ -1836,6 +1841,7 @@ bool AgentXmppChannel::BuildTorMulticastMessage(EnetItemType &item,
const Ip4Address *nh_ip,
const std::string &vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t label,
uint32_t tunnel_bmap,
const std::string &destination,
Expand Down Expand Up @@ -1923,6 +1929,7 @@ bool AgentXmppChannel::BuildEvpnMulticastMessage(EnetItemType &item,
const Ip4Address *nh_ip,
const std::string &vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t label,
uint32_t tunnel_bmap,
bool associate,
Expand Down Expand Up @@ -2007,6 +2014,7 @@ bool AgentXmppChannel::BuildEvpnUnicastMessage(EnetItemType &item,
const Ip4Address *nh_ip,
const std::string &vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t label,
uint32_t tunnel_bmap,
const PathPreference
Expand Down Expand Up @@ -2145,6 +2153,7 @@ bool AgentXmppChannel::ControllerSendEvpnRouteCommon(AgentRoute *route,
const Ip4Address *nh_ip,
std::string vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t label,
uint32_t tunnel_bmap,
const std::string &destination,
Expand All @@ -2163,8 +2172,8 @@ bool AgentXmppChannel::ControllerSendEvpnRouteCommon(AgentRoute *route,
dynamic_cast<BridgeRouteEntry *>(route);
if (agent_->tsn_enabled()) {
//Second subscribe for TSN assited replication
if (BuildEvpnMulticastMessage(item, ss_node,
route, nh_ip, vn, sg_list,
if (BuildEvpnMulticastMessage(item, ss_node, route, nh_ip, vn,
sg_list, communities,
label, tunnel_bmap, associate,
l2_route->FindPath(agent_->
local_peer()),
Expand All @@ -2173,15 +2182,16 @@ bool AgentXmppChannel::ControllerSendEvpnRouteCommon(AgentRoute *route,
ret |= BuildAndSendEvpnDom(item, ss_node,
route, associate);
} else if (agent_->tor_agent_enabled()) {
if (BuildTorMulticastMessage(item, ss_node, route, nh_ip,
vn, sg_list, label, tunnel_bmap,
destination, source,
if (BuildTorMulticastMessage(item, ss_node, route, nh_ip, vn,
sg_list, communities, label,
tunnel_bmap, destination, source,
associate) == false)
return false;;
ret = BuildAndSendEvpnDom(item, ss_node, route, associate);
} else {
if (BuildEvpnMulticastMessage(item, ss_node, route, nh_ip, vn, sg_list,
label, tunnel_bmap, associate,
if (BuildEvpnMulticastMessage(item, ss_node, route, nh_ip, vn,
sg_list, communities, label,
tunnel_bmap, associate,
l2_route->FindPath(agent_->
multicast_peer()),
false) == false)
Expand All @@ -2190,7 +2200,7 @@ bool AgentXmppChannel::ControllerSendEvpnRouteCommon(AgentRoute *route,
}
} else {
if (BuildEvpnUnicastMessage(item, ss_node, route, nh_ip, vn, sg_list,
label, tunnel_bmap, path_preference,
communities, label, tunnel_bmap, path_preference,
associate) == false)
return false;;
ret = BuildAndSendEvpnDom(item, ss_node, route, associate);
Expand Down Expand Up @@ -2303,6 +2313,7 @@ bool AgentXmppChannel::ControllerSendEvpnRouteAdd(AgentXmppChannel *peer,
uint32_t label,
uint32_t tunnel_bmap,
const SecurityGroupList *sg_list,
const CommunityList *communities,
const std::string &destination,
const std::string &source,
const PathPreference
Expand All @@ -2316,6 +2327,7 @@ bool AgentXmppChannel::ControllerSendEvpnRouteAdd(AgentXmppChannel *peer,
nh_ip,
vn,
sg_list,
communities,
label,
tunnel_bmap,
destination,
Expand All @@ -2341,6 +2353,7 @@ bool AgentXmppChannel::ControllerSendEvpnRouteDelete(AgentXmppChannel *peer,
&nh_ip,
vn,
NULL,
NULL,
label,
tunnel_bmap,
destination,
Expand All @@ -2356,6 +2369,7 @@ bool AgentXmppChannel::ControllerSendRouteAdd(AgentXmppChannel *peer,
uint32_t label,
TunnelType::TypeBmap bmap,
const SecurityGroupList *sg_list,
const CommunityList *communities,
Agent::RouteTableType type,
const PathPreference
&path_preference)
Expand All @@ -2371,14 +2385,14 @@ bool AgentXmppChannel::ControllerSendRouteAdd(AgentXmppChannel *peer,
if (((type == Agent::INET4_UNICAST) || (type == Agent::INET6_UNICAST)) &&
(peer->agent()->simulate_evpn_tor() == false)) {
ret = peer->ControllerSendV4V6UnicastRouteCommon(route, vn,
sg_list, label, bmap,
path_preference, true,
sg_list, communities, label,
bmap, path_preference, true,
type);
}
if (type == Agent::EVPN) {
ret = peer->ControllerSendEvpnRouteCommon(route, nexthop_ip, vn,
sg_list, label, bmap,
"", "",
sg_list, communities, label,
bmap, "", "",
path_preference, true);
}
return ret;
Expand All @@ -2390,6 +2404,7 @@ bool AgentXmppChannel::ControllerSendRouteDelete(AgentXmppChannel *peer,
uint32_t label,
TunnelType::TypeBmap bmap,
const SecurityGroupList *sg_list,
const CommunityList *communities,
Agent::RouteTableType type,
const PathPreference
&path_preference)
Expand All @@ -2405,17 +2420,17 @@ bool AgentXmppChannel::ControllerSendRouteDelete(AgentXmppChannel *peer,
if (((type == Agent::INET4_UNICAST) || (type == Agent::INET6_UNICAST)) &&
(peer->agent()->simulate_evpn_tor() == false)) {
ret = peer->ControllerSendV4V6UnicastRouteCommon(route, vn,
sg_list, label,
sg_list, communities,
label,
bmap,
path_preference,
false,
type);
}
if (type == Agent::EVPN) {
Ip4Address nh_ip(0);
ret = peer->ControllerSendEvpnRouteCommon(route, &nh_ip, vn, NULL,
label, bmap,
"", "",
ret = peer->ControllerSendEvpnRouteCommon(route, &nh_ip, vn, NULL, NULL,
label, bmap, "", "",
path_preference, false);
}
return ret;
Expand Down
8 changes: 8 additions & 0 deletions src/vnsw/agent/controller/controller_peer.h
Expand Up @@ -71,6 +71,7 @@ class AgentXmppChannel {
uint32_t label,
uint32_t tunnel_bmap,
const SecurityGroupList *sg_list,
const CommunityList *communities,
Agent::RouteTableType type,
const PathPreference &path_preference);
static bool ControllerSendEvpnRouteAdd(AgentXmppChannel *peer,
Expand All @@ -80,6 +81,7 @@ class AgentXmppChannel {
uint32_t mpls_label,
uint32_t tunnel_bmap,
const SecurityGroupList *sg_list,
const CommunityList *communities,
const std::string &destination,
const std::string &source,
const PathPreference &path_preference);
Expand All @@ -92,6 +94,7 @@ class AgentXmppChannel {
uint32_t label,
uint32_t tunnel_bmap,
const SecurityGroupList *sg_list,
const CommunityList *communities,
Agent::RouteTableType type,
const PathPreference &path_preference);
static bool ControllerSendEvpnRouteDelete(AgentXmppChannel *peer,
Expand Down Expand Up @@ -135,6 +138,7 @@ class AgentXmppChannel {
const Ip4Address *nexthop_ip,
std::string vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t mpls_label,
uint32_t tunnel_bmap,
const std::string &destination,
Expand Down Expand Up @@ -164,6 +168,7 @@ class AgentXmppChannel {
bool ControllerSendV4V6UnicastRouteCommon(AgentRoute *route,
const std::string &vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t mpls_label,
uint32_t tunnel_bmap,
const PathPreference &path_preference,
Expand All @@ -175,6 +180,7 @@ class AgentXmppChannel {
const Ip4Address *nh_ip,
const std::string &vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t label,
uint32_t tunnel_bmap,
const std::string &destination,
Expand All @@ -186,6 +192,7 @@ class AgentXmppChannel {
const Ip4Address *nh_ip,
const std::string &vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t label,
uint32_t tunnel_bmap,
bool associate,
Expand All @@ -197,6 +204,7 @@ class AgentXmppChannel {
const Ip4Address *nh_ip,
const std::string &vn,
const SecurityGroupList *sg_list,
const CommunityList *communities,
uint32_t label,
uint32_t tunnel_bmap,
const PathPreference &path_prefernce,
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/controller/controller_route_path.cc
Expand Up @@ -245,6 +245,7 @@ ControllerLocalVmRoute::ControllerLocalVmRoute(const VmInterfaceKey &intf,
uint64_t sequence_number,
const AgentXmppChannel *channel) :
LocalVmRoute(intf, mpls_label, vxlan_id, force_policy, vn_name, flags, sg_list,
CommunityList(),
path_preference, Ip4Address(0)),
sequence_number_(sequence_number), channel_(channel) { }

Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/openstack/instance_service_server.cc
Expand Up @@ -421,6 +421,7 @@ InstanceServiceAsyncHandler::AddLocalVmRoute(const std::string& ip_address,
agent_->fabric_inet4_unicast_table()->
AddLocalVmRouteReq(novaPeer_.get(), vrf, ip.to_v4(), 32, intf_uuid,
"instance-service", mpls_label, SecurityGroupList(),
CommunityList(),
false, PathPreference(), Ip4Address(0));
return true;
}
Expand Down
7 changes: 7 additions & 0 deletions src/vnsw/agent/oper/agent_path.cc
Expand Up @@ -593,6 +593,7 @@ bool LocalVmRoute::AddChangePath(Agent *agent, AgentPath *path,
bool ret = false;
NextHop *nh = NULL;
SecurityGroupList path_sg_list;
CommunityList path_communities;

//TODO Based on key table type pick up interface
VmInterfaceKey intf_key(AgentKey::ADD_DEL_CHANGE, intf_.uuid_, "");
Expand Down Expand Up @@ -649,6 +650,12 @@ bool LocalVmRoute::AddChangePath(Agent *agent, AgentPath *path,
ret = true;
}

path_communities = path->communities();
if (path_communities != communities_) {
path->set_communities(communities_);
ret = true;
}

//Priority and sequence no of path are updated from path
//preference state machine
//Path preference value enqueued here would be copied
Expand Down

0 comments on commit bcefae6

Please sign in to comment.