From 58a0adbc293bf9bcf911d5055f95ebb5278ea654 Mon Sep 17 00:00:00 2001 From: glebius Date: Tue, 3 Apr 2012 18:10:48 +0000 Subject: Make it possible to switch pfsync(4) deferral mechanism on/off. Obtained from: OpenBSD --- sbin/ifconfig/ifpfsync.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'sbin') 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", -- cgit v1.1