diff options
author | Kristof Provost <kp@FreeBSD.org> | 2022-03-29 12:15:47 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2022-03-30 08:28:19 +0000 |
commit | 514039bb90853473078acd2fbba1b1bfb359aab5 (patch) | |
tree | 523d077ab0c8ac6729a75445e89c8271922d9137 | |
parent | 9bb06778f822ad6b47d2a825d47e284ca8dd29a1 (diff) | |
download | src-514039bb90853473078acd2fbba1b1bfb359aab5.tar.gz src-514039bb90853473078acd2fbba1b1bfb359aab5.zip |
libpfct: Return errno from pfctl_add_eth_rule()
If the pfctl_add_eth_rule() ioctl fails return the errno, not the error
returned by ioctl(). That will give us slightly more insight into what
went wrong, because ioctl() would always return -1.
Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r-- | lib/libpfctl/libpfctl.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 1e1a90594210..8696ef1ace25 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -786,7 +786,7 @@ pfctl_add_eth_rule(int dev, const struct pfctl_eth_rule *r, const char *anchor, struct pfioc_nv nv; nvlist_t *nvl, *addr; void *packed; - int error; + int error = 0; size_t size; nvl = nvlist_create(0); @@ -838,7 +838,8 @@ pfctl_add_eth_rule(int dev, const struct pfctl_eth_rule *r, const char *anchor, nv.size = size; nv.data = packed; - error = ioctl(dev, DIOCADDETHRULE, &nv); + if (ioctl(dev, DIOCADDETHRULE, &nv) != 0) + error = errno; free(packed); nvlist_destroy(nvl); |