OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MetadataProxy Class Reference

#include <metadata_proxy.h>

Collaboration diagram for MetadataProxy:

Classes

struct  MetadataStats
 
struct  SessionData
 

Public Types

typedef std::map< HttpSession
*, SessionData
SessionMap
 
typedef std::pair< HttpSession
*, SessionData
SessionPair
 
typedef std::map
< HttpConnection
*, HttpSession * > 
ConnectionSessionMap
 
typedef std::pair
< HttpConnection
*, HttpSession * > 
ConnectionSessionPair
 
typedef boost::intrusive_ptr
< HttpSession
HttpSessionPtr
 

Public Member Functions

 MetadataProxy (ServicesModule *module, const std::string &secret)
 
virtual ~MetadataProxy ()
 
void CloseSessions ()
 
void Shutdown ()
 
void HandleMetadataRequest (HttpSession *session, const HttpRequest *request)
 
void HandleMetadataResponse (HttpConnection *conn, HttpSessionPtr session, std::string &msg, boost::system::error_code &ec)
 
void OnServerSessionEvent (HttpSession *session, TcpSession::Event event)
 
void OnClientSessionEvent (HttpClientSession *session, TcpSession::Event event)
 
const MetadataStatsmetadatastats () const
 
void ClearStats ()
 
int VhostIndex (const std::string &vhost_name)
 Returns index of a network device that is specified by vhost_name. More...
 
bool NetlinkGetVhostIp (Ip6Address &vhost_ll_ip)
 Adds an IP address specified in vhost_ll_ip to vhost0 interface inet6 addresses. More...
 
void NetlinkAddVhostNb (const IpAddress &nb_ip, const MacAddress &via_mac)
 Adds a new neighbour (an arp entry) with given IP and MAC addresses. More...
 
void NetlinkAddInterfaceRoute (const IpAddress &intf_addr)
 Adds routes to internal addresses of VM's interfaces. More...
 
void AdvertiseMetaDataLinkLocalRoutes (const VmInterface *vm, const Ip6Address &ll_ip, const VrfEntry *intf_vrf)
 Advertises routes to a given vm-interface via a given IPv6 address. Routes are announced in the fabric VRF entry and in a given VRF entry. More...
 
void DeleteMetaDataLinkLocalRoute (const VmInterface *vm_intf)
 Deletes an announced earlier route to a vm interface via a given IPv6 address. More...
 
const Ip6AddressIpv6ServiceAddress () const
 Returns an IPv6 address of the Metadata TF link local service. More...
 
void InitializeHttp6Server (const VmInterface *vhost0)
 Initializes an HTTP server for IPv6 requests. More...
 
void AdvertiseVhostRoute ()
 Advertises the LL route to vhost0 interface in the fabric VRF instance. More...
 
void DeleteVhostRoute ()
 Deletes the LL route to vhost0 interface in the fabric VRF instance. More...
 
void OnAVrfChange (DBTablePartBase *part, DBEntryBase *e)
 A callback that is invoked each time when a VRF entry is modified: added, changed or deleted. More...
 
void OnAFabricRouteChange (DBTablePartBase *part, DBEntryBase *e)
 A callback that is invoked each time when a route is modified in the fabric policy VRF inet4 unicast table. The callback is used to update IPv6 address of the metadata link local service. IPv6 address of the service is calculated as: FE80 + IPv4 address, e.g. for IPv4 169.254.169.254, the IPv6 address is FE80::A9FE:A9FE. More...
 
void OnAnInterfaceChange (DBTablePartBase *part, DBEntryBase *e)
 A callback which is invoked everytime any vm interface is changed. Handles deletion of routes associated with a deleted vm interface. More...
 
void RegisterListeners ()
 Registers callbacks to intercept Agent's events emerging when a VRF entry is modified or an Interface is modified. More...
 
void UnregisterListeners ()
 Unregisters all callbacks that were registered earlier to intercept Agent's events: MetadataProxy::OnAVrfChange, MetadataProxy::OnAFabricPolicyRouteChange, MetadataProxy::OnAnInterfaceChange. More...
 

Private Member Functions

HttpConnectionGetProxyConnection (HttpSession *session, bool conn_close, std::string *nova_hostname)
 
