From patchwork Thu Apr 20 22:18:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 753026 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3w8Cv31QPxz9s75 for ; Fri, 21 Apr 2017 08:18:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="epHNU5KA"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030731AbdDTWSa (ORCPT ); Thu, 20 Apr 2017 18:18:30 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:34726 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S945797AbdDTWS2 (ORCPT ); Thu, 20 Apr 2017 18:18:28 -0400 Received: by mail-io0-f180.google.com with SMTP id a103so90469151ioj.1 for ; Thu, 20 Apr 2017 15:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=+rv68fsKIPZMsxkuIhJA49Uknyo/bhKUwPPdFbv1yOc=; b=epHNU5KAETJXqcsWMJ3VCtpHpmD1v2hzK1jXYZI3hM4z8vwfGtlQq1vyAEoD7RESNW kXSy1QNkX5A0X5NyQH4/v7jdApS3T1FdF0dKdoSwBNlMu8fzLuoeeZEznxzaQ+cCpgta ZW5OuG/I81fMk5xmhqsQlRPPZPh/5wk/4SCTw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=+rv68fsKIPZMsxkuIhJA49Uknyo/bhKUwPPdFbv1yOc=; b=jAPaEg15KAqjjLUT1Nqj4Fo4jfJlhgFelz0yl0+6kFDvxBDH5LDT1iNghCjbed8DWX ybQuibCvc/pg7+7sfXV6cUGmdn69dAZHB9XGhf0VFTbE1aXuymIdpSZv5t1XsFHxuAqm IbXaQWBDQsoSkm4LZ9VjQYRjRmGSvrc/la3keIbgaEM62U6WRWoB7JjUd6E2CTQSSOX3 dlzTrguJp/PhVJEz6lW3HbrRRk5mG3nGJq8JV9099KEwNJvSPGNkfjcx1oh84GEmDHc1 rJL9ghG7F+wOiv2E2U+ZBg38divE/Hp1pwVERnKwUNT1qUwVBhpLNciauNez/RswIKQu dzng== X-Gm-Message-State: AN3rC/4GH6DE2hw/yz0gObIRMjiZVlEkUEcuSjYEa+wCFoQVcBCp2etL WXoFvCGPeq9rudK1 X-Received: by 10.98.72.86 with SMTP id v83mr9318001pfa.29.1492726705784; Thu, 20 Apr 2017 15:18:25 -0700 (PDT) Received: from [172.27.227.227] ([216.129.126.118]) by smtp.googlemail.com with ESMTPSA id y123sm12176132pfg.52.2017.04.20.15.18.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Apr 2017 15:18:25 -0700 (PDT) Subject: Re: [PATCH net] ipv4: Avoid caching dsts when lookup skipped nh oif check To: Robert Shearman , davem@davemloft.net References: <1492693132-4708-1-git-send-email-rshearma@brocade.com> Cc: netdev@vger.kernel.org From: David Ahern Message-ID: <7c395b52-d639-9001-c6fa-ccacec4ce0d9@cumulusnetworks.com> Date: Thu, 20 Apr 2017 16:18:23 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1492693132-4708-1-git-send-email-rshearma@brocade.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 4/20/17 6:58 AM, Robert Shearman wrote: > diff --git a/net/ipv4/route.c b/net/ipv4/route.c > index acd69cfe2951..f667783ffd19 100644 > --- a/net/ipv4/route.c > +++ b/net/ipv4/route.c > @@ -2125,6 +2125,14 @@ static struct rtable *__mkroute_output(const struct fib_result *res, > fi = NULL; > } > > + /* If the flag to skip the nh oif check is set then the output > + * device may not match the nh device, so cannot use or add to > + * cache in that case. > + */ > + if (unlikely(fl4->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF && > + FIB_RES_NH(*res).nh_dev != dev_out)) > + do_cache = false; > + > fnhe = NULL; > do_cache &= fi != NULL; > if (do_cache) { > I believe this is a better fix: fl4->flowi4_oif = dev_out->ifindex; flags |= RTCF_LOCAL; goto make_route; Fixes: 5f02ce24c2696 ("net: l3mdev: Allow the l3mdev to be a loopback") With your change above, references to vrf devices are still taken (dev_out is the vrf device based on the flow struct) even though the route's nexthop is in another domain. And the commit log should reference the use case which is policy routing overriding the VRF rule. diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 5e1e60546fce..fb74a16958af 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2407,7 +2407,7 @@ struct rtable *__ip_route_output_key_hash(struct net *net, struct flowi4 *fl4, } /* L3 master device is the loopback for that domain */ - dev_out = l3mdev_master_dev_rcu(dev_out) ? : net->loopback_dev; + dev_out = l3mdev_master_dev_rcu(FIB_RES_DEV(res)) ? : net->loopback_dev;