Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3998396pxb; Mon, 1 Feb 2021 09:46:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpWs/mtixj99VBMnCePck4SfvflGtGEf0DbwnThLx78fT+4zq5Gw3kpCS8bZ4ztBjpy5y8 X-Received: by 2002:a05:6402:11d3:: with SMTP id j19mr19969964edw.314.1612201560720; Mon, 01 Feb 2021 09:46:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612201560; cv=none; d=google.com; s=arc-20160816; b=xoAe0ed6pX/068paeYrQI8YgO8uJ99EcI9a8IAYBoSbAIxDRaTqDY0KDmo15KJKbcu cq5wpdwyR4dRZ57LPfvcEVl5iLHZjX42EQj+2XXUjJJszl+GbyaYWkk7MEBrxl0ozi84 F7hrgUO8nf5FVAZUDHBVR6flAllJcHY3YKzoCBYS/bkJIyUqI8AQ53Crw65G09tZUH61 9wSjev6F44zmzLjhvhxmWkFVt4X+LaXMpJm2l01/I6fPqGwv7OP4SnoCePEN0YFuz1+n q0C0BlQrVCQISO7BX4KYFkbn4nD5lpjmx6Nec43y2mNiq6tdAm+bDjbDYCLh4Z2yjEkJ AJbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=WhoU2kUvRuKMZfhfUtEuI8scs93aknEYSDxR+JVYRps=; b=P4+ecYdLIPA0vk9n4J8ObNFbEYg02NQ3mYoTA70SNrFkS2r6wI/xTZpICZniJgBKCw IADN5voeoNr7VfxywTH26dL1/lIyY3j5aLLT1Xm3YcC3+/rnVc/1jkEi6dV6e3nq+Lwh 3u2M343zpNV1q23tmDGFHqdXKh5xKu6N8GNnqBRkKVwu7doyUZ1urg2+cmShTXXwhwhi 3rImWH9w3soEkAfIJOn5zreG+kO5YHhJXXKPGnXeu3BicLQLouF4tJ4CftLyf4kppn4d O/2Z81kXTH13EqyKfK9K6MOq+RNHGwZg5RVuXCkIeEi4I7cdtb9Cofi2r9xO2EnbY+Wi QbWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KU98d4kr; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id go43si9698193ejc.565.2021.02.01.09.45.35; Mon, 01 Feb 2021 09:46:00 -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=@google.com header.s=20161025 header.b=KU98d4kr; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232173AbhBARoC (ORCPT + 99 others); Mon, 1 Feb 2021 12:44:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232374AbhBARmZ (ORCPT ); Mon, 1 Feb 2021 12:42:25 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BFA0C061756 for ; Mon, 1 Feb 2021 09:41:45 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id n4so10000522plx.23 for ; Mon, 01 Feb 2021 09:41:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=WhoU2kUvRuKMZfhfUtEuI8scs93aknEYSDxR+JVYRps=; b=KU98d4krPaUHsAn32CGyAdUpfMcKfAapZLi1h3ETI4Xj2cS7ct5tAL0PBk3hNyh+4F f6C/L+DBV2fcxpoocnFtCLDzgBwqhGXFW6ud1+842/nqwdI+9r5VPoGxxwJGrKfH5lae dUmNB6zMv9UgKnJTBDW5Vi9at6S4Mqh6I/8LSC/kN8yqBZhVX/9IucdkYtFi7U5leEe7 /rCvm03724Lsa3nzkzckikvsjoMGEOTQWejsyC/z8MrAkLzTR3gOZNBeS5N0ipPmnzB0 2PHl0NtY47LwwgL4bfd7plCyaUyJCbcrbhm8pPdhnvyOT1XfIDzC6kVCwiMRJyULFAxR 9SWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=WhoU2kUvRuKMZfhfUtEuI8scs93aknEYSDxR+JVYRps=; b=m6Zj352e3/rX5d5XIWXfyKuHzExcd6/STV5oip3pZI/hsuLHaSn+CAj+AwKsiGGouh X2mfZwj7czR4kQgOYJZG4bcFhJW+/IggrK+M32KPaScrVjU0qnX5unWtACsycqvv/uEu 7SYOCsole5R0aOLaO4E3hBOiGsAL3PYmyWZ3UTPmJc8jkyvrDRfovbSfddZ5R6UwsLAx epvK7KAnR+rMGQURwy8t1C8r8E2tfIozFjxGfgbFPSHdFuGumX7uC8sLPx4elI/bqdE8 XJcWTDWmioaXJiAB7z79vO2JPXUtV4+OCbjsuDZj5Mu40qstJG8Wm6ulUOi+V0TqSA4K bolg== X-Gm-Message-State: AOAM532CjRD2iBB8YtlVBu8x33xwarzfLR9hOYDmab5mmpwJWZKihPld 4oQFPMdXxL1tPuy0oA00g5WR05678+KV Sender: "brianvv via sendgmr" X-Received: from brianvv.c.googlers.com ([fda3:e722:ac3:10:7f:e700:c0a8:348]) (user=brianvv job=sendgmr) by 2002:a17:90a:3f08:: with SMTP id l8mr75900pjc.1.1612201304394; Mon, 01 Feb 2021 09:41:44 -0800 (PST) Date: Mon, 1 Feb 2021 17:41:31 +0000 In-Reply-To: <20210201174132.3534118-1-brianvv@google.com> Message-Id: <20210201174132.3534118-4-brianvv@google.com> Mime-Version: 1.0 References: <20210201174132.3534118-1-brianvv@google.com> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH net-next v3 3/4] net: use indirect call helpers for dst_mtu From: Brian Vazquez To: Brian Vazquez , Brian Vazquez , Eric Dumazet , Luigi Rizzo , "David S . Miller" , Jakub Kicinski Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch avoids the indirect call for the common case: ip6_mtu and ipv4_mtu Signed-off-by: Brian Vazquez --- include/net/dst.h | 4 +++- net/ipv4/route.c | 6 ++++-- net/ipv6/route.c | 6 ++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/net/dst.h b/include/net/dst.h index 3932e9931f08..9f474a79ed7d 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -194,9 +194,11 @@ dst_feature(const struct dst_entry *dst, u32 feature) return dst_metric(dst, RTAX_FEATURES) & feature; } +INDIRECT_CALLABLE_DECLARE(unsigned int ip6_mtu(const struct dst_entry *)); +INDIRECT_CALLABLE_DECLARE(unsigned int ipv4_mtu(const struct dst_entry *)); static inline u32 dst_mtu(const struct dst_entry *dst) { - return dst->ops->mtu(dst); + return INDIRECT_CALL_INET(dst->ops->mtu, ip6_mtu, ipv4_mtu, dst); } /* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */ diff --git a/net/ipv4/route.c b/net/ipv4/route.c index e26652ff7059..4fac91f8bd6c 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -135,7 +135,8 @@ static int ip_rt_gc_timeout __read_mostly = RT_GC_TIMEOUT; static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie); static unsigned int ipv4_default_advmss(const struct dst_entry *dst); -static unsigned int ipv4_mtu(const struct dst_entry *dst); +INDIRECT_CALLABLE_SCOPE +unsigned int ipv4_mtu(const struct dst_entry *dst); static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst); static void ipv4_link_failure(struct sk_buff *skb); static void ip_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, @@ -1311,7 +1312,7 @@ static unsigned int ipv4_default_advmss(const struct dst_entry *dst) return min(advmss, IPV4_MAX_PMTU - header_size); } -static unsigned int ipv4_mtu(const struct dst_entry *dst) +INDIRECT_CALLABLE_SCOPE unsigned int ipv4_mtu(const struct dst_entry *dst) { const struct rtable *rt = (const struct rtable *)dst; unsigned int mtu = rt->rt_pmtu; @@ -1333,6 +1334,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst) return mtu - lwtunnel_headroom(dst->lwtstate, mtu); } +EXPORT_SYMBOL(ipv4_mtu); static void ip_del_fnhe(struct fib_nh_common *nhc, __be32 daddr) { diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 41d8f801b75f..4d83700d5602 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -83,7 +83,8 @@ enum rt6_nud_state { static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie); static unsigned int ip6_default_advmss(const struct dst_entry *dst); -static unsigned int ip6_mtu(const struct dst_entry *dst); +INDIRECT_CALLABLE_SCOPE +unsigned int ip6_mtu(const struct dst_entry *dst); static struct dst_entry *ip6_negative_advice(struct dst_entry *); static void ip6_dst_destroy(struct dst_entry *); static void ip6_dst_ifdown(struct dst_entry *, @@ -3089,7 +3090,7 @@ static unsigned int ip6_default_advmss(const struct dst_entry *dst) return mtu; } -static unsigned int ip6_mtu(const struct dst_entry *dst) +INDIRECT_CALLABLE_SCOPE unsigned int ip6_mtu(const struct dst_entry *dst) { struct inet6_dev *idev; unsigned int mtu; @@ -3111,6 +3112,7 @@ static unsigned int ip6_mtu(const struct dst_entry *dst) return mtu - lwtunnel_headroom(dst->lwtstate, mtu); } +EXPORT_SYMBOL(ip6_mtu); /* MTU selection: * 1. mtu on route is locked - use it -- 2.30.0.365.g02bc693789-goog