From owner-freebsd-current@FreeBSD.ORG Sun Aug 24 21:42:09 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BB476CBF for ; Sun, 24 Aug 2014 21:42:09 +0000 (UTC) Received: from mail-ig0-x234.google.com (mail-ig0-x234.google.com [IPv6:2607:f8b0:4001:c05::234]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 873153804 for ; Sun, 24 Aug 2014 21:42:09 +0000 (UTC) Received: by mail-ig0-f180.google.com with SMTP id l13so1944412iga.1 for ; Sun, 24 Aug 2014 14:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=D665sF6+VGwA+Z/7pZKm7TNtX2kvqUGTZtXuum2GDJs=; b=q6LkIPxUuMTKOkDqpg31aFrWotNtMMFi6n2xdwio/1iCGOMudDfZr/WwqQhmx09M/R 7RR+tH7ImXDkrcXCHOZJyBT2DXQLi6GoX6tKz5V0FiKrCC/AI0DzFZLip0ACvltXWJ4X 34J5DzLniUUe6fKV3YS6LICLzYgcyHwaJy6Xj+Ohs5/qQQX6O+3GNQ8KN/3AIEGodmae Fg+3YJKxJHo4Lp08PoNbzN3yY0t5fNC8qlH2PY7a/883yyT0O1EYYe1vuVqUG+bx6kHk mX1n1sKDq6JcPn6uLBiA+azaaJ4PHIh/3+r+kybtLa8I5eCK6sRqBOtw5ETMWxD+nVCo 0obA== X-Received: by 10.50.55.68 with SMTP id q4mr11565628igp.44.1408916528819; Sun, 24 Aug 2014 14:42:08 -0700 (PDT) MIME-Version: 1.0 Sender: fedor.indutny@gmail.com Received: by 10.107.148.66 with HTTP; Sun, 24 Aug 2014 14:41:48 -0700 (PDT) In-Reply-To: References: From: Fedor Indutny Date: Mon, 25 Aug 2014 01:41:48 +0400 X-Google-Sender-Auth: 4nH1z46SVZTPaSTEuJJd3ATa9wA Message-ID: Subject: Re: KQueue 0-length UDP packet To: freebsd-current@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Aug 2014 21:42:09 -0000 Hello again! I just realized that the wording was probably a bit off. What I wanted to ask is: why does FreeBSD kqueue implementation treat `SO_RCVLOWAT` as a raw packet size watermark, and not using the actual data size for filtering out events? I am totally fine with the fact that it triggers event on 0-size udp packets, but the behavior itself seems a bit odd, right? Please let me know if this is a bug, and I'll submit a patch. Cheers, Fedor. On Sat, Aug 2, 2014 at 2:57 PM, Fedor Indutny wrote: > After reading that line more carefully, I wonder if this behavior is > really intentional here. > > It seems to me that `SO_RCVLOWAT` is supposed to set watermark value in > terms of > packet data bytes, not just raw packet size. And this is how `NOTE_LOWAT` > actually > works there, right? > > Could anyone please comment on this? Is it a bug? > > ---------------------- > > Regarding OSX: > > Submitted Apple Bug # 17894467 , with a patch. > > If anyone has friends at Apple who could help getting this in, please let > me know! > > Cheers, > Fedor. > > > On Sat, Aug 2, 2014 at 2:41 PM, Fedor Indutny wrote: > >> Guess I know the answer: >> >> https://cloudup.com/cCkjLhI4M2r >> >> Basically, OSX is checking `kn_data` and FreeBSD is using >> `so->so_rcv.sb_cc`. >> >> Thank you anyway! >> >> >> On Sat, Aug 2, 2014 at 1:39 PM, Fedor Indutny wrote: >> >>> Hello! >>> >>> I'm trying to figure out, why this code: >>> >>> https://github.com/indutny/0-udp >>> >>> Which basically sends a 0-length UDP packet to a server and polls >>> kqueue events on the server fd. >>> >>> Return 1 kevent on FreeBSD, and blocks indefinitely without >>> returning any events on OSX. >>> >>> So far I could see that FreeBSD and OSX are treating NOTE_LOWAT >>> differently: >>> >>> * >>> https://github.com/opensource-apple/xnu/blob/2fa84067f6cdeb23267f877ca4fd26201316da1b/bsd/kern/uipc_socket.c#L4461 >>> * >>> https://github.com/freebsd/freebsd/blob/6901832d8588537c81afbdb91d1a22deb5582c47/sys/kern/uipc_socket.c#L3163-L3164 >>> >>> FreeBSD's NOTE_LOWAT is overriding SO_RCVLOWAT, and OSX is using >>> SO_RVCLOWAT as a minimum value. But, since NOTE_LOWAT is not >>> involved here by default, I'm failing to see where exactly this >>> event could pass through kqueue filter. >>> >>> Could anyone with UDP and/or KQueue implementation knowledge >>> share some insights with me? >>> >>> Thank you very much! >>> Fedor. >>> >>> (NOTE: Duplicate, first email wasn't posted, because I wasn't subscribed >>> to the ML) >>> >> >> >