On accounting, if NO proxy packet, do preacct, acct, and then
authoraland <aland>
Thu, 2 Aug 2001 18:20:48 +0000 (18:20 +0000)
committeraland <aland>
Thu, 2 Aug 2001 18:20:48 +0000 (18:20 +0000)
if configured to proxy the packet, stop.  Otherwise, reply.

On proxy reply packet, don't do any of preacct or acct.  Simply
reply to the NAS

src/main/acct.c

index cdf9051..e1f9b76 100644 (file)
@@ -43,36 +43,41 @@ static const char rcsid[] = "$Id$";
  */
 int rad_accounting(REQUEST *request)
 {
-       int             reply;
+       int             reply = RLM_MODULE_OK;
 
-       if(!request->proxy) { /* Only need to do this once, before proxying */
+       if (!request->proxy) { /* Only need to do this once, before proxying */
                reply = module_preacct(request);
                if (reply != RLM_MODULE_NOOP &&
-                               reply != RLM_MODULE_OK &&
-                               reply != RLM_MODULE_UPDATED)
+                   reply != RLM_MODULE_OK &&
+                   reply != RLM_MODULE_UPDATED)
                        return reply;
                
+               /*
+                *      Do accounting, ONLY the first time through.
+                *      This is to ensure that we log the packet
+                *      immediately, even if the proxy never does.
+                */
+               reply = module_accounting(request);
+               
+               /*
+                *      Maybe one of the preacct modules has decided
+                *      that a proxy should be used. If so, get out of
+                *      here and send the proxied packet, but ONLY if
+                *      there isn't one already...
+                */
+               if (pairfind(request->config_items, PW_PROXY_TO_REALM)) {
+                       return reply;
+               }
        }
 
-       reply = RLM_MODULE_OK;
-
-       /*
-        *      Do accounting
-        */
-       reply = module_accounting(request);
-       
        /*
-        *      Maybe one of the preacct modules has decided
-        *      that a proxy should be used. If so, get out of
-        *      here and send the packet.
+        *      We get here IF we're not proxying, OR if we've
+        *      received the accounting reply from the end server,
+        *      THEN we can reply to the NAS.
         */
-       if(pairfind(request->config_items, PW_PROXY_TO_REALM)) {
-               return reply;
-       }
-
        if (reply == RLM_MODULE_NOOP ||
-                       reply == RLM_MODULE_OK ||
-                       reply == RLM_MODULE_UPDATED) {
+           reply == RLM_MODULE_OK ||
+           reply == RLM_MODULE_UPDATED) {
                /*
                 *      Now send back an ACK to the NAS.
                 */