Print more descriptive error message for too many EAP sessions
authorAlan T. DeKok <aland@freeradius.org>
Thu, 1 Oct 2009 13:06:59 +0000 (15:06 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 1 Oct 2009 13:08:18 +0000 (15:08 +0200)
src/modules/rlm_eap/mem.c

index 3b0d162..1b55a71 100644 (file)
@@ -295,6 +295,7 @@ int eaplist_add(rlm_eap_t *inst, EAP_HANDLER *handler)
         *      If we have a DoS attack, discard new sessions.
         */
        if (rbtree_num_elements(inst->session_tree) >= inst->max_sessions) {
+               status = -1;
                eaplist_expire(inst, handler->timestamp);
                goto done;
        }
@@ -361,13 +362,23 @@ int eaplist_add(rlm_eap_t *inst, EAP_HANDLER *handler)
        /*
         *      We don't need this any more.
         */
-       if (status) handler->request = NULL;
+       if (status > 0) handler->request = NULL;
 
        pthread_mutex_unlock(&(inst->session_mutex));
 
-       if (!status) {
+       if (status <= 0) {
                pairfree(&state);
-               radlog(L_ERR, "rlm_eap: Failed to store handler");
+
+               if (status < 0) {
+                       static time_t last_logged = 0;
+
+                       if (last_logged < handler->timestamp) {
+                               last_logged = handler->timestamp;
+                               radlog(L_ERR, "rlm_eap: Too many open sessions.  Try increasing \"max_sessions\" in the EAP module configuration");
+                       }                                      
+               } else {
+                       radlog(L_ERR, "rlm_eap: Internal error: failed to store handler");
+               }
                return 0;
        }