[Ns-developers] NetDevice link change callback

Tom Henderson tomh at tomh.org
Mon Jul 27 14:46:27 PDT 2009


Sébastien Vincent wrote:
> Hi all,
> 
> In NetDevice, there is a callback when device change state (UP or DOWN). 
> It is used mainly by ArpL3Protocol to flush ARP cache.
> But for future IPv6 integration, it would be also useful to use it to 
> purge Neighbor Discovery cache.
> 
> So I propose to replace single callback in NetDevice base and sub 
> classes by a list of link change callback.
> 
> The main API change would be :
> 
> NetDevice::SetLinkChangeCallback(Callback<void> callback) => 
> NetDevice::AddLinkChangeCallback(Callback<void> callback)
> 
> In all NetDevice's subclasses, replace all Callback<void> 
> m_linkChangeCallback by std::list<Callback<void> m_linkChangeCallbacks.
> When link change, call every callbacks of the list.
> 
> What do you think ?

Your proposal caused me to look a bit more closely at this.  I agree 
with you that the current callback shouldn't be monopolized by the 
ArpCache.  However, a few more suggestions/comments (not directed 
specifically at your proposal but in improving this part of the code in 
general):

1) use of TracedCallback?
Another option is to use a TracedCallback here, which some other 
developers have recommended in the past to use when there needs to be a 
list of callbacks.

I don't have a strong opinion but this question keeps popping up (also 
in Qasim's conntrack code) so I think we should clarify whether 
TracedCallback should also be used in non-tracing scenarios whenever you 
want a std::list of callbacks, or whether we want another general 
CallbackList of some sort that is not used by tracing code.

2) should we report link change, or link up?
The method name is not really suggestive of how the callback works, 
which does not call when the link changes in all cases but only when the 
link goes to up.  So, I would suggest either "AddLinkUpCallback" or 
"SetLinkChangeCallback" with an extra argument such as an enum for Up or 
Down.

I think others have raised the question "can I put a NetDevice into down 
state?" and presently the answer is no, but in practice, IFF_UP flag of 
a netdevice is settable, and it seems like we might want to add the 
capability to configure an interface to down state, which would trigger 
upcalls to both Ipv4 and Ipv6 stacks (and to the routing protocols).

Tom



More information about the Ns-developers mailing list