From owner-freebsd-net@freebsd.org Mon Sep 5 12:42:34 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 BC172A9D3FD for ; Mon, 5 Sep 2016 12:42:34 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-it0-x22a.google.com (mail-it0-x22a.google.com [IPv6:2607:f8b0:4001:c0b::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 8F701E8E for ; Mon, 5 Sep 2016 12:42:34 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-it0-x22a.google.com with SMTP id i184so144477593itf.1 for ; Mon, 05 Sep 2016 05:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sippysoft-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:from:date:message-id:subject:to; bh=Z8rsFxQItYuGWaoNoQKAqO5dxhPMfFpp6Q6NBR9GccU=; b=NA2tfzp21nLnIfsevEyuMeZw4QWe7k5sS/FcyLohChA91OhgO7XsZyWd83XrFoxmH6 VGM78RvLY2ehMtogJnHAxlgmVlOLZrLOP1POsmAAYcg9uwVqb7ix6A+QACZ1CLw2SYXo z5mZsrrvM09TNNez7g7FebRDsg6Eg7yuCo7awOgC+MkwvwY+xAw1LamS86l3HI+PZr7Q XU1s6HPPRCe3Eq+TFlYoxc5GWSZmooTcCiUmBG6kKOzB96UjT1Ncoqmd7VztmY4PPgA5 FKbi3F+bqf/+XPuOXQU7VpZX5MGOxaDKJ1ZRZQb34lSjOuihIw/yWVtLmhWgezeJhu3O 4LYQ== 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:from:date:message-id:subject :to; bh=Z8rsFxQItYuGWaoNoQKAqO5dxhPMfFpp6Q6NBR9GccU=; b=SY3QukGzirHu08RPYbhTWZCuQ1LSUrBVK2FQlS6HXoOKeRm2BcqDyutoBYSsFMyA3V bCVuzuPnFPziZ5KtKEg69nj7IdTRg5QPj0old9gTO/o/cx/3SUTz/s57V7usYLKdefdm TW9Aba42wnV1mMXVDdGEPMwCLaBuaK+XXeWg1BGynxOlJWO9VrgPC3z/wb9X4Q0JXqdo TE2In45Q3P+0886UmCUPS05BuPGcRtpCd89s/y2/joVMkVQt98RWEO4bkqe4WkAAqCDu 6pZmae9NhVoObUmIz80fCEnsgeqNwZKpe4CEW/UL+veJddUi+COXhgW1EwsFJ8Q0mTDA 85kw== X-Gm-Message-State: AE9vXwO13LTUfzAUl4gk+Snzq00E9pYf3m1XM8aKsgzmmcGCNy9gQgpWYpqx5o4IL+NdWJA2qYBEt8PdJBff2464 X-Received: by 10.36.190.75 with SMTP id i72mr24905634itf.92.1473079353750; Mon, 05 Sep 2016 05:42:33 -0700 (PDT) MIME-Version: 1.0 Sender: sobomax@sippysoft.com Received: by 10.36.149.196 with HTTP; Mon, 5 Sep 2016 05:42:33 -0700 (PDT) From: Maxim Sobolev Date: Mon, 5 Sep 2016 05:42:33 -0700 X-Google-Sender-Auth: -21eCBwmnteKcHNtlhC1YwtC6l8 Message-ID: Subject: Which UDP sockets the incoming packet is delivered to when both wildcard and non-wildcard listeners are present To: 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: Mon, 05 Sep 2016 12:42:34 -0000 Hi Netters, 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? OS in question is 10.3-RELEASE-p5 [ssp-root@dal23 ~]$ sockstat | grep 24421 | grep udp4 | grep -w 5071 b2bua python2.7 24421 7 udp4 *:5071 *:* b2bua python2.7 24421 58 udp4 X.Y.Z.W:5071 *:* I apologize if this is answered somewhere already, any pointers would be appreciated. Thanks! -Max