Don't open proxy UDP socket if it's not needed
authorAlan T. DeKok <aland@freeradius.org>
Sat, 2 Aug 2014 16:36:17 +0000 (18:36 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 2 Aug 2014 16:36:17 +0000 (18:36 +0200)
src/main/listen.c
src/main/realms.c

index 01d8c67..32fb82f 100644 (file)
@@ -3211,6 +3211,16 @@ add_sockets:
                }
        }
 
+#ifdef WITH_TCP
+       /*
+        *      We want to avoid opening a UDP proxy listener
+        *      when all of the home servers are TCP.
+        */
+       extern bool home_servers_udp;
+
+       if (!home_servers_udp) defined_proxy = true;
+#endif
+
        /*
         *      If we're proxying requests, open the proxy FD.
         *      Otherwise, don't do anything.
@@ -3225,7 +3235,7 @@ add_sockets:
                memset(&home, 0, sizeof(home));
 
                /*
-                *
+                *      Open a default UDP port
                 */
                home.proto = IPPROTO_UDP;
                home.src_ipaddr = server_ipaddr;
index e8c7254..765e536 100644 (file)
@@ -32,6 +32,9 @@ RCSID("$Id$")
 #include <fcntl.h>
 
 static rbtree_t *realms_byname = NULL;
+#ifdef WITH_TCP
+bool home_servers_udp = false;
+#endif
 
 #ifdef HAVE_REGEX_H
 typedef struct realm_regex_t {
@@ -508,9 +511,13 @@ static int home_server_add(realm_config_t *rc, CONF_SECTION *cs)
 
        home->proto = IPPROTO_UDP;
 #ifdef WITH_TCP
-       if (hs_proto) {
+       if (!hs_proto) {
+               home_servers_udp = true;
+
+       } else {
                if (strcmp(hs_proto, "udp") == 0) {
                        hs_proto = NULL;
+                       home_servers_udp = true;
 
                } else if (strcmp(hs_proto, "tcp") == 0) {
                        hs_proto = NULL;