carp: Lock MPSAFE, step 10 of 11
Make carp_softc.sc_carpdev and ifnet.if_carp accessing and updating
lockless MPSAFE.
carp_softc.sc_carpdev:
- Reader of the sc_carpdev will cache the value in temporary variable
and use the cached value instead of always accessing sc_carpdev,
which may be inconsistent due to change of sc_carpdev.
ifnet.if_carp
- if_carp is a pointer to the carp_softc container list, while the list
only contains pointer to carp_softc
- Reader of if_carp will cache the value in temporary variable and use
the cached value instead of always accessing if_carp, which may be
inconsistent due to if_carp updating.
- Updating of the if_carp is done in the following way:
ocif = ifp->if_carp;
ncif = cif_copy(ocif);
cif_modify(ncif);
ifp->if_carp = ncif;
netmsg_service_sync();
/* when we reach here all users of old if_carp (ocif) are done */
cif_free(ocif)