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 0E23E385E836 for ; Fri, 3 May 2024 08:07:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E23E385E836 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 0E23E385E836 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=1714723627; cv=none; b=uMT2WnZSz0qTnE5WAkZ/DYLRDwsFCYKLW0ypc1OYovEaI5M23g14rOQn/ruYltIVIAwbRIYoQ1MeACyGjjEODZPyrRcpV+qprY5HMsuNY5iW7SFArK8Z4a+b6eXdxHJMYRgliKQuyMdzqyAppo2U6BAHtPcHWprJ1Tgp3RqfNvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714723627; c=relaxed/simple; bh=7nf6xUDj/jdIvDyQlryoOXrdkOrKAPsyXeOKdETZ4aU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kMX0vgWC/qovflP4gBACFh7tcgWxOp5gJPWCf66FuJbUjrZ9LCwb33YTJu/FR1VZloNiKbE2MB8ce8IEgI1zP0yr+hIu14xGBBaBRp8Vx5xjG85Myekv4p6UuH1Yo0Ek3EIk0zFrGkDdBGdbLNqoV31obf+3KDm56n6rWK/CATk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714723625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DBqoHwzWfVvMG2PGIgm42yeMTWHZGdwApC87zZ5pfGY=; b=GmOBvUsv3nhLY78hbfbs4u3iDazaTIcaOIdUlUntasViI1xz3lUHzDmjAZwAuikaqSr+7M Tu4ne/WqFr/RbZuG2SGAAvRqv5ZCzvTSPLNatR/vLxXXa75/MZ5PnxiXLswZKWvhNkjUtt FsJF9FSkULN7IW8kCXNX8bfcRZ7NKoY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-9ihFFdx6OeyL0wAr6_VPQA-1; Fri, 03 May 2024 04:07:04 -0400 X-MC-Unique: 9ihFFdx6OeyL0wAr6_VPQA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2A23B3C025B7; Fri, 3 May 2024 08:07:04 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 511D81121312; Fri, 3 May 2024 08:07:03 +0000 (UTC) From: Florian Weimer To: Job Snijders Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2] resolv: add IPv6 support to inet_net_pton() In-Reply-To: (Job Snijders's message of "Tue, 16 Apr 2024 18:59:56 +0200") References: Date: Fri, 03 May 2024 10:07:01 +0200 Message-ID: <87jzkbgvyy.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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: * Job Snijders: > 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 > --- > resolv/inet_net_pton.c | 69 +++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 65 insertions(+), 4 deletions(-) I took a step back and looked at the IPv4 implementation. It does the weired flexible parsing that inet_aton does, and it tries to infer the network class if no prefix is given. (Classes are obsolete since CIDR was introduced in the early 90s.) Contrast this with inet_pton (the non-network variant), which does not handle the obsolete inet_aton number formats. Your inet_net_pton implementation for IPv6 is necessarily inconsistent, too, because it cannot infer classes (they do not exist for IPv6), so a bare address is treated as a /128 network. Your implementation is also inconsistent with the OpenBSD implementation, which is documented with this note: | when the number of bits is specified using =E2=80=9C/bits=E2=80=9D notati= on, the value | of the address still includes all bits supplied in the external | representation, even those bits which are the host part of an Internet | address. I think the interface would be more useful if it behaved consistently across IPv4 and IPv6. So =E2=80=9C192.192.0.1=E2=80=9D should be a 32-bit = prefix, and =E2=80=9C192.192.0.1/24=E2=80=9D should write the full 8 bytes to the desti= nation. (All excess bytes not written should probably be zeroed.) The inet_net_ntop function would have to be adjusted accordingly. We can preserve backwards compatibility for existing applications if we introduce a new symbol version. We need to do this anyway eventually because we want to move the symbol from libresolv to libc. Do you want to work on this? I think the documentation will be the largest part of a patch. Thanks, Florian