diff options
author | glebius <glebius@FreeBSD.org> | 2012-04-03 18:10:48 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2012-04-03 18:10:48 +0000 |
commit | 58a0adbc293bf9bcf911d5055f95ebb5278ea654 (patch) | |
tree | 5ae9aa8c24402b7540ed543dd8badab35c4b29b9 | |
parent | 4a817f8ca2d8bd5e782e41eb4c17c5b9a3775702 (diff) | |
download | FreeBSD-src-58a0adbc293bf9bcf911d5055f95ebb5278ea654.zip FreeBSD-src-58a0adbc293bf9bcf911d5055f95ebb5278ea654.tar.gz |
Make it possible to switch pfsync(4) deferral mechanism on/off.
Obtained from: OpenBSD
-rw-r--r-- | sbin/ifconfig/ifpfsync.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifpfsync.c b/sbin/ifconfig/ifpfsync.c index 2a388a1..0af89e2 100644 --- a/sbin/ifconfig/ifpfsync.c +++ b/sbin/ifconfig/ifpfsync.c @@ -52,6 +52,7 @@ void setpfsync_syncpeer(const char *, int, int, const struct afswtch *); void unsetpfsync_syncpeer(const char *, int, int, const struct afswtch *); void setpfsync_syncpeer(const char *, int, int, const struct afswtch *); void setpfsync_maxupd(const char *, int, int, const struct afswtch *); +void setpfsync_defer(const char *, int, int, const struct afswtch *); void pfsync_status(int); void @@ -162,6 +163,23 @@ setpfsync_maxupd(const char *val, int d, int s, const struct afswtch *rafp) err(1, "SIOCSETPFSYNC"); } +/* ARGSUSED */ +void +setpfsync_defer(const char *val, int d, int s, const struct afswtch *rafp) +{ + struct pfsyncreq preq; + + memset((char *)&preq, 0, sizeof(struct pfsyncreq)); + ifr.ifr_data = (caddr_t)&preq; + + if (ioctl(s, SIOCGETPFSYNC, (caddr_t)&ifr) == -1) + err(1, "SIOCGETPFSYNC"); + + preq.pfsyncr_defer = d; + if (ioctl(s, SIOCSETPFSYNC, (caddr_t)&ifr) == -1) + err(1, "SIOCSETPFSYNC"); +} + void pfsync_status(int s) { @@ -183,8 +201,10 @@ pfsync_status(int s) printf("syncpeer: %s ", inet_ntoa(preq.pfsyncr_syncpeer)); if (preq.pfsyncr_syncdev[0] != '\0' || - preq.pfsyncr_syncpeer.s_addr != INADDR_PFSYNC_GROUP) - printf("maxupd: %d\n", preq.pfsyncr_maxupdates); + preq.pfsyncr_syncpeer.s_addr != INADDR_PFSYNC_GROUP) { + printf("maxupd: %d ", preq.pfsyncr_maxupdates); + printf("defer: %s\n", preq.pfsyncr_defer ? "on" : "off"); + } } static struct cmd pfsync_cmds[] = { @@ -194,7 +214,9 @@ static struct cmd pfsync_cmds[] = { DEF_CMD("-syncif", 1, unsetpfsync_syncdev), DEF_CMD_ARG("syncpeer", setpfsync_syncpeer), DEF_CMD("-syncpeer", 1, unsetpfsync_syncpeer), - DEF_CMD_ARG("maxupd", setpfsync_maxupd) + DEF_CMD_ARG("maxupd", setpfsync_maxupd), + DEF_CMD("defer", 1, setpfsync_defer), + DEF_CMD("-defer", 0, setpfsync_defer), }; static struct afswtch af_pfsync = { .af_name = "af_pfsync", |