--- sbin/ifconfig/carp.c +++ sbin/ifconfig/carp.c @@ -161,7 +161,7 @@ { if (carpr_vhid == -1) - errx(1, "passwd requires vhid"); + errx(1, "pass requires vhid (must come first)"); carpr_key = val; } @@ -171,9 +171,14 @@ { if (carpr_vhid == -1) - errx(1, "advskew requires vhid"); + errx(1, "advskew requires vhid (must come first)"); carpr_advskew = atoi(val); + + if (carpr_advskew < 0 || carpr_advskew > CARP_MAXSKEW) + errx(1, "advskew must be something between 0 and %u", + CARP_MAXSKEW); + } static void @@ -181,9 +186,13 @@ { if (carpr_vhid == -1) - errx(1, "advbase requires vhid"); + errx(1, "advbase requires vhid (must come first)"); carpr_advbase = atoi(val); + + if (carpr_advbase < CARP_DFLTINTV || carpr_advbase > 255) + errx(1, "advbase must be greater than 0 and less than 256"); + } static void @@ -192,7 +201,7 @@ int i; if (carpr_vhid == -1) - errx(1, "state requires vhid"); + errx(1, "state requires vhid (must come first)"); for (i = 0; i <= CARP_MAXSTATE; i++) if (strcasecmp(carp_states[i], val) == 0) { --- sbin/ifconfig/ifconfig.8 +++ sbin/ifconfig/ifconfig.8 @@ -2841,7 +2841,7 @@ Specifies the skew to add to the base advertisement interval to make one host advertise slower than another host. It is specified in 1/256 of seconds. -The acceptable values are 1 to 254. +The acceptable values are 0 to 240. The default value is 0. .It Cm pass Ar phrase Set the authentication key to --- sys/netinet/ip_carp.c +++ sys/netinet/ip_carp.c @@ -1766,15 +1766,13 @@ } else CARP_LOCK(sc); locked = 1; - if (carpr.carpr_advbase > 0) { - if (carpr.carpr_advbase > 255 || - carpr.carpr_advbase < CARP_DFLTINTV) { - error = EINVAL; - break; - } - sc->sc_advbase = carpr.carpr_advbase; + if (carpr.carpr_advbase < CARP_DFLTINTV || + carpr.carpr_advbase > 255) { + error = EINVAL; + break; } - if (carpr.carpr_advskew >= 255) { + sc->sc_advbase = carpr.carpr_advbase; + if (carpr.carpr_advskew > CARP_MAXSKEW) { error = EINVAL; break; }