From patchwork Wed Oct 31 23:26:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Paasch X-Patchwork-Id: 991745 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=apple.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=apple.com header.i=@apple.com header.b="bLx5zi5D"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42lkyG1wkRz9s1c for ; Thu, 1 Nov 2018 10:27:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731207AbeKAI13 (ORCPT ); Thu, 1 Nov 2018 04:27:29 -0400 Received: from ma1-aaemail-dr-lapp03.apple.com ([17.171.2.72]:43340 "EHLO ma1-aaemail-dr-lapp03.apple.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730974AbeKAI13 (ORCPT ); Thu, 1 Nov 2018 04:27:29 -0400 Received: from pps.filterd (ma1-aaemail-dr-lapp03.apple.com [127.0.0.1]) by ma1-aaemail-dr-lapp03.apple.com (8.16.0.22/8.16.0.22) with SMTP id w9VNQx5L042120; Wed, 31 Oct 2018 16:27:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apple.com; h=content-transfer-encoding : sender : from : to : cc : subject : date : message-id : in-reply-to : references; s=20180706; bh=R3RLL1D9zzOmSG6An+ovE9i7YrSTaOADhUqCOfJcudU=; b=bLx5zi5DNmZswOcMyhttFmvboibOueh+lyfcr2wGcIp91mYm3oj9OA4D5CQCXFN98K+K n1XcYGvBMst/DT4G9bSXKqFeo9afKlEiB/i6cR36lNIDNXoRp8uyH0QwFs/y0TB8GE8E VjN+nGQIYq+DBY2JIiGGuzKLbiOPTFnYDUUOKdC8mTxcnaZ9iJ9U0nWuB3vzevHM1pZb NW19ggI4xVUDodihi3yOPrZXVF7VZQCLNZ54nJeJbhrscbW4uSHmd4mfuoc08RuFSkxS kZvpzzwUqAGTjNgY1vBs7DqESDHKYkzgran+mJ/eluR3CbcmYmMDCRTd33uPQB8pr9n1 4A== Received: from mr2-mtap-s01.rno.apple.com (mr2-mtap-s01.rno.apple.com [17.179.226.133]) by ma1-aaemail-dr-lapp03.apple.com with ESMTP id 2ncq119ed3-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Wed, 31 Oct 2018 16:27:09 -0700 Content-transfer-encoding: 7BIT Received: from nwk-mmpp-sz13.apple.com (nwk-mmpp-sz13.apple.com [17.128.115.216]) by mr2-mtap-s01.rno.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPS id <0PHH007UAL57SWA0@mr2-mtap-s01.rno.apple.com>; Wed, 31 Oct 2018 16:27:07 -0700 (PDT) Received: from process_viserion-daemon.nwk-mmpp-sz13.apple.com by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PHH00L00KY0E300@nwk-mmpp-sz13.apple.com>; Wed, 31 Oct 2018 16:27:07 -0700 (PDT) X-Va-A: X-Va-T-CD: 4b1e0bf36502e052fc75ad21b706ed24 X-Va-E-CD: a0ff70d125f22d4239d4daec6da8038f X-Va-R-CD: 574accd27a02a807920c43e1070b224e X-Va-CD: 0 X-Va-ID: 843854fd-bdf3-422d-8c9d-7c8dba57707a X-V-A: X-V-T-CD: 5c1d590bbb3e9640019563b4ec412a7e X-V-E-CD: a0ff70d125f22d4239d4daec6da8038f X-V-R-CD: 574accd27a02a807920c43e1070b224e X-V-CD: 0 X-V-ID: 46211267-d98a-4359-9715-6831ab9dd84f Received: from process_milters-daemon.nwk-mmpp-sz13.apple.com by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) id <0PHH00000L27M000@nwk-mmpp-sz13.apple.com>; Wed, 31 Oct 2018 16:27:06 -0700 (PDT) Authentication-results: corp.apple.com; spf=softfail smtp.mailfrom=cpaasch@apple.com; dmarc=quarantine header.from=apple.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-31_08:,, signatures=0 Received: from localhost ([17.192.155.217]) by nwk-mmpp-sz13.apple.com (Oracle Communications Messaging Server 8.0.2.3.20180614 64bit (built Jun 14 2018)) with ESMTPSA id <0PHH00067L56YKC0@nwk-mmpp-sz13.apple.com>; Wed, 31 Oct 2018 16:27:06 -0700 (PDT) From: Christoph Paasch To: netdev@vger.kernel.org Cc: Ian Swett , Leif Hedstrom , Jana Iyengar Subject: [RFC 2/2] udp: Support SO_DELAYED_BIND Date: Wed, 31 Oct 2018 16:26:35 -0700 Message-id: <20181031232635.33750-3-cpaasch@apple.com> X-Mailer: git-send-email 2.16.2 In-reply-to: <20181031232635.33750-1-cpaasch@apple.com> References: <20181031232635.33750-1-cpaasch@apple.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-10-31_08:, , signatures=0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For UDP, there is only a single socket-hash table, the udptable. We want to prevent incoming segments to match on this socket when SO_DELAYED_BIND is set. Thus, when computing the score for unconnected sockets, we simply prevent the match as long as the flag is set. Signed-off-by: Christoph Paasch --- net/ipv4/datagram.c | 1 + net/ipv4/udp.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c index 300921417f89..9bf0e0d2ea33 100644 --- a/net/ipv4/datagram.c +++ b/net/ipv4/datagram.c @@ -78,6 +78,7 @@ int __ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len inet->inet_id = jiffies; sk_dst_set(sk, &rt->dst); + sock_reset_flag(sk, SOCK_DELAYED_BIND); err = 0; out: return err; diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index ca3ed931f2a9..fb55f925342b 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -408,6 +408,9 @@ static int compute_score(struct sock *sk, struct net *net, score += 4; } + if (sock_flag(sk, SOCK_DELAYED_BIND)) + return -1; + if (sk->sk_incoming_cpu == raw_smp_processor_id()) score++; return score;