From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28A14C43381 for ; Wed, 27 Feb 2019 08:15:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB5AE218E0 for ; Wed, 27 Feb 2019 08:15:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z0krHlL2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729558AbfB0IPn (ORCPT ); Wed, 27 Feb 2019 03:15:43 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:44978 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbfB0IPn (ORCPT ); Wed, 27 Feb 2019 03:15:43 -0500 Received: by mail-pl1-f196.google.com with SMTP id c4so7612647pls.11 for ; Wed, 27 Feb 2019 00:15:43 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=/b6saLRwCU0ODaeXcT+GTcd2R52STlhzzemJxZEHoks=; b=Z0krHlL2uGS2oCYemX1w++iNyPZObrwcnfFa9cNTctnwMPSS8IfjIIAZpqROY3IKZt RRTVH0xjfHjR015epQS3qA977chMYWJhECj/sYpNLkDNO5keFtBJrmZW/1vDVegIKREl 5WB6Eb4xvMpUWg1oP23ZOwPQTXxITMPeoU76rLKgGI/ZxnBjGtry9I8FSwJVJY5+xxnH VnFS1W3k8Okt05rMgMCiAWgTE9MWqP5oLo1WL4FcSDGBO8SXgLjkGoXs1bOHh1ggbqMK qwPM9HBm7bcRySnsaAOIJjgFhYLKhYwtaaxfD2XfolNeP41iqXR/yZC3z/XCkKqHkTFb coHQ== 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:mime-version:content-transfer-encoding; bh=/b6saLRwCU0ODaeXcT+GTcd2R52STlhzzemJxZEHoks=; b=uaqXod8jqtg1zHDFisG1G/c49gYA2XB+QyORVSQJTBWX2Lkji4Zg1/jJ85C1uIosBk PX3kvTPPw62Wwa+hhz+dQnf3g0Qz5WrebcuqxGplt9Mr9Ay3Ne1E+HBereDMQPfvV8EA 8gXza9LmU049HZMYI+Le5haKflv1Vg8MpJlOWfol5s7XYiTl7VE3hPPUPCaN0kR4nI2N 357QtQ3Mj17o1WrrGJKzk1vO9TOCFRVLrV5NrTH4wsXIZ+mQH0UyUC7J+ed29DOZaXBW htV5uuyoriBCMdsaViWeni0zWXGGjnHxZZuRAat23E08Rsd1vi0RSgm+aPYmEhRHFgnM Rl1w== X-Gm-Message-State: AHQUAuZb+dHMZydevz0whqSUAkEokYNnn3AaRy7ymTnQ9rK03kMvrwNa qZwzKOXiTA3iWQIHaG5HCDiR/+P5OVI= X-Google-Smtp-Source: AHgI3IZr36D8JTMKkelNme3LRiRwWsgVuDjHVjgBss6v91mdxu/CJhKh6aITiol8VGGmpoPJgOMXDQ== X-Received: by 2002:a17:902:6686:: with SMTP id e6mr901791plk.208.1551255342752; Wed, 27 Feb 2019 00:15:42 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id f125sm1627453pfc.91.2019.02.27.00.15.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 00:15:42 -0800 (PST) From: Hangbin Liu To: netdev@vger.kernel.org Cc: David Ahern , Roopa Prabhu , davem@davemloft.net, Sabrina Dubroca , Hangbin Liu Subject: [PATCH v2 net] ipv4: Add ICMPv6 support when parse route ipproto Date: Wed, 27 Feb 2019 16:15:29 +0800 Message-Id: <20190227081529.23657-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190225074700.7316-1-liuhangbin@gmail.com> References: <20190225074700.7316-1-liuhangbin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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(-) diff --git a/include/net/ip.h b/include/net/ip.h index 8866bfce6121..80300e8a6280 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -716,7 +716,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 */ diff --git a/net/ipv4/netlink.c b/net/ipv4/netlink.c index f86bb4f06609..d8e3a1fb8e82 100644 --- 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 nlattr *attr, u8 *ip_proto, 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); diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 5163b64f8fb3..7bb9128c8363 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -2803,7 +2803,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, 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; } diff --git a/net/ipv6/route.c b/net/ipv6/route.c index ce15dc4ccbfa..6f949aa5b64f 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -4889,7 +4889,8 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, 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; } -- 2.19.2