Device Groups: name a group of devices and target it in firewall rules#9
Merged
Conversation
added 3 commits
July 3, 2026 18:21
Adds the backend that maps named device groups to nftables sets: - known_devices.sh / manage_groups.sh: enumerate groups from dhcp host sections and build/seed an nftables set (grp_<name>) per group from the current lease table - post_lease.sh: dnsmasq lease hook that adds/removes a device IP from its group set at runtime (no firewall restart) - gargoyle_firewall_util.sh: build the group sets before inserting restriction rules that reference them (ordering fix) - make_nftables_rules.c / restore_quotas.c: resolve GROUP:<name> targets to the corresponding nftables set - uci-defaults/gargoyle-init: initialise group support
Replaces the separate Static IPs and Known Devices panels with one Devices table. Each device is a single config host section with an optional fixed IP, optional IPv6 reservation (behind an Advanced toggle), and optional group. MAC is the only required field; the connected-hosts dropdown pre-fills name/MAC and the current lease IP. Group names are validated to a safe charset. One host section per device avoids the duplicate dhcp-host that previously crashed dnsmasq.
Adds group targeting to bandwidth quotas, traffic restrictions, and QoS download/upload pages so rules can be applied to an entire device group rather than individual IPs. restore_quotas.c group_name_to_set_name() was missing the consecutive- underscore squeeze that make_nftables_rules.c and the shell group_to_set_name() both implement via tr -s. A group name like "a-!-b" produced grp_a__b here but grp_a_b everywhere else, so quota rules silently targeted a non-existent set. Fixed by applying the squeeze check after all branches (identical structure to make_nftables_rules.c) so all underscore sources are covered. Restored executable bit (100755) on dhcp.sh, restriction.sh, qos_download.sh, and qos_upload.sh — stripped to 100644 by a core.fileMode mismatch. Uhttpd invokes these as CGI executables and returns 403 without the bit set. Removed six dead i18n keys from English-EN/dhcp.js (KnDevs, AdKD, EKD, AsKDs, dKDMErr, kdErr) left over from an earlier naming pass.
This was referenced Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a rebase of lantis1008/gargoyle#57 onto current
ispyisail/gargoylemaster (that PR predates the move off lantis and was never merged there). Reimplements the Known Devices / Device Groups concept for OpenWrt 24.10 / nftables — name a group of devices on the DHCP page, then target that group in Restrictions, Quotas, and QoS instead of listing IPs/MACs by hand.The three commits
1. nftables backend for named device groups
known_devices.sh/manage_groups.sh— enumerate groups fromconfig hostsections and build/seed an nftables set (grp_<name>) per group from the current lease table.post_lease.sh— dnsmasq lease hook that adds/removes a device's IP from its group set at runtime (no firewall restart).gargoyle_firewall_util.sh— build the group sets before inserting restriction rules that reference them (ordering fix).make_nftables_rules.c/restore_quotas.c— resolveGROUP:<name>targets to the corresponding nftables set.2. Unified Devices table on the DHCP page
config hostsection with an optional fixed IP, optional IPv6 reservation (behind an Advanced toggle), and optional group. MAC is the only required field.dhcp-hostthat the two-panel approach could generate.3. Target a device group in Restrictions, Quotas and QoS
Rebase notes
31 commits of drift had accumulated on master since this branch was created. One real conflict, in
package/gargoyle/files/www/js/dhcp.js: master had picked up a standalone fix (a5f7d5c1, "Skip incomplete UCI host entries with empty MAC") for the old two-panel code. The Device Groups rewrite already carries an equivalent (and more complete) empty-MAC skip as part of its own unified-table design, so the incoming rewrite was taken as-is — verified the resulting file has no leftover conflict markers and passesnode --check.Verification
make x86 FULL_BUILD=truein Docker: succeeded.make_nftables_rules.candrestore_quotas.c(the C sources this PR touches) compiled cleanly for all three x86 sub-architectures (one pre-existing, unrelated%cformat warning inrestore_quotas.c, not introduced by this change).config hostsection with agroupfield via UCI, ranmanage_groups.sh, confirmed it created the correctly-namedgrp_<name>nftables set (empty, as expected with no matching DHCP lease for the synthetic test MAC).Test plan