void CloseServerSession (HttpSession *session)
 
void CloseClientSession (HttpConnection *conn)
 
void ErrorClose (HttpSession *sesion, uint16_t error)
 
 DISALLOW_COPY_AND_ASSIGN (MetadataProxy)
 

Private Attributes

ServicesModuleservices_
 
std::string shared_secret_
 
MetadataServerhttp_server_
 A pointer to a HTTP server listening on a IPv4 socket for Metadata requests from tenants / virtual machines. More...
 
MetadataServerhttp_server6_
 A pointer to a HTTP server listening on a IPv6 socket for Metadata requests from tenants / virtual machines. More...
 
MetadataClienthttp_client_
 
SessionMap metadata_sessions_
 
ConnectionSessionMap metadata_proxy_sessions_
 
MetadataStats metadata_stats_
 
Ip6Address ipv6_service_address_
 An IPv6 address on which Metadata6 link local service listens on. We use it instead of IPv4 compute IP. More...
 
DBTableBase::ListenerId vrf_table_notify_id_
 an ID of a listener (callback) that acts when the VRF Table is modified More...
 
DBTableBase::ListenerId fabric_notify_id_
 an ID of a listener (callback) that acts when a Fabric Policy VRF entry is modified More...
 
DBTableBase::ListenerId intf_table_notify_id_
 an ID of a listener (callback) that acts when an InterfaceTable entry is modified More...
 
std::map< std::string, Ip6Addressll_ipv6_addresses_
 A correspondence table between a name of a vm interface, which requests a data from the service and the vm interface link local IPv6 address. The table is needed to obtain a link local address of vm interface in the MetadataProxy::DeleteMetaDataLinkLocalRoute function. More...
 
tbb::mutex ll_ipv6_addr_mutex_
 A mutex which prevents simultaneous access to MetadataProxy::ll_ipv6_addresses_ table and member functions: MetadataProxy::DeleteMetaDataLinkLocalRoute, MetadataProxy::AdvertiseMetaDataLinkLocalRoutes. More...
 

Detailed Description

Definition at line 16 of file metadata_proxy.h.

Member Typedef Documentation

Definition at line 42 of file metadata_proxy.h.

Definition at line 43 of file metadata_proxy.h.

typedef boost::intrusive_ptr<HttpSession> MetadataProxy::HttpSessionPtr

Definition at line 44 of file metadata_proxy.h.

Definition at line 40 of file metadata_proxy.h.

Definition at line 41 of file metadata_proxy.h.

Constructor & Destructor Documentation

MetadataProxy::MetadataProxy ( ServicesModule module,
const std::string &  secret 
)

Definition at line 83 of file metadata_proxy.cc.

Here is the call graph for this function:

MetadataProxy::~MetadataProxy ( )
virtual

Definition at line 105 of file metadata_proxy.cc.

Here is the call graph for this function:

Member Function Documentation

void MetadataProxy::AdvertiseMetaDataLinkLocalRoutes ( const VmInterface vm,
const Ip6Address ll_ip,
const VrfEntry intf_vrf 
)

Advertises routes to a given vm-interface via a given IPv6 address. Routes are announced in the fabric VRF entry and in a given VRF entry.

Parameters
vmis a pointer to the vm interface
ll_ipis an IPv6 address (prefix) to announce route to
intf_vrfis a pointer to the VRF entry to which the vm interface belongs to

Definition at line 35 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

void MetadataProxy::AdvertiseVhostRoute ( )

Advertises the LL route to vhost0 interface in the fabric VRF instance.

Definition at line 165 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

void MetadataProxy::ClearStats ( )
inline

Definition at line 59 of file metadata_proxy.h.

Here is the call graph for this function:

void MetadataProxy::CloseClientSession ( HttpConnection conn)
private

Definition at line 477 of file metadata_proxy.cc.

Here is the call graph for this function:

void MetadataProxy::CloseServerSession ( HttpSession session)
private

Definition at line 471 of file metadata_proxy.cc.

Here is the call graph for this function:

void MetadataProxy::CloseSessions ( )

Definition at line 109 of file metadata_proxy.cc.

Here is the call graph for this function:

void MetadataProxy::DeleteMetaDataLinkLocalRoute ( const VmInterface vm_intf)

