Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp914983pxu; Thu, 3 Dec 2020 16:19:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAlOlBtS71wpvMbbdVbzeB193PL0poy/sLS6Noz42aGZODst+T4tQ/a7R4Il07a1+oYrP7 X-Received: by 2002:a17:906:1e84:: with SMTP id e4mr4713563ejj.57.1607041169558; Thu, 03 Dec 2020 16:19:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607041169; cv=none; d=google.com; s=arc-20160816; b=XODClrsUdmuEz0cU7fc2oX1kGWcw4Ne+UwKGI4eBdS9303Sdei95b4GSzOHiFNe6bb by97ntQmRm6wFC3J885LPZXQHag2fHjtJU3rl1CUjcgpq3CADi7DDeh2WOr+gy7MdnAR hW8RPJQcCOOg1LLEmh8sy4LPy+kE40Equz03OH1DTMUjjk+dmLIw0WMNlwU+nBrp+PEJ 9LbM9w7HRTUofWQVlhDYj5aHAEJ62CSh+kXVZOCjo55Oi37XdE3KnD7b/KW1k3bQoH0Z f7DpoMBWKQEIY8PcX9Wy68lEE0Y7Ht3Lcb9Y2N4Zd7BrP/189n1J+P09Qku9APpuVRF0 /gOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:subject:message-id:date:from:mime-version :dkim-signature; bh=hW+tDMcroBnYjVio+hhjus4Lc01NoQdNAIz2e/PH8bE=; b=A9TEGdWmRVeHhsMbIhTybrg/1dtPLWWHO67PIqu/HIpbyCJqK5bE4/OXwE1MQy6Yef +SmK0IA9iEl+MAWrUApAy/I0tjDkccCJexzMfOKhgTAKp3IolGo1ozBaVHtZgczVKmo1 SD7HIhucbHi4bF+WLDERk/iJfLczbRzfhByjY6ujHyH9iv2dH+w2TKP235Aqdn7yKJOV sfDhLRB6yaCjPFLE2yuWwMXxx9JzQWS8mxacjkLTS6poKApEWzk5gJP8eEhWZZoiG2ai AAkKSZKJB1o/WJ67tBXjGrBzuFuwT7NiF2gtpA7XSHEGpF4la2ETqBSMwbrB39xEf5Mq koHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="D/wIGfko"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v21si383503ejh.106.2020.12.03.16.19.07; Thu, 03 Dec 2020 16:19:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="D/wIGfko"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728030AbgLDAQx (ORCPT + 99 others); Thu, 3 Dec 2020 19:16:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbgLDAQx (ORCPT ); Thu, 3 Dec 2020 19:16:53 -0500 Received: from mail-yb1-xb2d.google.com (mail-yb1-xb2d.google.com [IPv6:2607:f8b0:4864:20::b2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47B1FC061A4F for ; Thu, 3 Dec 2020 16:16:07 -0800 (PST) Received: by mail-yb1-xb2d.google.com with SMTP id o71so3790820ybc.2 for ; Thu, 03 Dec 2020 16:16:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=hW+tDMcroBnYjVio+hhjus4Lc01NoQdNAIz2e/PH8bE=; b=D/wIGfkoRntgV7Ro2xaCzABphrSrzeyCLVp+DJ7nI+LWZo5M+N0p48lSdg7K4DtZh6 zbdVyi/qse2yZmY4hzUfjFHNYHWOwrp64/4pdfU9+rTXFwH/HgrxfBLgrbZfGllb/8SK HcRtwMI6rLh47ubxH8nzzsA6mQ6/2AIIloyORSnlu5CDRdgINVcca7AwjFtmUZBtL9/5 Od5v5lSdZexg+NCA6fRiQEAE2b7xYH4Uyy5WD0evdk0hRolYKAkpiN4frfQ8y7uV13rk BOKpGyxDjKjmbg8SL8Yd5OQJDnXcrxASkg1VIPBAh/U+MV3qDKFjSC95IGPRNFJuTpqg rvSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=hW+tDMcroBnYjVio+hhjus4Lc01NoQdNAIz2e/PH8bE=; b=NDNhG1/2//GQM8fws8VRmanIC16F4A+aOFGzUc5rn0u96f3y6/M8HY///o15vdS+IL l+JA+QuP1IiSOOQ52TK/ZTaGwWsNjzmlqOepKCNxRu6fXVbGQeb+Grs9i+oNtO2/VZxj x9JVa/NxIi37jnaEm3PvadLIfo+nMqY+fDv6m7deiaeP3uZX2XWGfBc39XmGy92xkaR7 RFGGMV//DgopQ7m64WxJx+8OTwOWxtSXRh165UkCo60VUDcqoTGA5rMK4vYBM5fzRyJ1 fs1qqQ1DYgYRIJcgBlDrxac3M0A1oa+Na69HbnXOkHpXb2z5DpgTApb8/7GAN0tJ9+dj vdWg== X-Gm-Message-State: AOAM5333AZOdTurXaqksHRu8jZEMBoFyGG09X+v4P7/g8D0la0xwxK3M VnIS1ph48EhrBHFoJcfrfjl9+OmTWnTmhbsqexBab935nwI= X-Received: by 2002:a25:9345:: with SMTP id g5mr2473223ybo.208.1607040965867; Thu, 03 Dec 2020 16:16:05 -0800 (PST) MIME-Version: 1.0 From: James Courtier-Dutton Date: Fri, 4 Dec 2020 00:15:29 +0000 Message-ID: Subject: SO_REUSEADDR compatibility problems To: LKML Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, The use case I am struggling with is the use of a Windows program running in wine that is sending and receiving UDP packets. This particular windows program uses SO_REUSEADDR socket option and opens two sockets. Lets call the first one socket A, and the second one Socket B. The SO_REUSEADDR from the Windows application is translated by "wine" into a SO_REUSEADDR in Linux. Unfortunately the behaviour of these is different between Windows and Linux so the Windows application fails to run on Linux under wine. 1 ) On windows: All received unicast UDP packets will arrive on the first opened socket. Thus on socket A. 2) On Linux: All received unicast UDP packets will arrive on the last opened socket. Thus on socket B. The problem is that this windows program only expects to receive unicast UDP packets on socket A, and thus it sees no packets. There are no currently existing socket options in Linux that would permit wine to simulate the Windows behaviour. And thus, the reason I am asking the question here. Please can we add an extra socket option to the Linux socket options such that we can get wine to simulate Windows correctly. I.e. behave like (1) above. Now wine is pretty good at simulating most things Windows throws at it, but socket options is not one of them yet. Also note, that (1) is actually more secure than (2) because it prevents other applications with the same UserID from hijacking the socket. Although (2) is more helpful in more gracefully handling some error edge cases. Suggested new option name: SO_REUSEADDR_WS Kind Regards James