From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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) by dcvr.yhbt.net (Postfix) with ESMTPS id 2C0881F8C6 for ; Thu, 15 Jul 2021 05:14:30 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A38439DC4CF for ; Thu, 15 Jul 2021 05:14:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A38439DC4CF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1626326069; bh=5S7FfGG+yoG3/0QG90rzQlOctAtCi5Oa57YOrNK+bEo=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=F7AYZIZ/FJNU10JqgnKGMeHZZ1W0xlJL2UEJTU+HIJFzrCaSOcCbWdcd/zxAmxJfv QbAUKShcaIvd1yyoC+zhst3xnUixLYSGeOzFR/ztT33yL6ghBqKgD9bxKRnGSJpF3A zLxnwJaQv9ZcSkpe4glH/QP5/CNXrw56N8JIhKck= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 33BFA39A28E6 for ; Thu, 15 Jul 2021 05:01:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33BFA39A28E6 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-bBUshVX7POWFbWr5l8ZSmA-1; Thu, 15 Jul 2021 01:01:38 -0400 X-MC-Unique: bBUshVX7POWFbWr5l8ZSmA-1 Received: by mail-qv1-f71.google.com with SMTP id d17-20020a0cfe910000b02902e01fc8ee77so3220277qvs.21 for ; Wed, 14 Jul 2021 22:01:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=5S7FfGG+yoG3/0QG90rzQlOctAtCi5Oa57YOrNK+bEo=; b=V89lpKLca/Hz42i8x0q9rs+2tRdGbN8Q2PBEMyLIS3+WqaFlhyL1/9IgbHzGCTBPdB tuU1BMXnd6127DwjLmUAx2a+vbFXajMGsFmdW/wb3Dyp2jZqcJdXpEpkTgvDVJdhzpDG jyzsR/ct92vJjkqtu+Z3MJNFAGxxEQUgnBI60imFZdIdKiUNLQHuH09rHAQyQF+KVBc9 ALZfONxzTdI7faCD8RR/A+tSy6a3yas1z8bSawpznt6U4w5rBfac+cYiduDAnswqbs9R EUn1fDGvJQPOQFfDCfizesd+5SFoXYN6oEubOq3fRH95lDOgYijtB31+KR2L+3u4d0Pl X7TA== X-Gm-Message-State: AOAM531zLVWGtgVVlvjy0rBglrwhYxEiRmhjGzIjUdY1+aVL+1xy+YNB 5B/QXmw0UDzRkVzL3v0K54qgRhIvLl86vmff3VxLJ29NLRrYSr8SlXaGqs4nEeBiE/WLO3Khh89 dhcGeUo/kh28J0Swm53xEWOmRLYkwVqPyMnLkz0SWcCUDAkRXumVf+5piu3+eD5vxQKwPNw== X-Received: by 2002:ad4:5386:: with SMTP id i6mr2123700qvv.2.1626325297230; Wed, 14 Jul 2021 22:01:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTWxyzupJdEiCTqC6SW1HbSxjVr2AVoQ+pZIsdCAnb6VPqqF06/jDlp80zZ1eUnbqbMfWRvA== X-Received: by 2002:ad4:5386:: with SMTP id i6mr2123681qvv.2.1626325297046; Wed, 14 Jul 2021 22:01:37 -0700 (PDT) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id v20sm1631131qto.89.2021.07.14.22.01.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Jul 2021 22:01:36 -0700 (PDT) Subject: Re: [PATCH 18/30] resolv: Move __res_get_nsaddr to its own file and into libc To: Florian Weimer , libc-alpha@sourceware.org References: <9eda9ddcca31cb2c1457c0013237ef528293af58.1625755446.git.fweimer@redhat.com> Organization: Red Hat Message-ID: <23803ccc-6802-bf53-98d4-e127fa7896ab@redhat.com> Date: Thu, 15 Jul 2021 01:01:35 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <9eda9ddcca31cb2c1457c0013237ef528293af58.1625755446.git.fweimer@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: , From: Carlos O'Donell via Libc-alpha Reply-To: Carlos O'Donell Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On 7/8/21 11:04 AM, Florian Weimer via Libc-alpha wrote: > Eliminate the use of the EXT macro from it because it does not > add clarity. The function was added to res_send.c in 2015, and > the copyright year reflects that. OK for glibc 2.34. Tested without regression on x86_64 and i686. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell > --- > resolv/Makefile | 1 + > resolv/Versions | 1 + > resolv/res_get_nsaddr.c | 39 +++++++++++++++++++++++++++++++++++++++ > resolv/res_send.c | 25 ++++--------------------- > resolv/resolv-internal.h | 6 ++++++ > 5 files changed, 51 insertions(+), 21 deletions(-) > create mode 100644 resolv/res_get_nsaddr.c > > diff --git a/resolv/Makefile b/resolv/Makefile > index 7e142b9a14..6eed73de87 100644 > --- a/resolv/Makefile > +++ b/resolv/Makefile > @@ -46,6 +46,7 @@ routines := \ > res-close \ > res-name-checking \ > res-state \ > + res_get_nsaddr \ OK. > res_hconf \ > res_init \ > res_libc \ > diff --git a/resolv/Versions b/resolv/Versions > index 3e3b89a0b2..fc14cdb701 100644 > --- a/resolv/Versions > +++ b/resolv/Versions > @@ -81,6 +81,7 @@ libc { > __ns_name_skip; > __ns_name_uncompress; > __ns_name_unpack; > + __res_get_nsaddr; OK. > __res_iclose; > __resolv_context_get; > __resolv_context_get_override; > diff --git a/resolv/res_get_nsaddr.c b/resolv/res_get_nsaddr.c > new file mode 100644 > index 0000000000..593597bdd7 > --- /dev/null > +++ b/resolv/res_get_nsaddr.c > @@ -0,0 +1,39 @@ > +/* Name server address at specified index in res_state. OK. > + Copyright (C) 2015-2021 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include > +#include > +#include > + > +struct sockaddr * > +__res_get_nsaddr (res_state statp, unsigned int n) > +{ > + assert (n < statp->nscount); > + > + if (statp->nsaddr_list[n].sin_family == 0 > + && statp->_u._ext.nsaddrs[n] != NULL) > + /* statp->_u._ext.nsaddrs[n] holds an address that is larger than > + struct sockaddr, and user code did not update > + statp->nsaddr_list[n]. */ > + return (struct sockaddr *) statp->_u._ext.nsaddrs[n]; OK. > + else > + /* User code updated statp->nsaddr_list[n], or statp->nsaddr_list[n] > + has the same content as statp->_u._ext.nsaddrs[n]. */ > + return (struct sockaddr *) (void *) &statp->nsaddr_list[n]; OK. > +} > +libc_hidden_def (__res_get_nsaddr) > diff --git a/resolv/res_send.c b/resolv/res_send.c > index b6139c7d62..78f564ee85 100644 > --- a/resolv/res_send.c > +++ b/resolv/res_send.c > @@ -180,7 +180,6 @@ evNowTime(struct timespec *res) { > > /* Forward. */ > > -static struct sockaddr *get_nsaddr (res_state, unsigned int); OK. > static int send_vc(res_state, const u_char *, int, > const u_char *, int, > u_char **, int *, int *, int, u_char **, > @@ -215,7 +214,7 @@ res_ourserver_p(const res_state statp, const struct sockaddr_in6 *inp) > > for (ns = 0; ns < statp->nscount; ns++) { > const struct sockaddr_in *srv = > - (struct sockaddr_in *) get_nsaddr (statp, ns); > + (struct sockaddr_in *) __res_get_nsaddr (statp, ns); OK. > > if ((srv->sin_family == AF_INET) && > (srv->sin_port == port) && > @@ -226,7 +225,7 @@ res_ourserver_p(const res_state statp, const struct sockaddr_in6 *inp) > } else if (inp->sin6_family == AF_INET6) { > for (ns = 0; ns < statp->nscount; ns++) { > const struct sockaddr_in6 *srv > - = (struct sockaddr_in6 *) get_nsaddr (statp, ns); > + = (struct sockaddr_in6 *) __res_get_nsaddr (statp, ns); OK. > if ((srv->sin6_family == AF_INET6) && > (srv->sin6_port == inp->sin6_port) && > !(memcmp(&srv->sin6_addr, &in6addr_any, > @@ -608,22 +607,6 @@ res_send (const unsigned char *buf, int buflen, unsigned char *ans, int anssiz) > > /* Private */ > > -static struct sockaddr * > -get_nsaddr (res_state statp, unsigned int n) > -{ > - assert (n < statp->nscount); > - > - if (statp->nsaddr_list[n].sin_family == 0 && EXT(statp).nsaddrs[n] != NULL) > - /* EXT(statp).nsaddrs[n] holds an address that is larger than > - struct sockaddr, and user code did not update > - statp->nsaddr_list[n]. */ > - return (struct sockaddr *) EXT(statp).nsaddrs[n]; > - else > - /* User code updated statp->nsaddr_list[n], or statp->nsaddr_list[n] > - has the same content as EXT(statp).nsaddrs[n]. */ > - return (struct sockaddr *) (void *) &statp->nsaddr_list[n]; > -} > - OK. Remove. > /* Close the resolver structure, assign zero to *RESPLEN2 if RESPLEN2 > is not NULL, and return zero. */ > static int > @@ -717,7 +700,7 @@ send_vc(res_state statp, > const HEADER *hp = (HEADER *) buf; > const HEADER *hp2 = (HEADER *) buf2; > HEADER *anhp = (HEADER *) *ansp; > - struct sockaddr *nsap = get_nsaddr (statp, ns); > + struct sockaddr *nsap = __res_get_nsaddr (statp, ns); OK. > int truncating, connreset, n; > /* On some architectures compiler might emit a warning indicating > 'resplen' may be used uninitialized. However if buf2 == NULL > @@ -948,7 +931,7 @@ static int > reopen (res_state statp, int *terrno, int ns) > { > if (EXT(statp).nssocks[ns] == -1) { > - struct sockaddr *nsap = get_nsaddr (statp, ns); > + struct sockaddr *nsap = __res_get_nsaddr (statp, ns); OK. > socklen_t slen; > > /* only try IPv6 if IPv6 NS and if not failed before */ > diff --git a/resolv/resolv-internal.h b/resolv/resolv-internal.h > index e1e8aa3ef3..c18b1d0472 100644 > --- a/resolv/resolv-internal.h > +++ b/resolv/resolv-internal.h > @@ -103,4 +103,10 @@ void __res_thread_freeres (void) attribute_hidden; > success, -1 on failure. */ > int __res_enable_icmp (int family, int fd) attribute_hidden; > > + > +/* Returns the name server address for the indicated index. */ > +struct sockaddr *__res_get_nsaddr (res_state statp, unsigned int n); > +libc_hidden_proto (__res_get_nsaddr) OK. > + > + > #endif /* _RESOLV_INTERNAL_H */ > -- Cheers, Carlos.