From owner-freebsd-net@freebsd.org Tue Sep 6 07:03:30 2016 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 344FFB961CC for ; Tue, 6 Sep 2016 07:03:30 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-oi0-x231.google.com (mail-oi0-x231.google.com [IPv6:2607:f8b0:4003: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 E72A37F2 for ; Tue, 6 Sep 2016 07:03:29 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-oi0-x231.google.com with SMTP id w78so83994618oie.3 for ; Tue, 06 Sep 2016 00:03:29 -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=ORohFv63ZxhRYRNcxNjlbBqdTlD1eM5U06i2uDoJsmQ=; b=Vdbyl5a6JN1VbCoILlRA/+Clsb5yRNP29MplJeXs0yXNFUUUcZSTByUsGZSYtrjVup fVbcXML7naCjku83yiYrfAaZHAtt+NbDhQxgPEoJqSjwS62uNMJI/eX6pxGOiIFDQvtI PcWz/svQ37/GEA8DVHPvcpMxvnmhWF8glEXJcEz2qFD0we/YWFTy7HNqVrln2uSyO2fn vw+TE3/J2B0NqaMCaOeZOYubfaS5Ddec2wr0aq8N6u3YSvvTRslJCfR7RvdYL1FbHXhK CgVPfisJ6vM5Zuiy5n35xzhvFTMQxQTN7E1lHQpG9V3QSNdPXcNBHfD3MdsXIux+k6nP 6UqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ORohFv63ZxhRYRNcxNjlbBqdTlD1eM5U06i2uDoJsmQ=; b=fV6Tr/GcAMBzWvDs2MFdn0U144cjcVQWrUlHwmum5sC5KIQw03Y3fDX4644A/ODGS/ p6S3rGCYBOSl+GOjBI19i+Ww60ZrA+jWOXrgPJ8thyRJJWuHPeAMX00PWDulHYfNJNLL Yspr+YUzsJ5GAFtaI7yKldu+2xlVqA6Fptg7Kor/WaG/Lb4DKnKAYbB1fsRouwA4yrK6 29MPgHugDAEpwCwOZ2P5tdC6f9rYrpOP0HbHNJC/UNI+WAa8dBfXWzw3N2os0yl9eDH7 7o/+LbrqYDVEuzRsDpHZg/Inj6+IsOWZ9NiN8jI5YtjWfbozhpCUDRrhyFu3TH5tal1x 91fg== X-Gm-Message-State: AE9vXwMMrNWXuAPkvsrgoBJBa9fwrLY7gPjlA8qPWy6PHBUvIbp7J806ga1/i0EdimeOjMA6JNobAijjqO8xrgMX X-Received: by 10.107.55.194 with SMTP id e185mr3572432ioa.34.1473145408239; Tue, 06 Sep 2016 00:03:28 -0700 (PDT) MIME-Version: 1.0 Sender: sobomax@sippysoft.com Received: by 10.36.149.196 with HTTP; Tue, 6 Sep 2016 00:03:27 -0700 (PDT) In-Reply-To: References: From: Maxim Sobolev Date: Tue, 6 Sep 2016 00:03:27 -0700 X-Google-Sender-Auth: CUQLA0xx8jY9Wt08QN1hRPBkMx8 Message-ID: Subject: Re: Which UDP sockets the incoming packet is delivered to when both wildcard and non-wildcard listeners are present To: "Andrey V. Elsukov" Cc: FreeBSD Net , Gleb Smirnoff 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: Tue, 06 Sep 2016 07:03:30 -0000 Andrey, 1. Sockets are unconnected 2. Datagrams are unicast -Max On Mon, Sep 5, 2016 at 6:46 AM, Andrey V. Elsukov wrote: > On 05.09.16 15:42, Maxim Sobolev wrote: > > Suppose we have two threads in the system both bound to a same specific > UDP > > port, one using INADDR_ANY and another one using actual IP. When incoming > > message arrives to that port is there any guarantee as to which of those > > two threads going to see the message? The question has arisen from the > > observation that most of the time the thread that is bound to a specific > IP > > gets them, but occasionally we see INADDR_ANY-bound thread receiving few > > packets as well. So that behavior seems to be "almost deterministic" and > we > > are wondering where that "almost" part is expected or some kind of socket > > matching bug? > > Are your sockets connected? I.e. did you use connect+send? And do you > receive unicast datagrams or some broadcast/multicast can appear? > > -- > WBR, Andrey V. Elsukov > >