From patchwork Fri Jul 21 03:47:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 791882 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dLK5NCuq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xDGtp5q9kz9s7M for ; Fri, 21 Jul 2017 13:47:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030193AbdGUDro (ORCPT ); Thu, 20 Jul 2017 23:47:44 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:37165 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966051AbdGUDrm (ORCPT ); Thu, 20 Jul 2017 23:47:42 -0400 Received: by mail-pg0-f66.google.com with SMTP id t8so4315411pgs.4 for ; Thu, 20 Jul 2017 20:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YFEU5jLCPmIFHYFCDujMjHDA1GWEaaYLRxQXxsTHIn4=; b=dLK5NCuqs3h0+dkSDEgN0Pk8p6JV1M6IvvFab0gmEdr48xREf/PE05eDmzDU8G9QKB VkqNvWGq2a+D6Aa3J7QLLUb4KNYQNnGsNMHno0l4OxG9IFpLr6WKYAHL1Nn9A/+brc5V Ymatg1E3Qpgd6nK8qt1Zwz+U12S5XyMfIrx09h8oww8Ee0rPBvjkWqrqLfVTwJ9pDi+J kcsJm5yKRGqyiIgy5DOYzF9IK/s9pbouQtEKa6/OEQI00qCstZvAh4DEELpTXCL2C5CR OqGLrCxt1Kp+yL6S1BZp53ZfKbFfZH9uQKXcKqTcSHIWhUlSBMCZ/vH4bb3lGmPlpUqj qapg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YFEU5jLCPmIFHYFCDujMjHDA1GWEaaYLRxQXxsTHIn4=; b=jz/j9EYlZlxSVwJtnkV068jxkPh12ajUGZlLar957b8jodImKWRlFYBqnjdltV9gc+ klZ47mmznOifQUo+Nx0E5IEQo80b5QqZZrrZsIIaT9Sfvr+In1CD141aFFmxcuKkUq23 DQkTd7Ae4c6P7eWh6sV6YzI3idGR7uP7VORhG1Qg1Js9Xwv2Tl1lHszjWN3gMI8G/Lxr nWtRuhbSnEPyP9z/2b+7VUInXL/0FMWUCJMIsHZqo55bdBvksL91TLjSCIaqRORo3IWo hY93uVwiCkZz3TxIai/CK8z5/Lgl7zwfKf/szbc2AbJShdLZKstSTBNpOJkAZgeVLBvG qVFg== X-Gm-Message-State: AIVw111WYrz3vzZru32sT4Cj+tAHysueO9zpWwfqhcf9pUx+doMtdjsf X081wfmf6q6iTjq1 X-Received: by 10.84.209.170 with SMTP id y39mr6769036plh.235.1500608861926; Thu, 20 Jul 2017 20:47:41 -0700 (PDT) Received: from leo.usersys.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id y22sm6683535pfi.159.2017.07.20.20.47.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jul 2017 20:47:41 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Roopa Prabhu , WANG Cong , Hangbin Liu Subject: [PATCHv2 net] ipv6: should not return rt->dst.error if it is prohibit or blk hole entry. Date: Fri, 21 Jul 2017 11:47:15 +0800 Message-Id: <1500608835-24845-1-git-send-email-liuhangbin@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1500562286-14312-1-git-send-email-liuhangbin@gmail.com> References: <1500562286-14312-1-git-send-email-liuhangbin@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org After commit 18c3a61c4264 ("net: ipv6: RTM_GETROUTE: return matched fib result when requested"). When we get a prohibit ertry, we will return -EACCES directly. Before: + ip netns exec client ip -6 route get 2003::1 prohibit 2003::1 dev lo table unspec proto kernel src 2001::1 metric 4294967295 error -13 After: + ip netns exec server ip -6 route get 2002::1 RTNETLINK answers: Permission denied Fix this by add prohibit and blk hole check. Since ip6_null_entry's error is already -ENETUNREACH. Merge the ip6_null_entry check and error check together. Fixes: 18c3a61c4264 ("net: ipv6: RTM_GETROUTE: return matched fib...") Signed-off-by: Hangbin Liu --- net/ipv6/route.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 4d30c96..c290aa4 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -3637,13 +3637,8 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, dst = ip6_route_lookup(net, &fl6, 0); rt = container_of(dst, struct rt6_info, dst); - if (rt->dst.error) { - err = rt->dst.error; - ip6_rt_put(rt); - goto errout; - } - - if (rt == net->ipv6.ip6_null_entry) { + if (rt->dst.error && rt != net->ipv6.ip6_prohibit_entry && + rt != net->ipv6.ip6_blk_hole_entry) { err = rt->dst.error; ip6_rt_put(rt); goto errout;