[krbdev.mit.edu #6686] Re: [krbdev.mit.edu #6735] kprop and kpropd don't support IPv6
nalin@redhat.com via RT
rt-comment at krbdev.mit.edu
Mon Jun 28 14:15:25 EDT 2010
The kprop client seems to be working well, but kpropd currently gives me
this warning when run in standalone mode:
kpropd: Protocol not available while unsetting IPV6_V6ONLY option
This appears to happen because getaddrinfo() is returning a list of two
addresses (the first is the IPv4 wildcard address, and the second is the
IPv6 wildcard address), and kpropd is only using the first.
Checking that res->ai_family is AF_INET6 before calling setsockopt() at
line 277 suppresses the warning, but then it's still listening only for
IPv4 connections.
I've found that asking getaddrinfo() for an AF_INET6 address with
AI_ADDRCONFIG added to hints.ai_flags seems to reliably return an error
when IPv6 isn't supported, and falling back from there to asking for an
AF_INET address, while not particularly elegant, seems to do the job.
HTH,
Nalin
Index: src/slave/kpropd.c
===================================================================
--- src/slave/kpropd.c (revision 24148)
+++ src/slave/kpropd.c (working copy)
@@ -250,14 +250,22 @@
retry:
memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_UNSPEC;
+ hints.ai_family = AF_INET6;
hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_PASSIVE;
+ hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG | AI_V4MAPPED;
error = getaddrinfo(NULL, port, &hints, &res);
if (error != 0) {
- (void) fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(error));
- exit(1);
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+
+ error = getaddrinfo(NULL, port, &hints, &res);
+ if (error != 0) {
+ (void) fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(error));
+ exit(1);
+ }
}
finet = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
@@ -274,8 +282,9 @@
/* Typically, res will be the IPv6 wildcard address. Some systems, such as
* the *BSDs, don't accept IPv4 connections on this address by default. */
val = 0;
- if (setsockopt(finet, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val)) < 0)
- com_err(progname, errno, "while unsetting IPV6_V6ONLY option");
+ if (res->ai_family == AF_INET6)
+ if (setsockopt(finet, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val)) < 0)
+ com_err(progname, errno, "while unsetting IPV6_V6ONLY option");
#endif
/*
More information about the krb5-bugs
mailing list