Rework carp(4) IPv4 support.
Generic layer changes:
- Pass more detailed information to ifaddr_event handler.
o The ifaddr which triggers the event is passed in
o The action (add/delete/change) performed upon the ifaddr is
passed in
- Add ifa_prflags field in ifaddr_container. This field should
be used to hold protocol specific flags. For inet addresses,
IA_PRF_RTEXISTOK is defined to ignore rtinit() EEXIST error in
in_ifinit().
carp(4) changes:
- Add virtual address struct, which holds corresponding carp(4)
inet address and backing address of a "real" interface (backing
interface).
- The list holding virtual address struct is sorted. This is
mainly used to fix the bug in following case:
host1:
ifconfig carp0 192.168.5.1
ifconfig carp0 alias 192.168.5.2
host2:
ifconfig carp0 192.168.5.2
ifconfig carp0 alias 192.168.5.1
Before this change, the inet addresses sha1 calculated for these
two host will be different, thus CARP fails.
Based-on: OpenBSD
- Allow inet addresses to be added to carp(4) interface, even if
no backing interface could be found or the backing interface is
not running.
- Don't abuse IFF_UP, which is administrative flag; use IFF_RUNNING
instead.
- Factor out carp_stop().
- Handle ifaddr_event; most of the carp(4) inet address configuration
happens in this event handler. In carp_ioctl(), we just mark the
carp(4) interface IFF_UP|IFF_RUNNING and set IA_PRF_RTEXISTOK on
the inet address.
- Fix the ifdetach_event handler:
o Don't sit on the branch while we are sawing it off.
o We always need to leave the joined multicast group.
- Free carp_if to the proper kmalloc pool.
- Simplify the carp_if struct; except the TAILQ_HEAD, rest of the
fields are not used; nuke them.
- Use 'void *' as ifnet.if_carp's type. This could ease upcoming
carp(4) MPSAFE work.
- M_NOWAIT -> MB_DONTWAIT
- Throw in assertions
- Cleanup:
o Nuke SC2IFP
o Nuke carp_softc.sc_ifp compat shim
o Constify function parameters
o ...