FreeBSD Bugzilla – Attachment 243347 Details for
Bug 272459
pf(4) lists wrong return values for DIOCGETRULESETS and DIOCGETRULESET
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
a test program to articulate how I think the ioctl interface is supposed to work
pf-test.c (text/plain), 1.36 KB, created by
alex
on 2023-07-12 02:34:01 UTC
(
hide
)
Description:
a test program to articulate how I think the ioctl interface is supposed to work
Filename:
MIME Type:
Creator:
alex
Created:
2023-07-12 02:34:01 UTC
Size:
1.36 KB
patch
obsolete
>#include <assert.h> >#include <errno.h> >#include <fcntl.h> >#include <stdio.h> >#include <string.h> >#include <strings.h> > >#include <sys/ioctl.h> > >#include <net/if.h> >#include <net/pfvar.h> >#include <netpfil/pf/pf.h> > >int main() { > struct pfioc_ruleset ruleset; > int ret, fd; > const char *bogus_table = "bogus_table"; > > fd = open("/dev/pf", O_RDONLY); > assert(fd >= 0); > > // If the parent anchor at path can't be found, we get ENOENT > bzero(&ruleset, sizeof(struct pfioc_ruleset)); > bcopy(bogus_table, ruleset.path, strlen(bogus_table)); > ret = ioctl(fd, DIOCGETRULESETS, &ruleset); > assert(ret != 0); > assert(errno == ENOENT); > > // If the parent anchor at path can't be found, we get ENOENT > bzero(&ruleset, sizeof(struct pfioc_ruleset)); > bcopy(bogus_table, ruleset.path, strlen(bogus_table)); > ret = ioctl(fd, DIOCGETRULESET, &ruleset); > assert(ret != 0); > assert(errno == ENOENT); > > // We should always have a root anchor. Let's see how many anchors are directly attached > bzero(&ruleset, sizeof(struct pfioc_ruleset)); > ret = ioctl(fd, DIOCGETRULESETS, &ruleset); > assert(ret == 0); > int ruleset_count = ruleset.nr; > > // If the requested index is beyond the number of anchors that exist at a path, we get EBUSY > bzero(&ruleset, sizeof(struct pfioc_ruleset)); > ruleset.nr = ruleset_count + 1; > ret = ioctl(fd, DIOCGETRULESET, &ruleset); > assert(ret != 0); > assert(errno == EBUSY); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 272459
: 243347 |
243348