From patchwork Wed Feb 10 16:50:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Craig Gallek X-Patchwork-Id: 581493 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 19CA314012C for ; Thu, 11 Feb 2016 03:51:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753131AbcBJQvE (ORCPT ); Wed, 10 Feb 2016 11:51:04 -0500 Received: from mail-qg0-f52.google.com ([209.85.192.52]:35945 "EHLO mail-qg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753067AbcBJQuv (ORCPT ); Wed, 10 Feb 2016 11:50:51 -0500 Received: by mail-qg0-f52.google.com with SMTP id y9so18026607qgd.3 for ; Wed, 10 Feb 2016 08:50:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8bZwwP5uWosrWficEfa/+l9r/B6Vj5X8stUp6gaURRg=; b=G0h/MBaYGcZQopipwx+P0v8IVHdc8ljscKcQaXfckmreTTvyL1q4sRMHDSrxB6GB4H aP6oWuVYNfIYLa5R3YIrKVvsSBIdJ3XxikJXYrd5VSCzSvC5RwTIZvKUP81GU16OojS5 yUJTnW2zpbg9ByrX+THxxz0foTlFjNVLIkdOosr9VeVhqR6/FifGZ4bLSrGuRoZVB0Qo Ey0D3CyUqEUEVr1oTKb1jvVLT0sIPI4E8hjk8XIa2CqgQp7Mg43tXmuUAYHPrp66g4l1 MpwS3h8atD9K+nSCgjuIfuz7TsQhp9Cw1gV/VrXIdM9DKlo5g1+pjFEhVqOJ3MKzuMQC AdMQ== X-Gm-Message-State: AG10YORZz6+e1M/cbSglwaa/puVW2PgQWMeCv+yz2+bIgo8OdwDTLoXWoyKhnsqI39neYfHy X-Received: by 10.141.0.212 with SMTP id b203mr50745435qhd.104.1455123050814; Wed, 10 Feb 2016 08:50:50 -0800 (PST) Received: from cgallek-warp18.nyc.corp.google.com ([172.29.18.56]) by smtp.gmail.com with ESMTPSA id 2sm358088qgi.33.2016.02.10.08.50.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Feb 2016 08:50:49 -0800 (PST) From: Craig Gallek To: netdev@vger.kernel.org, David Miller Subject: [PATCH net-next v4 3/7] tcp: __tcp_hdrlen() helper Date: Wed, 10 Feb 2016 11:50:37 -0500 Message-Id: <1455123041-22638-4-git-send-email-kraigatgoog@gmail.com> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1455123041-22638-1-git-send-email-kraigatgoog@gmail.com> References: <1455123041-22638-1-git-send-email-kraigatgoog@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Craig Gallek tcp_hdrlen is wasteful if you already have a pointer to struct tcphdr. This splits the size calculation into a helper function that can be used if a struct tcphdr is already available. Signed-off-by: Craig Gallek --- include/linux/tcp.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index d909feeeaea2..bcbf51da4e1e 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -29,9 +29,14 @@ static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb) return (struct tcphdr *)skb_transport_header(skb); } +static inline unsigned int __tcp_hdrlen(const struct tcphdr *th) +{ + return th->doff * 4; +} + static inline unsigned int tcp_hdrlen(const struct sk_buff *skb) { - return tcp_hdr(skb)->doff * 4; + return __tcp_hdrlen(tcp_hdr(skb)); } static inline struct tcphdr *inner_tcp_hdr(const struct sk_buff *skb)