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 9ABC8385840B for ; Tue, 9 Apr 2024 12:31:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9ABC8385840B 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 9ABC8385840B 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=1712665911; cv=none; b=FfsvHhFhYsjSXxx9qOPfAayJquN8dg7i+EPyEsE93w/yiS7hjTEKb+JBBBqp7YQ5YbKmD/H0CdIG8XLy/YtBorvTBS30QnNO1e4g5Pkvi1B9xuArXRsS4DqfdVnN+URPUeqPlQ6yT5zmWTh8mrkERntkaPZRPWjOI3Q8NZna5dc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712665911; c=relaxed/simple; bh=Hn2MStLuTdYmGidd+ayXJPZEXZkdyZsv7yzZiyoLOhI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=wkHsg/CyJKGNyZpU/KNicAPFaYOVsc4WGr5GT48ovjGYWCTuofuTZoFvXMPEO+jqDshQdzZ5QNA8nCUayo2dxnvaoFQ+GDdMDbd11ciYTSh9T8wVQIMCmRJ8ZaOwvxA3NviRkvha4MD2qW0eCaxcbULsI3RslPUY3uvEWZ1ReMs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712665909; 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: in-reply-to:in-reply-to:references:references; bh=pFsMFdN1PqgV6jWfKv5q337cPBhkFaRqgKtALjIQQsg=; b=hnIOwCt5ieZJtY2H9RNDeCgsUm3g+Be+ZyJ6YcjkLtxf+1gIVJn5eXQQ8R/CPjUvvH+RtR jCSg45sA6nftwOqbsM52nB31msG83+RtIpSOJEMuoDJGhlYpTaKDeaYtEa3UsMsGdHMYy5 Jx5rdczZUEahmaKg1av1we8L/zsbs4k= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-MXM0uPWjMEmYP8VbXXRsLQ-1; Tue, 09 Apr 2024 08:31:47 -0400 X-MC-Unique: MXM0uPWjMEmYP8VbXXRsLQ-1 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-6ea2b0865bbso260015a34.3 for ; Tue, 09 Apr 2024 05:31:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712665907; x=1713270707; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pFsMFdN1PqgV6jWfKv5q337cPBhkFaRqgKtALjIQQsg=; b=AiqIV59eNtseOHeRJOjRciKMjMG+ZZD4zqHI/YQ9x5FfdUO92FW4axt+YI9gFHR+W0 a94rk5IUDAXHkYVn4pbU6XSZBmTebzKTW1kB4VdoD/rPGqEcgrPH2RQvuEC3Tq66iHh2 3lIyrTP1HsjlJ1Qp3lzw4BOwZALx+a5QZo6uIbviGkJKso1E2pN3aqzVDa/BQX48zz2B GCv5iPsr+2T80QO7gX2LTgIuz/aUxfCXRm9RrKSxnkGxf4T3UclV2EVQNAsCjq/Ul7K6 6gE2QeWlFe6+dUdiCnUNTUuybKV02isPbbYx5iGUZpyXbJlScKBYvEdN7BbGbzdrbKKU XeVg== X-Gm-Message-State: AOJu0YwkEPmYygoi/DX5xrDgrvyyoh7Cu7gIcPTG5HmerX2MVbKIfPk8 IwLHujLTLItiPjTsZ8W2u0C49B7vETMIF6Hl7bgTygVMXSIrcTZ406trEAFT+V1wH5PSBpL3AY5 I5WKe1p5vIuFOwGiywW8cOjstLsSxxkzapX5nszCdubu8EqKRxsmxna//FYn7CYfGAPfEAOlDP7 dFaxdrSU78cDUGlpMUcdmsrLh09e1YJxVp X-Received: by 2002:a05:6870:170e:b0:21e:a957:efef with SMTP id h14-20020a056870170e00b0021ea957efefmr12469364oae.19.1712665906988; Tue, 09 Apr 2024 05:31:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0pDF8U5zjw6KE7Xxl3fN+NNYrEzubMckwaLxrcdZuuXg71su7x/rCQvW8DdVbCwWVr2ydL8q6PpFjwCaWH9I= X-Received: by 2002:a05:6870:170e:b0:21e:a957:efef with SMTP id h14-20020a056870170e00b0021ea957efefmr12469349oae.19.1712665906743; Tue, 09 Apr 2024 05:31:46 -0700 (PDT) MIME-Version: 1.0 References: <20240408102543.18143-1-skolosov@redhat.com> In-Reply-To: <20240408102543.18143-1-skolosov@redhat.com> From: Arjun Shankar Date: Tue, 9 Apr 2024 14:31:35 +0200 Message-ID: Subject: Re: [PATCH 1/2] libsupport: Add xgetpeername To: Sergey Kolosov Cc: libc-alpha@sourceware.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,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: Hi Sergey, > The patch adds redirections for getpeername. This looks good to me. Reviewed-by: Arjun Shankar > diff --git a/support/Makefile b/support/Makefile > index 362a51f882..aa57207bdc 100644 > --- a/support/Makefile > +++ b/support/Makefile > @@ -131,6 +131,7 @@ libsupport-routines = \ > xfreopen \ > xftruncate \ > xgetline \ > + xgetpeername \ > xgetsockname \ > xlisten \ > xlseek \ OK. New routine. > diff --git a/support/xgetpeername.c b/support/xgetpeername.c > new file mode 100644 > index 0000000000..6f448e456a > --- /dev/null > +++ b/support/xgetpeername.c > @@ -0,0 +1,30 @@ > +/* getpeername with error checking. > + Copyright (C) 2024 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 > +#include > + > +void > +xgetpeername (int fd, struct sockaddr *sa, socklen_t *plen) > +{ > + if (getpeername (fd, sa, plen) != 0) > + FAIL_EXIT1 ("getpeername (%d): %m", fd); > +} OK. I compared this with xgetsockname and it's in line with that. > diff --git a/support/xsocket.h b/support/xsocket.h > index 3e44103546..4ac0e1f5ff 100644 > --- a/support/xsocket.h > +++ b/support/xsocket.h > @@ -26,6 +26,7 @@ > int xsocket (int, int, int); > void xsetsockopt (int, int, int, const void *, socklen_t); > void xgetsockname (int, struct sockaddr *, socklen_t *); > +void xgetpeername (int, struct sockaddr *, socklen_t *); > void xconnect (int, const struct sockaddr *, socklen_t); > void xbind (int, const struct sockaddr *, socklen_t); > void xlisten (int, int); OK.