Make SIFTR work again after r342125 (D18443).

Correct a logic error.

Only disable when already enabled or enable when disabled.

Submitted by:	Richard Scheffenegger
Reviewed by:	Cheng Cui
Obtained from:	Cheng Cui
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D18885
This commit is contained in:
brooks 2019-01-18 21:46:38 +00:00
parent 3d6c5e19e8
commit 8ba0807050

View File

@ -1219,7 +1219,7 @@ siftr_manage_ops(uint8_t action)
if ((s = sbuf_new(NULL, NULL, 200, SBUF_AUTOEXTEND)) == NULL) if ((s = sbuf_new(NULL, NULL, 200, SBUF_AUTOEXTEND)) == NULL)
return (-1); return (-1);
if (action == SIFTR_ENABLE) { if (action == SIFTR_ENABLE && siftr_pkt_manager_thr == NULL) {
/* /*
* Create our alq * Create our alq
* XXX: We should abort if alq_open fails! * XXX: We should abort if alq_open fails!
@ -1424,7 +1424,8 @@ siftr_manage_ops(uint8_t action)
alq_close(siftr_alq); alq_close(siftr_alq);
siftr_alq = NULL; siftr_alq = NULL;
} } else
error = EINVAL;
sbuf_delete(s); sbuf_delete(s);
@ -1445,15 +1446,17 @@ siftr_sysctl_enabled_handler(SYSCTL_HANDLER_ARGS)
new = siftr_enabled; new = siftr_enabled;
error = sysctl_handle_int(oidp, &new, 0, req); error = sysctl_handle_int(oidp, &new, 0, req);
if (error != 0 && req->newptr != NULL) { if (error == 0 && req->newptr != NULL) {
if (new > 1) if (new > 1)
return (EINVAL); return (EINVAL);
else if (new != siftr_enabled) { else if (new != siftr_enabled) {
error = siftr_manage_ops(new); if ((error = siftr_manage_ops(new)) == 0) {
if (error != 0) siftr_enabled = new;
} else {
siftr_manage_ops(SIFTR_DISABLE); siftr_manage_ops(SIFTR_DISABLE);
} }
} }
}
return (error); return (error);
} }
@ -1462,7 +1465,9 @@ siftr_sysctl_enabled_handler(SYSCTL_HANDLER_ARGS)
static void static void
siftr_shutdown_handler(void *arg) siftr_shutdown_handler(void *arg)
{ {
if (siftr_enabled == 1) {
siftr_manage_ops(SIFTR_DISABLE); siftr_manage_ops(SIFTR_DISABLE);
}
} }