Moved checks for detail to home_server_ldb
authorAlan T. DeKok <aland@freeradius.org>
Thu, 5 Feb 2009 11:05:38 +0000 (12:05 +0100)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 13 Feb 2009 12:41:14 +0000 (13:41 +0100)
Rather than proxying to a home server, and THEN deciding it
wasn't a good idea, we simply skip that home server during
the process of trying to find one.

src/main/event.c
src/main/realms.c

index 0119b5a..8a3e2a7 100644 (file)
@@ -1981,21 +1981,6 @@ static int successfully_proxied_request(REQUEST *request)
        pairadd(&request->packet->vps,
                pairmake("Realm", realmname, T_OP_EQ));
 
-#ifdef WITH_DETAIL
-       /*
-        *      We read the packet from a detail file, AND it came from
-        *      the server we're about to send it to.  Don't do that.
-        */
-       if ((request->packet->code == PW_ACCOUNTING_REQUEST) &&
-           (request->listener->type == RAD_LISTEN_DETAIL) &&
-           (home->ipaddr.af == AF_INET) &&
-           (request->packet->src_ipaddr.af == AF_INET) &&
-           (home->ipaddr.ipaddr.ip4addr.s_addr == request->packet->src_ipaddr.ipaddr.ip4addr.s_addr)) {
-               RDEBUG2("    rlm_realm: Packet came from realm %s, proxy cancelled", realmname);
-               return 0;
-       }
-#endif
-
        /*
         *      Allocate the proxy packet, only if it wasn't already
         *      allocated by a module.  This check is mainly to support
index 20245c5..afa45a6 100644 (file)
@@ -1851,6 +1851,19 @@ home_server *home_server_ldb(const char *realmname,
                        continue;
                }
 
+#ifdef WITH_DETAIL
+               /*
+                *      We read the packet from a detail file, AND it
+                *      came from this server.  Don't re-proxy it
+                *      there.
+                */
+               if ((request->listener->type == RAD_LISTEN_DETAIL) &&
+                   (request->packet->code == PW_ACCOUNTING_REQUEST) &&
+                   (fr_ipaddr_cmp(&home->ipaddr, &request->packet->src_ipaddr) == 0)) {
+                       continue;
+               }
+#endif
+
                if (pool->type != HOME_POOL_LOAD_BALANCE) {
                        return home;
                }