From owner-freebsd-hackers@freebsd.org Fri Jul 31 18:20:18 2015 Return-Path: Delivered-To: freebsd-hackers@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 29AF89B0B1A for ; Fri, 31 Jul 2015 18:20:18 +0000 (UTC) (envelope-from patrick.mooney@joyent.com) Received: from mail-ob0-f179.google.com (mail-ob0-f179.google.com [209.85.214.179]) (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 F2B5610CD for ; Fri, 31 Jul 2015 18:20:17 +0000 (UTC) (envelope-from patrick.mooney@joyent.com) Received: by obdeg2 with SMTP id eg2so59767276obd.0 for ; Fri, 31 Jul 2015 11:20:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :content-type; bh=wDU+jMtRlaAYN16NdOIgpJ90txj+tGwBToKbDf5JLEM=; b=UJ7YEWgsMTZZABD1TR3BN+aB4TYguAB3TsczziZm15Scn25v4E51v16a6ICc+HgWwY NNv+8WF18/vfjPoFjs8LlzqstQv7hCezy6gOBa1P13/4wldgUHRCFCCLnvNi5kBGPSA5 4490w61g5tiEiV+tLPsfX3TuKeNlITTyNVxgXYfA4yZ68mAPSDi6fUgighBq3fHO+OKM CnrRfeHRvnFvIn5JGs5vNps0NUgPdyxGBS4tyn/1GNRQzUwHCivGp4BUDPw/luoejnXg gz2BpirWrX+K9Gz/ZwjyJpwCaXiHMl/MbCWUiTNc7Ut/s+l4nM26BuZtqAWvPH0RdRuV 1QTg== X-Gm-Message-State: ALoCoQm93Yor7syWPlSlmUX49Dm5v5PodmqLWyDWIRVnqK5/CEU7euZtiPAPvSbD0avxRa/1ml/f MIME-Version: 1.0 X-Received: by 10.60.78.104 with SMTP id a8mr4670090oex.58.1438366811033; Fri, 31 Jul 2015 11:20:11 -0700 (PDT) Received: by 10.202.206.17 with HTTP; Fri, 31 Jul 2015 11:20:10 -0700 (PDT) Date: Fri, 31 Jul 2015 13:20:10 -0500 Message-ID: Subject: Interpretation of POSIX.1-2008 for recvmsg From: Patrick Mooney To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Jul 2015 18:20:18 -0000 Greetings, I have been researching differences in recvmsg() behavior across platforms (namely Illumos and Linux) with respect to MSG_PEEK and 0-length buffers. Certain Linux software I am attempting to run under Illumos makes a recvmsg() call with a 0-length iovec and flags set to MSG_PEEK in order to interrogate the size of a queued dgram. On native Linux, recvmsg() returns the size of the queued dgram (with the MSG_TRUNC flag set). On both Illumos and FreeBSD, a size of 0 is returned (with MSG_TRUNC set as well). In reading the POSIX spec (http://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html), it is not clear that returning 0 in this case is correct behavior. Here is a small test program I wrote up to display the differences in behavior: https://us-east.manta.joyent.com/patrick.mooney/public/recvmsg/peektest.c The output on Linux: peek len: 20 errno: 0 flags: 20 recv len: 20 errno: 0 flags: 0 ... versus BSD and Illumos: peek len: 0 errno: 2 flags: 12 recv len: 20 errno: 2 flags: 0 I am interested in your opinions on the matter. With regards, --Patrick