{"id":817704,"url":"http://patchwork.ozlabs.org/api/patches/817704/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/49b182d5f4690cff36a3aa6cbe06d7b3565eda54.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":"<49b182d5f4690cff36a3aa6cbe06d7b3565eda54.1506114055.git.pabeni@redhat.com>","list_archive_url":null,"date":"2017-09-22T21:06:30","name":"[RFC,06/11] ip/route: factor out helper for local route creation","commit_ref":null,"pull_url":null,"state":"rfc","archived":true,"hash":"c262594719429dbd40c90a2d0a131e03f7ff607a","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/49b182d5f4690cff36a3aa6cbe06d7b3565eda54.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/817704/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/817704/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-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx10.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 3xzQz64ml9z9sP1\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 23 Sep 2017 07:07:14 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752748AbdIVVHN (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 22 Sep 2017 17:07:13 -0400","from mx1.redhat.com ([209.132.183.28]:37322 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1752710AbdIVVHI (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tFri, 22 Sep 2017 17:07:08 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\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 7C6D2A0C23;\n\tFri, 22 Sep 2017 21:07:08 +0000 (UTC)","from dhcppc0.redhat.com (ovpn-116-39.ams2.redhat.com\n\t[10.36.116.39])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id B8A6B61F26;\n\tFri, 22 Sep 2017 21:07:06 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 7C6D2A0C23","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 06/11] ip/route: factor out helper for local route\n\tcreation","Date":"Fri, 22 Sep 2017 23:06:30 +0200","Message-Id":"<49b182d5f4690cff36a3aa6cbe06d7b3565eda54.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.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.39]);\n\tFri, 22 Sep 2017 21:07: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":"Will be used by a later patch to build the ifaddr dst cache.\nNo functional changes are introduced here.\n\nSigned-off-by: Paolo Abeni <pabeni@redhat.com>\n---\n include/net/route.h |  2 ++\n net/ipv4/route.c    | 30 ++++++++++++++++++++++--------\n 2 files changed, 24 insertions(+), 8 deletions(-)","diff":"diff --git a/include/net/route.h b/include/net/route.h\nindex 1b09a9368c68..ec09c3d73581 100644\n--- a/include/net/route.h\n+++ b/include/net/route.h\n@@ -176,6 +176,8 @@ static inline struct rtable *ip_route_output_gre(struct net *net, struct flowi4\n \treturn ip_route_output_key(net, fl4);\n }\n \n+struct rtable *ip_local_route_alloc(struct net_device *dev, unsigned int flags,\n+\t\t\t\t    u32 itag, unsigned char type, bool docache);\n int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 src,\n \t\t\t u8 tos, struct net_device *devin);\n int ip_route_input_rcu(struct sk_buff *skb, __be32 dst, __be32 src,\ndiff --git a/net/ipv4/route.c b/net/ipv4/route.c\nindex 94d4cd2d5ea4..515589f1b3d1 100644\n--- a/net/ipv4/route.c\n+++ b/net/ipv4/route.c\n@@ -1859,6 +1859,27 @@ static int ip_mkroute_input(struct sk_buff *skb,\n \treturn __mkroute_input(skb, res, in_dev, daddr, saddr, tos);\n }\n \n+struct rtable *ip_local_route_alloc(struct net_device *dev, unsigned int flags,\n+\t\t\t\t    u32 itag, unsigned char type, bool do_cache)\n+{\n+\tstruct in_device *in_dev = __in_dev_get_rcu(dev);\n+\tstruct net *net = dev_net(dev);\n+\tstruct rtable *rth;\n+\n+\trth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev,\n+\t\t\t   flags | RTCF_LOCAL, type,\n+\t\t\t   IN_DEV_CONF_GET(in_dev, NOPOLICY), false, do_cache);\n+\tif (!rth)\n+\t\treturn NULL;\n+\n+\trth->dst.output= ip_rt_bug;\n+#ifdef CONFIG_IP_ROUTE_CLASSID\n+\trth->dst.tclassid = itag;\n+#endif\n+\trth->rt_is_input = 1;\n+\treturn rth;\n+}\n+\n /*\n  *\tNOTE. We drop all the packets that has local source\n  *\taddresses, because every properly looped back packet\n@@ -1996,17 +2017,10 @@ out:\treturn err;\n \t\t}\n \t}\n \n-\trth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev,\n-\t\t\t   flags | RTCF_LOCAL, res->type,\n-\t\t\t   IN_DEV_CONF_GET(in_dev, NOPOLICY), false, do_cache);\n+\trth = ip_local_route_alloc(dev, flags, itag, res->type, do_cache);\n \tif (!rth)\n \t\tgoto e_nobufs;\n \n-\trth->dst.output= ip_rt_bug;\n-#ifdef CONFIG_IP_ROUTE_CLASSID\n-\trth->dst.tclassid = itag;\n-#endif\n-\trth->rt_is_input = 1;\n \tif (res->table)\n \t\trth->rt_table_id = res->table->tb_id;\n \n","prefixes":["RFC","06/11"]}