Skip to content

Commit

Permalink
Firewall: Automation: Filter - add set-prio[-low] for #8143
Browse files Browse the repository at this point in the history
  • Loading branch information
AdSchellevis committed Dec 28, 2024
1 parent 70b4823 commit 5eaa7fc
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,28 @@
Determines how packets route back in the opposite direction (replies), when set to default, packets on WAN type interfaces reply to their connected gateway on the interface (unless globally disabled). A specific gateway may be chosen as well here. This setting is only relevant in the context of a state, for stateless rules there is no defined opposite direction.
</help>
</field>
<field>
<type>header</type>
<label>Packet mangling</label>
</field>
<field>
<id>rule.set-prio</id>
<label>Set priority</label>
<type>dropdown</type>
<help>
Packets matching this rule will be assigned a specific queueing priority. If the
packet is transmitted on a vlan(4) interface, the queueing priority
will be written as the priority code point in the 802.1Q VLAN
header
</help>
</field>
<field>
<id>rule.set-prio-low</id>
<label>Set priority [low-delay]</label>
<type>dropdown</type>
<help>
Used in combination with set priority, packets which have a TOS of lowdelay and TCP ACKs with no
data payload will be assigned this priority when offered.
</help>
</field>
</form>
12 changes: 11 additions & 1 deletion src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public function performValidation($validateFullModel = false)
}
if (empty((string)$rule->max) && ($rule->adaptivestart == '0' || $rule->adaptiveend == '0')) {
$messages->appendMessage(new Message(
gettext('Disabling adaptive timeouts is only supported in combination with a configured maximum number of states for the same rule.'),
gettext('Disabling adaptive timeouts is only supported in ".
"combination with a configured maximum number of states for the same rule.'),
$rule->max->__reference
));
} elseif ($rule->adaptivestart == '0' xor $rule->adaptiveend == '0') {
Expand Down Expand Up @@ -175,6 +176,15 @@ public function performValidation($validateFullModel = false)
$rule->adaptiveend->__reference
));
}

if ((string)$rule->{'set-prio'} == '' && (string)$rule->{'set-prio-low'} != '') {
$messages->appendMessage(new Message(
gettext("Set priority for low latency and acknowledgements ".
"requires a set priority for normal packets."),
$rule->{'set-prio-low'}->__reference
));
}

}
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,32 @@
<adaptiveend type="IntegerField">
<MinimumValue>0</MinimumValue>
</adaptiveend>
<set-prio type="OptionField">
<BlankDesc>Keep current priority</BlankDesc>
<OptionValues>
<opt1 value="1">Background (1, lowest)</opt1>
<opt0 value="0">Best Effort (0, default)</opt0>
<opt2 value="2">Excellent Effort (2)</opt2>
<opt3 value="3">Critical Applications (3)</opt3>
<opt4 value="4">Video (4)</opt4>
<opt5 value="5">Voice (5)</opt5>
<opt6 value="6">Internetwork Control (6)</opt6>
<opt7 value="7">Network Control (7, highest)</opt7>
</OptionValues>
</set-prio>
<set-prio-low type="OptionField">
<BlankDesc>Keep current priority</BlankDesc>
<OptionValues>
<opt1 value="1">Background (1, lowest)</opt1>
<opt0 value="0">Best Effort (0, default)</opt0>
<opt2 value="2">Excellent Effort (2)</opt2>
<opt3 value="3">Critical Applications (3)</opt3>
<opt4 value="4">Video (4)</opt4>
<opt5 value="5">Voice (5)</opt5>
<opt6 value="6">Internetwork Control (6)</opt6>
<opt7 value="7">Network Control (7, highest)</opt7>
</OptionValues>
</set-prio-low>
<categories type="ModelRelationField">
<Model>
<rulesets>
Expand Down

0 comments on commit 5eaa7fc

Please sign in to comment.