From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [PATCH] udp: Allow to defer reception until connect() happened Date: Wed, 28 Nov 2018 18:19:07 -0800 Message-ID: References: <20181129015626.85441-1-cpaasch@apple.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: netdev , Ian Swett , lhedstrom@apple.com, jri.ietf@gmail.com To: Christoph Paasch Return-path: Received: from mail-it1-f195.google.com ([209.85.166.195]:35617 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726872AbeK2NXC (ORCPT ); Thu, 29 Nov 2018 08:23:02 -0500 Received: by mail-it1-f195.google.com with SMTP id p197so1281244itp.0 for ; Wed, 28 Nov 2018 18:19:19 -0800 (PST) In-Reply-To: <20181129015626.85441-1-cpaasch@apple.com> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, Nov 28, 2018 at 5:57 PM Christoph Paasch wrote: > > There are use-cases where a host wants to use a UDP socket with a > specific 4-tuple. The way to do this is to bind() and then connect() the > socket. However, after the bind(), the socket starts receiving data even > if it does not match the intended 4-tuple. That is because after the > bind() UDP-socket will match in the lookup for all incoming UDP-traffic > that has the specific IP/port. > > This patch prevents any incoming traffic until the connect() system-call > is called whenever the app sets the UDP socket-option > UDP_WAIT_FOR_CONNECT. Please do not add something that could mislead applications writers to think UDP stack can scale. UDP stack does not have a full hash on 4-tuples, it means that incoming traffic on a 'shared port' has to scan a list of XXX sockets to find the best match ... Also you add another cache line miss in UDP lookup to access udp_sk()->wait_for_connect. recvfrom() can be used to filter whatever frame that came before the connect()