Skip to content

Add dscp field to FirewallRule model#919

Open
scottmsilver wants to merge 1 commit into
pfrest:masterfrom
scottmsilver:feat/firewall-rule-dscp
Open

Add dscp field to FirewallRule model#919
scottmsilver wants to merge 1 commit into
pfrest:masterfrom
scottmsilver:feat/firewall-rule-dscp

Conversation

@scottmsilver

@scottmsilver scottmsilver commented Jul 21, 2026

Copy link
Copy Markdown

Fixes #918.

What

Adds the dscp field to the FirewallRule model. The pfSense webConfigurator supports matching rules on a DSCP value (config field dscp, rendered as tos <value> in rules.debug), but the model didn't define it, so API clients submitting dscp had the value silently discarded — for policy-routing rules that means matching (and re-routing) far more traffic than intended.

How

  • StringField with pfSense's canonical choice list ($firewall_rules_dscp_types from guiconfig.inc), allow_empty for the unset case, placed with the other match-criteria fields.
  • test_dscp in APIModelsFirewallRuleTestCase, following the existing test_statetype pattern: creates a rule with dscp => af11, asserts the generated ruleset contains tos af11 ridentifier {tracker}, deletes the rule.

Testing

Beyond the included test case, the identical field definition was applied to a live pfSense 2.7.2 install (v2.4.0 package) and verified end-to-end:

  • POST /api/v2/firewall/rule with "dscp":"af11" → 200 with dscp echoed in the response
  • value persisted to config and returned on GET
  • after firewall/apply, pfctl -sr shows the rule with tos 0x28 (AF11) and rules.debug shows tos af11
  • rules created without dscp are unaffected (field defaults to empty)

The pfSense webConfigurator supports matching firewall rules on a DSCP
value (config field 'dscp', rendered as 'tos <value>' in rules.debug),
but the FirewallRule model did not define the field. API clients that
submitted 'dscp' had the value silently discarded: the rule was created
without the DSCP match, which for policy-routing rules meant matching
far more traffic than intended.

Adds the field with pfSense's canonical choice list (guiconfig.inc
$firewall_rules_dscp_types) and a test asserting the value reaches the
generated pfctl rule.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FirewallRule: 'dscp' field is silently discarded (model field missing)

2 participants