- Factor out if_purgeaddrs_nolink(), which frees all non-link ifaddrs no
ifnet.if_addrhead
- Use above function in if_detach() and free link ifaddr manually, add some
assertion there to make sure ifnet.if_addrhead is in sane state
Submitted-by: pavalos@
Obtained-from: FreeBSD (w/ modification)
For tap(4)
- Use if_purgeaddrs_nolink() to clean up tap's if_addrhead
- Cleaning up ifaddrs has nothing to do with current tap's mode (vmnet/tap)
- In non-vmnet mode, clear IFF_RUNNING if_flags when a tap is brought down
For tun(4)
- Use if_purgeaddrs_nolink() to clean up tun's if_addrhead
- Cleaning up ifaddrs has nothing to do with IFF_RUNNING
- in_control() is clever enough to set the RTF_HOST flags for tun, so tun
does not need to record that dst addr has been set. Since net/tun/if_tunvar.h
was exposed to /usr/include "accidentally", instead of nuking TUN_DSTADDR,
I just mark it as "unused" in comment.