6 #include <boost/uuid/uuid_io.hpp>
7 #include <boost/lexical_cast.hpp>
26 #include <controller/controller_types.h>
30 #include <xmpp_enet_types.h>
31 #include <xmpp_unicast_types.h>
34 using namespace boost::asio;
59 bool path_unresolved =
false;
72 assert(table != NULL);
77 assert(table != NULL);
80 bool comp_nh_policy =
false;
90 member->SetUnresolved(
true);
91 if (!path_unresolved) {
92 path_unresolved =
true;
97 std::unique_ptr<const NextHopKey> nh_key_ptr(nh_key);
99 std::move(nh_key_ptr)));
100 comp_nh_list.push_back(component_nh_key);
112 std::unique_ptr<const NextHopKey> nh_key_ptr(nh_key);
114 std::move(nh_key_ptr)));
115 comp_nh_list.push_back(component_nh_key);
117 member->UpdateDependentRoute(uc_rt);
118 member->SetUnresolved(
false);
120 new_list.push_back(member);
140 bool comp_nh_policy = comp_key->
GetPolicy();
141 bool new_comp_nh_policy =
false;
146 if (!comp_nh_policy) {
164 template <
typename TYPE>
171 const std::string &prefix_str) :
173 ecmp_load_balance_(ecmp_load_balance), tag_list_(tag_list),
174 copy_local_path_(false), vxlan_id_(0) {
177 std::string vrf_name = rt_table->
vrf_name();
180 uint32_t label = item->entry.next_hops.next_hop[0].label;
186 if (item->entry.local_preference != 0) {
187 preference = item->entry.local_preference;
199 if (is_routing_vrf) {
204 PathPreference rp(item->entry.sequence_number, preference,
false,
false);
207 sg_list_ = item->entry.security_group_list.security_group;
210 bool intf_exist =
false;
211 bool tun_exist =
false;
212 bool comp_nh_policy =
false;
213 for (uint32_t i = 0; i < item->entry.next_hops.next_hop.size(); i++) {
214 std::string nexthop_addr =
215 item->entry.next_hops.next_hop[i].address;
216 boost::system::error_code ec;
217 IpAddress addr = IpAddress::from_string(nexthop_addr, ec);
218 if (ec.value() != 0) {
220 "Error parsing nexthop ip address");
225 "Non IPv4 address not supported as nexthop");
230 std::stringstream msg;
231 msg <<
"Nexthop paths for prefix "
233 <<
" (" << item->entry.next_hops.next_hop.size()
234 <<
") exceed the maximum supported, ignoring them";
239 uint32_t label = item->entry.next_hops.next_hop[i].label;
242 (item->entry.next_hops.next_hop[i].tunnel_encapsulation_list);
246 if (mpls != NULL && !is_routing_vrf) {
250 item->entry.security_group_list.security_group,
265 std::unique_ptr<const NextHopKey> nh_key_ptr(nh_key);
267 std::move(nh_key_ptr)));
268 comp_nh_list.push_back(component_nh_key);
269 if (!comp_nh_policy) {
278 if (is_routing_vrf) {
282 item->entry.next_hops.next_hop[i],
289 (item->entry.next_hops.next_hop[i].tunnel_encapsulation_list);
302 (item->entry.next_hops.next_hop[i]);
314 std::unique_ptr<const NextHopKey> nh_key_ptr(nh_key);
316 std::move(nh_key_ptr)));
317 comp_nh_list.push_back(component_nh_key);
324 if (is_routing_vrf) {
326 AllocateTunnelNextHopKey(addr, mac);
337 std::unique_ptr<const NextHopKey> nh_key_ptr(nh_key);
339 std::move(nh_key_ptr)));
340 comp_nh_list.push_back(component_nh_key);
345 if (intf_exist && tun_exist) {
346 for (
auto &comp_nh_ptr : comp_nh_list) {
347 if (comp_nh_ptr ==
nullptr) {
357 comp_nh_policy =
true;
367 comp_nh_list, vrf_name));
381 const std::string &prefix_str,
382 const std::string vrf_name) :
384 ecmp_load_balance_(ecmp_load_balance), tag_list_(tag_list),
385 path_preference_(path_pref), tunnel_bmap_(tunnel_bmap),
386 copy_local_path_(false), vxlan_id_(0) {
389 if (vrf_name.size() == 0) {
399 FindVrfFromName(vrf_name)->vxlan_id();
410 std::vector<IpAddress> &tunnel_dest_list,
411 std::vector<uint32_t> &label_list,
412 const std::string &prefix_str,
413 const std::string &vrf_name):
415 ecmp_load_balance_(ecmp_load_balance), tag_list_(tag_list),
416 path_preference_(path_pref), tunnel_bmap_(tunnel_bmap),
417 copy_local_path_(false), tunnel_dest_list_(tunnel_dest_list),
418 label_list_(label_list), vrf_name_(vrf_name), vxlan_id_(0) {
424 const string &default_vrf,
426 const string &vrf_name,
435 bool ecmp_suppressed,
441 nh_req.
key.reset(
new TunnelNHKey(default_vrf, router_id, tunnel_dest,
false,
449 dest_vn_list, bmap, sg_list, tag_list, path_preference,
450 nh_req, ecmp_suppressed,
451 ecmp_load_balance, etree_leaf, rewrite_dmac);
457 const string &default_vrf,
459 const string &vrf_name,
468 bool ecmp_suppressed,
476 rewrite_dmac, label));
482 dest_vn_list, bmap, sg_list, tag_list, path_preference,
483 nh_req, ecmp_suppressed,
484 ecmp_load_balance, etree_leaf, rewrite_dmac);
526 assert(table != NULL);
540 member->SetUnresolved(
false);
547 FindActiveEntry(nh_key));
550 member->UpdateDependentRoute(uc_rt);
551 member->SetUnresolved(
false);
555 new_list.push_back(member);
567 false, new_tunnel_type,
630 if (path->
ChangeNH(agent, nh) ==
true)
634 path_sg_list = path->
sg_list();
703 if (path->
ChangeNH(agent, nh) ==
true)
706 path_sg_list = path->
sg_list();
754 if (local_path == NULL) {
770 if (mpls_vrf_uc_rt == NULL) {
825 if (path->
ChangeNH(agent, nh) ==
true) {
846 GetDBRequestKey().get()))->
Clone();
866 const TagList &tag_list,
const autogen::ItemType *item,
871 const TagList &tag_list,
const autogen::EnetItemType *item,
uint8_t prefix_length() const
!
uint64_t sequence_number() const
uint64_t sequence_number_
AgentPath * FindLocalVmPortPath() const
void set_path_preference(const PathPreference &rp)
SecurityGroupList sg_list_
const VnListType & dest_vn_list() const
PathPreference path_preference_
void SetDependentTable(AgentRouteTable *table)
bool ChangeNH(Agent *agent, NextHop *nh)
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
void set_gw_ip(const IpAddress &addr)
void set_unresolved(bool unresolved)
const std::string & vrf_name() const
const TagList & tag_list() const
const PathPreference & path_preference() const
TunnelType::TypeBmap tunnel_bmap_
bool force_policy() const
ClonedLocalPathList cloned_data_list_
void set_local_ecmp_mpls_label(MplsLabel *mpls)
NextHopTable * nexthop_table() const
DBTableBase * get_table() const
bool ipam_subnet_route() const
TunnelType::Type tunnel_type() const
Agent supports multiple route tables - Inet-unicast (IPv4/IPv6), Inet-multicast, bridge, EVPN (Type2/Type5). This base class contains common code for all types of route tables.
void set_sg_list(const SecurityGroupList &sg)
const NextHop * nexthop() const
boost::asio::ip::address IpAddress
void set_vxlan_id(uint32_t vxlan_id)
ControllerMplsRoute(const BgpPeer *peer, const string &vrf_name, const Ip4Address &addr, uint32_t label, const VnListType &dest_vn_list, int bmap, const SecurityGroupList &sg_list, const TagList &tag_list, const PathPreference &path_preference, DBRequest &req, bool ecmp_suppressed, const EcmpLoadBalance &ecmp_load_balance, bool etree_leaf, const MacAddress &rewrite_dmac=MacAddress())
PathPreference path_preference_
boost::shared_ptr< AgentPathEcmpComponent > AgentPathEcmpComponentPtr
std::vector< int > SecurityGroupList
static const uint32_t kInvalidExportLabel
std::unique_ptr< DBRequestData > data
InetUnicastAgentRouteTable * fabric_inet4_mpls_table() const
AgentDBEntry * FindActiveEntry(const DBEntry *key)
static TypeBmap MplsType()
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
ControllerEcmpRoute(const BgpPeer *peer, const VnListType &vn_list, const EcmpLoadBalance &ecmp_load_balance, const TagList &tag_list, const TYPE *item, const AgentRouteTable *rt_table, const std::string &prefix_str)
InetUnicastRouteEntry * FindRoute(const IpAddress &ip)
boost::shared_ptr< const ComponentNHKey > ComponentNHKeyPtr
const string & GetName() const
bool NexthopToInterfacePolicy() const
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
MplsTable * mpls_table() const
VxlanRoutingManager * vxlan_routing_manager() const
std::unique_ptr< DBRequestKey > KeyPtr
bool ReorderCompositeNH(Agent *agent, CompositeNHKey *nh, bool &comp_nh_policy, const AgentPath *local_path)
Base class for all Route entries in agent.
void Swap(DBRequest *rhs)
CompositeNHKey * composite_nh_key()
void ResetEcmpMemberList(AgentPathEcmpComponentPtrList list)
std::vector< ComponentNHKeyPtr > ComponentNHKeyList
static TypeBmap MplsoMplsType()
NextHop::Type GetType() const
const std::string & fabric_vrf_name() const
bool UpdateWithParams(const SecurityGroupList &sg_list, const TagList &tag_list, const CommunityList &community_list, const PathPreference &path_preference, const TunnelType::TypeBmap bmap, const EcmpLoadBalance &ecmp_load_balance, const VnListType &vn_list, DBRequest &nh_req)
void set_tunnel_bmap(TunnelType::TypeBmap bmap)
virtual Agent::RouteTableType GetTableType() const =0
static void AddInterfaceComponentToList(const std::string &prefix_str, const std::string &vrf_name, const NhType &nh_item, ComponentNHKeyList &comp_nh_list)
Adds an interface or a composite of interfaces nexthops to the list of components NH keys needed for ...
static bool IsRoutingVrf(const VrfEntry *vrf)
Determines whether the pointer to the VRF instance is of routing type.
static const uint32_t kInvalidvxlan_id
MacAddress GetTunnelMac(const autogen::EnetNextHopType &nh)
void set_ecmp_suppressed(bool suppresed)
virtual bool CanDeletePath(Agent *agent, AgentPath *path, const AgentRoute *rt) const
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *rt)
static ControllerVmRoute * MakeControllerVmRoute(const BgpPeer *peer, const string &default_vrf, const Ip4Address &router_id, const string &vrf_name, const Ip4Address &tunnel_dest, TunnelType::TypeBmap bmap, uint32_t label, MacAddress rewrite_dmac, const VnListType &dest_vn_list, const SecurityGroupList &sg_list, const TagList &tag_list, const PathPreference &path_preference, bool ecmp_suppressed, const EcmpLoadBalance &ecmp_load_balance, bool etree_leaf)
ControllerVmRoute(const BgpPeer *peer, const string &vrf_name, const Ip4Address &addr, uint32_t label, const VnListType &dest_vn_list, int bmap, const SecurityGroupList &sg_list, const TagList &tag_list, const PathPreference &path_preference, DBRequest &req, bool ecmp_suppressed, const EcmpLoadBalance &ecmp_load_balance, bool etree_leaf, const MacAddress &rewrite_dmac=MacAddress())
TunnelType::TypeBmap GetTypeBitmap(const autogen::EnetTunnelEncapsulationListType &encap)
PathPreference path_preference_
bool IpamSubnetRouteAvailable() const
std::vector< uint32_t > label_list_
const NextHop * GetActiveNextHop() const
Ip4Address router_id() const
void set_vrf_name(const std::string &vrf_name)
VNController * controller() const
std::unique_ptr< DBRequestKey > key
bool vxlan_routing_vn() const
void set_copy_local_path(bool copy_local_path)
static TypeBmap AllType()
const Peer * peer() const
static const uint32_t maximum_ecmp_paths
NextHop * discard_nh() const
std::vector< std::string > CommunityList
AgentXmppChannel * GetAgentXmppChannel() const
const SecurityGroupList sg_list_
void set_peer_sequence_number(uint64_t sequence_number)
uint64_t peer_sequence_number() const
std::set< std::string > VnListType
virtual KeyPtr GetDBRequestKey() const =0
void set_tunnel_dest(const Ip4Address &tunnel_dest)
static TypeBmap NativeType()
static Type ComputeType(TypeBmap bmap)
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
ControllerPeerPath(const BgpPeer *peer)
boost::asio::ip::address_v4 Ip4Address
std::vector< AgentPathEcmpComponentPtr > AgentPathEcmpComponentPtrList
static const uint32_t kInvalidLabel
VrfTable * vrf_table() const
virtual AgentRouteKey * Clone() const =0
std::vector< IpAddress > tunnel_dest_list_
EcmpLoadBalance ecmp_load_balance_
bool CopyToPath(AgentPath *path)
void UpdateEcmpHashFields(const Agent *agent, const EcmpLoadBalance &ecmp_load_balance, DBRequest &nh_req)
void set_tag_list(const TagList &tag)
void set_nexthop(NextHop *nh)
virtual std::string ToString() const =0
static ControllerMplsRoute * MakeControllerMplsRoute(const BgpPeer *peer, const string &default_vrf, const Ip4Address &router_id, const string &vrf_name, const Ip4Address &tunnel_dest, TunnelType::TypeBmap bmap, uint32_t label, MacAddress rewrite_dmac, const VnListType &dest_vn_list, const SecurityGroupList &sg_list, const TagList &tag_list, const PathPreference &path_preference, bool ecmp_suppressed, const EcmpLoadBalance &ecmp_load_balance, bool etree_leaf)
SecurityGroupList sg_list_
TunnelType::TypeBmap tunnel_bmap_
void Process(DBRequest &req)
void set_etree_leaf(bool leaf)
static bool IsVxlanAvailable(const Agent *agent)
Checks whether VxLAN routing manager is enabled or not.
void set_composite_nh_key(CompositeNHKey *key)
AgentRoute * GetParentRoute()
MplsLabel * FindMplsLabel(uint32_t label)
bool ecmp_suppressed() const
void set_label(uint32_t label)
void Process(DBRequest &req)
void set_dest_vn_list(const VnListType &dest_vn_list)
EcmpLoadBalance ecmp_load_balance_
virtual const NextHop * ComputeNextHop(Agent *agent) const
SecurityGroupList sg_list_
const VnListType vn_list_
void SetPolicy(bool policy)
const Peer * fabric_rt_export_peer() const
bool UpdateIpamHostFlags(bool ipam_host_route)
uint32_t tunnel_bmap() const
virtual AgentPath * FindPath(const Peer *peer) const
void set_tunnel_type(TunnelType::Type type)
void set_force_policy(bool force_policy)
TunnelType::TypeBmap tunnel_bmap_
EcmpLoadBalance ecmp_load_balance_
static TypeBmap VxlanType()
#define CONTROLLER_TRACE(obj,...)
virtual bool UpdateRoute(AgentRoute *route)
const SecurityGroupList & sg_list() const
uint32_t vxlan_id() const
const EcmpLoadBalance & ecmp_load_balance() const
void set_ecmp_load_balance(const EcmpLoadBalance &ecmp_load_balance)
void set_peer(const Peer *peer)
AgentRouteTable * GetDependentTable() const
std::vector< int > TagList
std::string GetBgpPeerName() const