OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ovsdb_route_data.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include <cmn/agent_cmn.h>
6 
7 #include <oper/route_common.h>
8 #include <oper/vrf.h>
9 #include <oper/tunnel_nh.h>
10 #include <oper/agent_sandesh.h>
11 
14 
15 using namespace std;
16 using namespace boost::asio;
17 
18 OvsdbRouteData::OvsdbRouteData(const Peer *peer, uint32_t vxlan_id,
19  const Ip4Address &tor_ip,
20  const Ip4Address &router_id,
21  const std::string &tor_vrf,
22  const std::string &dest_vn_name,
23  const SecurityGroupList &sg_list,
24  bool ha_stale_export, uint32_t sequence) :
25  AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
26  peer_(peer), vxlan_id_(vxlan_id), tor_ip_(tor_ip),
27  tor_vrf_(tor_vrf), router_id_(router_id), dest_vn_name_(dest_vn_name),
28  sg_list_(sg_list), ha_stale_export_(ha_stale_export), sequence_(sequence) {
29 }
30 
32  AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
33  peer_(peer), vxlan_id_() {
34 }
35 
37 }
38 
39 std::string OvsdbRouteData::ToString() const {
40  return "OVS Route Data";
41 }
42 
44  const AgentRoute *data) {
45  bool ret = false;
46  NextHop *nh = NULL;
47 
48  if (path->vxlan_id() != vxlan_id_) {
49  path->set_vxlan_id(vxlan_id_);
50  ret = true;
51  }
52 
53  if (!path->dest_vn_match(dest_vn_name_)) {
54  VnListType vn_list;
55  vn_list.insert(dest_vn_name_);
56  path->set_dest_vn_list(vn_list);
57  ret = true;
58  }
59 
60  if (path->sg_list() != sg_list_) {
61  path->set_sg_list(sg_list_);
62  ret = true;
63  }
64 
65  uint32_t pref = PathPreference::LOW;
66  // if it is a ha stale export check for path preference to be HA_STALE
67  if (ha_stale_export_) {
69  }
70  PathPreference path_preference(sequence_, pref, false, false);
71  if (path->path_preference() != path_preference) {
72  path->set_path_preference(path_preference);
73  ret = true;
74  }
75 
76  // Create Tunnel-NH first
79  nh_req.key.reset(new TunnelNHKey(tor_vrf_, router_id_, tor_ip_, false,
80  type));
81  nh_req.data.reset(new TunnelNHData());
82  agent->nexthop_table()->Process(nh_req);
83 
84  // Get the NH
85  TunnelNHKey key(tor_vrf_, router_id_, tor_ip_, false, type);
86  nh = static_cast<NextHop *>(agent->nexthop_table()->FindActiveEntry(&key));
87 
90 
91  path->set_unresolved(false);
92  if (path->ChangeNH(agent, nh) == true)
93  ret = true;
94 
95  return ret;
96 }
97 
99  AgentRouteData(AgentRouteData::ADD_DEL_CHANGE, false, 0),
100  sg_list_(sg_list) {
101 }
102 
104 }
105 
106 std::string OvsdbRouteResyncData::ToString() const {
107  return "OVS Route Resync";
108 }
109 
111  const AgentRoute *data) {
112  bool ret = false;
113  if (path->sg_list() != sg_list_) {
114  path->set_sg_list(sg_list_);
115  ret = true;
116  }
117 
118  return ret;
119 }
void set_path_preference(const PathPreference &rp)
Definition: agent_path.h:331
std::string dest_vn_name_
bool ChangeNH(Agent *agent, NextHop *nh)
Definition: agent_path.cc:119
void set_unresolved(bool unresolved)
Definition: agent_path.h:285
SecurityGroupList sg_list_
const PathPreference & path_preference() const
Definition: agent_path.h:329
NextHopTable * nexthop_table() const
Definition: agent.h:475
void set_sg_list(const SecurityGroupList &sg)
Definition: agent_path.h:291
void set_vxlan_id(uint32_t vxlan_id)
Definition: agent_path.h:281
std::vector< int > SecurityGroupList
Definition: agent.h:201
std::unique_ptr< DBRequestData > data
Definition: db_table.h:49
Ip4Address tor_ip_
SecurityGroupList sg_list_
AgentDBEntry * FindActiveEntry(const DBEntry *key)
Definition: agent_db.cc:110
virtual ~OvsdbRouteData()
Base class for all Route entries in agent.
Definition: agent_route.h:224
std::string tor_vrf_
void set_tunnel_bmap(TunnelType::TypeBmap bmap)
Definition: agent_path.h:289
uint8_t type
Definition: load_balance.h:109
Definition: agent.h:358
virtual std::string ToString() const
std::unique_ptr< DBRequestKey > key
Definition: db_table.h:48
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *data)
Definition: peer.h:44
std::set< std::string > VnListType
Definition: agent.h:212
static Type ComputeType(TypeBmap bmap)
Definition: nexthop.cc:33
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
OvsdbRouteData(const Peer *peer, uint32_t vxlan_id, const Ip4Address &tor_ip, const Ip4Address &router_id, const std::string &tor_vrf, const std::string &dest_vn_name, const SecurityGroupList &sg_list, bool ha_stale_export, uint32_t sequence)
Ip4Address router_id_
OvsdbRouteResyncData(const SecurityGroupList &sg_list)
void Process(DBRequest &req)
Definition: nexthop.cc:367
bool dest_vn_match(const std::string &vn) const
Definition: agent_path.cc:1809
virtual std::string ToString() const
void set_dest_vn_list(const VnListType &dest_vn_list)
Definition: agent_path.h:283
uint32_t tunnel_bmap() const
Definition: agent_path.h:267
void set_tunnel_type(TunnelType::Type type)
Definition: agent_path.h:290
static TypeBmap VxlanType()
Definition: nexthop.h:311
const SecurityGroupList & sg_list() const
Definition: agent_path.h:248
uint32_t vxlan_id() const
Definition: agent_path.h:265
virtual bool AddChangePathExtended(Agent *agent, AgentPath *path, const AgentRoute *data)