From owner-svn-src-head@freebsd.org Mon Apr 10 19:40:37 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE598D37597 for ; Mon, 10 Apr 2017 19:40:37 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-io0-x231.google.com (mail-io0-x231.google.com [IPv6:2607:f8b0:4001:c06::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6BBF91DA for ; Mon, 10 Apr 2017 19:40:37 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-io0-x231.google.com with SMTP id r16so53529731ioi.2 for ; Mon, 10 Apr 2017 12:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sippysoft-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=YwLfaDvJ3jOj0sxFtz/I4C+OqWxRBYOhuoYPierNsYI=; b=AqaX/fO/hcZhWtSt6X2l+VrQ2JGChACMpwo6orE7ZlLhupRpf+ZBSnQmnpBJOE0zvG mFnnyou8Phj2Z1elB8rTop04Y8KSRulyiRXSJref/7hByh95QOjy5AZS1tT2xcs55fMO 3bluvHtZczhnw7N28a/cfcnBMXmVCBlzKNEOPeVNQYkgLnz+XZxLFcb6BF0nNWG3wNpP OhuN5BjG5MMh9+3ON+zItGc9Dy39xRTGL49U8qCy4SZy6b0A70zyT0gVFFWyvrKuMVUb k7w0gXk+NL0v92tbHWk98xd9vkKhkRDpWzJciG6x5ADeIAu1iude++cTDkmjr83mm9We GUmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=YwLfaDvJ3jOj0sxFtz/I4C+OqWxRBYOhuoYPierNsYI=; b=gIv3oMGXFnosX0Z43gENDbK1IjU20pXhLTtuc1fbz1Lhd+PaTcVsjlEGUL6YUXWIUz NRCH6173+J8xm7MSDJ2rD2fsiCrTgQ5gP0gihLOYhzf1DnFLQSSIPRXImj5DQGTRotyc oZOKNHFbEKQdMl58CllwIpGkQj5TKg95R5U4hwwGSbLVzCZZU9+nHQZ+BPvwiAzsVyB2 gKilCZf9bwfUImuE25XoLvKZyuHcr9O93gLSqtKrlMfh2RoIIG4qOKOngZ000hCHFbyC lgvDQIBtYv82vnE7iyAOXOUH0uFlgJ+9J809Gx0mNKs7EPRoNAcY92KghDCg4XNImNV6 UILQ== X-Gm-Message-State: AN3rC/7xGafX3OFbEgstu6TleREADeXzW2w3fSukDBrTfKCz/bFcC6hUxqzmD+k4ttFZSAZhbh74KkxRHYvAxipG X-Received: by 10.36.170.68 with SMTP id y4mr13297852iti.7.1491853234973; Mon, 10 Apr 2017 12:40:34 -0700 (PDT) MIME-Version: 1.0 Sender: sobomax@sippysoft.com Received: by 10.36.112.210 with HTTP; Mon, 10 Apr 2017 12:40:34 -0700 (PDT) In-Reply-To: References: From: Maxim Sobolev Date: Mon, 10 Apr 2017 12:40:34 -0700 X-Google-Sender-Auth: QeyKm__Oqj-uId0iQMz0NyIxWCw Message-ID: Subject: Re: On shutting down UDP socket [Re: svn commit: r285910 - in head: lib/libc/sys sys/kern sys/sys] To: Ed Schouten Cc: Alexander Kabaev , Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org, mjg@freebsd.org, gnn@freebsd.org, FreeBSD Net Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Apr 2017 19:40:37 -0000 JFYI. I've opened a follow-up differential for this potential regression: https://reviews.freebsd.org/D10351 Thanks! -Max On Mon, Apr 10, 2017 at 7:43 AM, Maxim Sobolev wrote: > Hi Guys, I am sorry to bring this old thread up, but I think Ed's > comparison with other OSes here and in the relevant differential was not > entirely correct. What linux does (tested with 4.4.0) when UDP socket is > shut down is actually shutting down receiving end, so any threads that are > blocked in recv() on that socket return. Still shutdown() system call > itself returns ENOTCONN. FreeBSD on the other hand does not do anything for > the socket, so that the threads just hang. I am pretty sure there are at > least some software out there that relies on that behavior, at least in our > case we do. Bumped into this after upgrading to the 11.0. > > Therefore, I am curious about possibility to make our behavior match that > of Linux's, so we are not the odd one with regards to this, that is return > an error but still shutdown the socket? > > Small test case is attached. Both FreeBSD 10.3 and Linux 4.4.0 pass > (albeit Linux's shutdown() returns with an error), FreeBSD 11.0 fails. > > -Max > > On Sun, Aug 9, 2015 at 6:08 AM, Ed Schouten wrote: > >> Hi Alexander, >> >> 2015-08-09 14:55 GMT+02:00 Alexander Kabaev : >> > On Sun, 9 Aug 2015 09:37:13 +0200 >> > It most definitely does work, this is what I have done to get my >> > network scripts work again. I wonder if there are other means of >> > restricting raw sockets that can be used to achieve the result >> > authors of rtsold had hoped or? >> >> Yes, there sure are. We could for example call cap_rights_limit() on >> the socket and whitelist the exacty set of actions that the program >> needs. >> >> That said, it wouldn't make a difference in the end. It looks like >> rtsol/rtsold don't seem to drop any privileges or switch credentials >> after startup, assuming I haven't overlooked anything. Even if we were >> to restrict the raw socket, the process could always open a new one >> later on. >> >> I think it would make sense for now to just commit the patch that I >> proposed. Will push it into the tree tomorrow. >> >> Thanks, >> -- >> Ed Schouten >> Nuxi, 's-Hertogenbosch, the Netherlands >> KvK/VAT number: 62051717 >> >> >