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")
This commit is contained in:
Kristof Provost 2022-03-29 14:15:47 +02:00
parent 9bb06778f8
commit 514039bb90

View File

@ -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);