krb5 commit: Use pktinfo for explicit UDP wildcard listeners

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/d005beaa72c70bc28b2b0b49b9d83eff160ca8f1
commit d005beaa72c70bc28b2b0b49b9d83eff160ca8f1
Author: Greg Hudson <[email protected]>
Date:   Mon Dec 26 15:18:05 2016 -0500

    Use pktinfo for explicit UDP wildcard listeners
    
    In net-server.c, use pktinfo on UDP server sockets if they are bound
    to wildcard addresses, whether that is explicit or implicit in the
    address specification.
    
    ticket: 8530
    target_version: 1.15-next
    tags: pullup

 src/lib/apputils/net-server.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/lib/apputils/net-server.c b/src/lib/apputils/net-server.c
index d64ffdd..29ec84a 100644
--- a/src/lib/apputils/net-server.c
+++ b/src/lib/apputils/net-server.c
@@ -105,6 +105,17 @@ paddr(struct sockaddr *sa)
     return buf;
 }
 
+/* Return true if sa is an IPv4 or IPv6 wildcard address. */
+static int
+is_wildcard(struct sockaddr *sa)
+{
+    if (sa->sa_family == AF_INET6)
+        return IN6_IS_ADDR_UNSPECIFIED(&sa2sin6(sa)->sin6_addr);
+    else if (sa->sa_family == AF_INET)
+        return sa2sin(sa)->sin_addr.s_addr == INADDR_ANY;
+    return 0;
+}
+
 /* KDC data.  */
 
 enum conn_type {
@@ -753,7 +764,7 @@ setup_socket(struct socksetup *data, struct bind_address *ba,
     }
 
     /* Try to turn on pktinfo for UDP wildcard sockets. */
-    if (ba->type == UDP && ba->address == NULL) {
+    if (ba->type == UDP && is_wildcard(sock_address)) {
         krb5_klog_syslog(LOG_DEBUG, _("Setting pktinfo on socket %s"),
                          paddr(sock_address));
         ret = set_pktinfo(sock, sock_address->sa_family);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.