diff options
author | mav <mav@FreeBSD.org> | 2015-10-05 09:23:20 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2015-10-05 09:23:20 +0000 |
commit | 03f85b4859e09eaf3b0e12668b5acc45b7f33de2 (patch) | |
tree | 4db9436fda56689516df259f1ab15b48f0a6cce4 /sys/cam | |
parent | d74ee723c944e611bb6774c45c36912daf6d6b93 (diff) | |
download | FreeBSD-src-03f85b4859e09eaf3b0e12668b5acc45b7f33de2.zip FreeBSD-src-03f85b4859e09eaf3b0e12668b5acc45b7f33de2.tar.gz |
MFC r287855: Don't flap the HA link if sysctl is reset to the same value.
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/ctl/ctl_ha.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/cam/ctl/ctl_ha.c b/sys/cam/ctl/ctl_ha.c index 8d6604f..952e92a 100644 --- a/sys/cam/ctl/ctl_ha.c +++ b/sys/cam/ctl/ctl_ha.c @@ -622,28 +622,33 @@ ctl_ha_peer_sysctl(SYSCTL_HANDLER_ARGS) struct ha_softc *softc = (struct ha_softc *)arg1; struct sockaddr_in *sa; int error, b1, b2, b3, b4, p, num; + char buf[128]; - error = sysctl_handle_string(oidp, softc->ha_peer, - sizeof(softc->ha_peer), req); - if ((error != 0) || (req->newptr == NULL)) + strlcpy(buf, softc->ha_peer, sizeof(buf)); + error = sysctl_handle_string(oidp, buf, sizeof(buf), req); + if ((error != 0) || (req->newptr == NULL) || + strncmp(buf, softc->ha_peer, sizeof(buf)) == 0) return (error); sa = &softc->ha_peer_in; mtx_lock(&softc->ha_lock); - if ((num = sscanf(softc->ha_peer, "connect %d.%d.%d.%d:%d", + if ((num = sscanf(buf, "connect %d.%d.%d.%d:%d", &b1, &b2, &b3, &b4, &p)) >= 4) { softc->ha_connect = 1; softc->ha_listen = 0; - } else if ((num = sscanf(softc->ha_peer, "listen %d.%d.%d.%d:%d", + } else if ((num = sscanf(buf, "listen %d.%d.%d.%d:%d", &b1, &b2, &b3, &b4, &p)) >= 4) { softc->ha_connect = 0; softc->ha_listen = 1; } else { softc->ha_connect = 0; softc->ha_listen = 0; - if (softc->ha_peer[0] != 0) + if (buf[0] != 0) { + buf[0] = 0; error = EINVAL; + } } + strlcpy(softc->ha_peer, buf, sizeof(softc->ha_peer)); if (softc->ha_connect || softc->ha_listen) { memset(sa, 0, sizeof(*sa)); sa->sin_len = sizeof(struct sockaddr_in); |