Itay Alayoff <itay...@post.bgu.ac.il> wrote: > I'd like to know where is the policy eviction currently implemented?
The way I answer questions like this is to start from the configuration options, and working my way from bin/named/server.c (where the parsed config file is processed) I trace through to find the code that uses the options of interest. Often with an option like `some-thing` I can find most of the code by grepping for `some.?thing` but the spelling is not always that consistent. In this case, grepping for `cache.?size` I can see a line: dns_cache_setcachesize(cache, max_cache_size); So (unsurprisingly!) the next place to look is in lib/dns/cache.c where I find dns_cache_setcachesize() which sets up a callback function called water() to implement the limits. In turn water() invokes dns_db_overmem(). https://gitlab.isc.org/isc-projects/bind9/blob/master/lib/dns/cache.c#L880 There's an abstraction layer around BIND's in-memory database to support alternative back ends (look around for dyndb and sdb to follow this side-track) with a C OO interface that will feel familiar to kernel hackers. But we want to skip to the relevant point which for db matters is usually lib/dns/rbtdb.c, the red-black tree database. There are a bunch of method vtbl definitions in this file; we're looking for the `overmem` method. In fact, looking for `overmem` everywhere in the file should get you a bit closer to enlightenment. https://gitlab.isc.org/isc-projects/bind9/blob/master/lib/dns/rbtdb.c The rbtdb.c overmem() method actually says, /* This is an empty callback. See adb.c:water() */ The adb (address database) handles stuff like SRTT calculations and lameness flags etc. Reading around mentions of `overmem` and `water` in adb.c is again informative. https://gitlab.isc.org/isc-projects/bind9/blob/master/lib/dns/adb.c#L2305 This comment appears to be the crux: /*% * Examine the tail entry of the LRU list to see if it expires or is stale * (unused for some period); if so, the name entry will be freed. If the ADB * is in the overmem condition, the tail and the next to tail entries * will be unconditionally removed (unless they have an outstanding fetch). * We don't care about a race on 'overmem' at the risk of causing some * collateral damage or a small delay in starting cleanup, so we don't bother * to lock ADB (if it's not locked). * * Name bucket must be locked; adb may be locked; no other locks held. */ static void check_stale_name(dns_adb_t *adb, int bucket, isc_stdtime_t now) { Now you know everything I know about BIND's cache eviction policy :-) Tony. -- f.anthony.n.finch <d...@dotat.at> http://dotat.at/ North Rockall, Malin: Northwesterly 4 or 5, backing southerly 5 to 7 later. Rough. Fair. Good. _______________________________________________ Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from this list bind-users mailing list bind-users@lists.isc.org https://lists.isc.org/mailman/listinfo/bind-users