Skip to content

Commit

Permalink
ruleset: apply egress MSS fixup later to apply final MTU before wire
Browse files Browse the repository at this point in the history
Reduce scope of MSS fixup to TCP SYN packets only and relocate the fixing
of egress MSS to the mangle/postrouting chain in order to properly apply
final known MTU size.

Fixes: openwrt/openwrt#12112
Signed-off-by: Andris PE <[email protected]>
[fix S-o-b tag, fix commit author, reword commit message]
Signed-off-by: Jo-Philipp Wich <[email protected]>
  • Loading branch information
Andris PE authored and jow- committed Nov 3, 2023
1 parent 7392792 commit 698a533
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion root/usr/share/firewall4/templates/ruleset.uc
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,13 @@ table inet fw4 {
{% for (let rule in fw4.rules("mangle_postrouting")): %}
{%+ include("rule.uc", { fw4, zone: null, rule }) %}
{% endfor %}
{% for (let zone in fw4.zones()): %}
{% if (zone.mtu_fix): %}
{% for (let rule in zone.match_rules): %}
{%+ include("zone-mssfix.uc", { fw4, zone, rule, egress: true }) %}
{% endfor %}
{% endif %}
{% endfor %}
{% fw4.includes('chain-append', 'mangle_postrouting') %}
}
Expand Down Expand Up @@ -455,7 +462,6 @@ table inet fw4 {
{% if (zone.mtu_fix): %}
{% for (let rule in zone.match_rules): %}
{%+ include("zone-mssfix.uc", { fw4, zone, rule, egress: false }) %}
{%+ include("zone-mssfix.uc", { fw4, zone, rule, egress: true }) %}
{% endfor %}
{% endif %}
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion root/usr/share/firewall4/templates/zone-mssfix.uc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%+ if (rule.family): -%}
meta nfproto {{ fw4.nfproto(rule.family) }} {%+ endif -%}
{%+ include("zone-match.uc", { egress, rule }) -%}
tcp flags syn tcp option maxseg size set rt mtu {%+ if (zone.log & 2): -%}
tcp flags syn / syn,fin,rst tcp option maxseg size set rt mtu {%+ if (zone.log & 2): -%}
log prefix "MSSFIX {{ zone.name }} out: " {%+ endif -%}
comment "!fw4: Zone {{ zone.name }} {{
fw4.nfproto(rule.family, true)
Expand Down
4 changes: 2 additions & 2 deletions tests/01_configuration/01_ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ table inet fw4 {

chain mangle_postrouting {
type filter hook postrouting priority mangle; policy accept;
oifname "pppoe-wan" tcp flags syn / syn,fin,rst tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 egress MTU fixing"
}

chain mangle_input {
Expand All @@ -281,8 +282,7 @@ table inet fw4 {

chain mangle_forward {
type filter hook forward priority mangle; policy accept;
iifname "pppoe-wan" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 ingress MTU fixing"
oifname "pppoe-wan" tcp flags syn tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 egress MTU fixing"
iifname "pppoe-wan" tcp flags syn / syn,fin,rst tcp option maxseg size set rt mtu comment "!fw4: Zone wan IPv4/IPv6 ingress MTU fixing"
}
}
-- End --
Expand Down

0 comments on commit 698a533

Please sign in to comment.