{"id":818815,"url":"http://patchwork.ozlabs.org/api/patches/818815/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/accc6eb9b572f7f595deaca91a0c8f95a5144916.1506114055.git.pabeni@redhat.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<accc6eb9b572f7f595deaca91a0c8f95a5144916.1506114055.git.pabeni@redhat.com>","list_archive_url":null,"date":"2017-09-26T20:18:53","name":"[RFC,11/11] udp: dst lookup in early demux for unconnected sockets","commit_ref":null,"pull_url":null,"state":"rfc","archived":true,"hash":"4edbda705f58b4f83836fe5a34c10b8c207cf2f1","submitter":{"id":67312,"url":"http://patchwork.ozlabs.org/api/people/67312/?format=json","name":"Paolo Abeni","email":"pabeni@redhat.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/accc6eb9b572f7f595deaca91a0c8f95a5144916.1506114055.git.pabeni@redhat.com/mbox/","series":[{"id":4709,"url":"http://patchwork.ozlabs.org/api/series/4709/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=4709","date":"2017-09-22T21:06:24","name":"udp: full early demux for unconnected sockets","version":1,"mbox":"http://patchwork.ozlabs.org/series/4709/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/818815/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/818815/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=pabeni@redhat.com"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y1sjr4fmrz9t3Z\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 27 Sep 2017 06:19:12 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S937088AbdIZUTJ (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 26 Sep 2017 16:19:09 -0400","from mx1.redhat.com ([209.132.183.28]:53394 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S935846AbdIZUTJ (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tTue, 26 Sep 2017 16:19:09 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id CD5457E42A;\n\tTue, 26 Sep 2017 20:19:08 +0000 (UTC)","from dhcppc1.redhat.com (ovpn-116-44.ams2.redhat.com\n\t[10.36.116.44])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 1596560841;\n\tTue, 26 Sep 2017 20:19:06 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com CD5457E42A","From":"Paolo Abeni <pabeni@redhat.com>","To":"netdev@vger.kernel.org","Cc":"\"David S. Miller\" <davem@davemloft.net>,\n\tPablo Neira Ayuso <pablo@netfilter.org>, Florian Westphal <fw@strlen.de>,\n\tEric Dumazet <edumazet@google.com>,\n\tHannes Frederic Sowa <hannes@stressinduktion.org>","Subject":"[RFC PATCH 11/11] udp: dst lookup in early demux for unconnected\n\tsockets","Date":"Tue, 26 Sep 2017 22:18:53 +0200","Message-Id":"<accc6eb9b572f7f595deaca91a0c8f95a5144916.1506114055.git.pabeni@redhat.com>","In-Reply-To":"<cover.1506114055.git.pabeni@redhat.com>","References":"<cover.1506114055.git.pabeni@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tTue, 26 Sep 2017 20:19:08 +0000 (UTC)","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Now that all the helper are in place we can leverage them to\nfetch the appropriate destination for unconnected sockets,\nlooking up the ifaddr cache if not local bind are not allowed.\n\nSigned-off-by: Paolo Abeni <pabeni@redhat.com>\n---\n net/ipv4/udp.c | 10 ++++++++--\n net/ipv6/udp.c |  9 ++++++++-\n 2 files changed, 16 insertions(+), 3 deletions(-)","diff":"diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c\nindex b7202a15f360..87d48101efe2 100644\n--- a/net/ipv4/udp.c\n+++ b/net/ipv4/udp.c\n@@ -2259,9 +2259,15 @@ int udp_v4_early_demux(struct sk_buff *skb)\n \t\treturn 0;\n \n \tskb_set_noref_sk(skb, sk);\n-\tif (udp_use_rx_dst_cache(sk, skb))\n+\tif (udp_use_rx_dst_cache(sk, skb)) {\n \t\tudp_set_skb_rx_dst(sk, skb, 0);\n-\treturn 0;\n+\t\treturn 0;\n+\t}\n+\n+\tif (net->ipv4.sysctl_ip_nonlocal_bind)\n+\t\treturn 0;\n+\n+\treturn ip_route_try_local_rcu(net, skb, iph);\n }\n \n int udp_rcv(struct sk_buff *skb)\ndiff --git a/net/ipv6/udp.c b/net/ipv6/udp.c\nindex 67d340679c3a..360d54bc2359 100644\n--- a/net/ipv6/udp.c\n+++ b/net/ipv6/udp.c\n@@ -935,8 +935,15 @@ static void udp_v6_early_demux(struct sk_buff *skb)\n \t\treturn;\n \n \tskb_set_noref_sk(skb, sk);\n-\tif (udp6_use_rx_dst_cache(sk))\n+\tif (udp6_use_rx_dst_cache(sk)) {\n \t\tudp_set_skb_rx_dst(sk, skb, inet6_sk(sk)->rx_dst_cookie);\n+\t\treturn;\n+\t}\n+\n+\tif (net->ipv6.sysctl.ip_nonlocal_bind)\n+\t\treturn;\n+\n+\tip6_route_try_local_rcu_bh(net, skb);\n }\n \n static __inline__ int udpv6_rcv(struct sk_buff *skb)\n","prefixes":["RFC","11/11"]}