From owner-freebsd-net@freebsd.org Mon Apr 10 19:40:35 2017 Return-Path: Delivered-To: freebsd-net@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 E5250D3758F for ; Mon, 10 Apr 2017 19:40:35 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-io0-x22a.google.com (mail-io0-x22a.google.com [IPv6:2607:f8b0:4001:c06::22a]) (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 B30CC1C1 for ; Mon, 10 Apr 2017 19:40:35 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-io0-x22a.google.com with SMTP id t68so78114064iof.0 for ; Mon, 10 Apr 2017 12:40:35 -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=cEHYL1E+c2MfcEQUj4L/LLNQ5B14NQUBZpbeBT4PS/o+E9VUJrjKKeKX3yEa7fs39z 3GJCBguAMzOocf3JO6nin4E+KP0yfVvcgcz/ZulASj3RNYjPksYxbwAZOCsoHubIKx3O IVPEHw/otPfTdVkGRWs0cxFzfuRhSyoJO92DY88GVSfV8vlPj9HDxw0cmVvC2emznmyh 7i5oQY2pbCz4MaRXbDUVJA9sPwamDTka6F8qwVW644BP8LBhUQgWqK6hUNIyhwhihLIK ewqR0NT06HoX7vGF4t/iBtvQYXE1Ts4uoTfJHHZD+xwfyBdb84tYauNL6cYCE5i+2TQU 7jww== X-Gm-Message-State: AN3rC/53YDrV12RWRnOTKGz1YSU5O/JgNWuNLs3IUckefaWLbozpZL3vOQ/2cZv6Fz6R8+eTw+RdHnc+iQHOTaRn 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: freebsd-net@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Apr 2017 19:40:36 -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 >> >> >