MCPcopy Create free account
hub / github.com/F-Stack/f-stack / carp_setrun

Function carp_setrun

freebsd/netinet/ip_carp.c:1315–1371  ·  view source on GitHub ↗

* When in backup state, af indicates whether to reset the master down timer * for v4 or v6. If it's set to zero, reset the ones which are already pending. */

Source from the content-addressed store, hash-verified

1313 * for v4 or v6. If it's set to zero, reset the ones which are already pending.
1314 */
1315static void
1316carp_setrun(struct carp_softc *sc, sa_family_t af)
1317{
1318 struct timeval tv;
1319
1320 CARP_LOCK_ASSERT(sc);
1321
1322 if ((sc->sc_carpdev->if_flags & IFF_UP) == 0 ||
1323 sc->sc_carpdev->if_link_state != LINK_STATE_UP ||
1324 (sc->sc_naddrs == 0 && sc->sc_naddrs6 == 0) ||
1325 !V_carp_allow)
1326 return;
1327
1328 switch (sc->sc_state) {
1329 case INIT:
1330 carp_set_state(sc, BACKUP, "initialization complete");
1331 carp_setrun(sc, 0);
1332 break;
1333 case BACKUP:
1334 callout_stop(&sc->sc_ad_tmo);
1335 tv.tv_sec = 3 * sc->sc_advbase;
1336 tv.tv_usec = sc->sc_advskew * 1000000 / 256;
1337 switch (af) {
1338#ifdef INET
1339 case AF_INET:
1340 callout_reset(&sc->sc_md_tmo, tvtohz(&tv),
1341 carp_master_down, sc);
1342 break;
1343#endif
1344#ifdef INET6
1345 case AF_INET6:
1346 callout_reset(&sc->sc_md6_tmo, tvtohz(&tv),
1347 carp_master_down, sc);
1348 break;
1349#endif
1350 default:
1351#ifdef INET
1352 if (sc->sc_naddrs)
1353 callout_reset(&sc->sc_md_tmo, tvtohz(&tv),
1354 carp_master_down, sc);
1355#endif
1356#ifdef INET6
1357 if (sc->sc_naddrs6)
1358 callout_reset(&sc->sc_md6_tmo, tvtohz(&tv),
1359 carp_master_down, sc);
1360#endif
1361 break;
1362 }
1363 break;
1364 case MASTER:
1365 tv.tv_sec = sc->sc_advbase;
1366 tv.tv_usec = sc->sc_advskew * 1000000 / 256;
1367 callout_reset(&sc->sc_ad_tmo, tvtohz(&tv),
1368 carp_send_ad, sc);
1369 break;
1370 }
1371}
1372

Callers 4

carp_input_cFunction · 0.85
carp_master_down_lockedFunction · 0.85
carp_ioctlFunction · 0.85
carp_sc_stateFunction · 0.85

Calls 2

carp_set_stateFunction · 0.85
tvtohzFunction · 0.50

Tested by

no test coverage detected