Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1650752pxu; Sat, 12 Dec 2020 22:06:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzepZXwcuKMjLKKQxBLGqGNX2a7jAhPcGb/65C7HK6Nu+vjdEpHaFtxVHDFNDMGXpFHcNK X-Received: by 2002:a05:6402:229c:: with SMTP id cw28mr243736edb.285.1607839566089; Sat, 12 Dec 2020 22:06:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607839566; cv=none; d=google.com; s=arc-20160816; b=k6ypyOHpqFYO4eqXwe3vdh5ncdsmseTQhQfg3Qdb5Xle1lplWzrp+6dw/+PBAnJmiM 5xBOOHOJiRoZX3prR8RBb/8P/5aO3VgautI8o0x2dXWXTK0o/SnyASfyGKmN647gnknC 3LdP6XLlmyqKqY1Sy+KvIiZ7AG2JoLmzIeCNzsS+nqtWnttwfS76lRckQpapm0zk8SyZ 2Nls5YzwDAL1AGSapf8bCONwtdsaU9WmnpX8uwmnSrPkw11/pS3QgsGzhRWIzMmV7nDL Wyo+8gbwaW0pWLU8RfHYh+j6uNBTlm26v3NsaQn2+eqO8lPVFXiFn2KDyLpzgHORxoEz UXvw== 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=C5GRxECZMSAf9dCnY0cH/nYiIjSrdOWOHdN7BXATNyw=; b=o1Jg0ZVqpOgBtTW1B0AGoBOXLq1eLhcSZxQ0WukHXyHWvMGBSQR50fKMD4OeKfjKpI b6a7lVx1BkNHF2a7lE3+RjN82J6vRkHK9bAVvvNtiKHxBf6B3AKLi0JJu52Abz0V/Sdo 9b9e1ocKxL9q6PUrOCQsHbPK/WKFwk3xxe4xeQpit6IkDpjAHla+bLuESI6sMOBeV+yu MgKwwJMnAln6x9NttlfMwsz9b+EjiAb7utmia1DF73KFlLa7O8ekJNmMyLUy/p+/07Gu PStVtWjHVp1Ui2YKPeQmIpBWudoGwpnQn1kDpJXvMT3u57ZfYIIbKa4AhvXFKYNsq+xD Lmaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Sx+p6f2+; 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 l7si8523955edv.409.2020.12.12.22.05.43; Sat, 12 Dec 2020 22:06:06 -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=Sx+p6f2+; 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 S2437264AbgLKXfX (ORCPT + 99 others); Fri, 11 Dec 2020 18:35:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437382AbgLKXfF (ORCPT ); Fri, 11 Dec 2020 18:35:05 -0500 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E7BC0617B0 for ; Fri, 11 Dec 2020 15:33:50 -0800 (PST) Received: by mail-pf1-x449.google.com with SMTP id x20so7283710pfm.6 for ; Fri, 11 Dec 2020 15:33:50 -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=C5GRxECZMSAf9dCnY0cH/nYiIjSrdOWOHdN7BXATNyw=; b=Sx+p6f2+gq+Kdb4ohqFEnhQL+OWLM+Y3KCDTByYTlOqjisNR8gdz9Re64WWVyRflP/ QI9esAqrkUZz5a2XFGeX9HZf0mBeI3rsC0NdINzu/gmL3Kf3Xa7LIX2duwGZJGY0hGe2 LTj2aWm9XswFcXWR9pDLUVXzNnJbI2HKGrwrOQ5dmX8ztYwT3t4sNC/ZU1cJBFyjgBZ4 oNqYbSCjAkRc3naqdyX6wP6fDhKdYdEANMNgRwnUCHokS6dj8ZWzFhIWckfyLqGjWEDN r1s2ZjN0FFCwmlxOHAq5q7fdh4VHCGa07wYME5cBikzFxhsUm200E/qpvCEGmH4Zvx6S k6Lg== 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=C5GRxECZMSAf9dCnY0cH/nYiIjSrdOWOHdN7BXATNyw=; b=bjDywe/ac/gGISkHyP4Fsft/EA2zjA0PpomKDWhOSE6uwjSErFqD3laK0rUCIPJg1m N/vfg9KkMBTARHR01bREkS21qvhfG393EYp4dJIM7uK6r4Rqxz3VHM9Y28w9wsSPCcej pf7A3E0UzXtF2k9RZ60C2ouoqSdLkk7qhjb7vqsLSlo6hTNXFVG0h89qt9zYQhxyVO7P 0J1lmPebYqNfp0QUZ38r5wGj+IzF/6CkSgT76lTUMCp0rTbYFGgMtnTe/FGe1KuiqzjU 3W75ILkMfZZA3g70E0LweGWxslUUPcNCUFfqPZAuqEZkiFommwMwHF6bdliw9gItuiXu VPZg== X-Gm-Message-State: AOAM532HOX49+1mNziCK8Y6SHlqw5mAch/jIXPVTyu4Dkjj6Kthi1SFm tD1xKLMCvsK+zUjCOFzOJXQZYsEW4n7K 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:8a82:: with SMTP id x2mr15080767pjn.107.1607729630321; Fri, 11 Dec 2020 15:33:50 -0800 (PST) Date: Fri, 11 Dec 2020 23:33:40 +0000 In-Reply-To: <20201211233340.1503242-1-brianvv@google.com> Message-Id: <20201211233340.1503242-5-brianvv@google.com> Mime-Version: 1.0 References: <20201211233340.1503242-1-brianvv@google.com> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog Subject: [PATCH net-next v2 4/4] net: indirect call helpers for ipv4/ipv6 dst_check functions 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_dst_check and ipv4_dst_check Signed-off-by: brianvv --- include/net/dst.h | 7 ++++++- net/core/sock.c | 12 ++++++++++-- net/ipv4/route.c | 7 +++++-- net/ipv4/tcp_ipv4.c | 5 ++++- net/ipv6/route.c | 7 +++++-- net/ipv6/tcp_ipv6.c | 5 ++++- 6 files changed, 34 insertions(+), 9 deletions(-) diff --git a/include/net/dst.h b/include/net/dst.h index 9f474a79ed7d..26f134ad3a25 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -459,10 +459,15 @@ static inline int dst_input(struct sk_buff *skb) ip6_input, ip_local_deliver, skb); } +INDIRECT_CALLABLE_DECLARE(struct dst_entry *ip6_dst_check(struct dst_entry *, + u32)); +INDIRECT_CALLABLE_DECLARE(struct dst_entry *ipv4_dst_check(struct dst_entry *, + u32)); static inline struct dst_entry *dst_check(struct dst_entry *dst, u32 cookie) { if (dst->obsolete) - dst = dst->ops->check(dst, cookie); + dst = INDIRECT_CALL_INET(dst->ops->check, ip6_dst_check, + ipv4_dst_check, dst, cookie); return dst; } diff --git a/net/core/sock.c b/net/core/sock.c index 4fd7e785f177..753b831a9d70 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -526,11 +526,17 @@ int __sk_receive_skb(struct sock *sk, struct sk_buff *skb, } EXPORT_SYMBOL(__sk_receive_skb); +INDIRECT_CALLABLE_DECLARE(struct dst_entry *ip6_dst_check(struct dst_entry *, + u32)); +INDIRECT_CALLABLE_DECLARE(struct dst_entry *ipv4_dst_check(struct dst_entry *, + u32)); struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie) { struct dst_entry *dst = __sk_dst_get(sk); - if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) { + if (dst && dst->obsolete && + INDIRECT_CALL_INET(dst->ops->check, ip6_dst_check, ipv4_dst_check, + dst, cookie) == NULL) { sk_tx_queue_clear(sk); sk->sk_dst_pending_confirm = 0; RCU_INIT_POINTER(sk->sk_dst_cache, NULL); @@ -546,7 +552,9 @@ struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie) { struct dst_entry *dst = sk_dst_get(sk); - if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) { + if (dst && dst->obsolete && + INDIRECT_CALL_INET(dst->ops->check, ip6_dst_check, ipv4_dst_check, + dst, cookie) == NULL) { sk_dst_reset(sk); dst_release(dst); return NULL; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 4fac91f8bd6c..9e6537709794 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -133,7 +133,8 @@ static int ip_rt_gc_timeout __read_mostly = RT_GC_TIMEOUT; * Interface to generic destination cache. */ -static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie); +INDIRECT_CALLABLE_SCOPE +struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie); static unsigned int ipv4_default_advmss(const struct dst_entry *dst); INDIRECT_CALLABLE_SCOPE unsigned int ipv4_mtu(const struct dst_entry *dst); @@ -1188,7 +1189,8 @@ void ipv4_sk_redirect(struct sk_buff *skb, struct sock *sk) } EXPORT_SYMBOL_GPL(ipv4_sk_redirect); -static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie) +INDIRECT_CALLABLE_SCOPE struct dst_entry *ipv4_dst_check(struct dst_entry *dst, + u32 cookie) { struct rtable *rt = (struct rtable *) dst; @@ -1204,6 +1206,7 @@ static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie) return NULL; return dst; } +EXPORT_SYMBOL(ipv4_dst_check); static void ipv4_send_dest_unreach(struct sk_buff *skb) { diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index af2338294598..aba5061024c7 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1646,6 +1646,8 @@ u16 tcp_v4_get_syncookie(struct sock *sk, struct iphdr *iph, return mss; } +INDIRECT_CALLABLE_DECLARE(struct dst_entry *ipv4_dst_check(struct dst_entry *, + u32)); /* The socket must have it's spinlock held when we get * here, unless it is a TCP_LISTEN socket. * @@ -1665,7 +1667,8 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) sk_mark_napi_id(sk, skb); if (dst) { if (inet_sk(sk)->rx_dst_ifindex != skb->skb_iif || - !dst->ops->check(dst, 0)) { + !INDIRECT_CALL_1(dst->ops->check, ipv4_dst_check, + dst, 0)) { dst_release(dst); sk->sk_rx_dst = NULL; } diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 22caee290b6c..e074fb5964e2 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -81,7 +81,8 @@ enum rt6_nud_state { RT6_NUD_SUCCEED = 1 }; -static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie); +INDIRECT_CALLABLE_SCOPE +struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie); static unsigned int ip6_default_advmss(const struct dst_entry *dst); INDIRECT_CALLABLE_SCOPE unsigned int ip6_mtu(const struct dst_entry *dst); @@ -2612,7 +2613,8 @@ static struct dst_entry *rt6_dst_from_check(struct rt6_info *rt, return NULL; } -static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie) +INDIRECT_CALLABLE_SCOPE struct dst_entry *ip6_dst_check(struct dst_entry *dst, + u32 cookie) { struct dst_entry *dst_ret; struct fib6_info *from; @@ -2642,6 +2644,7 @@ static struct dst_entry *ip6_dst_check(struct dst_entry *dst, u32 cookie) return dst_ret; } +EXPORT_SYMBOL(ip6_dst_check); static struct dst_entry *ip6_negative_advice(struct dst_entry *dst) { diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 1a1510513739..9e61e4fda03e 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -1417,6 +1417,8 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff * return NULL; } +INDIRECT_CALLABLE_DECLARE(struct dst_entry *ipv4_dst_check(struct dst_entry *, + u32)); /* The socket must have it's spinlock held when we get * here, unless it is a TCP_LISTEN socket. * @@ -1470,7 +1472,8 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) sk_mark_napi_id(sk, skb); if (dst) { if (inet_sk(sk)->rx_dst_ifindex != skb->skb_iif || - dst->ops->check(dst, np->rx_dst_cookie) == NULL) { + INDIRECT_CALL_1(dst->ops->check, ip6_dst_check, + dst, np->rx_dst_cookie) == NULL) { dst_release(dst); sk->sk_rx_dst = NULL; } -- 2.29.2.576.ga3fc446d84-goog