diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -350,7 +350,6 @@ static void carp_master_down(void *); static void carp_master_down_locked(struct carp_softc *, const char* reason); -static void carp_send_ad(void *); static void carp_send_ad_locked(struct carp_softc *); static void vrrp_send_ad_locked(struct carp_softc *); static void carp_addroute(struct carp_softc *); @@ -1086,6 +1085,19 @@ return (carp_tag(sc, m)); } +static inline void +send_ad_locked(struct carp_softc *sc) +{ + switch (sc->sc_version) { + case CARP_VERSION_CARP: + carp_send_ad_locked(sc); + break; + case CARP_VERSION_VRRPv3: + vrrp_send_ad_locked(sc); + break; + } +} + /* * To avoid LORs and possible recursions this function shouldn't * be called directly, but scheduled via taskqueue. @@ -1102,7 +1114,7 @@ if (sc->sc_state == MASTER) { CARP_LOCK(sc); CURVNET_SET(sc->sc_carpdev->if_vnet); - carp_send_ad_locked(sc); + send_ad_locked(sc); CURVNET_RESTORE(); CARP_UNLOCK(sc); } @@ -1112,7 +1124,7 @@ /* Send a periodic advertisement, executed in callout context. */ static void -carp_send_ad(void *v) +carp_callout(void *v) { struct carp_softc *sc = v; struct epoch_tracker et; @@ -1120,7 +1132,7 @@ NET_EPOCH_ENTER(et); CARP_LOCK_ASSERT(sc); CURVNET_SET(sc->sc_carpdev->if_vnet); - carp_send_ad_locked(sc); + send_ad_locked(sc); CURVNET_RESTORE(); CARP_UNLOCK(sc); NET_EPOCH_EXIT(et); @@ -1204,11 +1216,7 @@ NET_EPOCH_ASSERT(); CARP_LOCK_ASSERT(sc); - - if (sc->sc_version == CARP_VERSION_VRRPv3) { - vrrp_send_ad_locked(sc); - return; - } + MPASS(sc->sc_version == CARP_VERSION_CARP); advskew = DEMOTE_ADVSKEW(sc); tv.tv_sec = sc->sc_advbase; @@ -1338,7 +1346,7 @@ #endif /* INET6 */ resched: - callout_reset(&sc->sc_ad_tmo, tvtohz(&tv), carp_send_ad, sc); + callout_reset(&sc->sc_ad_tmo, tvtohz(&tv), carp_callout, sc); } static void @@ -1519,7 +1527,7 @@ resched: callout_reset(&sc->sc_ad_tmo, sc->sc_vrrp_adv_inter * hz / 100, - carp_send_ad, sc); + carp_callout, sc); } static void @@ -1759,7 +1767,7 @@ switch (sc->sc_state) { case BACKUP: carp_set_state(sc, MASTER, reason); - carp_send_ad_locked(sc); + send_ad_locked(sc); #ifdef INET carp_send_arp(sc); #endif @@ -1851,11 +1859,11 @@ tv.tv_sec = sc->sc_advbase; tv.tv_usec = sc->sc_advskew * 1000000 / 256; callout_reset(&sc->sc_ad_tmo, tvtohz(&tv), - carp_send_ad, sc); + carp_callout, sc); } else { callout_reset(&sc->sc_ad_tmo, sc->sc_vrrp_adv_inter * hz / 100, - carp_send_ad, sc); + carp_callout, sc); } break; }