From patchwork Fri Sep 16 20:33:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Bernat X-Patchwork-Id: 671121 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 3sbRpS5MKWz9sC4 for ; Sat, 17 Sep 2016 06:34:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=bernat.im header.i=@bernat.im header.b=g1O8TxqF; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965479AbcIPUeV (ORCPT ); Fri, 16 Sep 2016 16:34:21 -0400 Received: from bart.luffy.cx ([78.47.78.131]:46358 "EHLO bart.luffy.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965082AbcIPUeT (ORCPT ); Fri, 16 Sep 2016 16:34:19 -0400 Received: from bart.luffy.cx (localhost [127.0.0.1]) by bart.luffy.cx (Postfix) with ESMTP id 39C4814FAB; Fri, 16 Sep 2016 22:34:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bernat.im; h=from:to:cc :subject:date:message-id:in-reply-to:references; s=postfix; bh=d WxCjo9Qt4V2m2/cRqx0+CDhTMw=; b=g1O8TxqFwBD6HAbPeUqA5UmG9JSTV8bcO p1N+vSOPLzyv9fbZyslZuGkA7aeGzygiL0aegi3UM/IrMUb8HwBHCpUi0bs8oDil BfWOSWhI7g6B1Zu9gEwdcD0gH2fqzcnmCojqUKdnnKKnTgwVrwXcdXJIQJ/IcmBJ YE1ROur/XE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bernat.im; h=from:to:cc :subject:date:message-id:in-reply-to:references; q=dns; s= postfix; b=RZKnQeJRlu1/jsfaCq3gciyIMtZfaqGSXQgik/Uf7UiZnGY2uS6kY rhuUPVBPDuBuoieNzduLEI2OzF41nGa6wVHqzGa960KGi6eMKovD3zIZfv4wnpJY k7ujZgAYzsVmRQU5aiuHPNnA+65oZD0ocYpEyG61RFcAmGbZaZU7sw= Received: from neo.luffy.cx (124.92.199.178.dynamic.wline.res.cust.swisscom.ch [178.199.92.124]) by bart.luffy.cx (Postfix) with ESMTPS id E9E1214174; Fri, 16 Sep 2016 22:34:15 +0200 (CEST) Received: by neo.luffy.cx (Postfix, from userid 500) id 883006B6; Fri, 16 Sep 2016 22:34:15 +0200 (CEST) From: Vincent Bernat To: David Ahern , "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy , netdev@vger.kernel.org Cc: Vincent Bernat Subject: [v2] net: ipv6: fallback to full lookup if table lookup is unsuitable Date: Fri, 16 Sep 2016 22:33:49 +0200 Message-Id: <20160916203349.31201-1-vincent@bernat.im> X-Mailer: git-send-email 2.9.3 In-Reply-To: <0e4071d6-a3cc-37a7-6a32-2169e0e3b305@cumulusnetworks.com> References: <0e4071d6-a3cc-37a7-6a32-2169e0e3b305@cumulusnetworks.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit 8c14586fc320 ("net: ipv6: Use passed in table for nexthop lookups") introduced a regression: insertion of an IPv6 route in a table not containing the appropriate connected route for the gateway but which contained a non-connected route (like a default gateway) fails while it was previously working: $ ip link add eth0 type dummy $ ip link set up dev eth0 $ ip addr add 2001:db8::1/64 dev eth0 $ ip route add ::/0 via 2001:db8::5 dev eth0 table 20 $ ip route add 2001:db8:cafe::1/128 via 2001:db8::6 dev eth0 table 20 RTNETLINK answers: No route to host $ ip -6 route show table 20 default via 2001:db8::5 dev eth0 metric 1024 pref medium After this patch, we get: $ ip route add 2001:db8:cafe::1/128 via 2001:db8::6 dev eth0 table 20 $ ip -6 route show table 20 2001:db8:cafe::1 via 2001:db8::6 dev eth0 metric 1024 pref medium default via 2001:db8::5 dev eth0 metric 1024 pref medium Signed-off-by: Vincent Bernat --- net/ipv6/route.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index ad4a7ff301fc..2c6c7257ff75 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1994,6 +1994,14 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg) if (cfg->fc_table) grt = ip6_nh_lookup_table(net, cfg, gw_addr); + if (grt) { + if (grt->rt6i_flags & RTF_GATEWAY || + (dev && dev != grt->dst.dev)) { + ip6_rt_put(grt); + grt = NULL; + } + } + if (!grt) grt = rt6_lookup(net, gw_addr, NULL, cfg->fc_ifindex, 1);