From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1aZIpR-0005PC-Ur for mharc-grub-devel@gnu.org; Fri, 26 Feb 2016 08:53:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZIpM-0005OV-DA for grub-devel@gnu.org; Fri, 26 Feb 2016 08:53:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aZIpH-0006fV-E6 for grub-devel@gnu.org; Fri, 26 Feb 2016 08:53:04 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:60265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aZIpH-0006fP-5X for grub-devel@gnu.org; Fri, 26 Feb 2016 08:52:59 -0500 Received: from pps.filterd (m0044008.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id u1QDmbJp001745; Fri, 26 Feb 2016 05:52:55 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=subject : to : references : cc : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=facebook; bh=IYL/gHjEwJ1iWFpGKKTwqDIa9BnykkLVv1FZuwu9+PU=; b=LEpKlwvYV4x3bh2BYInoAFXk+7S/1hLXRP4vfOu+bG8FQV/C4xaw/htVfvwqjg0ntuZd NIKdrne/G4eksqSKLGNl8NtxXmL5YGhnsXuQ5u+5XdyAkAIZOVcUAlLuzAAInw3PqCVP CK0dx+zLeCc16patUL7NbDpn7R99fvJarq8= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 21apnxr9p8-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Fri, 26 Feb 2016 05:52:55 -0800 Received: from localhost.localdomain (192.168.52.123) by mail.thefacebook.com (192.168.16.12) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 26 Feb 2016 05:52:52 -0800 Subject: Re: [PATCH] dns: realloc address buffer after each packet To: Andrei Borzenkov , The development of GNU GRUB References: <1456341072-13356-1-git-send-email-jbacik@fb.com> From: Josef Bacik Message-ID: <56D058B3.6060202@fb.com> Date: Fri, 26 Feb 2016 08:52:51 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.52.123] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-02-26_09:, , signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 67.231.145.42 Cc: Kernel Team X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Feb 2016 13:53:08 -0000 On 02/26/2016 05:22 AM, Andrei Borzenkov wrote: > On Wed, Feb 24, 2016 at 10:11 PM, Josef Bacik wrote: >> Sometimes DNS responses come in slower than we poll for them which can lead us >> to process multiple DNS packets which overflows the addresses array. So instead >> realloc the array each time to make sure we are accounting for any answers we >> currently have in the address array. We also move the caching of the addresses >> outside of the recv hook so we can be sure to cache all the responses at once >> instead of one packet at a time. Thanks, >> > > This still does not address the problem that we stop waiting for > further packets as soon as we get any response, so we still depend on > delivery order to get correct record. > > What about following > > - send both A and AAAA query concurrently if requested > - keep track of both requests (i.e. have data.id[2] and data.addresses[2]) > - reset request ID (or otherwise mark it as "received") as soon as we > got reply. Note that reply may contain no addresses - NXDOMAIN is > prerfectly valid - so condition should not be "got any record of type > A or AAAA" as it is now but rather simply "got reply to request with > id XX". This also allows us to implement negative caching at some > point :) So we check the rcode so a NXDOMAIN response will just be discarded, we don't have to worry about this case. > - return both A and AAAA results separately to grub_net_dns_lookup() > - combine them in grub_net_dns_lookup() depending on preference - i.e. > put either A or AAAA first in final result. > > This seems to cover all issues so far - we do not wait too long, we > are guaranteed to get both A and AAAA if we request them and we return > them in proper order for further processing. > > Do I miss something? > So my patch previous to this one changes it so DNS servers we get from dhcp are bound to either ipv4 or ipv6, so the only way we get PREFER_IPV* is if an admin sets it. So now the only time we'll get both an A _and_ an AAAA record is if we have both types of interfaces on the system, so it won't matter which answer is first as we'll be able to send traffic to either. I just side-stepped the issue by making it so that (at least automatically) we aren't asking for both records unless we are sure we have an interface to go along with both types of records. Thanks, Josef