From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 0996E384AB58 for ; Fri, 3 May 2024 15:32:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0996E384AB58 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0996E384AB58 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714750334; cv=none; b=ogGjLdxboEWp94XzbBSHXL55gHRhK2Gb8Id+vdoIR02D1IkeEV73H2RN1uZeFBsT/fgCtIbtxj9TMt2iws0BCpgnnTVovqNnoKAXftL3zCNpcCB5xOFzgmtTeXSq4U6PC02fhhwqZzhUoPmdX3Db3C1rDl/TORf0SeDtU3MvTx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714750334; c=relaxed/simple; bh=+IB3jKbH3ANkHbmDNpMbCepubvcOUf3AdMX1aaAyBF0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ZLtuNznS19TYRwf6nnElz5VfRYqTAUIdBCxf5u37Se+gV9p7TkmqQcqSWujcgOf62HbPeTfzB67HUSbPntyDmc+jEFJyVbKzZ7tD3IG671UZc10ZfaeS1O2YxVYUbGiKCVjsfDnjGt7Cggskw6vFBSGCpN5Vv+1ajnAZ+RukIPo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714750332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=Yhw466AEmWvjLqOZi3ZE5Twj6p73jIRpFzx8HLUg9oM=; b=a6Mv0zrYnx4CuRY4lmjQ3V8ntrvpos9APoaAgDpVgQcdK83QnFynR9rovw+MnUnqynhbD8 DOi0CdXqzPEh+Ozs1zhMjI9sglAP+lFBXhVgIUZckoB6llgTur30iwF/ruQ/9h9jyh0pJS v2NzrYGhfLgfWFLQGV61udwXCOfiz68= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-UCWAIX90MNC_51k3bd_rcg-1; Fri, 03 May 2024 11:32:10 -0400 X-MC-Unique: UCWAIX90MNC_51k3bd_rcg-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7909bc5790aso1322360185a.0 for ; Fri, 03 May 2024 08:32:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714750329; x=1715355129; h=content-transfer-encoding:in-reply-to:organization:autocrypt:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Yhw466AEmWvjLqOZi3ZE5Twj6p73jIRpFzx8HLUg9oM=; b=C6CsBjW3YAHF2lqiqTzQx5zPWAG8fJ+sZ3bgtSAJ6nLDSUbzrnjAbf4ATQzCxQyvTd q1i/oJP5baCdhVN+GgFNKdfxGtgWgOh+l+RxPoieNRjoZNbHhvu/3Cm+hkJ1oF1DiHG/ 8lSAGRdo2o3Lmm+Qw0VK1qiYOzBf0HY/BFgNQx+IYYw6Q6Z6t2DdGKYFcjPIO2H/1iOW /piBlr6rK38E6d1HAFEuMlJ8rqqtKGuO0hs0c7HcT3v03KIFsroz3rXdLaZPwG+p7DDt 8Td35R3OAXW6kDLlH1MUEHR6nKQRXaZgpKqEq+9SVPL1Gkye2P6h51o2efQ1Q24givji rZUw== X-Forwarded-Encrypted: i=1; AJvYcCWF1ChkvTGlD2MfeiicvNcxSpfbrdF2kZ6KmWFVV7p8GKTyUmpcPz67ncbx3gz6a/0WLolCGipxHG4lzgjPbBl9CiVrpwchuVg1 X-Gm-Message-State: AOJu0Yx2EETPTgVt/a05IXeyR+qbptBBDdM3zWmpzr0Zl4gOduzAkW7+ OgpxgDQpHjNkENhOOqSMFhJISOwI0A0Sq68O0IMTpzyvDZ2vt7bfUlxBivV4ZoJVZW7EPEOrRb7 FjIO5h/+0/y/O6oKYC9wRxFAjZ+U1wl5XrBO3/Th5UpfoK857biLWURQEOkK25VnsJA== X-Received: by 2002:a05:620a:5dce:b0:790:9625:d6d9 with SMTP id xy14-20020a05620a5dce00b007909625d6d9mr3135839qkn.35.1714750329520; Fri, 03 May 2024 08:32:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHnpeE+yl991OOQxTTgGFmG5UkS8yEEgVdyYbUF7ubSRcMvG+JfN4tvAsEfGDCqlTRAmbj/qQ== X-Received: by 2002:a05:620a:5dce:b0:790:9625:d6d9 with SMTP id xy14-20020a05620a5dce00b007909625d6d9mr3135805qkn.35.1714750329127; Fri, 03 May 2024 08:32:09 -0700 (PDT) Received: from [192.168.0.241] ([198.48.244.52]) by smtp.gmail.com with ESMTPSA id f2-20020ae9ea02000000b0078ec71866f7sm1309930qkg.58.2024.05.03.08.32.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 May 2024 08:32:08 -0700 (PDT) Message-ID: <6f5750e3-8ed4-47af-8e6a-857b7784d0d2@redhat.com> Date: Fri, 3 May 2024 11:32:07 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] resolv: add IPv6 support to inet_net_pton() To: Job Snijders , libc-alpha@sourceware.org References: From: Carlos O'Donell Autocrypt: addr=carlos@redhat.com; keydata= xsFNBFef5BoBEACvJ15QMMZh4stKHbz0rs78XsOdxuug37dum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GbNPD8+2k2mmC0OEtGBkj+VH39tRk+uLOcuXlGNSVk3xOyxni0 Nk9M0GvTvPKoah9gkvL/+AofN/31ABEBAAHCwXwEGAEIACYCGwwWIQRyc1QrOZYt97KZkxQW eStOolNA+AUCZK2RDAUJDwAD8gAKCRAWeStOolNA+B0MEACVxFO++NroEQxSQ0NCWod3aDmY mYn+/08wLTeMP+ajq19FEjU0Lh/GBJl6WlSHeJ5ZJlNSiXZuiSYGMYm73DBaoZlyjbD+H9NL LwLXgtfCZYlN6Iu8JRMfk9yevVBay7Be9DkPAk565ggo0UkIjpYftiLF4TUfqnI1yO6QKXgr J2DDwlP3iiCYnWFpHdBTB2/BRurpZoRquhRGzgcdGfRDtp16Pzm/u8BjfaU5/AFRjM0IDYQ6 PaQld0uZSZ0qOn0ts6usJws5gANq4U1oWJlqL/PHOFy9mbwUnKqq0oiWrmj+Mb+Ic6m9fqB3 5CHWUhxC1QozvkuY/sTsmXnG/mnbq2oFIVcgXDsnrDHf+0GyR+TrE4AQw1Pt2utsmU67LqNB Ru/2NbSFgwPv5wWjtNwDVGSZEXlV4qJGjh8S9aaGXhRTwJsnN6qkFS1m6vHKwqnRb5Qy4XDg 7kDrhFnTWe+XSwQt+HtGvIiXcR3EScJky76YlVsWDtvZMo3NePaC3qV5HAC8d2ZL3sFqxJRu sRyjE2l6s0EEK2MUgV/dwodftECrMdGktndVTYPqLnsua/PWWKYwYrNvD8slL6VFkXDZvLLv nat9vl9mBm15b76RHvKNlRcPbB9YYCbS5fhN2ObAsVbV1c5TdBCp8lp1Fa3YK0TA+WpNZVHK vjq6hMJAjA== Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 4/16/24 12:59, Job Snijders wrote: > Dear all, > > The below patch is a new revision to add IPv6 support to > inet_net_pton(). The patch is based on the OpenBSD implementation. > > Kind regards, > > Job > > Signed-off: Job Snijders In my context as a project steward, and because DJ asked me to look at this patch with regards to the license changes, I'm going to ask some clarifying questions to make sure we respect your wishes as the contributor of the patch. For the review I will note that: (a) You are using DCO... > --- > resolv/inet_net_pton.c | 69 +++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 65 insertions(+), 4 deletions(-) > > diff --git a/resolv/inet_net_pton.c b/resolv/inet_net_pton.c > index 63a47b7394..93753cb37f 100644 > --- a/resolv/inet_net_pton.c > +++ b/resolv/inet_net_pton.c > @@ -1,4 +1,6 @@ > /* > + * Copyright (c) 2024 Job Snijders > + * Copyright (c) 2012 by Gilles Chehade ... and (b) You add new copyright notices for specific individuals to the ISC license portion. Now the questions: (1) May you please confirm that you are contributing your own changes under the ISC License? - Gilles Chehade changes were already contributed under that license to OpenBSD. - The other acceptable license in this case, and it's up to you, would be LGPLv2.1+. The choice here is a balance between what glibc will accept e.g. compatible free license, and what you want to contribute under. If you are considering keeping this code in sync with OpenBSD, then it would be simpler to stay with the ISC License that we already have here. (2) Would you be amenable to using "Copyright The GNU Toolchain Authors." as your notice instead? - You are absolutely entitled to a copyright notice if you request it, but glibc project maintenance is simplified by a using a general notice. Please see: https://www.linuxfoundation.org/blog/blog/copyright-notices-in-open-source-software-projects - The notice from Gilles Chehade must be preserved because it comes from the copy of the OpenBSD implementation. Thank you for contributing to glibc! :-) I know Florian had some further down-thread suggestions, but the license and copyright issues still apply. > * Copyright (c) 1996,1999 by Internet Software Consortium. > * > * Permission to use, copy, modify, and distribute this software for any > @@ -19,6 +21,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -35,13 +38,16 @@ > > static int inet_net_pton_ipv4 (const char *src, u_char *dst, > size_t size) __THROW; > +static int inet_net_pton_ipv6 (const char *src, u_char *dst, > + size_t size) __THROW; > > /* > - * static int > + * int > * inet_net_pton(af, src, dst, size) > - * convert network number from presentation to network format. > - * accepts hex octets, hex strings, decimal octets, and /CIDR. > - * "size" is in bytes and describes "dst". > + * Convert network number from presentation format to network format. > + * If "af" is set to AF_INET, accept various formats like hex octets, > + * hex strings, or decimal octets. If "af" is set to AF_INET6, accept > + * IPv6 addresses. "size" is in bytes and describes "dst". > * return: > * number of bits, either imputed classfully or specified with /CIDR, > * or -1 if some failure occurred (check errno). ENOENT means it was > @@ -55,6 +61,8 @@ inet_net_pton (int af, const char *src, void *dst, size_t size) > switch (af) { > case AF_INET: > return (inet_net_pton_ipv4(src, dst, size)); > + case AF_INET6: > + return (inet_net_pton_ipv6(src, dst, size)); > default: > __set_errno (EAFNOSUPPORT); > return (-1); > @@ -196,3 +204,56 @@ inet_net_pton_ipv4 (const char *src, u_char *dst, size_t size) > __set_errno (EMSGSIZE); > return (-1); > } > + > + > +/* > + * Convert an IPv6 prefix from presentation format to network format. > + * Return the number of bits specified, or -1 as error (check errno). > + */ > +static int > +inet_net_pton_ipv6 (const char *src, u_char *dst, size_t size) > +{ > + struct in6_addr in6; > + int bits; > + long lbits; > + size_t bytes; > + char *ep, *sep; > + > + sep = strchr(src, '/'); > + > + if (__inet_pton_length(AF_INET6, src, sep ? sep - src : strlen(src), > + &in6) != 1) { > + __set_errno (ENOENT); > + return (-1); > + } > + > + if (sep == NULL) { > + bits = 128; > + goto out; > + } > + > + if (sep[0] == '\0' || !isascii(sep[0]) || !isdigit(sep[0])) { > + __set_errno (ENOENT); > + return (-1); > + } > + > + lbits = strtol(sep, &ep, 10); > + if (ep == sep || *ep != '\0') { > + __set_errno (ENOENT); > + return (-1); > + } > + if (lbits < 0 || lbits > 128) { > + __set_errno (EMSGSIZE); > + return (-1); > + } > + bits = lbits; > + > + out: > + bytes = (bits + 7) / 8; > + if (bytes > size) { > + __set_errno (EMSGSIZE); > + return (-1); > + } > + memcpy(dst, &in6.s6_addr, bytes); > + return (bits); > +} > -- Cheers, Carlos.