[mod_sofia] Implement maximum receiving requests per second max-recv-requests-per-second profile parameter. (Warning: Behaviour change. New default is 1000 requests per second)

This commit is contained in:
Andrey Volk 2021-10-13 18:21:52 +03:00
parent a3c6e70f56
commit 7ed2a99eb5
6 changed files with 21 additions and 0 deletions

View File

@ -36,6 +36,8 @@
<!-- <param name="bitpacking" value="aal2"/> -->
<!--max number of open dialogs in proceeding -->
<!--<param name="max-proceeding" value="1000"/>-->
<!--max number of receiving requests per second (Default: 1000, 0 - unlimited) -->
<!--<param name="max-recv-requests-per-second" value="0"/>-->
<!--session timers for all call to expire after the specified seconds -->
<!--<param name="session-timeout" value="1800"/>-->
<!--<param name="multiple-registrations" value="true"/>-->

View File

@ -172,6 +172,8 @@
<!-- <param name="bitpacking" value="aal2"/> -->
<!--max number of open dialogs in proceeding -->
<!--<param name="max-proceeding" value="1000"/>-->
<!--max number of receiving requests per second (Default: 1000, 0 - unlimited) -->
<!--<param name="max-recv-requests-per-second" value="0"/> -->
<!--session timers for all call to expire after the specified seconds -->
<!--<param name="session-timeout" value="1800"/>-->
<!-- Can be 'true' or 'contact' -->

View File

@ -205,6 +205,8 @@
<!-- <param name="bitpacking" value="aal2"/> -->
<!-- max number of open dialogs in proceeding -->
<!-- <param name="max-proceeding" value="1000"/> -->
<!-- max number of receiving requests per second (Default: 1000, 0 - unlimited) -->
<!-- <param name="max-recv-requests-per-second" value="0"/> -->
<!-- session timers for all call to expire after the specified seconds -->
<!-- <param name="session-timeout" value="1800"/> -->
<!-- Can be 'true' or 'contact' -->

View File

@ -3061,6 +3061,7 @@ static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t
stream->write_function(stream, "CNG \t%d\n", profile->cng_pt);
stream->write_function(stream, "SESSION-TO \t%d\n", profile->session_timeout);
stream->write_function(stream, "MAX-DIALOG \t%d\n", profile->max_proceeding);
stream->write_function(stream, "MAX-RECV-RPS \t%d\n", profile->max_recv_requests_per_second);
stream->write_function(stream, "NOMEDIA \t%s\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
stream->write_function(stream, "LATE-NEG \t%s\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
stream->write_function(stream, "PROXY-MEDIA \t%s\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
@ -3363,6 +3364,7 @@ static switch_status_t cmd_xml_status(char **argv, int argc, switch_stream_handl
stream->write_function(stream, " <cng>%d</cng>\n", profile->cng_pt);
stream->write_function(stream, " <session-to>%d</session-to>\n", profile->session_timeout);
stream->write_function(stream, " <max-dialog>%d</max-dialog>\n", profile->max_proceeding);
stream->write_function(stream, " <max-recv-rps>%d</max-recv-rps>\n", profile->max_recv_requests_per_second);
stream->write_function(stream, " <nomedia>%s</nomedia>\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
stream->write_function(stream, " <late-neg>%s</late-neg>\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
stream->write_function(stream, " <proxy-media>%s</proxy-media>\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");

View File

@ -722,6 +722,7 @@ struct sofia_profile {
uint32_t session_timeout;
uint32_t minimum_session_expires;
uint32_t max_proceeding;
uint32_t max_recv_requests_per_second;
uint32_t rtp_timeout_sec;
uint32_t rtp_hold_timeout_sec;
char *odbc_dsn;

View File

@ -3345,6 +3345,7 @@ void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void
TAG_IF(profile->session_timeout && profile->minimum_session_expires, NUTAG_MIN_SE(profile->minimum_session_expires)),
NUTAG_SESSION_TIMER(profile->session_timeout),
NTATAG_MAX_PROCEEDING(profile->max_proceeding),
NTATAG_MAX_RECV_REQUESTS_PER_SECOND(profile->max_recv_requests_per_second),
TAG_IF(profile->pres_type, NUTAG_ALLOW("PUBLISH")),
TAG_IF(profile->pres_type, NUTAG_ALLOW("SUBSCRIBE")),
TAG_IF(profile->pres_type, NUTAG_ENABLEMESSAGE(1)),
@ -4571,6 +4572,7 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
char *auth_subscriptions_value = NULL;
uint8_t disable_message_auth_flag = 0;
uint8_t disable_subscription_auth_flag = 0;
uint8_t max_recv_requests_per_second_initialized = 0;
if (!xprofilename) {
xprofilename = "unnamed";
@ -5307,6 +5309,12 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
if (v_max_proceeding >= 0) {
profile->max_proceeding = v_max_proceeding;
}
} else if (!strcasecmp(var, "max-recv-requests-per-second") && !zstr(val)) {
int v_max_recv_requests_per_second = atoi(val);
if (v_max_recv_requests_per_second >= 0) {
profile->max_recv_requests_per_second = v_max_recv_requests_per_second;
max_recv_requests_per_second_initialized = 1;
}
} else if (!strcasecmp(var, "rtp-timeout-sec") && !zstr(val)) {
int v = atoi(val);
if (v >= 0) {
@ -6097,6 +6105,10 @@ switch_status_t config_sofia(sofia_config_t reload, char *profile_name)
}
}
if (!max_recv_requests_per_second_initialized) {
profile->max_recv_requests_per_second = 1000;
}
if (!disable_message_auth_flag) {
if (!auth_messages_value || switch_true(auth_messages_value)) {
sofia_set_pflag(profile, PFLAG_AUTH_MESSAGES);