* network.c (setup_a_tcp_listener): Call setreuseaddr before calling bind.
authorKen Raeburn <raeburn@mit.edu>
Thu, 26 Feb 2004 03:43:00 +0000 (03:43 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 26 Feb 2004 03:43:00 +0000 (03:43 +0000)
(setup_tcp_listener_ports): Don't call setreuseaddr.  Log info about socket
option IPV6_V6ONLY in unsupported and success cases.

ticket: 2285
status: open

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16124 dc483132-0cff-0310-8789-dd5450dbe970

src/kdc/ChangeLog
src/kdc/network.c

index b95a6ac7eda138ea3811c6fdd74c6cd5ce6948d5..6c6378f4d8dc7299ee963de64ed703fe4fd2a125 100644 (file)
@@ -1,3 +1,10 @@
+2004-02-25  Ken Raeburn  <raeburn@mit.edu>
+
+       * network.c (setup_a_tcp_listener): Call setreuseaddr before
+       calling bind.
+       (setup_tcp_listener_ports): Don't call setreuseaddr.  Log info
+       about socket option IPV6_V6ONLY in unsupported and success cases.
+
 2004-02-24  Sam Hartman  <hartmans@avalanche-breakdown.mit.edu>
 
        * kerberos_v4.c (compat_decrypt_key): As below.
index 4c49102a945a65c8838100d4ec046eeffeced912..cc79b8093574feccf5ff0c0c7ad4393202c1b2a7 100644 (file)
@@ -358,6 +358,9 @@ setup_a_tcp_listener(struct socksetup *data, struct sockaddr *addr)
                paddr(addr));
        return -1;
     }
+    if (setreuseaddr(sock, 1) < 0)
+       com_err(data->prog, errno,
+               "Cannot enable SO_REUSEADDR on fd %d", sock);
     if (bind(sock, addr, socklen(addr)) == -1) {
        com_err(data->prog, errno,
                "Cannot bind TCP server socket on %s", paddr(addr));
@@ -434,16 +437,12 @@ setup_tcp_listener_ports(struct socksetup *data)
 #ifdef IPV6_V6ONLY
            if (setv6only(s6, 0))
                com_err(data->prog, errno, "setsockopt(IPV6_V6ONLY,0) failed");
+           else
+               com_err(data->prog, 0, "setsockopt(IPV6_V6ONLY,0) worked");
+#else
+           krb5_klog_syslog(LOG_INFO, "no IPV6_V6ONLY socket option support");
 #endif
 
-           if (setreuseaddr(s6, 0) < 0) {
-               com_err(data->prog, errno,
-                       "disabling SO_REUSEADDR on IPv6 TCP socket for port %d",
-                       port);
-               close(s6);
-               return -1;
-           }
-
            s4 = setup_a_tcp_listener(data, (struct sockaddr *)&sin4);
 #endif /* KRB5_USE_INET6 */
        }
@@ -803,6 +802,10 @@ static void accept_tcp_connection(struct connection *conn, const char *prog,
            strcpy(p, tmpbuf);
        }
     }
+#if 0
+    krb5_klog_syslog(LOG_INFO, "accepted TCP connection on socket %d from %s",
+                    s, newconn->u.tcp.addrbuf);
+#endif
 
     newconn->u.tcp.addr_s = addr_s;
     newconn->u.tcp.addrlen = addrlen;