tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Make sure to free all interface addresses in if_detach



Hi,

Addresses of an interface (struct ifaddr) have
a (reverse) pointer of an interface object
(ifa->ifa_ifp). If the addresses are surely
freed when their interface is destroyed, the
pointer is always valid and we don't need a
tweak of replacing the pointer to if_index like
mbuf.

Is the assumption is correct? No, for now.

The following patches ensure the assumption.

  http://www.netbsd.org/~ozaki-r/debug_ifaref.diff
  http://www.netbsd.org/~ozaki-r/free_all_ifa.diff

The 1st patch adds debugging functions to check
if all addresses are freed at the end of if_detach.

The 2nd patch tweaks some destruction functions
to satisfy the assumption.

- Deactivate the interface at the firstish of
  if_detach. This prevents in6_unlink_ifa from
  saving multicast addresses
- Invalidate rtcache(s) and clear a rtentry
  referencing an address on RTM_DELETE. rtcache(s)
  may delay freeing an address
- Replace callout_stop with callout_halt of DAD
  timers to ensure stopping such timers in
  if_detach

Any comments or suggestions? Am I missing some
cases?

Thanks,
  ozaki-r


Home | Main Index | Thread Index | Old Index