Deletes an announced earlier route to a vm interface via a given IPv6 address.

Parameters
vm_intfis a pointer to the vm interface for which route should be deleted

Definition at line 76 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

void MetadataProxy::DeleteVhostRoute ( )

Deletes the LL route to vhost0 interface in the fabric VRF instance.

Definition at line 191 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

MetadataProxy::DISALLOW_COPY_AND_ASSIGN ( MetadataProxy  )
private
void MetadataProxy::ErrorClose ( HttpSession sesion,
uint16_t  error 
)
private

Definition at line 484 of file metadata_proxy.cc.

Here is the call graph for this function:

HttpConnection * MetadataProxy::GetProxyConnection ( HttpSession session,
bool  conn_close,
std::string *  nova_hostname 
)
private

Definition at line 414 of file metadata_proxy.cc.

Here is the call graph for this function:

void MetadataProxy::HandleMetadataRequest ( HttpSession session,
const HttpRequest request 
)

Definition at line 143 of file metadata_proxy.cc.

Here is the call graph for this function:

void MetadataProxy::HandleMetadataResponse ( HttpConnection conn,
HttpSessionPtr  session,
std::string &  msg,
boost::system::error_code &  ec 
)

Definition at line 294 of file metadata_proxy.cc.

Here is the call graph for this function:

void MetadataProxy::InitializeHttp6Server ( const VmInterface vhost0)

Initializes an HTTP server for IPv6 requests.

Definition at line 144 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

const Ip6Address & MetadataProxy::Ipv6ServiceAddress ( ) const

Returns an IPv6 address of the Metadata TF link local service.

Returns
Ip6Address structure containing the IPv6 address

Definition at line 140 of file metadata_proxy_ip6.cc.

const MetadataStats& MetadataProxy::metadatastats ( ) const
inline

Definition at line 58 of file metadata_proxy.h.

void MetadataProxy::NetlinkAddInterfaceRoute ( const IpAddress intf_addr)

Adds routes to internal addresses of VM's interfaces.

Parameters
intf_addr- the internal IP address assigned to an interface (metadata IP)

Definition at line 493 of file linux/metadata_ipv6_netlink.cc.

Here is the call graph for this function:

void MetadataProxy::NetlinkAddVhostNb ( const IpAddress nb_ip,
const MacAddress via_mac 
)

Adds a new neighbour (an arp entry) with given IP and MAC addresses.

Parameters
nb_ip- the IP address of a neighbour
via_mac- the MAC address of a neighbour

Definition at line 18 of file freebsd/metadata_ipv6_netlink.cc.

bool MetadataProxy::NetlinkGetVhostIp ( Ip6Address vhost_ll_ip)

Adds an IP address specified in vhost_ll_ip to vhost0 interface inet6 addresses.

Parameters
vhost_ll_ipis a new IP address for vhost0 interface
Returns
true if address has been successfully bound to the interface and false otherwise

Definition at line 359 of file linux/metadata_ipv6_netlink.cc.

Here is the call graph for this function:

void MetadataProxy::OnAFabricRouteChange ( DBTablePartBase part,
DBEntryBase e 
)

A callback that is invoked each time when a route is modified in the fabric policy VRF inet4 unicast table. The callback is used to update IPv6 address of the metadata link local service. IPv6 address of the service is calculated as: FE80 + IPv4 address, e.g. for IPv4 169.254.169.254, the IPv6 address is FE80::A9FE:A9FE.

Parameters
partis a pointer to a table partititon containing corresponding modified route
eis a pointer to the modified InetUnicastRouteEntry

Definition at line 222 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

void MetadataProxy::OnAnInterfaceChange ( DBTablePartBase part,
DBEntryBase e 
)

A callback which is invoked everytime any vm interface is changed. Handles deletion of routes associated with a deleted vm interface.

Parameters
partis a pointer to a table partititon containing corresponding vm interface
eis a pointer to the vm interface

Definition at line 262 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

void MetadataProxy::OnAVrfChange ( DBTablePartBase part,
DBEntryBase e 
)

A callback that is invoked each time when a VRF entry is modified: added, changed or deleted.

