From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH] ip: set the close-on-exec flag for descriptors Date: Mon, 08 Jul 2013 09:05:06 -0700 Message-ID: <1373299506.4979.112.camel@edumazet-glaptop> References: <1370332874-584-1-git-send-email-avagin@openvz.org> <20130604091150.48f3b1ca@nehalam.linuxnetplumber.net> <1373293036.4979.105.camel@edumazet-glaptop> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: Stephen Hemminger , netdev@vger.kernel.org To: Andrey Wagin Return-path: Received: from mail-pa0-f51.google.com ([209.85.220.51]:62483 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751534Ab3GHQFJ (ORCPT ); Mon, 8 Jul 2013 12:05:09 -0400 Received: by mail-pa0-f51.google.com with SMTP id lf11so4498194pab.38 for ; Mon, 08 Jul 2013 09:05:09 -0700 (PDT) In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On Mon, 2013-07-08 at 19:51 +0400, Andrey Wagin wrote: > Hi Eric, > > 2013/7/8 Eric Dumazet : > >> Applied > > > > It seems it could break ip command for old kernels, as SOCK_CLOEXEC is > > supported from 2.6.27 > > > > Not sure if its worth a patch, to do the normal socket() call followed > > by legacy fcntl() one. > > fcntl is not safe for multithread applications. If libnetlink isn't > going to be used for them, I don't have objection. The patch is > attached. > If you want multithread safety, you could attempt the SOCK_CLOEXEC, and fall back in case of error to legacy socket()/fcntl()