diff --git a/src/vnsw/agent/cmn/agent.h b/src/vnsw/agent/cmn/agent.h index b95796ab61d..eea6184814e 100644 --- a/src/vnsw/agent/cmn/agent.h +++ b/src/vnsw/agent/cmn/agent.h @@ -125,6 +125,7 @@ void intrusive_ptr_add_ref(const PhysicalDeviceVn *p); //class SecurityGroup; typedef std::vector SecurityGroupList; +typedef std::vector CommunityList; class AgentDBTable; class InterfaceTable; diff --git a/src/vnsw/agent/controller/controller_export.cc b/src/vnsw/agent/controller/controller_export.cc index 0212f39ebd1..deeaef38be0 100644 --- a/src/vnsw/agent/controller/controller_export.cc +++ b/src/vnsw/agent/controller/controller_export.cc @@ -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; @@ -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(); } @@ -172,7 +176,8 @@ void RouteExport::UnicastNotify(AgentXmppChannel *bgp_xmpp_peer, AgentXmppChannel::ControllerSendRouteAdd(bgp_xmpp_peer, static_cast(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 { @@ -181,7 +186,7 @@ void RouteExport::UnicastNotify(AgentXmppChannel *bgp_xmpp_peer, static_cast(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; } @@ -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()); } } diff --git a/src/vnsw/agent/controller/controller_export.h b/src/vnsw/agent/controller/controller_export.h index c70d8d8b305..02c37968b5a 100644 --- a/src/vnsw/agent/controller/controller_export.h +++ b/src/vnsw/agent/controller/controller_export.h @@ -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. diff --git a/src/vnsw/agent/controller/controller_peer.cc b/src/vnsw/agent/controller/controller_peer.cc index b56f056a2c7..8b83a81c96a 100644 --- a/src/vnsw/agent/controller/controller_peer.cc +++ b/src/vnsw/agent/controller/controller_peer.cc @@ -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, @@ -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; @@ -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, @@ -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, @@ -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 @@ -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, @@ -2163,8 +2172,8 @@ bool AgentXmppChannel::ControllerSendEvpnRouteCommon(AgentRoute *route, dynamic_cast(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()), @@ -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) @@ -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); @@ -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 @@ -2316,6 +2327,7 @@ bool AgentXmppChannel::ControllerSendEvpnRouteAdd(AgentXmppChannel *peer, nh_ip, vn, sg_list, + communities, label, tunnel_bmap, destination, @@ -2341,6 +2353,7 @@ bool AgentXmppChannel::ControllerSendEvpnRouteDelete(AgentXmppChannel *peer, &nh_ip, vn, NULL, + NULL, label, tunnel_bmap, destination, @@ -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) @@ -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; @@ -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) @@ -2405,7 +2420,8 @@ 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, @@ -2413,9 +2429,8 @@ bool AgentXmppChannel::ControllerSendRouteDelete(AgentXmppChannel *peer, } 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; diff --git a/src/vnsw/agent/controller/controller_peer.h b/src/vnsw/agent/controller/controller_peer.h index d318fd785eb..8119026f805 100644 --- a/src/vnsw/agent/controller/controller_peer.h +++ b/src/vnsw/agent/controller/controller_peer.h @@ -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, @@ -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); @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/src/vnsw/agent/controller/controller_route_path.cc b/src/vnsw/agent/controller/controller_route_path.cc index 51017fb6909..2d2c8db1e81 100644 --- a/src/vnsw/agent/controller/controller_route_path.cc +++ b/src/vnsw/agent/controller/controller_route_path.cc @@ -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) { } diff --git a/src/vnsw/agent/openstack/instance_service_server.cc b/src/vnsw/agent/openstack/instance_service_server.cc index 35db048d997..654b390062d 100644 --- a/src/vnsw/agent/openstack/instance_service_server.cc +++ b/src/vnsw/agent/openstack/instance_service_server.cc @@ -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; } diff --git a/src/vnsw/agent/oper/agent_path.cc b/src/vnsw/agent/oper/agent_path.cc index c82b0040331..ff797526df2 100644 --- a/src/vnsw/agent/oper/agent_path.cc +++ b/src/vnsw/agent/oper/agent_path.cc @@ -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_, ""); @@ -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 diff --git a/src/vnsw/agent/oper/agent_path.h b/src/vnsw/agent/oper/agent_path.h index 1892769af04..b71964d7bc6 100644 --- a/src/vnsw/agent/oper/agent_path.h +++ b/src/vnsw/agent/oper/agent_path.h @@ -168,6 +168,7 @@ class AgentPath : public Path { virtual bool IsLess(const AgentPath &right) const; const SecurityGroupList &sg_list() const {return sg_list_;} + const CommunityList &communities() const {return communities_;} const std::string &dest_vn_name() const {return dest_vn_name_;} uint32_t GetActiveLabel() const; NextHop *nexthop() const; @@ -199,7 +200,9 @@ class AgentPath : public Path { void set_tunnel_bmap(TunnelType::TypeBmap bmap) {tunnel_bmap_ = bmap;} void set_tunnel_type(TunnelType::Type type) {tunnel_type_ = type;} void set_sg_list(const SecurityGroupList &sg) {sg_list_ = sg;} + void set_communities(const CommunityList &communities) {communities_ = communities;} void clear_sg_list() { sg_list_.clear(); } + void clear_communities() { communities_.clear(); } void set_tunnel_dest(const Ip4Address &tunnel_dest) { tunnel_dest_ = tunnel_dest; } @@ -282,6 +285,7 @@ class AgentPath : public Path { // Use nexthop with policy irrespective of interface configuration bool force_policy_; SecurityGroupList sg_list_; + CommunityList communities_; // tunnel destination address Ip4Address tunnel_dest_; @@ -426,12 +430,14 @@ class LocalVmRoute : public AgentRouteData { LocalVmRoute(const VmInterfaceKey &intf, uint32_t mpls_label, uint32_t vxlan_id, bool force_policy, const string &vn_name, uint8_t flags, const SecurityGroupList &sg_list, + const CommunityList &communities, const PathPreference &path_preference, const IpAddress &subnet_gw_ip) : AgentRouteData(false), intf_(intf), mpls_label_(mpls_label), vxlan_id_(vxlan_id), force_policy_(force_policy), dest_vn_name_(vn_name), proxy_arp_(false), sync_route_(false), - flags_(flags), sg_list_(sg_list), tunnel_bmap_(TunnelType::MplsType()), + flags_(flags), sg_list_(sg_list), communities_(communities), + tunnel_bmap_(TunnelType::MplsType()), path_preference_(path_preference), subnet_gw_ip_(subnet_gw_ip) { } virtual ~LocalVmRoute() { } @@ -439,6 +445,7 @@ class LocalVmRoute : public AgentRouteData { virtual std::string ToString() const {return "local VM";} virtual bool AddChangePath(Agent *agent, AgentPath *path, const AgentRoute *rt); + const CommunityList &communities() const {return communities_;} const SecurityGroupList &sg_list() const {return sg_list_;} void set_tunnel_bmap(TunnelType::TypeBmap bmap) {tunnel_bmap_ = bmap;} const PathPreference& path_preference() const { return path_preference_;} @@ -459,6 +466,7 @@ class LocalVmRoute : public AgentRouteData { bool sync_route_; uint8_t flags_; SecurityGroupList sg_list_; + CommunityList communities_; TunnelType::TypeBmap tunnel_bmap_; PathPreference path_preference_; IpAddress subnet_gw_ip_; @@ -655,9 +663,10 @@ class Inet4UnicastGatewayRoute : public AgentRouteData { Inet4UnicastGatewayRoute(const Ip4Address &gw_ip, const std::string &vrf_name, const std::string &vn_name, - uint32_t label, const SecurityGroupList &sg) : + uint32_t label, const SecurityGroupList &sg, + const CommunityList &communities) : AgentRouteData(false), gw_ip_(gw_ip), vrf_name_(vrf_name), - vn_name_(vn_name), mpls_label_(label), sg_list_(sg) { + vn_name_(vn_name), mpls_label_(label), sg_list_(sg), communities_(communities) { } virtual ~Inet4UnicastGatewayRoute() { } virtual bool AddChangePath(Agent *agent, AgentPath *path, @@ -670,6 +679,7 @@ class Inet4UnicastGatewayRoute : public AgentRouteData { std::string vn_name_; uint32_t mpls_label_; const SecurityGroupList sg_list_; + const CommunityList communities_; DISALLOW_COPY_AND_ASSIGN(Inet4UnicastGatewayRoute); }; diff --git a/src/vnsw/agent/oper/evpn_route.cc b/src/vnsw/agent/oper/evpn_route.cc index 25625823abd..9d5df225385 100644 --- a/src/vnsw/agent/oper/evpn_route.cc +++ b/src/vnsw/agent/oper/evpn_route.cc @@ -210,7 +210,8 @@ void EvpnAgentRouteTable::AddLocalVmRoute(const Peer *peer, intf->vxlan_id(), false, vn_name, InterfaceNHFlags::BRIDGE, - sg_id_list, path_pref, + sg_id_list, CommunityList(), + path_pref, IpAddress()); data->set_tunnel_bmap(TunnelType::AllType()); diff --git a/src/vnsw/agent/oper/inet_interface.cc b/src/vnsw/agent/oper/inet_interface.cc index 0ff313c33e9..607a28cb7d2 100644 --- a/src/vnsw/agent/oper/inet_interface.cc +++ b/src/vnsw/agent/oper/inet_interface.cc @@ -166,7 +166,8 @@ static void AddDefaultRoute(Agent *agent, InetUnicastAgentRouteTable *table, table->AddGatewayRoute(agent->local_peer(), vrf->GetName(), Ip4Address(0), 0, gw, vn_name, - MplsTable::kInvalidLabel, SecurityGroupList()); + MplsTable::kInvalidLabel, SecurityGroupList(), + CommunityList()); return; } diff --git a/src/vnsw/agent/oper/inet_unicast_route.cc b/src/vnsw/agent/oper/inet_unicast_route.cc index 8e693d057b4..fcd0c0c7f90 100644 --- a/src/vnsw/agent/oper/inet_unicast_route.cc +++ b/src/vnsw/agent/oper/inet_unicast_route.cc @@ -802,6 +802,12 @@ bool Inet4UnicastGatewayRoute::AddChangePath(Agent *agent, AgentPath *path, path->set_sg_list(sg_list_); } + CommunityList path_communities; + path_communities = path->communities(); + if (path_communities != communities_) { + path->set_communities(communities_); + } + //Reset to new gateway route, no nexthop for indirect route path->set_gw_ip(gw_ip_); path->ResetDependantRoute(rt); @@ -1099,6 +1105,7 @@ InetUnicastAgentRouteTable::AddLocalVmRouteReq(const Peer *peer, const string &vn_name, uint32_t label, const SecurityGroupList &sg_list, + const CommunityList &communities, bool force_policy, const PathPreference &path_preference, @@ -1107,7 +1114,7 @@ InetUnicastAgentRouteTable::AddLocalVmRouteReq(const Peer *peer, LocalVmRoute *data = new LocalVmRoute(intf_key, label, VxLanTable::kInvalidvxlan_id, force_policy, vn_name, InterfaceNHFlags::INET4, sg_list, - path_preference, subnet_gw_ip); + communities, path_preference, subnet_gw_ip); AddLocalVmRouteReq(peer, vm_vrf, addr, plen, data); } @@ -1135,6 +1142,7 @@ InetUnicastAgentRouteTable::AddLocalVmRoute(const Peer *peer, const string &vn_name, uint32_t label, const SecurityGroupList &sg_list, + const CommunityList &communities, bool force_policy, const PathPreference &path_preference, @@ -1145,7 +1153,7 @@ InetUnicastAgentRouteTable::AddLocalVmRoute(const Peer *peer, VmInterfaceKey intf_key(AgentKey::ADD_DEL_CHANGE, intf_uuid, ""); req.data.reset(new LocalVmRoute(intf_key, label, VxLanTable::kInvalidvxlan_id, force_policy, vn_name, - InterfaceNHFlags::INET4, sg_list, + InterfaceNHFlags::INET4, sg_list, communities, path_preference, subnet_gw_ip)); InetUnicastTableProcess(Agent::GetInstance(), vm_vrf, req); } @@ -1400,12 +1408,14 @@ static void AddGatewayRouteInternal(const Peer *peer, const Ip4Address &dst_addr, uint8_t plen, const Ip4Address &gw_ip, const string &vn_name, uint32_t label, - const SecurityGroupList &sg_list) { + const SecurityGroupList &sg_list, + const CommunityList &communities) { req->oper = DBRequest::DB_ENTRY_ADD_CHANGE; req->key.reset(new InetUnicastRouteKey(peer, vrf_name, dst_addr, plen)); req->data.reset(new Inet4UnicastGatewayRoute(gw_ip, vrf_name, - vn_name, label, sg_list)); + vn_name, label, sg_list, + communities)); } void InetUnicastAgentRouteTable::AddGatewayRoute(const Peer *peer, @@ -1416,10 +1426,12 @@ void InetUnicastAgentRouteTable::AddGatewayRoute(const Peer *peer, const string &vn_name, uint32_t label, const SecurityGroupList - &sg_list) { + &sg_list, + const CommunityList + &communities) { DBRequest req; AddGatewayRouteInternal(peer, &req, vrf_name, dst_addr, plen, gw_ip, vn_name, - label, sg_list); + label, sg_list, communities); Inet4UnicastTableProcess(Agent::GetInstance(), vrf_name, req); } @@ -1432,10 +1444,12 @@ InetUnicastAgentRouteTable::AddGatewayRouteReq(const Peer *peer, const string &vn_name, uint32_t label, const SecurityGroupList - &sg_list) { + &sg_list, + const CommunityList + &communities) { DBRequest req; AddGatewayRouteInternal(peer, &req, vrf_name, dst_addr, plen, gw_ip, - vn_name, label, sg_list); + vn_name, label, sg_list, communities); Inet4UnicastTableEnqueue(Agent::GetInstance(), &req); } diff --git a/src/vnsw/agent/oper/inet_unicast_route.h b/src/vnsw/agent/oper/inet_unicast_route.h index ff6e49a5c7d..d42249537b7 100644 --- a/src/vnsw/agent/oper/inet_unicast_route.h +++ b/src/vnsw/agent/oper/inet_unicast_route.h @@ -203,6 +203,7 @@ class InetUnicastAgentRouteTable : public AgentRouteTable { const uuid &intf_uuid, const string &vn_name, uint32_t label, const SecurityGroupList &sg_list, + const CommunityList &communities, bool force_policy, const PathPreference &path_preference, const IpAddress &subnet_gw_ip); @@ -211,6 +212,7 @@ class InetUnicastAgentRouteTable : public AgentRouteTable { const uuid &intf_uuid, const string &vn_name, uint32_t label, const SecurityGroupList &sg_list, + const CommunityList &communities, bool force_policy, const PathPreference &path_preference, const IpAddress &subnet_gw_ip); @@ -293,13 +295,15 @@ class InetUnicastAgentRouteTable : public AgentRouteTable { const Ip4Address &dst_addr,uint8_t plen, const Ip4Address &gw_ip, const std::string &vn_name, uint32_t label, - const SecurityGroupList &sg_list); + const SecurityGroupList &sg_list, + const CommunityList &communities); static void AddGatewayRouteReq(const Peer *peer, const string &vrf_name, const Ip4Address &dst_addr,uint8_t plen, const Ip4Address &gw_ip, const std::string &vn_name, uint32_t label, - const SecurityGroupList &sg_list); + const SecurityGroupList &sg_list, + const CommunityList &communities); void AddIpamSubnetRoute(const string &vm_vrf, const IpAddress &addr, uint8_t plen, const std::string &vn_name); void AddInterfaceRouteReq(Agent *agent, const Peer *peer, diff --git a/src/vnsw/agent/oper/test/test_inet_interface.cc b/src/vnsw/agent/oper/test/test_inet_interface.cc index 910d026b84b..43e7d35de1e 100644 --- a/src/vnsw/agent/oper/test/test_inet_interface.cc +++ b/src/vnsw/agent/oper/test/test_inet_interface.cc @@ -318,7 +318,8 @@ static void RestoreInetConfig(Agent *agent) { table->AddGatewayRouteReq(agent->local_peer(), agent->fabric_vrf_name(), Ip4Address(0), 0, param->vhost_gw(), agent->fabric_vrf_name(), - MplsTable::kInvalidLabel, SecurityGroupList()); + MplsTable::kInvalidLabel, SecurityGroupList(), + CommunityList()); client->WaitForIdle(); } diff --git a/src/vnsw/agent/oper/test/test_intf.cc b/src/vnsw/agent/oper/test/test_intf.cc index 3b45d485552..6bbfa564a04 100644 --- a/src/vnsw/agent/oper/test/test_intf.cc +++ b/src/vnsw/agent/oper/test/test_intf.cc @@ -1978,6 +1978,115 @@ TEST_F(IntfTest, IntfStaticRoute) { EXPECT_FALSE(VmPortFind(1)); } +//Add and delete static route with community +TEST_F(IntfTest, IntfStaticRouteWithCommunity) { + struct PortInfo input[] = { + {"vnet1", 1, "1.1.1.10", "00:00:00:01:01:01", 1, 1}, + }; + + client->Reset(); + CreateVmportEnv(input, 1); + client->WaitForIdle(); + EXPECT_TRUE(VmPortActive(input, 0)); + + //Add a static route + struct TestIp4Prefix static_route[] = { + { Ip4Address::from_string("24.1.1.0"), 24}, + { Ip4Address::from_string("16.1.1.0"), 16}, + }; + + std::vector communities = list_of("no-advertise")("64512:9999"); + AddInterfaceRouteTable("static_route", 1, static_route, 2, NULL, communities); + AddLink("virtual-machine-interface", "vnet1", + "interface-route-table", "static_route"); + client->WaitForIdle(); + EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, + static_route[0].plen_)); + EXPECT_TRUE(RouteFind("vrf1", static_route[1].addr_, + static_route[1].plen_)); + InetUnicastRouteEntry *rt = + RouteGet("vrf1", static_route[0].addr_, static_route[0].plen_); + EXPECT_TRUE(rt != NULL); + const AgentPath *path = rt->GetActivePath(); + EXPECT_TRUE(path != NULL); + EXPECT_EQ(path->communities().size(), 2); + EXPECT_EQ(path->communities(), communities); + + DoInterfaceSandesh("vnet1"); + client->WaitForIdle(); + + //Delete the link between interface and route table + DelLink("virtual-machine-interface", "vnet1", + "interface-route-table", "static_route"); + client->WaitForIdle(); + EXPECT_FALSE(RouteFind("vrf1", static_route[0].addr_, + static_route[0].plen_)); + EXPECT_FALSE(RouteFind("vrf1", static_route[1].addr_, + static_route[1].plen_)); + DoInterfaceSandesh("vnet1"); + client->WaitForIdle(); + + DelLink("virtual-machine-interface", "vnet1", + "interface-route-table", "static_route"); + DeleteVmportEnv(input, 1, true); + client->WaitForIdle(); + EXPECT_FALSE(VmPortFind(1)); +} + +//Add and delete static route with community with nexthop +TEST_F(IntfTest, IntfStaticRouteWithCommunityWithNexthop) { + struct PortInfo input[] = { + {"vnet1", 1, "1.1.1.10", "00:00:00:01:01:01", 1, 1}, + }; + + client->Reset(); + CreateVmportEnv(input, 1); + client->WaitForIdle(); + EXPECT_TRUE(VmPortActive(input, 0)); + + //Add a static route + struct TestIp4Prefix static_route[] = { + { Ip4Address::from_string("24.1.1.0"), 24}, + { Ip4Address::from_string("16.1.1.0"), 16}, + }; + + std::vector communities = list_of("no-advertise")("64512:9999"); + AddInterfaceRouteTable("static_route", 1, static_route, 2, "1.1.1.2", communities); + AddLink("virtual-machine-interface", "vnet1", + "interface-route-table", "static_route"); + client->WaitForIdle(); + EXPECT_TRUE(RouteFind("vrf1", static_route[0].addr_, + static_route[0].plen_)); + EXPECT_TRUE(RouteFind("vrf1", static_route[1].addr_, + static_route[1].plen_)); + + InetUnicastRouteEntry *rt = + RouteGet("vrf1", static_route[0].addr_, static_route[0].plen_); + EXPECT_TRUE(rt != NULL); + const AgentPath *path = rt->GetActivePath(); + EXPECT_TRUE(path != NULL); + EXPECT_EQ(path->communities().size(), 2); + EXPECT_EQ(path->communities(), communities); + DoInterfaceSandesh("vnet1"); + client->WaitForIdle(); + + //Delete the link between interface and route table + DelLink("virtual-machine-interface", "vnet1", + "interface-route-table", "static_route"); + client->WaitForIdle(); + EXPECT_FALSE(RouteFind("vrf1", static_route[0].addr_, + static_route[0].plen_)); + EXPECT_FALSE(RouteFind("vrf1", static_route[1].addr_, + static_route[1].plen_)); + DoInterfaceSandesh("vnet1"); + client->WaitForIdle(); + + DelLink("virtual-machine-interface", "vnet1", + "interface-route-table", "static_route"); + DeleteVmportEnv(input, 1, true); + client->WaitForIdle(); + EXPECT_FALSE(VmPortFind(1)); +} //Add static route, deactivate interface and make static routes are deleted TEST_F(IntfTest, IntfStaticRoute_1) { struct PortInfo input[] = { diff --git a/src/vnsw/agent/oper/vm_interface.cc b/src/vnsw/agent/oper/vm_interface.cc index d230c18a1d8..066d0902064 100644 --- a/src/vnsw/agent/oper/vm_interface.cc +++ b/src/vnsw/agent/oper/vm_interface.cc @@ -291,7 +291,8 @@ static void BuildStaticRouteList(VmInterfaceConfigData *data, IFMapNode *node) { if (add) { data->static_route_list_.list_.insert - (VmInterface::StaticRoute(data->vrf_name_, ip, plen, gw)); + (VmInterface::StaticRoute(data->vrf_name_, ip, plen, gw, + it->community_attributes.community_attribute)); } } } @@ -2486,7 +2487,8 @@ void VmInterface::UpdateIpv4InterfaceRoute(bool old_ipv4_active, bool force_upda old_addr != primary_ip_addr_ || vm_ip_gw_addr_ != ip) { vm_ip_gw_addr_ = ip; AddRoute(vrf_->GetName(), primary_ip_addr_, 32, vn_->GetName(), - policy_enabled_, ecmp_, vm_ip_gw_addr_, Ip4Address(0)); + policy_enabled_, ecmp_, vm_ip_gw_addr_, Ip4Address(0), + CommunityList()); } else if (policy_change == true) { // If old-l3-active and there is change in policy, invoke RESYNC of // route to account for change in NH policy @@ -2534,8 +2536,8 @@ void VmInterface::UpdateIpv6InterfaceRoute(bool old_ipv6_active, bool force_upda //TODO: change subnet_gw_ip to Ip6Address InetUnicastAgentRouteTable::AddLocalVmRoute (peer_.get(), vrf_->GetName(), primary_ip6_addr_, 128, GetUuid(), - vn_->GetName(), label_, sg_id_list, false, path_preference, - vm_ip6_gw_addr_); + vn_->GetName(), label_, sg_id_list, CommunityList(), false, + path_preference, vm_ip6_gw_addr_); } else if (policy_change == true) { // If old-l3-active and there is change in policy, invoke RESYNC of // route to account for change in NH policy @@ -2620,8 +2622,8 @@ void VmInterface::UpdateMetadataRoute(bool old_ipv4_active, VrfEntry *old_vrf) { InetUnicastAgentRouteTable::AddLocalVmRoute (agent->link_local_peer(), agent->fabric_vrf_name(), mdata_addr_, - 32, GetUuid(), vn_->GetName(), label_, SecurityGroupList(), true, - path_preference, Ip4Address(0)); + 32, GetUuid(), vn_->GetName(), label_, SecurityGroupList(), + CommunityList(), true, path_preference, Ip4Address(0)); } // Delete meta-data route @@ -3075,7 +3077,8 @@ void VmInterface::SetPathPreference(PathPreference *pref, bool ecmp, void VmInterface::AddRoute(const std::string &vrf_name, const IpAddress &addr, uint32_t plen, const std::string &dest_vn, bool policy, bool ecmp, const IpAddress &gw_ip, - const IpAddress &dependent_rt) { + const IpAddress &dependent_rt, + const CommunityList &communities) { SecurityGroupList sg_id_list; CopySgIdList(&sg_id_list); @@ -3085,7 +3088,7 @@ void VmInterface::AddRoute(const std::string &vrf_name, const IpAddress &addr, InetUnicastAgentRouteTable::AddLocalVmRoute(peer_.get(), vrf_name, addr, plen, GetUuid(), dest_vn, label_, - sg_id_list, false, + sg_id_list, communities, false, path_preference, gw_ip); return; } @@ -3213,11 +3216,13 @@ void VmInterface::InstanceIp::L3Activate(VmInterface *interface, if (ip_.is_v4()) { interface->AddRoute(interface->vrf()->GetName(), ip_.to_v4(), 32, interface->vn()->GetName(), true, ecmp_, - interface->GetGateway(ip_), Ip4Address(0)); + interface->GetGateway(ip_), Ip4Address(0), + CommunityList()); } else if (ip_.is_v6()) { interface->AddRoute(interface->vrf()->GetName(), ip_.to_v6(), 128, interface->vn()->GetName(), true, ecmp_, - interface->GetGateway(ip_), Ip6Address()); + interface->GetGateway(ip_), Ip6Address(), + CommunityList()); } installed_ = true; } @@ -3386,7 +3391,7 @@ void VmInterface::FloatingIp::L3Activate(VmInterface *interface, if (floating_ip_.is_v4()) { interface->AddRoute(vrf_.get()->GetName(), floating_ip_.to_v4(), 32, vn_->GetName(), true, interface->ecmp(), Ip4Address(0), - GetFixedIp(interface)); + GetFixedIp(interface), CommunityList()); if (table->update_floatingip_cb().empty() == false) { table->update_floatingip_cb()(interface, vn_.get(), floating_ip_.to_v4(), false); @@ -3394,7 +3399,8 @@ void VmInterface::FloatingIp::L3Activate(VmInterface *interface, } else if (floating_ip_.is_v6()) { interface->AddRoute(vrf_.get()->GetName(), floating_ip_.to_v6(), 128, vn_->GetName(), true, interface->ecmp6(), - Ip6Address(), GetFixedIp(interface)); + Ip6Address(), GetFixedIp(interface), + CommunityList()); //TODO:: callback for DNS handling } @@ -3532,18 +3538,21 @@ void VmInterface::FloatingIpList::Remove(FloatingIpSet::iterator &it) { // StaticRoute routines ///////////////////////////////////////////////////////////////////////////// VmInterface::StaticRoute::StaticRoute() : - ListEntry(), vrf_(""), addr_(), plen_(0), gw_() { + ListEntry(), vrf_(""), addr_(), plen_(0), gw_(), communities_() { } VmInterface::StaticRoute::StaticRoute(const StaticRoute &rhs) : ListEntry(rhs.installed_, rhs.del_pending_), vrf_(rhs.vrf_), - addr_(rhs.addr_), plen_(rhs.plen_), gw_(rhs.gw_) { + addr_(rhs.addr_), plen_(rhs.plen_), gw_(rhs.gw_), + communities_(rhs.communities_) { } VmInterface::StaticRoute::StaticRoute(const std::string &vrf, const IpAddress &addr, - uint32_t plen, const IpAddress &gw) : - ListEntry(), vrf_(vrf), addr_(addr), plen_(plen), gw_(gw) { + uint32_t plen, const IpAddress &gw, + const CommunityList &communities) : + ListEntry(), vrf_(vrf), addr_(addr), plen_(plen), gw_(gw), + communities_(communities) { } VmInterface::StaticRoute::~StaticRoute() { @@ -3593,7 +3602,7 @@ void VmInterface::StaticRoute::Activate(VmInterface *interface, vrf_, addr_.to_v4(), plen_, gw_.to_v4(), interface->vn_->GetName(), interface->vrf_->table_label(), - sg_id_list); + sg_id_list, communities_); } else { IpAddress dependent_ip; bool ecmp = false; @@ -3607,7 +3616,7 @@ void VmInterface::StaticRoute::Activate(VmInterface *interface, interface->AddRoute(vrf_, addr_, plen_, interface->vn_->GetName(), interface->policy_enabled(), - ecmp, IpAddress(), dependent_ip); + ecmp, IpAddress(), dependent_ip, communities_); } } @@ -3810,7 +3819,7 @@ void VmInterface::AllowedAddressPair::Activate(VmInterface *interface, } interface->AddRoute(vrf_, addr_, plen_, interface->vn_->GetName(), interface->policy_enabled(), - ecmp_, gw_ip_, dependent_rt); + ecmp_, gw_ip_, dependent_rt, CommunityList()); } installed_ = true; } diff --git a/src/vnsw/agent/oper/vm_interface.h b/src/vnsw/agent/oper/vm_interface.h index 43527f25f9c..c4fd377cf84 100644 --- a/src/vnsw/agent/oper/vm_interface.h +++ b/src/vnsw/agent/oper/vm_interface.h @@ -183,7 +183,8 @@ class VmInterface : public Interface { StaticRoute(); StaticRoute(const StaticRoute &rhs); StaticRoute(const std::string &vrf, const IpAddress &addr, - uint32_t plen, const IpAddress &gw); + uint32_t plen, const IpAddress &gw, + const CommunityList &communities); virtual ~StaticRoute(); bool operator() (const StaticRoute &lhs, const StaticRoute &rhs) const; @@ -196,6 +197,7 @@ class VmInterface : public Interface { IpAddress addr_; uint32_t plen_; IpAddress gw_; + CommunityList communities_; }; typedef std::set StaticRouteSet; @@ -575,7 +577,8 @@ class VmInterface : public Interface { void AddRoute(const std::string &vrf_name, const IpAddress &ip, uint32_t plen, const std::string &vn_name, bool policy, bool ecmp, const IpAddress &gw_ip, - const IpAddress &dependent_ip); + const IpAddress &dependent_ip, + const CommunityList &communties); void DeleteRoute(const std::string &vrf_name, const IpAddress &ip, uint32_t plen); void ResolveRoute(const std::string &vrf_name, const Ip4Address &addr, diff --git a/src/vnsw/agent/pkt/test/test_flowtable.cc b/src/vnsw/agent/pkt/test/test_flowtable.cc index d8a81310399..f1064c95e7a 100644 --- a/src/vnsw/agent/pkt/test/test_flowtable.cc +++ b/src/vnsw/agent/pkt/test/test_flowtable.cc @@ -119,7 +119,7 @@ class FlowTableTest : public ::testing::Test { Agent::GetInstance()->fabric_inet4_unicast_table()-> AddLocalVmRouteReq(NULL, vrf, addr, 32, intf->GetUuid(), intf->vn()->GetName(), label, - SecurityGroupList(), false, PathPreference(), + SecurityGroupList(), CommunityList(), false, PathPreference(), Ip4Address(0)); client->WaitForIdle(); EXPECT_TRUE(RouteFind(vrf, addr, 32)); diff --git a/src/vnsw/agent/pkt/test/test_pkt_fip.cc b/src/vnsw/agent/pkt/test/test_pkt_fip.cc index 4fed483b927..efce52dc4da 100644 --- a/src/vnsw/agent/pkt/test/test_pkt_fip.cc +++ b/src/vnsw/agent/pkt/test/test_pkt_fip.cc @@ -314,7 +314,7 @@ static void Setup() { vnet[3]->GetUuid(), vnet[3]->vn()->GetName(), vnet[3]->label(), - SecurityGroupList(), 0, + SecurityGroupList(), CommunityList(), 0, PathPreference(), Ip4Address(0)); client->WaitForIdle(); EXPECT_TRUE(RouteFind("default-project:vn2:vn2", addr, 32)); @@ -1295,7 +1295,8 @@ TEST_F(FlowTest, FIP_traffic_to_leaked_routes) { vnet[5]->primary_ip_addr(), 32, vnet[5]->GetUuid(), vnet[5]->vn()->GetName(), - vnet[5]->label(), SecurityGroupList(), 0, + vnet[5]->label(), SecurityGroupList(), + CommunityList(), 0, PathPreference(), Ip4Address(0)); client->WaitForIdle(); diff --git a/src/vnsw/agent/pkt/test/test_pkt_flow.cc b/src/vnsw/agent/pkt/test/test_pkt_flow.cc index b4e4f359f57..f040f7a3d8e 100644 --- a/src/vnsw/agent/pkt/test/test_pkt_flow.cc +++ b/src/vnsw/agent/pkt/test/test_pkt_flow.cc @@ -131,8 +131,8 @@ class FlowTest : public ::testing::Test { agent()->fabric_inet4_unicast_table()-> AddLocalVmRouteReq(agent()->local_peer(), vrf, addr, 32, intf->GetUuid(), intf->vn()->GetName(), label, - SecurityGroupList(), false, PathPreference(), - Ip4Address(0)); + SecurityGroupList(), CommunityList(), false, + PathPreference(), Ip4Address(0)); client->WaitForIdle(); EXPECT_TRUE(RouteFind(vrf, addr, 32)); } diff --git a/src/vnsw/agent/pkt/test/test_pkt_flowv6.cc b/src/vnsw/agent/pkt/test/test_pkt_flowv6.cc index be400f485e8..d1060bd472e 100644 --- a/src/vnsw/agent/pkt/test/test_pkt_flowv6.cc +++ b/src/vnsw/agent/pkt/test/test_pkt_flowv6.cc @@ -62,7 +62,7 @@ class FlowTestV6 : public ::testing::Test { rt_table->AddLocalVmRouteReq(agent()->local_peer(), vrf, addr, 128, intf->GetUuid(), intf->vn()->GetName(), label, - SecurityGroupList(), false, + SecurityGroupList(), CommunityList(), false, PathPreference(), Ip6Address()); client->WaitForIdle(); diff --git a/src/vnsw/agent/pkt/test/test_sg_flow.cc b/src/vnsw/agent/pkt/test/test_sg_flow.cc index 8ea32b37ea7..e42abd341dd 100644 --- a/src/vnsw/agent/pkt/test/test_sg_flow.cc +++ b/src/vnsw/agent/pkt/test/test_sg_flow.cc @@ -551,7 +551,7 @@ TEST_F(SgTest, Fwd_Sg_Change_2) { Agent::GetInstance()->fabric_inet4_unicast_table()-> AddLocalVmRouteReq(bgp_peer_, "vrf1", vm_ip, 32, vm_intf->GetUuid(), "vn1", vm_intf->label(), - sg_list, false, PathPreference(), Ip4Address(0)); + sg_list, CommunityList(), false, PathPreference(), Ip4Address(0)); client->WaitForIdle(); //Packet egress from vnet2, so that its the first entry in flow route map @@ -568,7 +568,8 @@ TEST_F(SgTest, Fwd_Sg_Change_2) { Agent::GetInstance()->fabric_inet4_unicast_table()-> AddLocalVmRouteReq(bgp_peer_, "vrf1", vm_ip, 32, vm_intf->GetUuid(), "vn1", vm_intf->label(), - SecurityGroupList(), false, PathPreference(), Ip4Address(0)); + SecurityGroupList(), CommunityList(), false, PathPreference(), + Ip4Address(0)); client->WaitForIdle(); FlowEntry *fe = FlowGet(vnet[1]->vrf()->vrf_id(), vnet_addr[1], @@ -615,7 +616,8 @@ TEST_F(SgTest, Fwd_Sg_Change_3) { Agent::GetInstance()->fabric_inet4_unicast_table()-> AddLocalVmRouteReq(bgp_peer_, "vrf1", vm_ip, 32, vm_intf->GetUuid(), "vn1", vm_intf->label(), - SecurityGroupList(), false, PathPreference(), Ip4Address(0)); + SecurityGroupList(), CommunityList(), false, PathPreference(), + Ip4Address(0)); client->WaitForIdle(); TxIpPacket(vnet[1]->id(), vnet_addr[1], vnet_addr[2], 1); @@ -639,7 +641,8 @@ TEST_F(SgTest, Fwd_Sg_Change_3) { Agent::GetInstance()->fabric_inet4_unicast_table()-> AddLocalVmRouteReq(bgp_peer_, "vrf1", vm_ip, 32, vm_intf->GetUuid(), "vn1", vm_intf->label(), - sg_list, false, PathPreference(), Ip4Address(0)); + sg_list, CommunityList(), false, PathPreference(), + Ip4Address(0)); client->WaitForIdle(); EXPECT_TRUE(ValidateAction(vnet[1]->vrf()->vrf_id(), vnet_addr[1], diff --git a/src/vnsw/agent/pkt/test/test_vrf_assign_acl.cc b/src/vnsw/agent/pkt/test/test_vrf_assign_acl.cc index 3a64d772f7c..115fd65739a 100644 --- a/src/vnsw/agent/pkt/test/test_vrf_assign_acl.cc +++ b/src/vnsw/agent/pkt/test/test_vrf_assign_acl.cc @@ -109,12 +109,14 @@ class TestVrfAssignAclFlow : public ::testing::Test { AddLocalVmRouteReq(agent_->local_peer(), "default-project:vn2:vn2", ip2, 24, MakeUuid(1), "default-project:vn1", 16, SecurityGroupList(), - false, PathPreference(), Ip4Address(0)); + CommunityList(), false, + PathPreference(), Ip4Address(0)); agent_->fabric_inet4_unicast_table()-> AddLocalVmRouteReq(agent_->local_peer(), "default-project:vn3:vn3", ip2, 24, MakeUuid(1), "default-project:vn1", 16, SecurityGroupList(), - false, PathPreference(), Ip4Address(0)); + CommunityList(), false, + PathPreference(), Ip4Address(0)); client->WaitForIdle(); } @@ -191,7 +193,8 @@ TEST_F(TestVrfAssignAclFlow, VrfAssignAcl3) { AddLocalVmRouteReq(agent_->local_peer(), "default-project:vn1:vn1", ip1, 24, MakeUuid(3), "default-project:vn2", 16, SecurityGroupList(), - false, PathPreference(), Ip4Address(0)); + CommunityList(), false, + PathPreference(), Ip4Address(0)); AddAddressVrfAssignAcl("intf1", 1, "1.1.1.0", "2.1.1.0", 6, 1, 65535, 1, 65535, "vrf4", "true"); TestFlow flow[] = { @@ -419,7 +422,8 @@ TEST_F(TestVrfAssignAclFlow, FloatingIp) { AddLocalVmRouteReq(agent_->local_peer(), "default-project:vn1:vn1", ip1, 24, MakeUuid(3), "default-project:vn2", 16, SecurityGroupList(), - false, PathPreference(), Ip4Address(0)); + CommunityList(), false, + PathPreference(), Ip4Address(0)); client->WaitForIdle(); //Add an ACL, such that for traffic from vn4:vn4 to default-project:vn2, @@ -444,7 +448,7 @@ TEST_F(TestVrfAssignAclFlow, FloatingIp) { AddLocalVmRouteReq(agent_->local_peer(), "default-project:vn3:vn3", ip2, 32, MakeUuid(7), "default-project:vn1", 16, SecurityGroupList(), - false, PathPreference(), Ip4Address(0)); + CommunityList(), false, PathPreference(), Ip4Address(0)); client->WaitForIdle(); TestFlow flow[] = { @@ -489,7 +493,8 @@ TEST_F(TestVrfAssignAclFlow, FloatingIp1) { AddLocalVmRouteReq(agent_->local_peer(), "default-project:vn1:vn1", ip1, 24, MakeUuid(3), "default-project:vn2", 16, SecurityGroupList(), - false, PathPreference(), Ip4Address(0)); + CommunityList(), false, + PathPreference(), Ip4Address(0)); client->WaitForIdle(); AddVrf("vrf9"); @@ -551,7 +556,8 @@ TEST_F(TestVrfAssignAclFlow, FloatingIp2) { AddLocalVmRouteReq(agent_->local_peer(), "default-project:vn1:vn1", ip1, 24, MakeUuid(3), "default-project:vn1", 16, SecurityGroupList(), - false, PathPreference(), Ip4Address(0)); + CommunityList(), false, + PathPreference(), Ip4Address(0)); client->WaitForIdle(); AddAddressVrfAssignAcl("intf7", 7, "4.1.1.0", "2.1.1.0", 6, 1, 65535, @@ -607,7 +613,8 @@ TEST_F(TestVrfAssignAclFlow, VrfAssignAclWithMirror1) { AddLocalVmRouteReq(agent_->local_peer(), "default-project:vn1:vn1", ip1, 24, MakeUuid(3), "default-project:vn2", 16, SecurityGroupList(), - false, PathPreference(), Ip4Address(0)); + CommunityList(), false, + PathPreference(), Ip4Address(0)); client->WaitForIdle(); AddMirrorAcl("Acl", 10, "default-project:vn1", "default-project:vn2", "pass", @@ -647,7 +654,8 @@ TEST_F(TestVrfAssignAclFlow, FloatingIp_1) { AddLocalVmRouteReq(agent_->local_peer(), "default-project:vn1:vn1", ip1, 24, MakeUuid(3), "default-project:vn2", 16, SecurityGroupList(), - false, PathPreference(), Ip4Address(0)); + CommunityList(), false, + PathPreference(), Ip4Address(0)); client->WaitForIdle(); //Add an ACL, such that for traffic from vn4:vn4 to default-project:vn2, diff --git a/src/vnsw/agent/test/test_cmn_util.h b/src/vnsw/agent/test/test_cmn_util.h index 39cb8cbe88a..f0263c37292 100644 --- a/src/vnsw/agent/test/test_cmn_util.h +++ b/src/vnsw/agent/test/test_cmn_util.h @@ -374,6 +374,9 @@ void AddInterfaceRouteTable(const char *name, int id, TestIp4Prefix *addr, int count); void AddInterfaceRouteTable(const char *name, int id, TestIp4Prefix *addr, int count, const char *nexthop); +void AddInterfaceRouteTable(const char *name, int id, TestIp4Prefix *addr, + int count, const char *nexthop, + const std::vector &communities); void AddInterfaceRouteTableV6(const char *name, int id, TestIp6Prefix *addr, int count); void ShutdownAgentController(Agent *agent); diff --git a/src/vnsw/agent/test/test_nh.cc b/src/vnsw/agent/test/test_nh.cc index 48fd386d490..503a32f526a 100644 --- a/src/vnsw/agent/test/test_nh.cc +++ b/src/vnsw/agent/test/test_nh.cc @@ -1794,7 +1794,8 @@ TEST_F(CfgTest, EcmpNH_17) { agent_->fabric_inet4_unicast_table()-> AddLocalVmRouteReq(bgp_peer, "vrf1", ip, 32, MakeUuid(1), "vn1", intf->label(), - SecurityGroupList(), false, PathPreference(), Ip4Address(0)); + SecurityGroupList(), CommunityList(), false, PathPreference(), + Ip4Address(0)); client->WaitForIdle(); InetUnicastRouteEntry *rt = RouteGet("vrf1", ip, 32); @@ -2438,7 +2439,8 @@ TEST_F(CfgTest, EcmpNH_18) { agent_->fabric_inet4_unicast_table()-> AddLocalVmRouteReq(bgp_peer, "vrf1", ip, 32, MakeUuid(1), "vn1", vm_intf->label(), - SecurityGroupList(), false, PathPreference(), Ip4Address(0)); + SecurityGroupList(), CommunityList(), false, PathPreference(), + Ip4Address(0)); client->WaitForIdle(); EXPECT_TRUE(rt->GetActiveNextHop()->GetType() == NextHop::INTERFACE); diff --git a/src/vnsw/agent/test/test_route.cc b/src/vnsw/agent/test/test_route.cc index b288cee8b9f..89fec4db702 100644 --- a/src/vnsw/agent/test/test_route.cc +++ b/src/vnsw/agent/test/test_route.cc @@ -179,7 +179,7 @@ class RouteTest : public ::testing::Test { Agent::GetInstance()->fabric_inet4_unicast_table()->AddGatewayRouteReq (Agent::GetInstance()->local_peer(), vrf_name, ip, plen, server, "", MplsTable::kInvalidLabel, - SecurityGroupList()); + SecurityGroupList(), CommunityList()); client->WaitForIdle(); } @@ -1053,6 +1053,7 @@ TEST_F(RouteTest, RouteToDeletedNH_1) { MakeUuid(1), "Test", 10, SecurityGroupList(), + CommunityList(), false, PathPreference(), Ip4Address(0)); @@ -1098,6 +1099,7 @@ TEST_F(RouteTest, RouteToDeletedNH_2) { MakeUuid(1), "Test", 10, SecurityGroupList(), + CommunityList(), false, PathPreference(), Ip4Address(0)); @@ -1106,6 +1108,7 @@ TEST_F(RouteTest, RouteToDeletedNH_2) { MakeUuid(1), "Test", 10, SecurityGroupList(), + CommunityList(), false, PathPreference(), Ip4Address(0)); @@ -1120,6 +1123,7 @@ TEST_F(RouteTest, RouteToDeletedNH_2) { MakeUuid(1), "Test", 10, SecurityGroupList(), + CommunityList(), false, PathPreference(), Ip4Address(0)); @@ -1159,6 +1163,7 @@ TEST_F(RouteTest, RouteToInactiveInterface) { MakeUuid(1), "Test", 10, SecurityGroupList(), + CommunityList(), false, PathPreference(), Ip4Address(0)); @@ -1173,6 +1178,7 @@ TEST_F(RouteTest, RouteToInactiveInterface) { MakeUuid(1), "Test", 10, SecurityGroupList(), + CommunityList(), false, PathPreference(), Ip4Address(0)); diff --git a/src/vnsw/agent/test/test_util.cc b/src/vnsw/agent/test/test_util.cc index 8a1d5fc45f3..b76dd958b0d 100644 --- a/src/vnsw/agent/test/test_util.cc +++ b/src/vnsw/agent/test/test_util.cc @@ -2,6 +2,8 @@ * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. */ +#include + #include "base/os.h" #include "test/test_cmn_util.h" #include "test/test_init.h" @@ -1751,6 +1753,36 @@ void AddInterfaceRouteTable(const char *name, int id, TestIp4Prefix *rt, AddNode("interface-route-table", name, id, buff); } +void AddInterfaceRouteTable(const char *name, int id, TestIp4Prefix *rt, + int count, const char *nexthop, + const std::vector &communities) { + std::ostringstream o_str; + + for (int i = 0; i < count; i++) { + o_str << "\n" + << "\n" << rt->addr_.to_string() + << "/" << rt->plen_ << " \n" << "\n"; + if (nexthop) { + o_str << "" << nexthop << "\n"; + } + o_str << "\" \"\n"; + o_str << "\n"; + BOOST_FOREACH(string community, communities) { + o_str << "" + << community + << "\n"; + } + o_str << "\n"; + o_str << "\n"; + rt++; + } + + char buff[10240]; + sprintf(buff, "\n" + "%s" + "\n", o_str.str().c_str()); + AddNode("interface-route-table", name, id, buff); +} void AddInterfaceRouteTableV6(const char *name, int id, TestIp6Prefix *rt, int count) {