Make it possible to switch pfsync(4) deferral mechanism on/off.

Obtained from:	OpenBSD
This commit is contained in:
glebius 2012-04-03 18:10:48 +00:00
parent 4a817f8ca2
commit 58a0adbc29

View File

@ -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",