Skip to content

Commit d9b3fca

Browse files
kraigatgoogdavem330
authored andcommitted
tcp: __tcp_hdrlen() helper
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 <kraig@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 496611d commit d9b3fca

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

include/linux/tcp.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@ static inline struct tcphdr *tcp_hdr(const struct sk_buff *skb)
2929
return (struct tcphdr *)skb_transport_header(skb);
3030
}
3131

32+
static inline unsigned int __tcp_hdrlen(const struct tcphdr *th)
33+
{
34+
return th->doff * 4;
35+
}
36+
3237
static inline unsigned int tcp_hdrlen(const struct sk_buff *skb)
3338
{
34-
return tcp_hdr(skb)->doff * 4;
39+
return __tcp_hdrlen(tcp_hdr(skb));
3540
}
3641

3742
static inline struct tcphdr *inner_tcp_hdr(const struct sk_buff *skb)

0 commit comments

Comments
 (0)