Collaboration diagram for IP Cache API:

Modules

 IP Cache Internals
 

Classes

class  ipcache_entry
 

Functions

void ipcache_purgelru (void *)
 
void ipcache_nbgethostbyname (const char *name, IPH *handler, void *handlerData)
 
void ipcache_init (void)
 
const ipcache_addrsipcache_gethostbyname (const char *name, int flags)
 
void ipcacheInvalidate (const char *name)
 
void ipcacheInvalidateNegative (const char *name)
 
static const Dns::CachedIpsipcacheCheckNumeric (const char *name)
 
void ipcacheMarkGoodAddr (const char *name, const Ip::Address &addr)
 
void ipcache_restart (void)
 
int ipcacheAddEntryFromHosts (const char *name, const char *ipaddr)
 
variable_listsnmp_netIpFn (variable_list *Var, snint *ErrP)
 

Detailed Description

Introduction

The IP cache is a built-in component of squid providing Hostname to IP-Number translation functionality and managing the involved data-structures. Efficiency concerns require mechanisms that allow non-blocking access to these mappings. The IP cache usually doesn't block on a request except for special cases where this is desired (see below).

Function Documentation

◆ ipcache_gethostbyname()

const ipcache_addrs * ipcache_gethostbyname ( const char *  name,
int  flags 
)

Is different from ipcache_nbgethostbyname in that it only checks if an entry exists in the cache and does not by default contact the DNS, unless this is requested, by setting the flags.

Parameters
nameHost name to resolve.
flagsDefault is NULL, set to IP_LOOKUP_IF_MISS to explicitly perform DNS lookups.
Return values
NULLAn error occurred during lookup
NULLNo results available in cache and no lookup specified
*Pointer to the ipcahce_addrs structure containing the lookup results

Definition at line 728 of file ipcache.cc.

References ipcache_entry::addrs, assert, debugs, ipcache_entry::flags, _ipcache_stats::hits, IP_LOOKUP_IF_MISS, ipcache_get(), ipcache_nbgethostbyname(), ipcacheCheckNumeric(), ipcacheExpiredEntry(), ipcacheRelease(), IpcacheStats, ipcache_entry::lastref, _ipcache_stats::misses, _ipcache_stats::negative_hits, ipcache_entry::Flags::negcached, _ipcache_stats::numeric_hits, _ipcache_stats::requests, and squid_curtime.

Referenced by Acl::DestinationAsnCheck::match(), ACLDestinationIP::match(), and netdbClosestParent().

◆ ipcache_init()

void ipcache_init ( void  )

Initialize the ipcache. Is called from mainInitialize() after disk initialization and prior to the reverse FQDNCache initialization

Definition at line 695 of file ipcache.cc.

References Config, debugs, hash4, hash_create(), hashPrime(), SquidConfig::high, Important, ip_table, SquidConfig::ipcache, ipcache_high, ipcache_low, ipcacheRegisterWithCacheManager(), IpcacheStats, SquidConfig::low, lru_list, and SquidConfig::size.

Referenced by mainInitialize().

◆ ipcache_nbgethostbyname()

void ipcache_nbgethostbyname ( const char *  name,
IPH handler,
void *  handlerData 
)
Parameters
nameHost to resolve.
handlerPointer to the function to be called when the reply from the IP cache (or the DNS if the IP cache misses)
handlerDataInformation that is passed to the handler and does not affect the IP cache.

XXX: on hits and some errors, the handler is called immediately instead of scheduling an async call. This reentrant behavior means that the user job must be extra careful after calling ipcache_nbgethostbyname, especially if the handler destroys the job. Moreover, the job has no way of knowing whether the reentrant call happened. Comm::Connection setup usually protects the job by scheduling an async call, but some user code calls ipcache_nbgethostbyname directly.

Definition at line 608 of file ipcache.cc.

References debugs, handler(), and ipcache_nbgethostbyname_().

Referenced by DestinationIPLookup::checkForAsync(), ClientRequestContext::hostHeaderVerify(), icpIncomingConnectionOpened(), ipcache_gethostbyname(), netdbPingSite(), Adaptation::Icap::Xaction::openConnection(), peerAlive(), and peerRefreshDNS().

◆ ipcache_purgelru()

◆ ipcache_restart()

void ipcache_restart ( void  )

Recalculate IP cache size upon reconfigure. Is called to clear the IPCache's data structures, cancel all pending requests.

Definition at line 1102 of file ipcache.cc.

References Config, SquidConfig::high, SquidConfig::ipcache, ipcache_high, ipcache_low, SquidConfig::low, purge_entries_fromhosts(), and SquidConfig::size.

Referenced by mainReconfigureFinish().

◆ ipcacheAddEntryFromHosts()

int ipcacheAddEntryFromHosts ( const char *  name,
const char *  ipaddr 
)

Adds a "static" entry from /etc/hosts

Parameters
nameHostname to be linked with IP
ipaddrIP Address to be cached.
Return values
0Success.
1IP address is invalid or other error.

Definition at line 1123 of file ipcache.cc.

References ipcache_entry::addrs, DBG_IMPORTANT, debugs, Ip::EnableIpv6, ipcache_entry::flags, ipcache_entry::Flags::fromhosts, ipcache_get(), ipcacheAddEntry(), ipcacheLockEntry(), ipcacheRelease(), ipcacheUnlockEntry(), Ip::Address::isIPv6(), ipcache_entry::locks, and Dns::CachedIps::pushUnique().

Referenced by parseEtcHosts().

◆ ipcacheCheckNumeric()

static const Dns::CachedIps * ipcacheCheckNumeric ( const char *  name)
static

◆ ipcacheInvalidate()

void ipcacheInvalidate ( const char *  name)

Definition at line 864 of file ipcache.cc.

References ipcache_entry::expires, ipcache_get(), and squid_curtime.

Referenced by clientReplyContext::purgeRequest().

◆ ipcacheInvalidateNegative()

void ipcacheInvalidateNegative ( const char *  name)

◆ ipcacheMarkGoodAddr()

void ipcacheMarkGoodAddr ( const char *  name,
const Ip::Address addr 
)

Definition at line 1074 of file ipcache.cc.

References ipcache_get().

Referenced by Comm::ConnOpener::sendAnswer().

◆ snmp_netIpFn()

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors