From patchwork Thu Mar 17 08:11:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 52028 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D715395200D for ; Thu, 17 Mar 2022 08:12:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D715395200D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1647504742; bh=+yUOYOoQhlGnESOhcjzDOxE2smJjvYvGp/EMhlxTyg4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=o1/bkFznxBuBt+6AKhoBCfZKaBq0smdRte5Xf7hD8LD7/WR3JZBJZXfMpLzCUc308 6K5vQYI8RAmCtahaLnZwJwcgN9PVISjOGQfAM18UyfHp246IQe9XBPB9NUuzL8vyYE NdW21aRLkC3wMWpeY1ewcH4plQYUjuc1MXCFfNKk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from burlywood.elm.relay.mailchannels.net (burlywood.elm.relay.mailchannels.net [23.83.212.26]) by sourceware.org (Postfix) with ESMTPS id 8B6413857C4A for ; Thu, 17 Mar 2022 08:12:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B6413857C4A X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id EAE57800D0E; Thu, 17 Mar 2022 08:11:58 +0000 (UTC) Received: from pdx1-sub0-mail-a307.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 860FB8009AD; Thu, 17 Mar 2022 08:11:58 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1647504718; a=rsa-sha256; cv=none; b=FNVFznv+k1HDFOFG7LWux8cempiaiRPPEX9DGL+sTcLcB+YqB7Xd15Eyc/JiA5DTpDbLMY AxLeUItqBfwg5/jjUEqEthp2r3jUcKLZKsTMo+76Ai8j6lVD7JiLCLeJvvzjtE2i8KcDUE yyhMCAK4JZFTqRNh/8KWeb9osqFl988XC+lw12zUelDdaFuU/QjYXt5dnORL2L6dZuAeKc fXlvkTH7/J8GG67wIeSq0h9zpsjuVKQkPARMCBPJqdJ6yf3pOaZQ1JrUyQgysoGapnSFSF EbrRo5Wtc1Qc5ICI2NAdqkQNnbp9sjXJ31QtsqskPBufdMtBE4saDtmJJvjDMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1647504718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+yUOYOoQhlGnESOhcjzDOxE2smJjvYvGp/EMhlxTyg4=; b=IeKd3JfUyFotVr6YWG3quwfASsxC0Yy3R8x9dLdLSwf3iP+5zpRq3lJ3NFwpGuh7tNHvr4 AdFQwf50hkg8KGBF/+pMCKSK4m6cWlQJ+CXZwdyJ6dSi4+y/tz4iO7X+QjZqSiqL3HH/oK GZ3TxPhhdppNzP+UZT69+MEJ9lfvn+qJprs1A7DORNoY+0Ef2QFS5Ex75YMErEbBsasWJ2 le4KaloG3dGCICJ09bOY+twiaa80JsHKot3j+Ngf2YOtqHQe0Al5gf1pEqvlypjlVbKN08 DfjpCKKNvTQkJcY+RT8S+1u2ec6OZ5N25fzUTjpPkPkz7ZKcoguOFOW1j9AMjw== ARC-Authentication-Results: i=1; rspamd-74bfb75fc6-qgm8m; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a307.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.121.210.153 (trex/6.5.3); Thu, 17 Mar 2022 08:11:58 +0000 X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Plucky-Hook: 4afd01e30b5896c8_1647504718795_3880189893 X-MC-Loop-Signature: 1647504718794:1376591856 X-MC-Ingress-Time: 1647504718794 Received: from rhbox.intra.reserved-bit.com (unknown [1.186.123.88]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a307.dreamhost.com (Postfix) with ESMTPSA id 4KK0H03W18z21; Thu, 17 Mar 2022 01:11:56 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v3 00/12] getaddrinfo facelift and fixes Date: Thu, 17 Mar 2022 13:41:28 +0530 Message-Id: <20220317081140.3098156-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220308100717.1006126-1-siddhesh@sourceware.org> References: <20220308100717.1006126-1-siddhesh@sourceware.org> MIME-Version: 1.0 X-Spam-Status: No, score=-3488.6 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H2, RCVD_IN_SBL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The gaih_inet implementation, which forms the core of getaddrinfo, is quite complex in its implementation, making it hard to follow or debug. Particularly, allocations for gaih_addrtuples to store intermediate results are particularly hard to track because of the way in which it is written. This patchset is an attempt at cleaning up the implementation to make it much easier to follow. In the process, it also fixes a couple of bugs, one that was the trigger for this cleanup and another that was discovered during the cleanup. Changes from v2: - 1/12: reinitialized got_ipv6 too, changed test case to run in a container. - 8/12: Fix leak on realloc failure - Rest: updated review comments. Changes from v1: - Fixed nit: boolean coercion in convert_hostent_to_gaih_addrtuple - Dropped DNS tests in tst-nss-gai-actions test since they are unnecessary and the files tests are sufficient. Siddhesh Poyarekar (12): Simplify allocations and fix merge and continue actions [BZ #28931] gaih_inet: Simplify canon name resolution getaddrinfo: Fix leak with AI_ALL [BZ #28852] gaih_inet: Simplify service resolution gaih_inet: make numeric lookup a separate routine gaih_inet: Split simple gethostbyname into its own function gaih_inet: Split nscd lookup code into its own function. gaih_inet: separate nss lookup loop into its own function gaih_inet: make gethosts into a function gaih_inet: split loopback lookup into its own function gaih_inet: Split result generation into its own function gethosts: Return EAI_MEMORY on allocation failure nss/Makefile | 1 + nss/tst-nss-gai-actions.c | 149 ++ nss/tst-nss-gai-actions.root/etc/host.conf | 1 + nss/tst-nss-gai-actions.root/etc/hosts | 508 +++++++ sysdeps/posix/getaddrinfo.c | 1520 +++++++++++--------- 5 files changed, 1464 insertions(+), 715 deletions(-) create mode 100644 nss/tst-nss-gai-actions.c create mode 100644 nss/tst-nss-gai-actions.root/etc/host.conf create mode 100644 nss/tst-nss-gai-actions.root/etc/hosts