mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-18 02:19:39 +00:00
snmp_pf: use libpfctl's pfctl_get_rules_info() rather than DIOCGETRULES
Prefer libpfctl functions over direct access to the ioctl whenever possible. Sponsored by: Rubicon Communications, LLC ("Netgate")
This commit is contained in:
parent
47a0b59379
commit
2905d10b39
@ -1513,24 +1513,21 @@ pfa_refresh(void)
|
||||
static int
|
||||
pfl_scan_ruleset(const char *path)
|
||||
{
|
||||
struct pfioc_rule pr;
|
||||
struct pfctl_rules_info rules;
|
||||
struct pfctl_rule rule;
|
||||
char anchor_call[MAXPATHLEN] = "";
|
||||
struct pfl_entry *e;
|
||||
u_int32_t nr, i;
|
||||
|
||||
bzero(&pr, sizeof(pr));
|
||||
strlcpy(pr.anchor, path, sizeof(pr.anchor));
|
||||
pr.rule.action = PF_PASS;
|
||||
if (ioctl(dev, DIOCGETRULES, &pr)) {
|
||||
if (pfctl_get_rules_info(dev, &rules, PF_PASS, path)) {
|
||||
syslog(LOG_ERR, "pfl_scan_ruleset: ioctl(DIOCGETRULES): %s",
|
||||
strerror(errno));
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (nr = pr.nr, i = 0; i < nr; i++) {
|
||||
pr.nr = i;
|
||||
if (pfctl_get_rule(dev, pr.nr, pr.ticket, pr.anchor,
|
||||
PF_PASS, &rule, pr.anchor_call)) {
|
||||
for (nr = rules.nr, i = 0; i < nr; i++) {
|
||||
if (pfctl_get_rule(dev, i, rules.ticket, path,
|
||||
PF_PASS, &rule, anchor_call)) {
|
||||
syslog(LOG_ERR, "pfl_scan_ruleset: ioctl(DIOCGETRULE):"
|
||||
" %s", strerror(errno));
|
||||
goto err;
|
||||
|
Loading…
Reference in New Issue
Block a user