From patchwork Fri Mar 24 09:46:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lebrun X-Patchwork-Id: 743120 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vqJg658pyz9s8B for ; Fri, 24 Mar 2017 20:54:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=uclouvain.be header.i=@uclouvain.be header.b="zF68G2as"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756444AbdCXJya (ORCPT ); Fri, 24 Mar 2017 05:54:30 -0400 Received: from smtp.sgsi.ucl.ac.be ([130.104.5.67]:36231 "EHLO smtp4.sgsi.ucl.ac.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751620AbdCXJy0 (ORCPT ); Fri, 24 Mar 2017 05:54:26 -0400 X-Greylist: delayed 491 seconds by postgrey-1.27 at vger.kernel.org; Fri, 24 Mar 2017 05:54:26 EDT Received: from mailboxes.uclouvain.be (mailboxes.uclouvain.be [130.104.6.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp4.sgsi.ucl.ac.be (Postfix) with ESMTPS id 4BAA967DB04 for ; Fri, 24 Mar 2017 10:46:05 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.9.2 smtp4.sgsi.ucl.ac.be 4BAA967DB04 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=uclouvain.be; s=selucl; t=1490348765; bh=e58wxmaBjA3EE5Lu/pORlJ94+Ee2cGeQIsiKdNIIdq8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=zF68G2asFf5BCKGUDilqvfLMl9vysHRowmyZxQR1Fcu8pDQyBsuQ2OJ9jO42lfqr7 NhveCyWj2e0Lq3ikNBxMQ7OrzMrE09HIFJ+WF0Z3ZsQUHN3RS3iyn7FB3EwnpIxBYo 18zXrKGnBamwDE+QHf94cRxDxEtt9pYTxJwXGJ58= X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99.2 at smtp-4 Received: from localhost.localdomain (130.104.228.78) by ucl-mbx04.OASIS.UCLOUVAIN.BE (10.10.10.24) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Fri, 24 Mar 2017 10:46:04 +0100 From: David Lebrun To: CC: David Lebrun Subject: [PATCH net-next 2/2] ipv6: sr: use dst_cache in seg6_input Date: Fri, 24 Mar 2017 10:46:27 +0100 Message-ID: <20170324094627.16796-3-david.lebrun@uclouvain.be> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20170324094627.16796-1-david.lebrun@uclouvain.be> References: <20170324094627.16796-1-david.lebrun@uclouvain.be> MIME-Version: 1.0 X-Originating-IP: [130.104.228.78] X-ClientProxiedBy: UCL-CAS03.OASIS.UCLOUVAIN.BE (10.10.10.43) To ucl-mbx04.OASIS.UCLOUVAIN.BE (10.10.10.24) X-SGSI-Information: X-SGSI-MailScanner-ID: 4BAA967DB04.A5881 X-SGSI-MailScanner: Found to be clean X-SGSI-SpamCheck: n'est pas un polluriel, SpamAssassin (not cached, score=-3.001, requis 5, autolearn=not spam, ALL_TRUSTED -2.00, BAYES_00 -1.90, DKIM_SIGNED 0.10, DKIM_VALID -0.10, DKIM_VALID_AU -0.10, MISSING_FROM 1.00, RP_MATCHES_RCVD -0.00) X-SGSI-From: david.lebrun@uclouvain.be X-SGSI-Spam-Status: No Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We already use dst_cache in seg6_output, when handling locally generated packets. We extend it in seg6_input, to also handle forwarded packets, and avoid unnecessary fib lookups. Performances for SRH encapsulation before the patch: Result: OK: 5656067(c5655678+d388) usec, 5000000 (1000byte,0frags) 884006pps 7072Mb/sec (7072048000bps) errors: 0 Performances after the patch: Result: OK: 4774543(c4774084+d459) usec, 5000000 (1000byte,0frags) 1047220pps 8377Mb/sec (8377760000bps) errors: 0 Signed-off-by: David Lebrun --- net/ipv6/seg6_iptunnel.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c index dda2c51..30ef1d1 100644 --- a/net/ipv6/seg6_iptunnel.c +++ b/net/ipv6/seg6_iptunnel.c @@ -237,6 +237,9 @@ static int seg6_do_srh(struct sk_buff *skb) static int seg6_input(struct sk_buff *skb) { + struct dst_entry *orig_dst = skb_dst(skb); + struct dst_entry *dst = NULL; + struct seg6_lwt *slwt; int err; err = seg6_do_srh(skb); @@ -245,8 +248,30 @@ static int seg6_input(struct sk_buff *skb) return err; } + slwt = seg6_lwt_lwtunnel(orig_dst->lwtstate); + +#ifdef CONFIG_DST_CACHE + preempt_disable(); + dst = dst_cache_get(&slwt->cache); + preempt_enable(); +#endif + skb_dst_drop(skb); - ip6_route_input(skb); + + if (!dst) { + ip6_route_input(skb); +#ifdef CONFIG_DST_CACHE + dst = skb_dst(skb); + if (!dst->error) { + preempt_disable(); + dst_cache_set_ip6(&slwt->cache, dst, + &ipv6_hdr(skb)->saddr); + preempt_enable(); + } +#endif + } else { + skb_dst_set(skb, dst); + } return dst_input(skb); }