[CodeGen] Migrate to FoldingSet's typed lookup/insert/erase. NFC (#219830)
Rename SelectionDAG::FindNodeOrInsertPos to lookupNode and use the new
FoldingSetInsertToken API in place of `void *`.
In SelectionDAG the token is named `InsertToken`, as Token there means
the chain operand (TokenFactor, EntryToken).
tests/sys/kern/unix_stream: fix bad assertion
kqueue returns a value != -1 on error. Test for that instead of any
non-zero value to confirm that success was achieved when calling
`kqueue`.
This issue exists with ATF 0.22+ [1].
MFC after: 2 weeks
Reported by: clang (-Wparenthesis)
[1]: https://github.com/freebsd/atf/pull/72
tests/sys/sys/bitstring_test: fix build with ATF 0.22+
Do not assign `b` in the `ATF_REQUIRE` macro. Set and test `b`
separately to avoid the issue cited by clang++/g++ after
implementing the change referenced in [1].
MFC after: 2 weeks
Reported by: clang (-Wparenthesis)
Reference: https://github.com/freebsd/atf/pull/72
xlockmore-lite: Remove FILESDIR / PATCHDIR.
Not only were these wrong (relative not absolute), they overwrote the correct
settings coming from Makefile.common.
[SCCP] Fix missing worklist push for recursive calls that update lattice values (#219826)
For a recursive call, the call instruction itself is a user of the
function's arguments. Because I == CurI, I->comesBefore(CurI) is false,
and the condition triggers an early return. The recursive call
instruction was skipped and never pushed back onto the worklist, halting
the solver prematurely before reaching a fixpoint. This caused the
solver to incorrectly believe arguments were hardcoded constants rather
than a wider constant range, resulting in invalid branch folding.
The Fix: This patch updates the condition to explicitly check if I comes
strictly after CurI.
Fixes: https://github.com/llvm/llvm-project/issues/219503
if_bridge: Fix NULL softc dereference in bridge_input()
In bridge_input, sc is initialized to NULL and doesn't get
resolved until after the Ethernet header pullup.
So the pullup's failure path ends up dereferencing the NULL sc
when bumping up IFCOUNTER_IERRORS.
The m_freem call right under it is redundant as the failure path in
m_pullup already freed the chain.
Drop both lines, matching what we have in bridge_output.
ether_input_internal() discards frames shorter than ETHER_HDR_LEN
before the bridge hook, so it is unlikely that it will fire.
We still keep the guard as lagg(4) and ng_ether(4) may replace
the mbuf before the bridge hook.
Signed-off-by: Aaron Espinoza <acesp25 at freebsd.org>
Reviewed by: pouria
Pull Request: https://github.com/freebsd/freebsd-src/pull/2393
Name the license expiry alerts after the support contract
This commit adds changes to retitle the two expiry alerts, which said the license was expiring when what actually expires is the support contract — the alert bodies and the renewal mail have said so all along, and a license carries no expiry of its own. Class names are deliberately unchanged so user set alert levels and policies keep matching.
Document alert applicability and the frozen inventory
This commit adds changes to document the applicability axes and the frozen inventory in the alert plugin docs, since the only record of how to regenerate that file lived in the test module's own docstring and you only found it after CI had already failed. The populations are pulled in with automodule so a new one documents itself, and the page spells out what does and does not require a regeneration plus what each guard test means when it fails.
Say which systems the enclosure alerts newly reach
This commit adds changes to test the failover run gates and to correct what the enclosure change was described as affecting. post_failover_blackout and require_stable_peer move out of the run loop into source_run_gates_pass so both can be checked without a middleware object or a running service, and a frozen inventory test pins which sources carry them and what each one is gated on.
failover_related was gating enclosure_status on an HA licence, which is a licensing predicate in front of a hardware question. Enclosure faults are now reported on every iX appliance that lacks an ENTERPRISE_HA licence, both unlicensed appliances and single controller licensed ones (ENTERPRISE_SINGLE, FREENAS-CERTIFIED). The earlier note said only "unlicensed appliances", which undercounts the fleet by the whole licensed single controller half. EnclosureHealthy is INFO and is raised once per enclosure, expansion shelves included, so affected systems will see several new informational alerts.
The matrix legend claimed a source row meant the source is ran, which was never true: it models applies_to only, and never post_failover_blackout, require_stable_peer, the schedule or source locks. That is the only change to the golden file.
Drive the alert enforcement sites from unit tests
This commit adds changes to test the four sites in plugins/alert.py that consume an applicability rule, rather than only the rules themselves. The run and send axes had no execution coverage at all: emptying the excluded-source set, deleting the alert purge loop, or making the send filter answer True all left the suite green. These drive __run_alerts and send_alerts against stub sources through a shared harness, and record what the policies delete, since dropping the purge loop still leaves the alert list correct and nothing else can see it.
The purge is worth pinning on its own because it destroys state: a source whose rule stops admitting this system loses the alerts it had persisted, and when it applies again they come back with a fresh uuid and their dismissed flag cleared. There is also an asymmetry three lines apart in that loop, deliberate but unasserted until now, where a rule-excluded source is purged and a gate-blocked one is only skipped.
Also fixes both AST scanners. BondStatus is a shipped source that does not carry the AlertSource name suffix, so the black hole check never saw it or the three classes it creates; keying off the subclass relation the loader itself uses picks it up and keeps the two modules from disagreeing. Reading attribute-spelled bases stops a class written as base.AlertClass dropping out of the frozen inventory with nothing to show for it. Both scanners now carry an invariant test, so a shape they cannot model fails instead of silently shrinking what is covered.
Remove the broken SATA DOM wear alert
This commit adds changes to delete the SATA DOM wear alert source and its two classes. The source calls disk.sata_dom_lifetime_left, which was removed in 25.10 and has no implementation anywhere, so it raises on every run on any M or Z series chassis and produces nothing but alert source failures.
Alerts already persisted on existing systems clear on the next start through the stale source check in initialize, which runs before the policies are built, so nothing is announced as cleared. No migration is needed, matching how every previous alert source removal was handled.
Move alert gating onto hardware and license axes
This commit adds changes to give every declaration under alert/source its own applicability rule on the decoupled hardware and license axes, and points the enforcement sites in plugins/alert.py at those rules instead of system.product_type. The products lines stay for now because the API field still reads them. HA classes take a hardware applies_to alongside listed_when on purpose, so on iX hardware whose HA licence is absent or lapsed they leave the settings catalogue without being silenced, and a source that no longer applies now has its stored alerts dropped rather than stranding them undismissable. The two scheduled-reboot classes are the exception: they are gated on the HA licence itself, so a system without one stops seeing them at all.
sata_dom_wear is knowingly shipped in a broken state: its source calls disk.sata_dom_lifetime_left, which was removed in March 2025, so appliances will see the check fail. That is a deliberate, signed-off decision and not an oversight.
The checked-in matrix under pytest/unit/alert/golden spells out old versus new applicability per population for every declaration, and its test regenerates and diffs it so no population change lands unread.
Give a working command for regenerating the alert inventory
This commit fixes an issue where the documented way to regenerate the alert applicability inventory does not work: run from the repository root it imports the installed middlewared rather than the working tree, and collection fails before anything is regenerated. Both the docs and the module docstring now give the invocation CI uses, from `src/middlewared` with `PYTHONPATH=.`.
Type alert applicability against AlertSource and AlertClass
This commit adds changes to drop the Declaration protocols in favour of TYPE_CHECKING imports of AlertSource and AlertClass, which is what review asked for, and to tighten the surface while we are in there: rule_name is no longer re-exported now that declaration_rule_name is the only entry point production goes through, and the Rule docstring keeps just the part that constrains how you write one, which is to name it so the black-hole diagnostic has something to report.
Dropping the protocols makes alert.applicability depend on alert.base, and import-linter counts TYPE_CHECKING imports, so that broke the package layering contract: engine reached vocabulary and snapshot through alert.base importing the whole package. alert/base.py now takes Rule from the engine module directly, which is the only thing it ever wanted, and the contract holds without an ignore.
Express alert applicability rules as functions and cache them once
This commit adds changes to replace the applicability rule dataclasses with plain functions that take facts, and to route every applicability answer through a single Applicability object holding one reading of those facts and memoizing per declaration. Nothing in the tree ever introspected rule structure, so the isinstance dispatch and the AnyOf/AllOf combinators go away with it, and because the seven vocabulary names are unchanged no alert declaration moves and the golden matrix is byte for byte identical.
The five separate get_facts() reads in the alert plugin become one, invalidated on system.post_license_update so an upload takes effect on both nodes at once. A None license is never cached, since get_license() returns None both for "no license" and "the daemon did not answer" and we do not want a hiccup to stick until restart.