OpenSDN source code
|
#include <metadata_proxy.h>
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 MetadataStats & | metadatastats () 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 Ip6Address & | Ipv6ServiceAddress () 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 | |
HttpConnection * | GetProxyConnection (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 | |
ServicesModule * | services_ |
std::string | shared_secret_ |
MetadataServer * | http_server_ |
A pointer to a HTTP server listening on a IPv4 socket for Metadata requests from tenants / virtual machines. More... | |
MetadataServer * | http_server6_ |
A pointer to a HTTP server listening on a IPv6 socket for Metadata requests from tenants / virtual machines. More... | |
MetadataClient * | http_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, Ip6Address > | ll_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... | |
Definition at line 16 of file metadata_proxy.h.
typedef std::map<HttpConnection *, HttpSession *> MetadataProxy::ConnectionSessionMap |
Definition at line 42 of file metadata_proxy.h.
typedef std::pair<HttpConnection *, HttpSession *> MetadataProxy::ConnectionSessionPair |
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.
typedef std::map<HttpSession *, SessionData> MetadataProxy::SessionMap |
Definition at line 40 of file metadata_proxy.h.
typedef std::pair<HttpSession *, SessionData> MetadataProxy::SessionPair |
Definition at line 41 of file metadata_proxy.h.
MetadataProxy::MetadataProxy | ( | ServicesModule * | module, |
const std::string & | secret | ||
) |
|
virtual |
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.
vm | is a pointer to the vm interface |
ll_ip | is an IPv6 address (prefix) to announce route to |
intf_vrf | is a pointer to the VRF entry to which the vm interface belongs to |
Definition at line 35 of file metadata_proxy_ip6.cc.
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.
|
inline |
|
private |
|
private |
void MetadataProxy::CloseSessions | ( | ) |
void MetadataProxy::DeleteMetaDataLinkLocalRoute | ( | const VmInterface * | vm_intf | ) |
Deletes an announced earlier route to a vm interface via a given IPv6 address.
vm_intf | is a pointer to the vm interface for which route should be deleted |
Definition at line 76 of file metadata_proxy_ip6.cc.
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.
|
private |
|
private |
|
private |
void MetadataProxy::HandleMetadataRequest | ( | HttpSession * | session, |
const HttpRequest * | request | ||
) |
void MetadataProxy::HandleMetadataResponse | ( | HttpConnection * | conn, |
HttpSessionPtr | session, | ||
std::string & | msg, | ||
boost::system::error_code & | ec | ||
) |
void MetadataProxy::InitializeHttp6Server | ( | const VmInterface * | vhost0 | ) |
Initializes an HTTP server for IPv6 requests.
Definition at line 144 of file metadata_proxy_ip6.cc.
const Ip6Address & MetadataProxy::Ipv6ServiceAddress | ( | ) | const |
Returns an IPv6 address of the Metadata TF link local service.
Definition at line 140 of file metadata_proxy_ip6.cc.
|
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.
intf_addr | - the internal IP address assigned to an interface (metadata IP) |
Definition at line 493 of file linux/metadata_ipv6_netlink.cc.
void MetadataProxy::NetlinkAddVhostNb | ( | const IpAddress & | nb_ip, |
const MacAddress & | via_mac | ||
) |
Adds a new neighbour (an arp entry) with given IP and MAC addresses.
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.
vhost_ll_ip | is a new IP address for vhost0 interface |
Definition at line 359 of file linux/metadata_ipv6_netlink.cc.
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.
part | is a pointer to a table partititon containing corresponding modified route |
e | is a pointer to the modified InetUnicastRouteEntry |
Definition at line 222 of file metadata_proxy_ip6.cc.
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.
part | is a pointer to a table partititon containing corresponding vm interface |
e | is a pointer to the vm interface |
Definition at line 262 of file metadata_proxy_ip6.cc.
void MetadataProxy::OnAVrfChange | ( | DBTablePartBase * | part, |
DBEntryBase * | e | ||
) |
A callback that is invoked each time when a VRF entry is modified: added, changed or deleted.
part | is a pointer to a table partititon containing corresponding VRF entry |
e | is a pointer to the modified VrfEntry |
Definition at line 199 of file metadata_proxy_ip6.cc.
void MetadataProxy::OnClientSessionEvent | ( | HttpClientSession * | session, |
TcpSession::Event | event | ||
) |
void MetadataProxy::OnServerSessionEvent | ( | HttpSession * | session, |
TcpSession::Event | event | ||
) |
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.
void MetadataProxy::Shutdown | ( | ) |
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.
int MetadataProxy::VhostIndex | ( | const std::string & | vhost_name | ) |
Returns index of a network device that is specified by vhost_name.
vhost_name | is a name of a network device |
Definition at line 26 of file metadata_proxy_ip6.cc.
|
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.
|
private |
Definition at line 170 of file metadata_proxy.h.
|
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.
|
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.
|
private |
an ID of a listener (callback) that acts when an InterfaceTable entry is modified
Definition at line 189 of file metadata_proxy.h.
|
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.
|
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.
|
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.
|
private |
Definition at line 172 of file metadata_proxy.h.
|
private |
Definition at line 171 of file metadata_proxy.h.
|
private |
Definition at line 173 of file metadata_proxy.h.
|
private |
Definition at line 159 of file metadata_proxy.h.
|
private |
Definition at line 160 of file metadata_proxy.h.
|
private |
an ID of a listener (callback) that acts when the VRF Table is modified
Definition at line 181 of file metadata_proxy.h.