aboutsummaryrefslogtreecommitdiff
path: root/sbin/ifconfig/ifpfsync.c
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2023-06-14 13:00:49 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2023-06-16 07:19:21 +0000
commit7fa282e616c303261904cb6158959d5a784dc3ee (patch)
tree16ae79d99e60e88a91fbd93d3dccf70dd0380a5e /sbin/ifconfig/ifpfsync.c
parent9e8174289236de996199aadc6357c05eafba3b38 (diff)
Diffstat (limited to 'sbin/ifconfig/ifpfsync.c')
-rw-r--r--sbin/ifconfig/ifpfsync.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/sbin/ifconfig/ifpfsync.c b/sbin/ifconfig/ifpfsync.c
index 81bf463db117..b97b9925c644 100644
--- a/sbin/ifconfig/ifpfsync.c
+++ b/sbin/ifconfig/ifpfsync.c
@@ -51,10 +51,11 @@
#include "ifconfig.h"
static int
-pfsync_do_ioctl(int s, uint cmd, nvlist_t **nvl)
+pfsync_do_ioctl(if_ctx *ctx, uint cmd, nvlist_t **nvl)
{
void *data;
size_t nvlen;
+ struct ifreq ifr = {};
data = nvlist_pack(*nvl, &nvlen);
@@ -64,7 +65,7 @@ pfsync_do_ioctl(int s, uint cmd, nvlist_t **nvl)
ifr.ifr_cap_nv.length = nvlen;
free(data);
- if (ioctl(s, cmd, (caddr_t)&ifr) == -1) {
+ if (ioctl_ctx_ifr(ctx, cmd, &ifr) == -1) {
free(ifr.ifr_cap_nv.buffer);
return -1;
}
@@ -172,7 +173,7 @@ setpfsync_syncdev(if_ctx *ctx, const char *val, int dummy __unused)
if (strlen(val) > IFNAMSIZ)
errx(1, "interface name %s is too long", val);
- if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
if (nvlist_exists_string(nvl, "syncdev"))
@@ -180,7 +181,7 @@ setpfsync_syncdev(if_ctx *ctx, const char *val, int dummy __unused)
nvlist_add_string(nvl, "syncdev", val);
- if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
}
@@ -189,7 +190,7 @@ unsetpfsync_syncdev(if_ctx *ctx, const char *val __unused, int dummy __unused)
{
nvlist_t *nvl = nvlist_create(0);
- if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
if (nvlist_exists_string(nvl, "syncdev"))
@@ -197,7 +198,7 @@ unsetpfsync_syncdev(if_ctx *ctx, const char *val __unused, int dummy __unused)
nvlist_add_string(nvl, "syncdev", "");
- if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
}
@@ -210,7 +211,7 @@ setpfsync_syncpeer(if_ctx *ctx, const char *val, int dummy __unused)
nvlist_t *nvl = nvlist_create(0);
- if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
if ((ecode = getaddrinfo(val, NULL, NULL, &peerres)) != 0)
@@ -239,7 +240,7 @@ setpfsync_syncpeer(if_ctx *ctx, const char *val, int dummy __unused)
nvlist_add_nvlist(nvl, "syncpeer",
pfsync_sockaddr_to_syncpeer_nvlist(&addr));
- if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
nvlist_destroy(nvl);
@@ -254,7 +255,7 @@ unsetpfsync_syncpeer(if_ctx *ctx, const char *val __unused, int dummy __unused)
nvlist_t *nvl = nvlist_create(0);
- if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
if (nvlist_exists_nvlist(nvl, "syncpeer"))
@@ -263,7 +264,7 @@ unsetpfsync_syncpeer(if_ctx *ctx, const char *val __unused, int dummy __unused)
nvlist_add_nvlist(nvl, "syncpeer",
pfsync_sockaddr_to_syncpeer_nvlist(&addr));
- if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
nvlist_destroy(nvl);
@@ -279,13 +280,13 @@ setpfsync_maxupd(if_ctx *ctx, const char *val, int dummy __unused)
if ((maxupdates < 0) || (maxupdates > 255))
errx(1, "maxupd %s: out of range", val);
- if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
nvlist_free_number(nvl, "maxupdates");
nvlist_add_number(nvl, "maxupdates", maxupdates);
- if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
nvlist_destroy(nvl);
@@ -296,13 +297,13 @@ setpfsync_defer(if_ctx *ctx, const char *val __unused, int d)
{
nvlist_t *nvl = nvlist_create(0);
- if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
nvlist_free_number(nvl, "flags");
nvlist_add_number(nvl, "flags", d ? PFSYNCF_DEFER : 0);
- if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
nvlist_destroy(nvl);
@@ -317,13 +318,13 @@ setpfsync_version(if_ctx *ctx, const char *val, int dummy __unused)
/* Don't verify, kernel knows which versions are supported.*/
version = atoi(val);
- if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
nvlist_free_number(nvl, "version");
nvlist_add_number(nvl, "version", version);
- if (pfsync_do_ioctl(ctx->io_s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
nvlist_destroy(nvl);
@@ -343,7 +344,7 @@ pfsync_status(if_ctx *ctx)
nvl = nvlist_create(0);
- if (pfsync_do_ioctl(ctx->io_s, SIOCGETPFSYNCNV, &nvl) == -1) {
+ if (pfsync_do_ioctl(ctx, SIOCGETPFSYNCNV, &nvl) == -1) {
nvlist_destroy(nvl);
return;
}