Skip to content

Commit 5453f6d

Browse files
authored
Merge pull request #4527 from esl/check-and-fix-shapers
Validate and fix XMPP traffic shapers
2 parents e9a8901 + 85268c0 commit 5453f6d

18 files changed

+89
-106
lines changed

big_tests/tests/mod_global_distrib_SUITE.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,13 @@ init_per_group(start_checks, Config) ->
159159
dynamic_modules:ensure_modules(NodeSpec, domain(), [{mod_global_distrib, stopped}]),
160160
Config1;
161161
init_per_group(multi_connection, Config) ->
162+
Config1 = mongoose_helper:backup_and_set_config_option(
163+
Config, [shaper, normal, max_rate], 100000), % needed to send many messages quickly
162164
ExtraConfig = #{bounce => #{resend_after_ms => 20000},
163165
connections => #{%% Disable unused feature to avoid interference
164166
connections_per_endpoint => 100,
165167
disabled_gc_interval => 10000}},
166-
init_per_group_generic([{extra_config, ExtraConfig} | Config]);
168+
init_per_group_generic([{extra_config, ExtraConfig} | Config1]);
167169
init_per_group(invalidation, Config) ->
168170
Config1 = init_per_group(invalidation_generic, Config),
169171
NodeBin = <<"fake_node@localhost">>,
@@ -255,6 +257,9 @@ end_per_group(invalidation, Config) ->
255257
redis_query(europe_node1, [<<"HDEL">>, ?config(nodes_key, Config),
256258
?config(node_to_expire, Config)]),
257259
end_per_group_generic(Config);
260+
end_per_group(multi_connection, Config) ->
261+
mongoose_helper:restore_config_option(Config, [shaper, normal, max_rate]),
262+
end_per_group_generic(Config);
258263
end_per_group(_, Config) ->
259264
end_per_group_generic(Config).
260265

doc/configuration/access.md

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -50,40 +50,6 @@ The `blocked` access class can be defined in the [`acl` section](acl.md) and mat
5050