Parameters
partis a pointer to a table partititon containing corresponding VRF entry
eis a pointer to the modified VrfEntry

Definition at line 199 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

void MetadataProxy::OnClientSessionEvent ( HttpClientSession session,
TcpSession::Event  event 
)

Definition at line 387 of file metadata_proxy.cc.

Here is the call graph for this function:

void MetadataProxy::OnServerSessionEvent ( HttpSession session,
TcpSession::Event  event 
)

Definition at line 370 of file metadata_proxy.cc.

Here is the call graph for this function:

void MetadataProxy::RegisterListeners ( )

Registers callbacks to intercept Agent's events emerging when a VRF entry is modified or an Interface is modified.

Definition at line 281 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

void MetadataProxy::Shutdown ( )

Definition at line 123 of file metadata_proxy.cc.

Here is the call graph for this function:

void MetadataProxy::UnregisterListeners ( )

Unregisters all callbacks that were registered earlier to intercept Agent's events: MetadataProxy::OnAVrfChange, MetadataProxy::OnAFabricPolicyRouteChange, MetadataProxy::OnAnInterfaceChange.

Definition at line 298 of file metadata_proxy_ip6.cc.

Here is the call graph for this function:

int MetadataProxy::VhostIndex ( const std::string &  vhost_name)

Returns index of a network device that is specified by vhost_name.

Parameters
vhost_nameis a name of a network device
Returns
integer index of a network device

Definition at line 26 of file metadata_proxy_ip6.cc.

Member Data Documentation

DBTableBase::ListenerId MetadataProxy::fabric_notify_id_
private

an ID of a listener (callback) that acts when a Fabric Policy VRF entry is modified

Definition at line 185 of file metadata_proxy.h.

MetadataClient* MetadataProxy::http_client_
private

Definition at line 170 of file metadata_proxy.h.

MetadataServer* MetadataProxy::http_server6_
private

A pointer to a HTTP server listening on a IPv6 socket for Metadata requests from tenants / virtual machines.

Definition at line 168 of file metadata_proxy.h.

MetadataServer* MetadataProxy::http_server_
private

A pointer to a HTTP server listening on a IPv4 socket for Metadata requests from tenants / virtual machines.

Definition at line 164 of file metadata_proxy.h.

DBTableBase::ListenerId MetadataProxy::intf_table_notify_id_
private

an ID of a listener (callback) that acts when an InterfaceTable entry is modified

Definition at line 189 of file metadata_proxy.h.

Ip6Address MetadataProxy::ipv6_service_address_
private

An IPv6 address on which Metadata6 link local service listens on. We use it instead of IPv4 compute IP.

Definition at line 177 of file metadata_proxy.h.

tbb::mutex MetadataProxy::ll_ipv6_addr_mutex_
private

A mutex which prevents simultaneous access to MetadataProxy::ll_ipv6_addresses_ table and member functions: MetadataProxy::DeleteMetaDataLinkLocalRoute, MetadataProxy::AdvertiseMetaDataLinkLocalRoutes.

Definition at line 201 of file metadata_proxy.h.

std::map<std::string, Ip6Address> MetadataProxy::ll_ipv6_addresses_
private

A correspondence table between a name of a vm interface, which requests a data from the service and the vm interface link local IPv6 address. The table is needed to obtain a link local address of vm interface in the MetadataProxy::DeleteMetaDataLinkLocalRoute function.

Definition at line 195 of file metadata_proxy.h.

ConnectionSessionMap MetadataProxy::metadata_proxy_sessions_
private

Definition at line 172 of file metadata_proxy.h.

SessionMap MetadataProxy::metadata_sessions_
private

Definition at line 171 of file metadata_proxy.h.

MetadataStats MetadataProxy::metadata_stats_
private

Definition at line 173 of file metadata_proxy.h.

ServicesModule* MetadataProxy::services_
private

Definition at line 159 of file metadata_proxy.h.

std::string MetadataProxy::shared_secret_
private

Definition at line 160 of file metadata_proxy.h.

DBTableBase::ListenerId MetadataProxy::vrf_table_notify_id_
private

an ID of a listener (callback) that acts when the VRF Table is modified

Definition at line 181 of file metadata_proxy.h.


The documentation for this class was generated from the following files: