#include "squid.h"
#include "CachePeer.h"
#include "CachePeers.h"
#include "cbdata.h"
#include "event.h"
#include "fde.h"
#include "fs_io.h"
#include "FwdState.h"
#include "HttpReply.h"
#include "icmp/net_db.h"
#include "internal.h"
#include "ip/Address.h"
#include "log/File.h"
#include "MemObject.h"
#include "mgr/Registration.h"
#include "mime_header.h"
#include "neighbors.h"
#include "PeerSelectState.h"
#include "sbuf/SBuf.h"
#include "SquidConfig.h"
#include "Store.h"
#include "StoreClient.h"
#include "tools.h"
#include "wordlist.h"
#include "icmp/IcmpSquid.h"
#include "ipcache.h"
Go to the source code of this file.
Classes | |
class | netdbExchangeState |
Enumerations | |
enum | netdb_conn_state_t { STATE_NONE , STATE_HEADER , STATE_BODY } |
Functions | |
CBDATA_CLASS_INIT (netdbExchangeState) | |
Ip::Address | networkFromInaddr (const Ip::Address &a) |
static void | netdbRelease (netdbEntry *n) |
static void | netdbHashInsert (netdbEntry *n, Ip::Address &addr) |
static void | netdbHashDelete (const char *key) |
static void | netdbHostInsert (netdbEntry *n, const char *hostname) |
static void | netdbHostDelete (const net_db_name *x) |
static void | netdbPurgeLRU (void) |
static netdbEntry * | netdbLookupHost (const char *key) |
static net_db_peer * | netdbPeerByName (const netdbEntry *n, const char *) |
static net_db_peer * | netdbPeerAdd (netdbEntry *n, CachePeer *e) |
static const char * | netdbPeerName (const char *name) |
static int | netdbLRU (const void *A, const void *B) |
static netdbEntry * | netdbLookupAddr (const Ip::Address &addr) |
static netdbEntry * | netdbAdd (Ip::Address &addr) |
static void | netdbSendPing (const ipcache_addrs *ia, const Dns::LookupDetails &, void *data) |
static int | sortByRtt (const void *A, const void *B) |
static int | sortPeerByRtt (const void *A, const void *B) |
static void | netdbSaveState (void *) |
static void | netdbReloadState (void) |
static void | netdbExchangeHandleReply (void *data, StoreIOBuffer receivedData) |
void | netdbInit (void) |
void | netdbPingSite (const char *hostname) |
void | netdbHandlePingReply (const Ip::Address &from, int hops, int rtt) |
void | netdbDump (StoreEntry *sentry) |
int | netdbHostHops (const char *host) |
int | netdbHostRtt (const char *host) |
void | netdbHostData (const char *host, int *samp, int *rtt, int *hops) |
void | netdbUpdatePeer (const AnyP::Uri &url, CachePeer *e, int irtt, int ihops) |
void | netdbExchangeUpdatePeer (Ip::Address &addr, CachePeer *e, double rtt, double hops) |
void | netdbDeleteAddrNetwork (Ip::Address &addr) |
void | netdbBinaryExchange (StoreEntry *s) |
void | netdbExchangeStart (void *data) |
static CachePeer * | findUsableParentAtHostname (PeerSelector *ps, const char *const hostname, const HttpRequest &request) |
CachePeer * | netdbClosestParent (PeerSelector *ps) |
Variables | |
static hash_table * | addr_table = nullptr |
static hash_table * | host_table = nullptr |
static IPH | netdbSendPing |
static STCB | netdbExchangeHandleReply |
static wordlist * | peer_names = nullptr |
Enumeration Type Documentation
◆ netdb_conn_state_t
enum netdb_conn_state_t |
Function Documentation
◆ CBDATA_CLASS_INIT()
CBDATA_CLASS_INIT | ( | netdbExchangeState | ) |
◆ findUsableParentAtHostname()
|
static |
a netdbClosestParent() helper to find the first usable parent CachePeer responsible for the given hostname
Definition at line 1235 of file net_db.cc.
References CurrentCachePeers(), neighborType(), PEER_PARENT, peerHTTPOkay(), and HttpRequest::url.
Referenced by netdbClosestParent().
◆ netdbAdd()
|
static |
Definition at line 265 of file net_db.cc.
References Config, SquidConfig::high, SquidConfig::Netdb, netdbHashInsert(), netdbLookupAddr(), and netdbPurgeLRU().
Referenced by netdbExchangeUpdatePeer(), and netdbSendPing().
◆ netdbBinaryExchange()
void netdbBinaryExchange | ( | StoreEntry * | s | ) |
Definition at line 1107 of file net_db.cc.
References addr_table, StoreEntry::append(), assert, StoreEntry::buffer(), StoreEntry::complete(), StoreEntry::flush(), Ip::Address::getInAddr(), hash_first(), hash_next(), netdbEntry::hops, int, Ip::Address::isIPv4(), MEM_4K_BUF, memAllocate(), memFree(), NETDB_EX_HOPS, NETDB_EX_NETWORK, NETDB_EX_RTT, netdbEntry::network, StoreEntry::replaceHttpReply(), netdbEntry::rtt, Http::scBadRequest, Http::scOkay, HttpReply::setHeaders(), squid_curtime, and storeAppendPrintf().
Referenced by internalStart().
◆ netdbClosestParent()
CachePeer * netdbClosestParent | ( | PeerSelector * | ps | ) |
Definition at line 1258 of file net_db.cc.
References assert, Dns::CachedIps::current(), findUsableParentAtHostname(), AnyP::Uri::host(), ipcache_gethostbyname(), netdbEntry::last_use_time, netdbEntry::n_peers, netdbLookupAddr(), netdbLookupHost(), net_db_peer::peername, netdbEntry::peers, PeerSelector::request, net_db_peer::rtt, netdbEntry::rtt, squid_curtime, and HttpRequest::url.
Referenced by PeerSelector::selectSomeNeighbor().
◆ netdbDeleteAddrNetwork()
void netdbDeleteAddrNetwork | ( | Ip::Address & | addr | ) |
Definition at line 1090 of file net_db.cc.
References debugs, netdbLookupAddr(), netdbRelease(), and netdbEntry::network.
Referenced by Comm::ConnOpener::sendAnswer().
◆ netdbDump()
void netdbDump | ( | StoreEntry * | sentry | ) |
Definition at line 877 of file net_db.cc.
References addr_table, DBG_CRITICAL, debugs, hash_first(), hash_next(), hashKeyStr(), net_db_peer::hops, netdbEntry::hops, netdbEntry::hosts, netdbEntry::n_peers, netdbEntry::network, net_db_name::next, net_db_peer::peername, netdbEntry::peers, netdbEntry::pings_recv, netdbEntry::pings_sent, net_db_peer::rtt, netdbEntry::rtt, sortByRtt(), storeAppendPrintf(), xcalloc(), and xfree.
Referenced by netdbInit().
◆ netdbExchangeHandleReply()
|
static |
Definition at line 664 of file net_db.cc.
References Store::ParsingBuffer::appended(), assert, Assure, store_client::atEof(), MemObject::baseReply(), Store::ParsingBuffer::c_str(), netdbExchangeState::connstate, Store::ParsingBuffer::consume(), Store::ParsingBuffer::contentSize(), StoreIOBuffer::data, DBG_IMPORTANT, debugs, double, netdbExchangeState::e, EBIT_TEST, ENTRY_ABORTED, StoreIOBuffer::error, StoreEntry::flags, StoreIOBuffer::flags, CbcPointer< Cbc >::get(), int, Ip::Address::isAnyAddr(), StoreIOBuffer::length, StoreEntry::mem(), NETDB_EX_HOPS, NETDB_EX_NETWORK, NETDB_EX_RTT, netdbExchangeHandleReply, netdbExchangeUpdatePeer(), StoreIOBuffer::offset, netdbExchangeState::p, netdbExchangeState::parsingBuffer, StoreIOBuffer::positionAt(), netdbExchangeState::sc, Http::scNone, Http::scOkay, Ip::Address::setAnyAddr(), size, HttpReply::sline, Store::ParsingBuffer::space(), STATE_BODY, STATE_HEADER, Http::StatusLine::status(), storeClientCopy(), and CbcPointer< Cbc >::valid().
◆ netdbExchangeStart()
void netdbExchangeStart | ( | void * | data | ) |
Definition at line 1197 of file net_db.cc.
References assert, DBG_IMPORTANT, debugs, netdbExchangeState::e, Security::PeerOptions::encryptTransport, HttpRequest::flags, HttpRequest::FromUrlXXX(), FwdState::fwdStart(), RefCount< C >::getRaw(), CachePeer::host, CachePeer::http_port, internalRemoteUri(), CachePeer::login, RequestFlags::loopDetected, Store::ParsingBuffer::makeInitialSpace(), Http::METHOD_GET, MYNAME, netdbExchangeHandleReply, netdbExchangeState::parsingBuffer, netdbExchangeState::r, netdbExchangeState::sc, CachePeer::secure, storeClientCopy(), storeClientListAdd(), storeCreateEntry(), HttpRequest::url, and AnyP::Uri::userInfo().
Referenced by peerDNSConfigure().
◆ netdbExchangeUpdatePeer()
void netdbExchangeUpdatePeer | ( | Ip::Address & | addr, |
CachePeer * | e, | ||
double | rtt, | ||
double | hops | ||
) |
Definition at line 1043 of file net_db.cc.
References assert, debugs, net_db_peer::expires, net_db_peer::hops, CachePeer::host, Ip::Address::isIPv4(), netdbEntry::n_peers, netdbAdd(), netdbLookupAddr(), netdbPeerAdd(), netdbPeerByName(), netdbEntry::peers, net_db_peer::rtt, sortPeerByRtt(), and squid_curtime.
Referenced by netdbExchangeHandleReply().
◆ netdbHandlePingReply()
void netdbHandlePingReply | ( | const Ip::Address & | from, |
int | hops, | ||
int | rtt | ||
) |
Definition at line 844 of file net_db.cc.
References debugs, netdbEntry::hops, netdbLookupAddr(), netdbEntry::network, netdbEntry::pings_recv, and netdbEntry::rtt.
Referenced by IcmpSquid::Recv().
◆ netdbHashDelete()
|
static |
Definition at line 126 of file net_db.cc.
References addr_table, debug_trap(), hash_lookup(), and hash_remove_link().
Referenced by netdbRelease().
◆ netdbHashInsert()
|
static |
Definition at line 117 of file net_db.cc.
References addr_table, assert, hash_join(), hash_lookup(), hash_link::key, MAX_IPSTRLEN, netdbEntry::network, networkFromInaddr(), and Ip::Address::toStr().
Referenced by netdbAdd(), and netdbReloadState().
◆ netdbHostData()
Definition at line 977 of file net_db.cc.
References netdbEntry::hops, int, netdbEntry::last_use_time, netdbLookupHost(), netdbEntry::pings_recv, netdbEntry::rtt, and squid_curtime.
Referenced by htcpTstReply().
◆ netdbHostDelete()
|
static |
Definition at line 158 of file net_db.cc.
References assert, hash_remove_link(), host_table, netdbEntry::hosts, netdbEntry::link_count, net_db_name::net_db_entry, and net_db_name::next.
Referenced by netdbRelease().
◆ netdbHostHops()
int netdbHostHops | ( | const char * | host | ) |
Definition at line 944 of file net_db.cc.
References netdbEntry::hops, netdbEntry::last_use_time, netdbLookupHost(), and squid_curtime.
Referenced by PeerSelector::checkNetdbDirect(), and doV2Query().
◆ netdbHostInsert()
|
static |
Definition at line 150 of file net_db.cc.
References assert, hash_join(), hash_lookup(), and host_table.
Referenced by netdbReloadState(), and netdbSendPing().
◆ netdbHostRtt()
int netdbHostRtt | ( | const char * | host | ) |
Definition at line 960 of file net_db.cc.
References netdbEntry::last_use_time, netdbLookupHost(), netdbEntry::rtt, and squid_curtime.
Referenced by PeerSelector::checkNetdbDirect(), doV2Query(), neighborsDigestSelect(), and urnParseReply().
◆ netdbInit()
void netdbInit | ( | void | ) |
Definition at line 803 of file net_db.cc.
References addr_table, Config, eventAddIsh(), hash_create(), hash_string, hashPrime(), SquidConfig::high, host_table, SquidConfig::Netdb, netdbDump(), netdbReloadState(), netdbSaveState(), and Mgr::RegisterAction().
Referenced by serverConnectionsOpen().
◆ netdbLookupAddr()
|
static |
Definition at line 254 of file net_db.cc.
References addr_table, hash_lookup(), MAX_IPSTRLEN, networkFromInaddr(), and Ip::Address::toStr().
Referenced by netdbAdd(), netdbClosestParent(), netdbDeleteAddrNetwork(), netdbExchangeUpdatePeer(), netdbHandlePingReply(), netdbReloadState(), and netdbSendPing().
◆ netdbLookupHost()
|
static |
Definition at line 178 of file net_db.cc.
References hash_lookup(), host_table, and net_db_name::net_db_entry.
Referenced by netdbClosestParent(), netdbHostData(), netdbHostHops(), netdbHostRtt(), netdbPingSite(), netdbReloadState(), netdbSendPing(), and netdbUpdatePeer().
◆ netdbLRU()
|
static |
◆ netdbPeerAdd()
|
static |
Definition at line 416 of file net_db.cc.
References debugs, CachePeer::host, netdbEntry::n_peers, netdbEntry::n_peers_alloc, netdbPeerName(), netdbEntry::network, net_db_peer::peername, netdbEntry::peers, safe_free, and xcalloc().
Referenced by netdbExchangeUpdatePeer(), and netdbUpdatePeer().
◆ netdbPeerByName()
|
static |
Definition at line 402 of file net_db.cc.
References netdbEntry::n_peers, net_db_peer::peername, and netdbEntry::peers.
Referenced by netdbExchangeUpdatePeer(), and netdbUpdatePeer().
◆ netdbPeerName()
|
static |
Definition at line 651 of file net_db.cc.
References wordlist::key, wordlist::next, peer_names, and wordlistAdd().
Referenced by netdbPeerAdd().
◆ netdbPingSite()
void netdbPingSite | ( | const char * | hostname | ) |
Definition at line 827 of file net_db.cc.
References ipcache_nbgethostbyname(), netdbLookupHost(), netdbSendPing, netdbEntry::next_ping_time, squid_curtime, and xstrdup.
Referenced by TunnelStateData::connectDone(), FwdState::dispatch(), doV2Query(), and urnParseReply().
◆ netdbPurgeLRU()
|
static |
Definition at line 223 of file net_db.cc.
References addr_table, assert, Config, hash_first(), hash_next(), SquidConfig::low, SquidConfig::Netdb, netdbLRU(), netdbRelease(), xcalloc(), and xfree.
Referenced by netdbAdd().
◆ netdbRelease()
|
static |
Definition at line 185 of file net_db.cc.
References netdbEntry::hosts, netdbEntry::link_count, netdbEntry::n_peers, netdbEntry::n_peers_alloc, netdbHashDelete(), netdbHostDelete(), netdbEntry::network, net_db_name::next, netdbEntry::peers, and safe_free.
Referenced by netdbDeleteAddrNetwork(), and netdbPurgeLRU().
◆ netdbReloadState()
|
static |
Definition at line 529 of file net_db.cc.
References assert, Config, current_time, DBG_IMPORTANT, debugs, FD_READ_METHOD(), file_close(), file_open(), getCurrentTime(), netdbEntry::hops, netdbEntry::last_use_time, SquidConfig::netdbFilename, netdbHashInsert(), netdbHostInsert(), netdbLookupAddr(), netdbLookupHost(), netdbEntry::next_ping_time, O_BINARY, netdbEntry::pings_recv, netdbEntry::pings_sent, netdbEntry::rtt, safe_free, sb, tvSubMsec(), w_space, xcalloc(), and xfree.
Referenced by netdbInit().
◆ netdbSaveState()
|
static |
Definition at line 465 of file net_db.cc.
References addr_table, Config, current_time, DBG_IMPORTANT, debugs, eventAddIsh(), getCurrentTime(), hash_first(), hash_next(), hashKeyStr(), netdbEntry::hops, netdbEntry::hosts, netdbEntry::last_use_time, logfileClose(), logfileOpen(), logfilePrintf(), MYNAME, SquidConfig::netdbFilename, netdbSaveState(), netdbEntry::network, net_db_name::next, netdbEntry::next_ping_time, netdbEntry::pings_recv, netdbEntry::pings_sent, netdbEntry::rtt, tvSubMsec(), and xstrerr().
Referenced by netdbInit(), and netdbSaveState().
◆ netdbSendPing()
|
static |
Definition at line 281 of file net_db.cc.
References Config, Dns::CachedIps::current(), DBG_IMPORTANT, debugs, IcmpSquid::DomainPing(), hash_lookup(), host_table, netdbEntry::hosts, icmpEngine, netdbEntry::last_use_time, netdbEntry::link_count, net_db_name::net_db_entry, SquidConfig::Netdb, netdbAdd(), netdbHostInsert(), netdbLookupAddr(), netdbLookupHost(), netdbEntry::network, net_db_name::next, netdbEntry::next_ping_time, SquidConfig::period, netdbEntry::pings_sent, squid_curtime, and xfree.
◆ netdbUpdatePeer()
Definition at line 1002 of file net_db.cc.
References debugs, double, net_db_peer::expires, net_db_peer::hops, AnyP::Uri::host(), CachePeer::host, netdbEntry::n_peers, netdbLookupHost(), netdbPeerAdd(), netdbPeerByName(), netdbEntry::peers, net_db_peer::rtt, sortPeerByRtt(), and squid_curtime.
Referenced by PeerSelector::handleHtcpParentMiss(), and PeerSelector::handleIcpParentMiss().
◆ networkFromInaddr()
Ip::Address networkFromInaddr | ( | const Ip::Address & | a | ) |
Definition at line 349 of file net_db.cc.
References Ip::Address::applyMask(), debugs, Ip::Address::getInAddr(), and Ip::Address::isIPv6().
Referenced by netdbHashInsert(), and netdbLookupAddr().
◆ sortByRtt()
|
static |
◆ sortPeerByRtt()
|
static |
Definition at line 451 of file net_db.cc.
References A, B, and net_db_peer::rtt.
Referenced by netdbExchangeUpdatePeer(), and netdbUpdatePeer().
Variable Documentation
◆ addr_table
|
static |
Definition at line 92 of file net_db.cc.
Referenced by netdbBinaryExchange(), netdbDump(), netdbHashDelete(), netdbHashInsert(), netdbInit(), netdbLookupAddr(), netdbPurgeLRU(), and netdbSaveState().
◆ host_table
|
static |
Definition at line 93 of file net_db.cc.
Referenced by netdbHostDelete(), netdbHostInsert(), netdbInit(), netdbLookupHost(), and netdbSendPing().
◆ netdbExchangeHandleReply
|
static |
Definition at line 108 of file net_db.cc.
Referenced by netdbExchangeHandleReply(), and netdbExchangeStart().
◆ netdbSendPing
|
static |
Definition at line 107 of file net_db.cc.
Referenced by netdbPingSite().
◆ peer_names
|
static |
Definition at line 114 of file net_db.cc.
Referenced by netdbPeerName().