From patchwork Fri Mar 30 17:53:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 893453 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="Y0qZr1oH"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40CTXJ2BN0z9s0t for ; Sat, 31 Mar 2018 04:44:48 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752511AbeC3Roq (ORCPT ); Fri, 30 Mar 2018 13:44:46 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:35516 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751868AbeC3Rnu (ORCPT ); Fri, 30 Mar 2018 13:43:50 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2UHUrK2028026; Fri, 30 Mar 2018 17:43:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=um1xh4seFaBRxSrYNlyqvWn0Pv241pbW6Xt7RtIgyKA=; b=Y0qZr1oHNEWsnC7XWL4Mv0f3qLNWzEwftcQpjezNq737d5L+TnF3wRKAKmjyZtf3Qqo4 x6dKWed+nbrqSXzfQWozAaoWiHDfvyApLWBljf8zzcfPX1wYZ+u2xoyMJP3ljJqUt9wl 4JYyM/W/n7eoCrj6UPfeR7MVBt6AGYdGTYIeTeGqGtNiDGaW+iUlrjxMBH1gRqBhIsLn eE4NQ0yC1T2hK+aw/o0llvuduZqvHpe8dX7ydjV9ZN6nrjyejW/U4U8yOJX+QjZrI2Rn 6jRDIWIFgNHdVRnbRyTbrLKmbcCi25bO2HgDlYVy4g6JLI5QSaq5k996hRdEzJgeaQMW EA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2h1sq2g1b5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Mar 2018 17:43:47 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w2UHhkPL007385 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Mar 2018 17:43:46 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2UHhk31028527; Fri, 30 Mar 2018 17:43:46 GMT Received: from ak.ru.oracle.com (/10.162.80.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 30 Mar 2018 10:43:45 -0700 From: Alexey Kodanev To: netdev@vger.kernel.org Cc: Eric Dumazet , Martin KaFai Lau , David Miller , Alexey Kodanev Subject: [PATCH net v4 1/3] ipv6: add a wrapper for ip6_dst_store() with flowi6 checks Date: Fri, 30 Mar 2018 20:53:07 +0300 Message-Id: <1522432389-15850-2-git-send-email-alexey.kodanev@oracle.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1522432389-15850-1-git-send-email-alexey.kodanev@oracle.com> References: <1522432389-15850-1-git-send-email-alexey.kodanev@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8848 signatures=668697 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=976 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803300175 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move commonly used pattern of ip6_dst_store() usage to a separate function - ip6_dst_store_flow(), which will check the addresses for equality using the flow information, before saving them. There is no functional changes in this patch. In addition, it will be used in the next patch, in ip6_sk_dst_lookup_flow(). Signed-off-by: Alexey Kodanev --- include/net/ipv6.h | 3 ++- net/ipv6/datagram.c | 9 +-------- net/ipv6/ip6_output.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 8606c91..1dd31ca 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -971,7 +971,8 @@ static inline struct sk_buff *ip6_finish_skb(struct sock *sk) } unsigned int ip6_dst_mtu_forward(const struct dst_entry *dst); - +void ip6_dst_store_flow(struct sock *sk, struct dst_entry *dst, + const struct flowi6 *fl6); int ip6_dst_lookup(struct net *net, struct sock *sk, struct dst_entry **dst, struct flowi6 *fl6); struct dst_entry *ip6_dst_lookup_flow(const struct sock *sk, struct flowi6 *fl6, diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index a9f7eca..8b4fa0c 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -106,14 +106,7 @@ int ip6_datagram_dst_update(struct sock *sk, bool fix_sk_saddr) } } - ip6_dst_store(sk, dst, - ipv6_addr_equal(&fl6.daddr, &sk->sk_v6_daddr) ? - &sk->sk_v6_daddr : NULL, -#ifdef CONFIG_IPV6_SUBTREES - ipv6_addr_equal(&fl6.saddr, &np->saddr) ? - &np->saddr : -#endif - NULL); + ip6_dst_store_flow(sk, dst, &fl6); out: fl6_sock_release(flowlabel); diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index a8a9195..ed87ce5 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -943,6 +943,23 @@ static struct dst_entry *ip6_sk_dst_check(struct sock *sk, return dst; } +void ip6_dst_store_flow(struct sock *sk, struct dst_entry *dst, + const struct flowi6 *fl6) +{ +#ifdef CONFIG_IPV6_SUBTREES + struct ipv6_pinfo *np = inet6_sk(sk); +#endif + + ip6_dst_store(sk, dst, + ipv6_addr_equal(&fl6->daddr, &sk->sk_v6_daddr) ? + &sk->sk_v6_daddr : NULL, +#ifdef CONFIG_IPV6_SUBTREES + ipv6_addr_equal(&fl6->saddr, &np->saddr) ? + &np->saddr : +#endif + NULL); +} + static int ip6_dst_lookup_tail(struct net *net, const struct sock *sk, struct dst_entry **dst, struct flowi6 *fl6) {