Skip to content

Make ingress egress ratelimit bins separate again. #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions etc/qosmate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ DYNAMIC_RULES=$(generate_dynamic_nft_rules)
# Check if ACKRATE is greater than 0
if [ "$ACKRATE" -gt 0 ]; then
ack_rules="\
meta length < 100 tcp flags & ack == ack add @xfst4ack {ct id limit rate over ${XFSTACKRATE}/second} counter jump drop995
meta length < 100 tcp flags & ack == ack add @fast4ack {ct id limit rate over ${FASTACKRATE}/second} counter jump drop95
meta length < 100 tcp flags & ack == ack add @med4ack {ct id limit rate over ${MEDACKRATE}/second} counter jump drop50
meta length < 100 tcp flags & ack == ack add @slow4ack {ct id limit rate over ${SLOWACKRATE}/second} counter jump drop50"
meta length < 100 tcp flags & ack == ack add @xfst4ack {ct id . ct direction limit rate over ${XFSTACKRATE}/second} counter jump drop995
meta length < 100 tcp flags & ack == ack add @fast4ack {ct id . ct direction limit rate over ${FASTACKRATE}/second} counter jump drop95
meta length < 100 tcp flags & ack == ack add @med4ack {ct id . ct direction limit rate over ${MEDACKRATE}/second} counter jump drop50
meta length < 100 tcp flags & ack == ack add @slow4ack {ct id . ct direction limit rate over ${SLOWACKRATE}/second} counter jump drop50"
else
ack_rules="# ACK rate regulation disabled as ACKRATE=0 or not set."
fi
Expand Down Expand Up @@ -344,16 +344,17 @@ fi
# Check if UDP rate limiting should be applied
if [ "$UDP_RATE_LIMIT_ENABLED" -eq 1 ]; then
udp_rate_limit_rules="\
meta l4proto udp ip dscp > cs2 add @udp_meter {ct id limit rate over 450/second} counter ip dscp set cs0 counter
meta l4proto udp ip6 dscp > cs2 add @udp_meter {ct id limit rate over 450/second} counter ip6 dscp set cs0 counter"
meta l4proto udp ip dscp > cs2 add @udp_meter {ct id . ct direction limit rate over 450/second} counter ip dscp set cs0 counter
meta l4proto udp ip6 dscp > cs2 add @udp_meter {ct id . ct direction limit rate over 450/second} counter ip6 dscp set cs0 counter"
else
udp_rate_limit_rules="# UDP rate limiting is disabled."
fi

# Check if TCP upgrade for slow connections should be applied
if [ "$TCP_UPGRADE_ENABLED" -eq 1 ]; then
tcp_upgrade_rules="
meta l4proto tcp add @slowtcp {ct id limit rate 150/second burst 150 packets } counter jump mark_af42"
meta l4proto tcp add @slowtcp {ct id . ct direction limit rate 150/second burst 150 packets } ip dscp set af42 counter
meta l4proto tcp add @slowtcp {ct id . ct direction limit rate 150/second burst 150 packets} ip6 dscp set af42 counter"
else
tcp_upgrade_rules="# TCP upgrade for slow connections is disabled"
fi
Expand Down Expand Up @@ -417,27 +418,27 @@ table inet dscptag {
}


set xfst4ack { typeof ct id
set xfst4ack { typeof ct id . ct direction
flags dynamic;
timeout 5m
}
set fast4ack { typeof ct id
set fast4ack { typeof ct id . ct direction
flags dynamic;
timeout 5m
}
set med4ack { typeof ct id
set med4ack { typeof ct id . ct direction
flags dynamic;
timeout 5m
}
set slow4ack { typeof ct id
set slow4ack { typeof ct id . ct direction
flags dynamic;
timeout 5m
}
set udp_meter {typeof ct id
set udp_meter {typeof ct id . ct direction
flags dynamic;
timeout 5m
}
set slowtcp {typeof ct id
set slowtcp {typeof ct id . ct direction
flags dynamic;
timeout 5m
}
Expand Down