Page MenuHomeFreeBSD

libpfctl: Fix displaying deeply nested anchors
ClosedPublic

Authored by jlduran on Sun, Oct 26, 2:29 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 12, 12:26 AM
Unknown Object (File)
Mon, Nov 10, 9:28 AM
Unknown Object (File)
Sat, Nov 1, 12:39 AM
Unknown Object (File)
Fri, Oct 31, 10:29 PM
Unknown Object (File)
Fri, Oct 31, 9:00 PM
Unknown Object (File)
Fri, Oct 31, 8:17 PM
Unknown Object (File)
Tue, Oct 28, 8:56 AM
Unknown Object (File)
Mon, Oct 27, 1:39 AM

Details

Summary

Set the number of rulesets (i.e., anchors) directly attached to the
anchor and its path in pfctl_get_ruleset().

While here, add a test to document this behavior.

PR: 290478
Fixes: 041ce1d690f1 ("pfctl: recursively flush rules and tables")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Remove patch file for bugzila.

Note that the previous behavior was:

$ pfctl -sA
foo
$ pfctl -a foo -sA
foo/bar
foo/baz

The new behavior (compatible with OpenBSD) is:

$ pfctl -sA
foo
foo/bar
foo/baz
$ pfctl -a foo -sA
foo/bar
foo/baz

Ignore stderr for now, it throws a bogus warning about an (ethernet) anchor not found (PR 280516).

sbin/pfctl/pfctl.c
3029 ↗(On Diff #165059)

I wonder if we shouldn't do this in libpfct's pfctl_get_ruleset() instead.
Okay, it's a little silly to give the 'anchor' argument straight back to the caller, but on the other hand, it also doesn't make much sense to return only a partially completed struct pfioc_ruleset.
Or perhaps we shouldn't be using struct pfioc_ruleset, but should be using a pfctl_ruleset that doesn't have the path field at all (and then use 'anchor' in later code here, rather than pr.path).

jlduran retitled this revision from pfctl: Fix displaying multiple nested anchors to libpfctl: Fix displaying deeply nested anchors.Mon, Oct 27, 7:52 PM
jlduran edited the summary of this revision. (Show Details)
jlduran marked an inline comment as done.

Address suggestions:

  • Implement the fix in pfctl_get_ruleset()
  • Set both, the number of anchors, and the path in the struct
  • Extend the test as requested by the PR reporter. It now tests deeply nested anchors (NOT that we are encouraging users to take advantage of this possibility, but rather to avoid regressions)
This revision is now accepted and ready to land.Tue, Oct 28, 9:55 AM