OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
global_vrouter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef vnsw_agent_global_router_h_
6 #define vnsw_agent_global_router_h_
7 
8 #include <cmn/agent_cmn.h>
9 #include <oper/oper_db.h>
10 #include <oper/ecmp_load_balance.h>
12 
13 class OperDB;
14 class VnEntry;
15 class VrfEntry;
16 class IFMapNode;
17 class AgentRouteResync;
18 class AgentRouteEncap;
19 class AgentUtXmlFlowThreshold;
20 class EcmpLoadBalance;
21 class CryptTunnelTable;
22 
23 namespace autogen {
24  struct LinklocalServiceEntryType;
25  struct FlowAgingTimeout;
26  class GlobalVrouterConfig;
27 }
28 
30  const VrfEntry *vrf_;
31  // set of linklocal addresses added to the VN
32  std::set<IpAddress> addresses_;
33 
34  LinkLocalDBState(const VrfEntry *vrf) : DBState(), vrf_(vrf) {}
35  void Add(const IpAddress &address) { addresses_.insert(address); }
36  void Delete(const IpAddress &address) { addresses_.erase(address); }
37 };
38 
39 struct PortConfig {
41 
42  struct PortRange {
43  PortRange(uint16_t start, uint16_t end):
44  port_start(start), port_end(end) {}
45 
46  uint16_t port_start;
47  uint16_t port_end;
48  };
49 
50  void Trim();
51  uint16_t port_count;
52  std::vector<PortRange> port_range;
53 };
54 
55 // Handle Global Vrouter configuration
56 class GlobalVrouter : public OperIFMapTable {
57 public:
58  enum CryptMode {
62  };
63  static const std::string kMetadataService;
64  static const std::string kMetadataService6;
65  static const Ip4Address kLoopBackIp;
66  static const int32_t kDefaultFlowExportRate = 0;
67  static const int32_t kDisableSampling = -1;
68 
72 
73  LinkLocalServiceKey(const IpAddress &addr, uint16_t port)
75  bool operator<(const LinkLocalServiceKey &rhs) const;
76  };
77 
78  // Config data for each linklocal service
82  std::vector<Ip4Address> ipfabric_service_ip;
84 
85  LinkLocalService(const std::string &service_name,
86  const std::string &fabric_dns_name,
87  const std::vector<Ip4Address> &fabric_ip,
88  uint16_t fabric_port);
89  bool operator==(const LinkLocalService &rhs) const;
90  bool IsAddressInUse(const Ip4Address &ip) const;
92  };
93 
95  FlowAgingTimeoutKey(uint8_t proto, uint16_t port_arg):
96  protocol(proto), port(port_arg) { }
97  uint8_t protocol;
98  uint16_t port;
99  bool operator==(const FlowAgingTimeoutKey &rhs) const {
100  return (protocol == rhs.protocol && port == rhs.port);
101  }
102 
103  bool operator<(const FlowAgingTimeoutKey &rhs) const {
104  if (protocol != rhs.protocol) {
105  return protocol < rhs.protocol;
106  }
107  return port < rhs.port;
108  }
109  };
110 
111  typedef std::string CryptTunnelKey;
112  struct CryptTunnel {
114  CryptTunnel(CryptMode cmode): mode(cmode) {};
115  bool operator==(const CryptTunnel &rhs) const {
116  return (mode == rhs.mode);
117  }
118  bool operator<(const CryptTunnel &rhs) const {
119  return (mode < rhs.mode);
120  }
121  };
122 
123  // map of linklocal service data, with (ip, port) as key
124  typedef std::map<LinkLocalServiceKey, LinkLocalService> LinkLocalServicesMap;
125  typedef std::pair<LinkLocalServiceKey, LinkLocalService> LinkLocalServicesPair;
126 
127  typedef std::map<CryptTunnelKey, CryptTunnel> CryptTunnelsMap;
128  typedef std::pair<CryptTunnelKey, CryptTunnel> CryptTunnelsPair;
129 
130  typedef std::map<FlowAgingTimeoutKey, uint32_t> FlowAgingTimeoutMap;
131  typedef std::pair<FlowAgingTimeoutKey, uint32_t> FlowAgingTimeoutPair;
132 
133  //Map used to audit for port pool configuration change
134  typedef std::map<uint8_t, PortConfig> ProtocolPortSet;
135 
137  virtual ~GlobalVrouter();
138  void CreateDBClients();
139 
142  }
143  int32_t flow_export_rate() const { return flow_export_rate_; }
144 
145  void ConfigDelete(IFMapNode *node);
146  void ConfigAddChange(IFMapNode *node);
147  void ConfigManagerEnqueue(IFMapNode *node);
148 
149  void GlobalVrouterConfig(IFMapNode *node);
150  void UpdateSLOConfig(IFMapNode *node);
151 
154  bool FindLinkLocalService(const std::string &service_name,
155  IpAddress *service_ip,
156  uint16_t *service_port,
157  std::string *fabric_hostname,
158  Ip4Address *fabric_ip,
159  uint16_t *fabric_port) const;
160 
163  bool FindLinkLocalService(const IpAddress &service_ip,
164  uint16_t service_port,
165  std::string *service_name,
166  Ip4Address *fabric_ip,
167  uint16_t *fabric_port) const;
168 
170  bool FindLinkLocalService(const std::string &service_name,
171  std::set<IpAddress> *service_ip) const;
172 
175  bool FindLinkLocalService(const IpAddress &service_ip,
176  std::set<std::string> *service_names) const;
177 
178  void LinkLocalRouteUpdate(const std::vector<Ip4Address> &addr_list);
179  bool IsAddressInUse(const Ip4Address &ip) const;
180  bool IsLinkLocalAddressInUse(const IpAddress &ip) const;
183 
184  uint64_t PendingFabricDnsRequests() const;
185  void ResyncRoutes();
186  const EcmpLoadBalance &ecmp_load_balance() const;
187  bool configured() const { return configured_; }
188 
190 private:
191  class FabricDnsResolver;
193  typedef std::vector<autogen::LinklocalServiceEntryType> LinkLocalServiceList;
194  typedef std::vector<autogen::EncryptionTunnelEndpoint> EncryptionTunnelEndpointList;
195  typedef std::vector<autogen::FlowAgingTimeout> FlowAgingTimeoutList;
196 
197  void UpdateLinkLocalServiceConfig(const LinkLocalServiceList &linklocal_list);
199  bool ChangeNotify(LinkLocalServicesMap *old_value,
200  LinkLocalServicesMap *new_value);
201  void AddLinkLocalService(const LinkLocalServicesMap::iterator &it);
202  void DeleteLinkLocalService(const LinkLocalServicesMap::iterator &it);
203  void ChangeLinkLocalService(const LinkLocalServicesMap::iterator &old_it,
204  const LinkLocalServicesMap::iterator &new_it);
205 
208  const std::string encrypt_mode_str);
211  CryptTunnelsMap *new_value);
212  void AddCryptTunnelEndpoint(const CryptTunnelsMap::iterator &it);
213  void DeleteCryptTunnelEndpoint(const CryptTunnelsMap::iterator &it);
214  void ChangeCryptTunnelEndpoint(const CryptTunnelsMap::iterator &old_it,
215  const CryptTunnelsMap::iterator &new_it);
216 
217  void UpdateFlowAging(autogen::GlobalVrouterConfig *cfg);
218  void DeleteFlowAging();
219 
220  void UpdatePortConfig(autogen::GlobalVrouterConfig *cfg);
221  void DeletePortConfig();
222 
226  boost::scoped_ptr<LinkLocalRouteManager> linklocal_route_mgr_;
227  boost::scoped_ptr<FabricDnsResolver> fabric_dns_resolver_;
234  bool configured_; //true when global-vrouter-config stanza is present
235  boost::uuids::uuid slo_uuid_; //SLO associated with global-vrouter
236 };
237 
238 #endif // vnsw_agent_global_router_h_
std::pair< CryptTunnelKey, CryptTunnel > CryptTunnelsPair
void LinkLocalRouteUpdate(const std::vector< Ip4Address > &addr_list)
const VrfEntry * vrf_
void GlobalVrouterConfig(IFMapNode *node)
std::map< LinkLocalServiceKey, LinkLocalService > LinkLocalServicesMap
void ConfigManagerEnqueue(IFMapNode *node)
LinkLocalService(const std::string &service_name, const std::string &fabric_dns_name, const std::vector< Ip4Address > &fabric_ip, uint16_t fabric_port)
ForwardingMode
Definition: agent.h:403
Definition: vrf.h:86
bool operator<(const CryptTunnel &rhs) const
Agent * agent() const
Definition: oper_db.h:245
bool operator==(const LinkLocalService &rhs) const
void DeleteFlowAging()
boost::asio::ip::address IpAddress
Definition: address.h:13
uint16_t port_count
void UpdateFlowAging(autogen::GlobalVrouterConfig *cfg)
std::pair< FlowAgingTimeoutKey, uint32_t > FlowAgingTimeoutPair
LinkLocalServiceKey(const IpAddress &addr, uint16_t port)
virtual ~GlobalVrouter()
FlowAgingTimeoutKey(uint8_t proto, uint16_t port_arg)
LinkLocalDBState(const VrfEntry *vrf)
boost::uuids::uuid uuid
CryptTunnel(CryptMode cmode)
bool operator==(const CryptTunnel &rhs) const
int32_t flow_export_rate_
CryptMode crypt_mode_
bool IsVrouterPresentCryptTunnelConfig(const EncryptionTunnelEndpointList &endpoint_list)
bool ChangeNotifyCryptTunnels(CryptTunnelsMap *old_value, CryptTunnelsMap *new_value)
void UpdateCryptTunnelEndpointConfig(const EncryptionTunnelEndpointList &endpoint_list, const std::string encrypt_mode_str)
void ChangeCryptTunnelEndpoint(const CryptTunnelsMap::iterator &old_it, const CryptTunnelsMap::iterator &new_it)
const EcmpLoadBalance & ecmp_load_balance() const
bool FindLinkLocalService(const std::string &service_name, IpAddress *service_ip, uint16_t *service_port, std::string *fabric_hostname, Ip4Address *fabric_ip, uint16_t *fabric_port) const
Get link local service configuration info, for a given service name.
static const int32_t kDisableSampling
void CreateDBClients()
void UpdatePortConfig(autogen::GlobalVrouterConfig *cfg)
Agent::ForwardingMode forwarding_mode() const
boost::scoped_ptr< FabricDnsResolver > fabric_dns_resolver_
LinkLocalServicesMap linklocal_services_map_
void DeleteCryptTunnelEndpointConfig()
CryptTunnelsMap crypt_tunnels_map_
boost::uuids::uuid slo_uuid_
ProtocolPortSet protocol_port_set_
Definition: agent.h:358
bool ChangeNotify(LinkLocalServicesMap *old_value, LinkLocalServicesMap *new_value)
uint64_t PendingFabricDnsRequests() const
std::map< uint8_t, PortConfig > ProtocolPortSet
void AddCryptTunnelEndpoint(const CryptTunnelsMap::iterator &it)
PortRange(uint16_t start, uint16_t end)
std::vector< Ip4Address > ipfabric_service_ip
const LinkLocalServicesMap & linklocal_services_map() const
static const std::string kMetadataService6
DBTable::DBTableWalkRef vn_update_walk_ref_
bool operator<(const LinkLocalServiceKey &rhs) const
std::vector< autogen::FlowAgingTimeout > FlowAgingTimeoutList
std::vector< autogen::LinklocalServiceEntryType > LinkLocalServiceList
bool IsLinkLocalAddressInUse(const IpAddress &ip) const
boost::uuids::uuid slo_uuid() const
boost::intrusive_ptr< AgentRouteWalker > AgentRouteWalkerPtr
void ConfigDelete(IFMapNode *node)
int32_t flow_export_rate() const
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
Definition: vn.h:151
bool operator<(const FlowAgingTimeoutKey &rhs) const
Agent::ForwardingMode forwarding_mode_
FlowAgingTimeoutMap flow_aging_timeout_map_
friend class AgentUtXmlFlowThreshold
std::set< IpAddress > addresses_
static const std::string kMetadataService
void ChangeLinkLocalService(const LinkLocalServicesMap::iterator &old_it, const LinkLocalServicesMap::iterator &new_it)
std::map< CryptTunnelKey, CryptTunnel > CryptTunnelsMap
bool configured() const
bool IsAddressInUse(const Ip4Address &ip) const
void DeleteLinkLocalService(const LinkLocalServicesMap::iterator &it)
boost::scoped_ptr< LinkLocalRouteManager > linklocal_route_mgr_
void AddLinkLocalService(const LinkLocalServicesMap::iterator &it)
void UpdateLinkLocalServiceConfig(const LinkLocalServiceList &linklocal_list)
GlobalVrouter(Agent *agent)
std::map< FlowAgingTimeoutKey, uint32_t > FlowAgingTimeoutMap
void Delete(const IpAddress &address)
std::vector< autogen::EncryptionTunnelEndpoint > EncryptionTunnelEndpointList
EcmpLoadBalance ecmp_load_balance_
void ConfigAddChange(IFMapNode *node)
void UpdateSLOConfig(IFMapNode *node)
boost::intrusive_ptr< DBTableWalk > DBTableWalkRef
Definition: db_table.h:169
bool operator==(const FlowAgingTimeoutKey &rhs) const
void DeleteLinkLocalServiceConfig()
void Add(const IpAddress &address)
std::string CryptTunnelKey
void DeleteCryptTunnelEndpoint(const CryptTunnelsMap::iterator &it)
bool IsAddressInUse(const Ip4Address &ip) const
std::vector< PortRange > port_range
std::pair< LinkLocalServiceKey, LinkLocalService > LinkLocalServicesPair
AgentRouteWalkerPtr agent_route_resync_walker_
void DeletePortConfig()
static const Ip4Address kLoopBackIp
static const int32_t kDefaultFlowExportRate