Re: [PATCH 2/2] Support IPv6 in port allocator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/31/2013 06:33 PM, Daniel P. Berrange wrote:
> On Thu, Oct 31, 2013 at 04:40:11PM +0100, Ján Tomko wrote:
>> Also try to bind on IPv6 to check if the port is occupied.
>>
>> https://bugzilla.redhat.com/show_bug.cgi?id=1025407
>> ---
>>  src/util/virportallocator.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>>  1 file changed, 38 insertions(+), 7 deletions(-)
> 
> Have you tested this on a system where the IPv6 kernel module is
> not present, and on a system with IPv6 kmod is present, but no
> interfaces have any IPv6 addresses (not even link-local ones).
> I'm concerned this is going to trigger failures on IPv4 only
> hosts.

When the ipv6 module is not present, socket(AF_INET6) returns EAFNOSUPPORT.
With sysctl net.ipv6.conf.all.disable_ipv6=1 even bind succeeds.

> 
>> diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c
>> index 1922ea6..24b4bff 100644
>> --- a/src/util/virportallocator.c
>> +++ b/src/util/virportallocator.c

>> +    if (family == AF_INET6) {
>> +        addr = (struct sockaddr*)&addr6;
>> +        addrlen = sizeof(addr6);
>> +        ipv6 = true;
>> +    } else if (family == AF_INET) {
>> +        addr = (struct sockaddr*)&addr4;
>> +        addrlen = sizeof(addr4);
> 
> family can be AF_INET or AF_INET6 here...
> 
>> +    } else {
>> +        virReportError(VIR_ERR_INTERNAL_ERROR, _("Unknown family %d"), family);
>> +        return -1;
>> +    }
>>  
>>      *used = false;
>>  
>>      fd = socket(PF_INET, SOCK_STREAM, 0);
> 
> ...but you're hardcoding PF_INET here. I'm not sure it is valid
> to use an PF_INET socket with an AF_INET6 address in bind().

Ouch, rebase error. That can't work.
s/PF_INET/family/

> 
>>      if (fd < 0) {
>> +        if (errno == EAFNOSUPPORT)
>> +            return 0;
>>          virReportSystemError(errno, "%s", _("Unable to open test socket"));
>>          goto cleanup;
>>      }

Jan

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]