From nobody Fri Sep 10 19:20:42 2021 X-Original-To: hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 81E3617A41AE; Fri, 10 Sep 2021 19:20:46 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4H5m1V2cz5z3HgS; Fri, 10 Sep 2021 19:20:46 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qv1-xf34.google.com with SMTP id z12so1971716qvx.5; Fri, 10 Sep 2021 12:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=kkAhsRL4lhviXZIdCNoN365Ee+BbmlPi3nCQuMQ6kJU=; b=k3Y/UehdDeyehjjOTsIIOP/8jSGvqxse5rVfAB92/k0ne3PFOHpLD89fAldVmTj6XK Y/YrSFr0+hMLVixGVbtnU2ad6MVwieFsscR1mH8aQ715KprTPMRvSmCAWUNuLQjfaArk bSozn78qswTyJ8YXK7ZL/+Ib44PwHNpPR1Hns97bXA2qUVQm4P/q7KxO665mAhdJniKJ hiYadRWkaepSADys/lNqjpV6cI9tkGGXIpON5pc2dyzIUvKfrakkYcHfp5mEZ1Sg+sOh jqqcfaDdWQRjJNSPmI/VnI6mRYk9QMEbWp1aoAKu37gJgen+qSdVrDOlHNuMJNE21iBr MvTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=kkAhsRL4lhviXZIdCNoN365Ee+BbmlPi3nCQuMQ6kJU=; b=JwrcqS1rqatjQOCyxFPx5PB9FkV8pFN6G/i6CdIe4KuaauRp8vchnJoW04U7fPwpNW WSA/37U4NuA+JPOs+5ULrm7qJxXLA67Sk/qB4nHv7lzdzOor4i6mnHzdLprW738xNq1X 4t6tWrkiDlHXZSLQhK/MOCAuqi/TjaI2W7lYO29xow1Tf6J8DsR/VzjkkIt1zSTRksHI rZ2MaGdwd+eIperFOLvXf5aKLA1ZfD8GAhtsJTsnYu5bDSwDTsftT48W6iEIsr1TCIBz YEldEwMsLFFh2S7TEZNqMZP++i2UiKInQimXn806HF/jw02PwEMeuC6eC1SUblo0TyDY Q/jQ== X-Gm-Message-State: AOAM532yC5jsAuxglMiEUQuP7h8uXNsZeq33Q9GWmJawsO4+8R+wfY8I BTew4kiIRIU+6ID+oAEsRDUVvjjj4Z6kVA== X-Google-Smtp-Source: ABdhPJxjwSWZJZjeuXxFkzcYOHKRkEA01QzZojH+eszkCz38igBLnrp4npVNZJ7NVNbOL5CDVDtCpg== X-Received: by 2002:a0c:9a8a:: with SMTP id y10mr10077529qvd.15.1631301640171; Fri, 10 Sep 2021 12:20:40 -0700 (PDT) Received: from nuc ([142.126.175.196]) by smtp.gmail.com with ESMTPSA id g7sm3693998qtj.28.2021.09.10.12.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 12:20:39 -0700 (PDT) Date: Fri, 10 Sep 2021 15:20:42 -0400 From: Mark Johnston To: Andriy Gapon Cc: "net@FreeBSD.org" , hackers@freebsd.org Subject: Re: recvmsg() "short receive" after FIONREAD Message-ID: References: <500a2272-c1b3-3f97-0096-9fe8117c4b95@FreeBSD.org> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <500a2272-c1b3-3f97-0096-9fe8117c4b95@FreeBSD.org> X-Rspamd-Queue-Id: 4H5m1V2cz5z3HgS X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Fri, Sep 10, 2021 at 09:51:38PM +0300, Andriy Gapon wrote: > > > I observe a problem with the code that can be seen here: > https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/modules/rtp/sap.c#L142 > > The code uses ioctl(FIONREAD) to check the size of available data in a socket. > Does / should this work? Yes, FIONREAD returns the number of available bytes in the socket receive buffer. > Then the code calls recvmsg() on the socket with single vector with iov_len > equal to the size obtained earlier. > > But the return value from recvmsg() is smaller than the iov_len value. > In my test I see 215 vs expected 263 (so, the difference is 48). What type of socket is it? Is it possible that there are control messages in the receive buffer? They would be dropped here since the code does not specify a buffer for them, but they are counted in the return value of FIONREAD. > Does this ring a bell to anyone? > I see this on a month old 14.0-CURRENT arm64. It doesn't sound familiar to me at least.