Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp418155pxb; Wed, 3 Mar 2021 06:37:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJArZ0KKbuj+i38da0wLi1XeMPJG0wDAItHjmERmRJgWgTt7N4PtB8DOKRIMytyh/9RR7d X-Received: by 2002:a17:906:271b:: with SMTP id z27mr25592670ejc.313.1614782246292; Wed, 03 Mar 2021 06:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614782246; cv=none; d=google.com; s=arc-20160816; b=mBlAj0K28s1ExtRrNqHwZGDN0EaqQDnktj1jyq7cKA67tQnAxyULkhqzkmZyqWclvi y3tg/hTxftr0AjN/iL1GM6CaFEhuD8Ddk/1ZAQfiIz9iuWXpG9e1mDbn/jmjQyxd7YPk j//db4i2w/n8LL5fH0XLXuqvLnnp/xod9+rc4qSFA1LHcrwpoKpJLv82Sbc8J4ru07Rb e8H+2sD1B14SzwEQGby/S0ORVsZPhboLAUHg8nNBzUifZhiCThD4Kd8Ctw75/HjurveC 7WEcXJ09zhtEatFp2gllRBWXLq2e383yE36/lpyqDu927by/WIQPicocewK86K5aTGVs yHBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aoaU0qXFH4JRoRNJyHVOgV69XcdKdoxdKw+NO21KxPk=; b=sQv3qwBYr+LKOI9SAeir6hqDaXuBaGdfV9xbrBjXGb0JfO4txUJ3idGxqLTk6wCN4d c6JUyEpN2ugXibOTfffYeloTQX1XwZ8ZucLfNuIym6XZRh1rtuIbYjOj09LgFa1z8Sv8 gV5wT3UQxbKx+AOCub5ebepKJ7VY9VjyXRoPsWr2cjXQjeW2wA/2pJ4SsLdXK96l+ZqM ZMYFa72LLev+ZyiMP9OQ1um67eUINWsyAoxVfT5LFPQFbMxdgCNQc7BmsOsoQkNXM8NL aCtaHPWGx0KC171eZ8FLYwiCQTb4y76gqnyD0IbfmIWIDeNOB8ye3wIvEIw1MTTUJsJm y8GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DK7Kyt5z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h12si14470393edk.467.2021.03.03.06.36.42; Wed, 03 Mar 2021 06:37:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DK7Kyt5z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244312AbhCAV23 (ORCPT + 99 others); Mon, 1 Mar 2021 16:28:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:57224 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237938AbhCARSU (ORCPT ); Mon, 1 Mar 2021 12:18:20 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8603264F8D; Mon, 1 Mar 2021 16:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617217; bh=wOVN1u2LGymUx/373gRg6Rpugo8cKvlLKTL4NLEV9QQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DK7Kyt5zQW9AqeUTLwTk6KVdYgVdLqqwV/sVno2EiTBll892qC8uEAjLUfd9vV3ug T/Xgh2pmql/5eTaqzdGrW1vf2mzOM0iW2PZlNkXW6zWf+cdWrSqA6LKxFmg5U8C+vv muocYn/O0tp2RDc1QyRYtlDe9eLHsPZH0WjeYIUs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: [PATCH 4.19 243/247] ipv6: icmp6: avoid indirect call for icmpv6_send() Date: Mon, 1 Mar 2021 17:14:23 +0100 Message-Id: <20210301161043.606826156@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet commit cc7a21b6fbd945f8d8f61422ccd27203c1fafeb7 upstream. If IPv6 is builtin, we do not need an expensive indirect call to reach icmp6_send(). v2: put inline keyword before the type to avoid sparse warnings. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/linux/icmpv6.h | 22 +++++++++++++++++++++- net/ipv6/icmp.c | 5 +++-- net/ipv6/ip6_icmp.c | 10 +++++----- 3 files changed, 29 insertions(+), 8 deletions(-) --- a/include/linux/icmpv6.h +++ b/include/linux/icmpv6.h @@ -13,12 +13,32 @@ static inline struct icmp6hdr *icmp6_hdr #include #if IS_ENABLED(CONFIG_IPV6) -extern void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info); typedef void ip6_icmp_send_t(struct sk_buff *skb, u8 type, u8 code, __u32 info, const struct in6_addr *force_saddr); +#if IS_BUILTIN(CONFIG_IPV6) +void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, + const struct in6_addr *force_saddr); +static inline void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info) +{ + icmp6_send(skb, type, code, info, NULL); +} +static inline int inet6_register_icmp_sender(ip6_icmp_send_t *fn) +{ + BUILD_BUG_ON(fn != icmp6_send); + return 0; +} +static inline int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn) +{ + BUILD_BUG_ON(fn != icmp6_send); + return 0; +} +#else +extern void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info); extern int inet6_register_icmp_sender(ip6_icmp_send_t *fn); extern int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn); +#endif + int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type, unsigned int data_len); --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c @@ -418,8 +418,8 @@ static int icmp6_iif(const struct sk_buf /* * Send an ICMP message in response to a packet in error */ -static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, - const struct in6_addr *force_saddr) +void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, + const struct in6_addr *force_saddr) { struct inet6_dev *idev = NULL; struct ipv6hdr *hdr = ipv6_hdr(skb); @@ -592,6 +592,7 @@ out: out_bh_enable: local_bh_enable(); } +EXPORT_SYMBOL(icmp6_send); /* Slightly more convenient version of icmp6_send. */ --- a/net/ipv6/ip6_icmp.c +++ b/net/ipv6/ip6_icmp.c @@ -9,6 +9,8 @@ #if IS_ENABLED(CONFIG_IPV6) +#if !IS_BUILTIN(CONFIG_IPV6) + static ip6_icmp_send_t __rcu *ip6_icmp_send; int inet6_register_icmp_sender(ip6_icmp_send_t *fn) @@ -37,14 +39,12 @@ void icmpv6_send(struct sk_buff *skb, u8 rcu_read_lock(); send = rcu_dereference(ip6_icmp_send); - - if (!send) - goto out; - send(skb, type, code, info, NULL); -out: + if (send) + send(skb, type, code, info, NULL); rcu_read_unlock(); } EXPORT_SYMBOL(icmpv6_send); +#endif #if IS_ENABLED(CONFIG_NF_NAT) #include