From patchwork Wed Mar 5 14:36:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Henriques X-Patchwork-Id: 326996 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id DD84E2C0079 for ; Thu, 6 Mar 2014 01:38:27 +1100 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1WLCxj-0004vr-HI; Wed, 05 Mar 2014 14:38:23 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1WLCxL-0004jn-M2 for kernel-team@lists.ubuntu.com; Wed, 05 Mar 2014 14:37:59 +0000 Received: from bl6-122-102.dsl.telepac.pt ([82.155.122.102] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1WLCxL-0002TW-Dy; Wed, 05 Mar 2014 14:37:59 +0000 From: Luis Henriques To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Subject: [PATCH 3.5 34/62] net: add and use skb_gso_transport_seglen() Date: Wed, 5 Mar 2014 14:36:38 +0000 Message-Id: <1394030226-26652-35-git-send-email-luis.henriques@canonical.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1394030226-26652-1-git-send-email-luis.henriques@canonical.com> References: <1394030226-26652-1-git-send-email-luis.henriques@canonical.com> X-Extended-Stable: 3.5 Cc: Florian Westphal , "David S. Miller" X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com 3.5.7.32 -stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal commit de960aa9ab4decc3304959f69533eef64d05d8e8 upstream. This moves part of Eric Dumazets skb_gso_seglen helper from tbf sched to skbuff core so it may be reused by upcoming ip forwarding path patch. Signed-off-by: Florian Westphal Acked-by: Eric Dumazet Signed-off-by: David S. Miller [ luis: backported to 3.5: used davem's backport to 3.4: - no skb_gso_seglen helper in 3.4, leave tbf alone ] Signed-off-by: Luis Henriques --- include/linux/skbuff.h | 2 ++ net/core/skbuff.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 160f3ea..0d40dda 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2171,6 +2171,8 @@ extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, extern struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features); +unsigned int skb_gso_transport_seglen(const struct sk_buff *skb); + static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, int len, void *buffer) { diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 1e37e1a..50f7c96 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -47,6 +47,8 @@ #include #include #include +#include +#include #include #ifdef CONFIG_NET_CLS_ACT #include @@ -3358,3 +3360,26 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, return true; } EXPORT_SYMBOL(skb_try_coalesce); + +/** + * skb_gso_transport_seglen - Return length of individual segments of a gso packet + * + * @skb: GSO skb + * + * skb_gso_transport_seglen is used to determine the real size of the + * individual segments, including Layer4 headers (TCP/UDP). + * + * The MAC/L2 or network (IP, IPv6) headers are not accounted for. + */ +unsigned int skb_gso_transport_seglen(const struct sk_buff *skb) +{ + const struct skb_shared_info *shinfo = skb_shinfo(skb); + unsigned int hdr_len; + + if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) + hdr_len = tcp_hdrlen(skb); + else + hdr_len = sizeof(struct udphdr); + return hdr_len + shinfo->gso_size; +} +EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);