diff --git a/apps/emqx/src/emqx_schema.erl b/apps/emqx/src/emqx_schema.erl index 8509dc245..f552fae7f 100644 --- a/apps/emqx/src/emqx_schema.erl +++ b/apps/emqx/src/emqx_schema.erl @@ -30,6 +30,7 @@ -include_lib("hocon/include/hoconsc.hrl"). -include_lib("logger.hrl"). +-define(MAX_INT_MQTT_PACKET_SIZE, 268435456). -define(MAX_INT_TIMEOUT_MS, 4294967295). %% floor(?MAX_INT_TIMEOUT_MS / 1000). -define(MAX_INT_TIMEOUT_S, 4294967). @@ -45,6 +46,7 @@ -type timeout_duration_s() :: 0..?MAX_INT_TIMEOUT_S. -type timeout_duration_ms() :: 0..?MAX_INT_TIMEOUT_MS. -type bytesize() :: integer(). +-type mqtt_max_packet_size() :: 1..?MAX_INT_MQTT_PACKET_SIZE. -type wordsize() :: bytesize(). -type percent() :: float(). -type file() :: string(). @@ -71,6 +73,7 @@ -typerefl_from_string({timeout_duration_s/0, emqx_schema, to_timeout_duration_s}). -typerefl_from_string({timeout_duration_ms/0, emqx_schema, to_timeout_duration_ms}). -typerefl_from_string({bytesize/0, emqx_schema, to_bytesize}). +-typerefl_from_string({mqtt_max_packet_size/0, emqx_schema, to_bytesize}). -typerefl_from_string({wordsize/0, emqx_schema, to_wordsize}). -typerefl_from_string({percent/0, emqx_schema, to_percent}). -typerefl_from_string({comma_separated_list/0, emqx_schema, to_comma_separated_list}). @@ -151,6 +154,7 @@ timeout_duration_s/0, timeout_duration_ms/0, bytesize/0, + mqtt_max_packet_size/0, wordsize/0, percent/0, file/0, @@ -3357,7 +3361,7 @@ mqtt_general() -> )}, {"max_packet_size", sc( - bytesize(), + mqtt_max_packet_size(), #{ default => <<"1MB">>, desc => ?DESC(mqtt_max_packet_size) diff --git a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl index 47acee58b..c22a5318b 100644 --- a/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl +++ b/apps/emqx_dashboard/src/emqx_dashboard_swagger.erl @@ -852,6 +852,8 @@ typename_to_spec("timeout()", _Mod) -> }; typename_to_spec("bytesize()", _Mod) -> #{type => string, example => <<"32MB">>}; +typename_to_spec("mqtt_max_packet_size()", _Mod) -> + #{type => string, example => <<"32MB">>}; typename_to_spec("wordsize()", _Mod) -> #{type => string, example => <<"1024KB">>}; typename_to_spec("map()", _Mod) -> diff --git a/changes/ce/fix-11184.en.md b/changes/ce/fix-11184.en.md new file mode 100644 index 000000000..46a790a72 --- /dev/null +++ b/changes/ce/fix-11184.en.md @@ -0,0 +1 @@ +Config value for `max_packet_size` has a max value of 256MB defined by protocol. This is now enforced and any configuration with a value greater than that will break.