5151
For this rule to take effect, it needs to be referenced in the options of a [C2S listener](../listeners/listen-c2s.md#listenc2saccess).
5252

53-
### C2S Shaper
54-
55-
The `c2s_shaper` rule is used to determine the shaper used to limit the incoming traffic on C2S connections:
56-
57-
```toml
58-
c2s_shaper = [
59-
{acl = "admin", value = "none"},
60-
{acl = "all", value = "normal"}
61-
]
62-
```
63-
64-
It has the following logic:
65-
66-
* if the access class is `admin`, the returned value is `"none"`,
67-
* otherwise, the returned value is `"normal"`.
68-
69-
The `admin` access class can be defined in the `acl` to specify admin users who will bypass the `normal` shaper.
70-
71-
For this rule to take effect, it needs to be referenced in the options of a [C2S listener](../listeners/listen-c2s.md#listenc2sshaper).
72-
73-
### S2S Shaper
74-
75-
The `s2s_shaper` rule is used to determine the shaper used to limit the incoming traffic on C2S connections:
76-
77-
```toml
78-
s2s_shaper = [
79-
{acl = "all", value = "fast"}
80-
]
81-
```
82-
83-
It assigns the `fast` shaper to all S2S connections.
84-
85-
For this rule to take effect, it needs to be referenced in the options of an [S2S listener](../listeners/listen-s2s.md#listens2sshaper).
86-
8753
### MUC
8854

8955
The following rules manage the permissions of MUC operations:

doc/configuration/listen.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ The number of processes accepting new connections on the listening socket.
9595
### `listen.*.shaper`
9696
* **Syntax:** string, shaper name
9797
* **Default:** `"none"` (no shaper)
98-
* **Example:** `shaper = "c2s_shaper"`
98+
* **Example:** `shaper = "normal"`
9999

100100
The shaper name that determines what traffic shaper is used to limit the incoming XMPP traffic to prevent the server from being flooded with incoming data.
101101
The shaper referenced here needs to be defined in the [`shaper`](../configuration/shaper.md) configuration section.

doc/configuration/shaper.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ This is the typical definition of an XMPP shaper, which accepts the maximum data
3131
max_rate = 1000
3232
```
3333

34-
To make use of it, the [corresponding rule](access.md#c2s-shaper) should be defined in the `access` section.
35-
Finally, the C2S listener has to be configured to use the defined shaper - see the [C2S Example](../listeners/listen-c2s.md#c2s-listener-configuration-example).
34+
To make use of it, the C2S listener has to be configured to use the defined shaper - see the [C2S Example](../listeners/listen-c2s.md#c2s-listener-configuration-example).
3635

3736
### S2S Shaper
3837

@@ -43,8 +42,7 @@ For S2S connections we need to increase the limit as they receive the accumulate
4342
max_rate = 50_000
4443
```
4544

46-
To make use of it, the [corresponding rule](access.md#s2s-shaper) should be defined in the `access` section.
47-
Finally, the S2S listener has to be configured to use the defined shaper - see the [S2S Example](../listeners/listen-s2s.md#s2s-listener-configuration-example).
45+
To make use of it, the S2S listener has to be configured to use the defined shaper - see the [S2S Example](../listeners/listen-s2s.md#s2s-listener-configuration-example).
4846

4947
### MAM Shapers
5048

doc/listeners/listen-c2s.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,20 @@ The following section configures two C2S listeners.
164164
[[listen.c2s]]
165165
port = 5222
166166
access = "c2s"
167-
shaper = "c2s_shaper"
167+
shaper = "normal"
168168
max_stanza_size = 65536
169169
tls.certfile = "server.pem"
170170
tls.dhfile = "dh_server.pem"
171171

172172
[[listen.c2s]]
173173
port = 5223
174174
access = "c2s"
175-
shaper = "c2s_shaper"
175+
shaper = "normal"
176176
max_stanza_size = 65536
177177
```
178178

179179
* One at port 5222, which accepts a plain TCP connection and allows to use StartTLS for upgrading it to an encrypted one. The files containing the certificate and the DH parameter are also provided.
180180
* One at port 5223, which accepts only encrypted TLS connections. It is called Direct TLS.
181181

182-
Both listeners use `c2s` and `c2s_shaper` rules for access management and traffic shaping, respectively.
182+
Both listeners use the `c2s` access rule and the `normal` traffic shaper.
183+
They need to be defined in the [`access`](../configuration/access.md) and [`shaper`](../configuration/shaper.md) sections, respectively (the default configuration file includes them).

doc/listeners/listen-s2s.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ They have the same semantics as the corresponding [c2s options](listen-c2s.md#tl
1616
## S2S listener configuration example
1717

1818
The following section configures an S2S listener with some basic settings set up.
19-
The `s2s_shaper` access rule is used, which requires a definition in the [`access`](../configuration/access.md) section.
19+
The `fast` shaper is used, which requires a definition in the [`shaper`](../configuration/shaper.md) section (the default configuration file includes it).
2020

2121
```toml
2222
[[listen.s2s]]
2323
port = 5269
24-
shaper = "s2s_shaper"
24+
shaper = "fast"
2525
max_stanza_size = 131072
2626
tls.dhfile = "dh_server.pem"
2727
```

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
{prometheus_cowboy, "0.1.9"},
6161

6262
%%% Stateless libraries
63-
{opuntia, "1.1.0"},
63+
{opuntia, "1.1.2"},
6464
{fast_scram, "0.7.0"},
6565
{idna, "6.1.1"},
6666
{uuid, "2.0.7", {pkg, uuid_erl}},

rebar.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
{ref,"e55adf8a54b8d9262ce157cf2d8f88b4b94b7023"}},
8080
0},
8181
{<<"observer_cli">>,{pkg,<<"observer_cli">>,<<"1.8.2">>},0},
82-
{<<"opuntia">>,{pkg,<<"opuntia">>,<<"1.1.0">>},0},
82+
{<<"opuntia">>,{pkg,<<"opuntia">>,<<"1.1.2">>},0},
8383
{<<"p1_utils">>,{pkg,<<"p1_utils">>,<<"1.0.26">>},1},
8484
{<<"pa">>,
8585
{git,"https://github.com/erszcz/pa.git",
@@ -160,7 +160,7 @@
160160
{<<"mimerl">>, <<"D0CD9FC04B9061F82490F6581E0128379830E78535E017F7780F37FEA7545726">>},
161161
{<<"mysql">>, <<"3BAD7F35107E141989B0B4FAB47C9E73626BC5FEF38EDF8CCFDA5EC3EFA83B30">>},
162162
{<<"observer_cli">>, <<"9962E6818E75774EC829875016BE61A6BCA87E95AD18ECD7FBCF4F23F1278C57">>},
163-
{<<"opuntia">>, <<"96DBDF5A1A1D9CEEE6649F08E27B7A4AC8FFFFCFA88404242327130122355766">>},
163+
{<<"opuntia">>, <<"A781E231032F892F930E60ACB00F8DF6AFDE3F035F66A5C760320C8E0FA41A3F">>},
164164
{<<"p1_utils">>, <<"67B0C4AC9FA3BA3EF563B31AA111B0A004439A37FAC85E027F1C3617E1C7EC6C">>},
165165
{<<"parse_trans">>, <<"BB87AC362A03CA674EBB7D9D498F45C03256ADED7214C9101F7035EF44B798C7">>},
166166
{<<"pooler">>, <<"898CD1FA301FC42D4A8ED598CE139B71CA85B54C16AB161152B5CC5FBDCFA1A8">>},
@@ -228,7 +228,7 @@
228228
{<<"mimerl">>, <<"A1E15A50D1887217DE95F0B9B0793E32853F7C258A5CD227650889B38839FE9D">>},
229229
{<<"mysql">>, <<"186D7E6DF9CAD33BD9F8F61856F45F2F1962F80B645F163DA744F66C626DA63E">>},
230230
{<<"observer_cli">>, <<"93AE523D42D566B176F7AE77A0BF36802DAB8BB51A6086316CCE66A7CFB5D81F">>},
231-
{<<"opuntia">>, <<"8F70DAA6BD35AE58D96061CDB0FC2AF79DB5C73B0F7564B8BEC2B2DEB703EB8F">>},
231+
{<<"opuntia">>, <<"76D3C52362E63D1A55CF76209E1324D80A2E853600C2485D44D6F57E963F1A10">>},
232232
{<<"p1_utils">>, <<"D0379E8C1156B98BD64F8129C1DE022FCCA4F2FDB7486CE73BF0ED2C3376B04C">>},
233233
{<<"parse_trans">>, <<"F99E368830BEA44552224E37E04943A54874F08B8590485DE8D13832B63A2DC3">>},
234234
{<<"pooler">>, <<"058D85C5081289B90E97E4DDDBC3BB5A3B4A19A728AB3BC88C689EFCC36A07C7">>},

rel/files/mongooseim.toml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
[[listen.c2s]]
128128
port = {{{c2s_port}}}
129129
access = "c2s"
130-
shaper = "c2s_shaper"
130+
shaper = "normal"
131131
max_stanza_size = 65536
132132
{{#tls_config}}
133133
{{{tls_config}}}
@@ -145,7 +145,7 @@
145145

146146
[[listen.s2s]]
147147
port = {{{incoming_s2s_port}}}
148-
shaper = "s2s_shaper"
148+
shaper = "fast"
149149
max_stanza_size = 131072
150150
{{#tls_config}}
151151
{{{tls_config}}}
@@ -304,15 +304,6 @@
304304
{acl = "all", value = "allow"}
305305
]
306306

307-
c2s_shaper = [
308-
{acl = "admin", value = "none"},
309-
{acl = "all", value = "normal"}
310-
]
311-
312-
s2s_shaper = [
313-
{acl = "all", value = "fast"}
314-
]
315-
316307
muc_admin = [
317308
{acl = "admin", value = "allow"}
318309
]

rel/mim1.vars-toml.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"[[listen.c2s]]
6969
port = {{ c2s_tls_port }}
7070
access = \"c2s\"
71-
shaper = \"c2s_shaper\"
71+
shaper = \"normal\"
7272
max_stanza_size = 65536
7373
tls.certfile = \"priv/ssl/fake_server.pem\"
7474
tls.cacertfile = \"priv/ssl/cacert.pem\"

0 commit comments

Comments
 (0)