]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Check for too many SRTP errors before warning
authorTravis Cross <tc@traviscross.com>
Sun, 29 Jun 2014 20:40:49 +0000 (20:40 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 29 Jun 2014 20:49:46 +0000 (20:49 +0000)
We're checking whether we've hit the warning threshold before checking
whether we should just end the call.  This causes an off-by-one error
where we take one SRTP error more than intended.

This commit reverses the order of the tests.

src/switch_rtp.c

index 9a6c3cf5e065b5f5a381c28b07510a91fc1a9dc5..eccce9d71c3ae5b8389ca3e0e8a522dab349c0b7 100644 (file)
@@ -4808,11 +4808,7 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
                                                if (stat == err_status_replay_fail) msg="replay check failed";
                                                else if (stat == err_status_auth_fail) msg="auth check failed";
                                                else msg="";
-                                               if (errs >= WARN_SRTP_ERRS && !(errs % WARN_SRTP_ERRS)) {
-                                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
-                                                                                         "SRTP %s unprotect failed with code %d (%s) %ld bytes %d errors\n",
-                                                                                         rtp_type(rtp_session), stat, msg, (long)*bytes, errs);
-                                               } else if (errs >= MAX_SRTP_ERRS) {
+                                               if (errs >= MAX_SRTP_ERRS) {
                                                        switch_channel_t *channel = switch_core_session_get_channel(rtp_session->session);
                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
                                                                                          "SRTP %s unprotect failed with code %d (%s) %ld bytes %d errors\n",
@@ -4820,6 +4816,10 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
                                                                                          "Ending call due to SRTP error\n");
                                                        switch_channel_hangup(channel, SWITCH_CAUSE_SRTP_READ_ERROR);
+                                               } else if (errs >= WARN_SRTP_ERRS && !(errs % WARN_SRTP_ERRS)) {
+                                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING,
+                                                                                         "SRTP %s unprotect failed with code %d (%s) %ld bytes %d errors\n",
+                                                                                         rtp_type(rtp_session), stat, msg, (long)*bytes, errs);
                                                }
                                        }
                                        sbytes = 0;