Adhere to standard binding behaviour of other components:
Use the address read to get all addresses and binding ok instead
of using the arcane "interface name" bind option. CARP VIPs are
ignored although allowed to be selected... something we should just
remove since interfaces_addresses() will load all aliases as well.
We also will not get tentative or otherwise unusable addresses.
Next stop for this code is probaby MVC conversion.
It has the downside of losing changes to config.xml but
we are far more likely to run the tests than to change
the file. Ideally, the UUIDs should not shift.
The configd call "filter diag table_size" is quite convenient when inspecting the aliases grid, but if we're only interested in the names and descriptions, it adds quite some overhead.
We can skip the collection of this information by constructing with $skip_dynamic_info set to "true" now, which increases performance quite a bit.
pf in FreeBSD 14.x supports dnpipe and dnqueue targets which hook dummynet, in theory we should be able to use these as well although our solution uses ipfw
for the shaper.
There might be some risks involved when using shapers in pf and configuring rules in ipfw, which is also why this feature is marked experimental.
Benefits of offering shaper targets in our standard firewall are increased flexibility (use of large aliases for example) and cleaner rulesets for example.
A quick test of a rule to shape iperf3 traffic does seem to work as expected.
While testing some changes I ran configctl service reload all and got a timeout error. After doing some digging I found that this relates to netflow data collection and doesn't happen if netflow collection is disabled.
After a bit of poking around it is due to the daemon/samplicate processes keeping a pipe open shared with the reload_all script, which then never termintes. Adding the daemon -f parameter fixes.
While here ignore all return values consistently. Most of them are
ignored, some of them already on the add case. Makes little sense
to report errors on a fraction of operations and adding the same route
will unfortunately yield an error anyway so it's not helpful in the
bulk of cases either.
Although this might not be the final version, it adds the relevant metadata to the form definitions and offers a very simple template which can be used as a partial().
Example input field:
<field>
<id>sysctl.tunable</id>
<label>Tunable</label>
<type>text</type>
<grid_view>
<sequence>1</sequence>
</grid_view>
</field>
grid_view entries contain a sequence which may overwrite the default order and can overwrite any data-* attribute available, e.g. <sortable>false</sortable> would remove the sortable option from the field.
Perform some small cleanups in ControllerBase and add method to extract grid fields, sample config data:
<field>
<id>sysctl.value</id>
<label>Value</label>
<type>text</type>
<grid_view>
<sequence>2</sequence>
</grid_view>
</field>
Which results in the following output:
(
[sequence] => 2
[visible] => false
[ignore] => false
[sortable] => false
[width] =>
[label] => Value
[id] => sysctl.value
[type] => text
[fieldname] => value
)
* redirect sleep output to avoid it holding the pipe to daemon process open
* add comment explaining the sleep
* use daemon -m0 parameter to prevent restart failures
This was changed from a simple redirect of the sleep command after
discussion with Franco on https://github.com/opnsense/core/pull/8109
Sometimes its practical to be able to reset model settings to their defaults, in which case it makes sense to have a simple handle on the base model to flush all for a specific model.
Although this is a "hammer" (unable to validate referential constraints on its own), there is practical use when trying to reset a component to its factory state.
If useful, we could add a factory reset handle to the ApiMutableModelControllerBase class at some point as well to facility a "flush" in a more generic way.