Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp861620pxu; Fri, 11 Dec 2020 16:48:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuQ0M7BlRvUYZT5MmkcmFETaMBP77EuxLmZgSpeeYNdGYVlB9Wwg5Lkjie9d/hJqj2cO7q X-Received: by 2002:a50:c406:: with SMTP id v6mr15119368edf.367.1607734094749; Fri, 11 Dec 2020 16:48:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607734094; cv=none; d=google.com; s=arc-20160816; b=wEFkyhzJCOSs3rAd9ZsOL0Hq/onfXvRlpgt0BYvcNQewz/HTLaB3zEduPcn5WmuEV1 dlJeiz3OIax6UPsmXp5ZTFcpBrLg+zqkS7ougLXBzChzs3moLyhPQxMv8kTThEdc3LYf pjBl1Dk7ytN0Frup03eQDaUmOSS9DSSGw6SjoRQB72HwidUoWXz4bzC8ve6ikvbOMTCw lrRxtCtFM/1RnE5xpz4LzZZaWrdBaCAVlb9kAouZ9Rht2V0FjgrOGLe5fRT/zL3HW5N8 C3LmNNHVHMnqyuC9GHV4vDR1VYT1AqsKCGZZpBG4gZb9SeVRa/ZJrR9E2O2nuC42Qzx/ G+3Q== 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=thwvCtn6LNG/FDpSFGyZ6Wmg72wk3C6bCvqdBXCPvKo=; b=hJZHQMVzRh0pQZr5KUiFJEkB7s9iYXp84pv52nuf4KAEvgb0KEWtxkhSPVIOlBS2bF 1/KNtD2Ef+2CjruFMT+NzJMu+BWn9cwhVHabj9NP+wmZsA97x+J7bCTvHL9M5AEXlRL2 fqcYvNWYI83rOsRynENWpGX20tOi9xJfj7tAeEbevBG282Wc6xdimwnCGz2qzIk8ZbzL ruSF+kd1tJ7EFUpQJYM5TKZFNyqG0RXA8vPdvb8HnXG/KVTfdUH1GNIT9EtuNh0sKMtC IlzDMDjmMt9vlrXu6X6yUFTknru5A9seozQYDkpydbyUV/mdpHeWFayxpmW2xK+H6Z0A vUiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="a8/DNSDq"; 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 y4si5887491edp.451.2020.12.11.16.47.11; Fri, 11 Dec 2020 16:48:14 -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="a8/DNSDq"; 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 S2391670AbgLKCAC (ORCPT + 99 others); Thu, 10 Dec 2020 21:00:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391607AbgLKB7u (ORCPT ); Thu, 10 Dec 2020 20:59:50 -0500 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19F1EC0617A7 for ; Thu, 10 Dec 2020 17:58:35 -0800 (PST) Received: by mail-qk1-x74a.google.com with SMTP id t127so5394906qkf.0 for ; Thu, 10 Dec 2020 17:58:35 -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=thwvCtn6LNG/FDpSFGyZ6Wmg72wk3C6bCvqdBXCPvKo=; b=a8/DNSDqSFYuM4vlu1Nh8GoAoU/a0wAqBG4bORngP+gURnE0AIhr6hxeKYy6LArvlv ngaB6UXYn8N24qxxq/ph04+wGnd9v1eLX+q+K8p2B2WDfXPexQ5H2ZmUmov+o2DfryuW 0WWg1W7ZjOEiJDkjl2gCn/iZk98tXAGcAZet5pHYZrFa9+PT0XA4e6Eu2Ecl9trOJ12G NpypZ/VaR82IQg8Mg1NlyoW4qaKry964GMsxWjwpDXslPje6NNyeCnMIEjwHSyCJlOD4 eNAN6xxSAPl1078mCOnMpBLF3/T00FMtkQJsx6Kho6h9249YPNfu+k2D9P/cxccqzJVj y15w== 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=thwvCtn6LNG/FDpSFGyZ6Wmg72wk3C6bCvqdBXCPvKo=; b=H4cbzx02Xr6Y9vMYCQJ2Y2F0F2+nkPty3l7ZLPj7Vdzf41I61HRdAeHtW62Bf6dUwc cA/N1DHvUABMILTyuag4LK6UzCwtRdIEYjftHeo2HomBRmwRfeM8jVTWZ1OA3k1BA/R2 +6HxEFSgYBSI0L4YI+1LsELNFDruFcHFnlm65vTgCQ7iz5prd4lrWHuY1hExyUstM0u0 t0OjFs+eRTTlel8Q8wp7V++TbIudIOV1MbdpmWYyu8VinF+JZO3ps8IeM/SCX14h9Qgh RxSbZe3Adu49RqU7xt37FHGle0fzbmbL+cmW2KOCsW8FiZZUBLmfz/SKwj/wSaJs/7fA aH6g== X-Gm-Message-State: AOAM533/T00pnXcFsa/9ehCTuCjU9FKGiy2ZcH8CE5VzD70eATiaNuVb eXp/4IcIiyDkntsgBL5SXYavftTx6JGx 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:a0c:f20f:: with SMTP id h15mr12835454qvk.54.1607651914229; Thu, 10 Dec 2020 17:58:34 -0800 (PST) Date: Fri, 11 Dec 2020 01:58:22 +0000 In-Reply-To: <20201211015823.1079574-1-brianvv@google.com> Message-Id: <20201211015823.1079574-4-brianvv@google.com> Mime-Version: 1.0 References: <20201211015823.1079574-1-brianvv@google.com> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog Subject: [PATCH net-next 3/4] net: use indirect call helpers for dst_mtu From: Brian Vazquez To: Brian Vazquez , Brian Vazquez , Eric Dumazet , "David S . Miller" 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 From: brianvv This patch avoids the indirect call for the common case: ip6_mtu and ipv4_mtu Signed-off-by: brianvv --- 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 188e114b29b4..22caee290b6c 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.29.2.576.ga3fc446d84-goog