Rework carp(4) IPv4 support.
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 26 Dec 2008 11:14:19 +0000 (19:14 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 26 Dec 2008 12:48:20 +0000 (20:48 +0800)
commit5bd4422ea3a838c306436350229ff4bc24397660
tree1710c83b78283d854d6a4d87a892136a1ab032fc
parent6615506001dcd5c9679192eb21cf9901dd60ecd2
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  ...
sbin/ifconfig/ifcarp.c
sys/net/if_var.h
sys/net/pf/pf_if.c
sys/netinet/if_ether.c
sys/netinet/if_ether.h
sys/netinet/in.c
sys/netinet/in_var.h
sys/netinet/ip_carp.c
sys/netinet/ip_carp.h
sys/netinet6/in6.c