Skip to content

Commit a84da5a

Browse files
committed
Apply 15Mbps global ratelimit
1 parent e37f33b commit a84da5a

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

ROUTING-POLICY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ These are defined in `get_region_tag` of [`custom_filters.conf.j2`](roles/config
2727

2828
## BGP Communities
2929

30-
The [standard dn42 BGP Communities](https://dn42.net/howto/Bird-communities) for max. inter-AS link latency, bandwidth, and encryption are supported. All of my nodes so far are marked as >= 100 Mbps bandwidth, as capacity varies and I cannot guarantee anything higher.
30+
The [standard dn42 BGP Communities](https://dn42.net/howto/Bird-communities) for max. inter-AS link latency, bandwidth, and encryption are supported. All of my nodes so far are marked as >= 10 Mbps bandwidth, as capacity varies and I cannot guarantee anything higher.
3131

3232
### Large communities
3333

global-config/general.yml

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ ownnets4:
66
ownnets6:
77
- fd86:bad:11b7::/48
88

9+
# Default ratelimit (Mbps) for outgoing traffic on dn42 interfaces
10+
dn42_ratelimit: 15
11+
# ref: https://unix.stackexchange.com/a/100797
12+
# burst size should be >= rate / kernel HZ, in units of bytes. This uses 2x that for a bit more room
13+
dn42_ratelimit_tc_args: "root tbf rate {{ dn42_ratelimit }}mbit latency 10ms burst {{ (dn42_ratelimit / 250 * 2 * 125000) | int }}"
14+
915
# Dummy device names for IGP and Anycast services
1016
# To simplify IGP configuration in Bird this assumes that all dummy interface names follow a pattern
1117
# Note: forwarding rules are managed separately in roles/config-iptables/

hosts.yml

-3
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ dn42routers:
310310
dn42_regions: [52]
311311
location: "Tokyo, JP"
312312
wg_pubkey: "iJXjwJGGrUTQy/P3OXmZ5lM4cjrDAd9K+vonZVUZjxY="
313-
wg_ratelimit: 200 # Mbps
314313
link_local_ip6: "fe80::124"
315314
link_local_ip4: "169.254.108.124"
316315
igp_upstreams:
@@ -335,7 +334,6 @@ dn42routers:
335334
dn42_regions: [51]
336335
location: "Singapore, SG"
337336
wg_pubkey: "X3m9VMzZYN4Oe2QUb7DcnmVymwKSLbPUCB5ElD8igjo="
338-
wg_ratelimit: 120 # Mbps
339337
link_local_ip6: "fe80::1080:39"
340338
link_local_ip4: "169.254.108.39"
341339
igp_upstreams:
@@ -388,7 +386,6 @@ dn42routers:
388386
dn42_regions: [52]
389387
location: "Hong Kong, HK"
390388
wg_pubkey: "eedTHubyl5caiHH50GkknQa8SQtAF8q7aqmL26w5qSs="
391-
wg_ratelimit: 100 # Mbps
392389
link_local_ip6: "fe80::1080:38"
393390
link_local_ip4: "169.254.108.38"
394391
peerfinder_uuid: !vault |

roles/config-bird2/config/community_filters.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int dn42_crypto;
4444
dn42_bandwidth = update_bandwidth(link_bandwidth) - 20;
4545
dn42_crypto = update_crypto(link_crypto) - 30;
4646
# TODO: abstract this out into a config variable
47-
if dn42_bandwidth > 4 then dn42_bandwidth = 4;
47+
if dn42_bandwidth > 3 then dn42_bandwidth = 3;
4848
return true;
4949
}
5050

roles/config-wireguard/templates/dn42_interface.conf.j2

+2-5
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ iface {{ ifname }} inet static
3939
{% endfor %}
4040
{# Disable Martian filtering for local addresses, as we may be forwarding responses for anycast services from another node #}
4141
post-up sysctl -w net.ipv4.conf.{{ ifname }}.accept_local=1
42-
{% set limit_mbit = peer_info.get('wg_ratelimit', wg_ratelimit|default(0)) | int %}
43-
{% if limit_mbit and not peer_info.get('is_internal_node') %}
44-
{# ref: https://unix.stackexchange.com/a/100797 #}
45-
{# burst size should be >= rate / kernel HZ, in units of bytes. This uses 2x that for a bit more room #}
46-
post-up tc qdisc add dev {{ ifname }} root tbf rate {{ limit_mbit }}mbit latency 10ms burst {{ (limit_mbit / 250 * 2 * 125000) | int }}
42+
{% if dn42_ratelimit and ifname.startswith('dn42') %}
43+
post-up tc qdisc add dev {{ ifname }} {{ dn42_ratelimit_tc_args }}
4744
{% endif %}
4845
post-down ip link del {{ ifname }}

0 commit comments

Comments
 (0)