Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5901299imb; Fri, 8 Mar 2019 05:06:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzClqcghUUXsUFJ+XgzwPCWYXfscbKnE9xNFalsAfW5BXMNV4Apy9Uo95h18LXcNHXaXsBK X-Received: by 2002:a17:902:e113:: with SMTP id cc19mr19039848plb.179.1552050378836; Fri, 08 Mar 2019 05:06:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552050378; cv=none; d=google.com; s=arc-20160816; b=YTwPkvink013sZLqR/NWvxPddD7ASZJWXYAeDjT+DPihiO083yyF6tmRplI6AurQ6j oU0rJIYQ6B5TQZ/FUg2p5jVfsDRaIziMF4UDEPrZ/2MbH7vciycaTBJJmCiuV6lv3xF+ 2XcKlBii4rqbmMx83kIvDSG83N68XPE81p0i6LfXrB/hPWzzp9f3/lgaIEZp5k8skLus Vnbe+dLpXvY3QiCCc+t8r5soYyUvFbBspho5xPj1sbzeVJoqGG/laLUexF1gSM7eEC6U ZTpcgzDJFOMwrgpaPVhQRj2YXbrBCSmhba99WQGQgjoooCBlsGdaGT3z3d0o//I8o7Kr TotA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=brBB62Vy3M1wi8Eh+i1DcwOlq+C9jG0bE6bfSEsP+g0=; b=tzPcXYBbV6as1qPUfpq8/V7jbfFWYK5L21sWzSRjPN3rcQaK4bnfqZz0rdHrWPRjzP 5LOe0sGIle7oHI4knnnbMjYwdzn9DMoFaZKLECtl+7fjVt6VdP9IHH35Ob0azTdOo3Z1 5IINk3u0SxKUgKqwK1h/11cDEYAAvqShumb/G4JYB1Ef1Izxt0RdAEVtirq6sPLre0Ct J2vIyjGofTykbgPOMEkoriseTTDWa8AVATSoD+Cmz2ZtipN6CVXqyLiWFIqldpgQTBJE XpyK4E+xc/ouHmON2+VSbhMhgY2d6mulqAooS30F/msxEInrGytq7YCKAmEH/TCAE6Mw VlaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xpWmjvHw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si6369789pgc.122.2019.03.08.05.06.02; Fri, 08 Mar 2019 05:06:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xpWmjvHw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727673AbfCHM6m (ORCPT + 99 others); Fri, 8 Mar 2019 07:58:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:35036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728044AbfCHM6h (ORCPT ); Fri, 8 Mar 2019 07:58:37 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CD2BB20449; Fri, 8 Mar 2019 12:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552049916; bh=1iaQKpZ+NBJrfufJ5gS3ru8ut1VRLtvr4dXyWM+M6ww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xpWmjvHwmgIPXfApZ0AlZnnawruvDChKJQSs+RpxTsdH/eF0TM10cRGx9YczPk7vN v1DxVGHRut/RS9KSOxXxgNL2WuqGnY5YmIGhyW0xjyBUjo78K08RgB/bARUurSmfKc Bslj6lOJ5EoYLKagDAMhQSjobr5tSXr4gADJzZXI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianlin Shi , Hangbin Liu , "David S. Miller" Subject: [PATCH 4.19 26/68] ipv4: Add ICMPv6 support when parse route ipproto Date: Fri, 8 Mar 2019 13:49:56 +0100 Message-Id: <20190308124912.090410704@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190308124910.696595153@linuxfoundation.org> References: <20190308124910.696595153@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hangbin Liu [ Upstream commit 5e1a99eae84999a2536f50a0beaf5d5262337f40 ] For ip rules, we need to use 'ipproto ipv6-icmp' to match ICMPv6 headers. But for ip -6 route, currently we only support tcp, udp and icmp. Add ICMPv6 support so we can match ipv6-icmp rules for route lookup. v2: As David Ahern and Sabrina Dubroca suggested, Add an argument to rtm_getroute_parse_ip_proto() to handle ICMP/ICMPv6 with different family. Reported-by: Jianlin Shi Fixes: eacb9384a3fe ("ipv6: support sport, dport and ip_proto in RTM_GETROUTE") Signed-off-by: Hangbin Liu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/net/ip.h | 2 +- net/ipv4/netlink.c | 17 +++++++++++++---- net/ipv4/route.c | 2 +- net/ipv6/route.c | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) --- a/include/net/ip.h +++ b/include/net/ip.h @@ -687,7 +687,7 @@ extern int sysctl_icmp_msgs_burst; int ip_misc_proc_init(void); #endif -int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, +int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, u8 family, struct netlink_ext_ack *extack); #endif /* _IP_H */ --- a/net/ipv4/netlink.c +++ b/net/ipv4/netlink.c @@ -3,9 +3,10 @@ #include #include #include +#include #include -int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, +int rtm_getroute_parse_ip_proto(struct nlattr *attr, u8 *ip_proto, u8 family, struct netlink_ext_ack *extack) { *ip_proto = nla_get_u8(attr); @@ -13,11 +14,19 @@ int rtm_getroute_parse_ip_proto(struct n switch (*ip_proto) { case IPPROTO_TCP: case IPPROTO_UDP: + return 0; case IPPROTO_ICMP: + if (family != AF_INET) + break; + return 0; +#if IS_ENABLED(CONFIG_IPV6) + case IPPROTO_ICMPV6: + if (family != AF_INET6) + break; return 0; - default: - NL_SET_ERR_MSG(extack, "Unsupported ip proto"); - return -EOPNOTSUPP; +#endif } + NL_SET_ERR_MSG(extack, "Unsupported ip proto"); + return -EOPNOTSUPP; } EXPORT_SYMBOL_GPL(rtm_getroute_parse_ip_proto); --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2814,7 +2814,7 @@ static int inet_rtm_getroute(struct sk_b if (tb[RTA_IP_PROTO]) { err = rtm_getroute_parse_ip_proto(tb[RTA_IP_PROTO], - &ip_proto, extack); + &ip_proto, AF_INET, extack); if (err) return err; } --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -4907,7 +4907,8 @@ static int inet6_rtm_getroute(struct sk_ if (tb[RTA_IP_PROTO]) { err = rtm_getroute_parse_ip_proto(tb[RTA_IP_PROTO], - &fl6.flowi6_proto, extack); + &fl6.flowi6_proto, AF_INET6, + extack); if (err) goto errout; }