Skip to content

Commit 3fb03b5

Browse files
Florian Westphalgregkh
authored andcommitted
net: add and use skb_gso_transport_seglen()
commit de960aa upstream. [ no skb_gso_seglen helper in 3.10, leave tbf alone ] 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 <fw@strlen.de> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b306713 commit 3fb03b5

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

‎include/linux/skbuff.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,8 @@ extern int skb_shift(struct sk_buff *tgt, struct sk_buff *skb,
24882488
extern struct sk_buff *skb_segment(struct sk_buff *skb,
24892489
netdev_features_t features);
24902490

2491+
unsigned int skb_gso_transport_seglen(const struct sk_buff *skb);
2492+
24912493
static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
24922494
int len, void *buffer)
24932495
{

‎net/core/skbuff.c‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
#include <linux/in.h>
4848
#include <linux/inet.h>
4949
#include <linux/slab.h>
50+
#include <linux/tcp.h>
51+
#include <linux/udp.h>
5052
#include <linux/netdevice.h>
5153
#ifdef CONFIG_NET_CLS_ACT
5254
#include <net/pkt_sched.h>
@@ -3471,3 +3473,26 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
34713473
return true;
34723474
}
34733475
EXPORT_SYMBOL(skb_try_coalesce);
3476+
3477+
/**
3478+
* skb_gso_transport_seglen - Return length of individual segments of a gso packet
3479+
*
3480+
* @skb: GSO skb
3481+
*
3482+
* skb_gso_transport_seglen is used to determine the real size of the
3483+
* individual segments, including Layer4 headers (TCP/UDP).
3484+
*
3485+
* The MAC/L2 or network (IP, IPv6) headers are not accounted for.
3486+
*/
3487+
unsigned int skb_gso_transport_seglen(const struct sk_buff *skb)
3488+
{
3489+
const struct skb_shared_info *shinfo = skb_shinfo(skb);
3490+
unsigned int hdr_len;
3491+
3492+
if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
3493+
hdr_len = tcp_hdrlen(skb);
3494+
else
3495+
hdr_len = sizeof(struct udphdr);
3496+
return hdr_len + shinfo->gso_size;
3497+
}
3498+
EXPORT_SYMBOL_GPL(skb_gso_transport_seglen);

0 commit comments

Comments
 (0)