Subject: Re: dynamic sysctl
To: Jason Thorpe <thorpej@wasabisystems.com>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 11/14/2003 14:40:52
>> and then you have all the mappings for name<->number under net.  for
>> the children of those nodes, you simply iterate.
>
>What happens if the name<->number mappings change in between the 
>mapping call and the walking?  It's dynamic, so you're going to have to 
>expect this.

good question.

the answer is that each node has a version number (an int -- i am
studiously ignoring the case where the version number wraps around).

when a node is created the global version counter is incremented and
the new version number is assigned to the new node and its parent,
straight up to the root of the tree.

likewise, when a node is destroyed, the global version number is
incremented, and the new version number is assigned to the parent of
the node that is being destroyed all the way back up the tree.

sysctlnametomib() just checks that all the versions are the same at
the top of the tree each time it's called, and for those that have
changed, it purges that data from its cache.

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."