From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by sourceware.org (Postfix) with ESMTPS id 247673858C3A for ; Mon, 27 Sep 2021 16:33:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 247673858C3A Received: by mail-qt1-x832.google.com with SMTP id m26so5672256qtn.1 for ; Mon, 27 Sep 2021 09:33:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MvTzZ6gSksApWojf3h5GcFeKOStMWWrPIg0zuADuW5w=; b=TZPnpOnJ2NE7LJTLgZ+BvgCahdz5FgfCOzuZEsjOCdx7DIy7hjITLDRlRR/6tNi6wH LmuoQqGUy9LiAW9qnUlueQXiA3cuo76bH9yaflrstG6Ct7xAl8TDN0EDgUwjaEzSriUG egn/jGXdJfqGVcYovCzndvjfPmurLHX1AHrsIba77gi5ix0Yq9cgUxlkM4eITsUDUVhD yViT07PxvlN3/hu2MZYTPygRlhOjXYC8oXU8KSvQ+iEYO9PoFcLFXUwSjBJjxRdQLA6J IiMdqDJLcYm0RDljnZ/mE351sNE0A2NhjIJO1trKJFAl8AQUBbOK+mIbCfekN1kNsDY4 pkpQ== X-Gm-Message-State: AOAM530Ueis8s8udJz9wD3M+m4WegtyRHrUv3trtFF+3qbrS2PZgR+M8 CKwhMnlgl3QwjyBfyqq4O2nWwli2tHTjaw== X-Google-Smtp-Source: ABdhPJy5PmEXqC2UGKcqWUPlsHvKgIzGBU2x1sGjxJ0hpqHzOz3QmQnAO4wbzSF9eC85kw+72cpTmw== X-Received: by 2002:ac8:143:: with SMTP id f3mr810802qtg.238.1632760421571; Mon, 27 Sep 2021 09:33:41 -0700 (PDT) Received: from ?IPv6:2804:431:c7cb:b338:9c1f:21e4:d45:b086? ([2804:431:c7cb:b338:9c1f:21e4:d45:b086]) by smtp.gmail.com with ESMTPSA id r139sm12795450qke.84.2021.09.27.09.33.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Sep 2021 09:33:41 -0700 (PDT) Subject: Re: [PATCH] Linux: Simplify __opensock and fix race condition [BZ #28353] To: Florian Weimer Cc: libc-alpha@sourceware.org References: <875yumghzs.fsf@oldenburg.str.redhat.com> <48158338-3d06-72aa-5e1b-0cb34e7325cc@linaro.org> <87wnn2f18n.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Message-ID: Date: Mon, 27 Sep 2021 13:33:39 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <87wnn2f18n.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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-List-Received-Date: Mon, 27 Sep 2021 16:33:43 -0000 On 27/09/2021 13:10, Florian Weimer wrote: > * Adhemerval Zanella: > >> Wouldn't be better to move it as the generic implementation (and also cleanup >> it by removing unsualy families like IPX, AX25, and APPLETALK)? > > I don't know what Hurd needs, sorry. The difference with your proposal seems to be that AF_INET is used as default instead of AF_NETLINK and AF_UNIX is not used. Also Hurd does not define AF_IPX, AF_AX25, nor AF_APPLETALK so we can safely remove them. What about: int __opensock (void) { int type = SOCK_DGRAM | SOCK_CLOEXEC; int fd; #ifdef AF_NETLINK /* SOCK_DGRAM is supported by all address families. (Netlink does not support SOCK_STREAM.) */ fd = __socket (AF_NETLINK, type, 0); if (fd >= 0) return fd; #endif fd = __socket (AF_UNIX, type, 0); if (fd >= 0) return fd; fd = __socket (AF_INET, type, 0); if (fd >= 0) return fd; fd = __socket (AF_INET6, type, 0); if (fd >= 0) return fd; __set_errno (ENOENT); return fd; } I assume moving from AF_INET to AF_UNIX should be safe for Hurd [1]. (And it also fixes the missing SOCK_CLOEXEC) [1] https://www.gnu.org/software/hurd/hurd/networking.html