Skip to content

Commit 8e08bb7

Browse files
lxinkuba-moo
authored andcommitted
packet: add TP_STATUS_GSO_TCP for tp_status
Introduce TP_STATUS_GSO_TCP tp_status flag to tell the af_packet user that this is a TCP GSO packet. When parsing IPv4 BIG TCP packets in tcpdump/libpcap, it can use tp_len as the IPv4 packet len when this flag is set, as iph tot_len is set to 0 for IPv4 BIG TCP packets. Signed-off-by: Xin Long <[email protected]> Reviewed-by: David Ahern <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 50e6fb5 commit 8e08bb7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

include/uapi/linux/if_packet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct tpacket_auxdata {
115115
#define TP_STATUS_BLK_TMO (1 << 5)
116116
#define TP_STATUS_VLAN_TPID_VALID (1 << 6) /* auxdata has valid tp_vlan_tpid */
117117
#define TP_STATUS_CSUM_VALID (1 << 7)
118+
#define TP_STATUS_GSO_TCP (1 << 8)
118119

119120
/* Tx ring - header status */
120121
#define TP_STATUS_AVAILABLE 0

net/packet/af_packet.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
22962296
else if (skb->pkt_type != PACKET_OUTGOING &&
22972297
skb_csum_unnecessary(skb))
22982298
status |= TP_STATUS_CSUM_VALID;
2299+
if (skb_is_gso(skb) && skb_is_gso_tcp(skb))
2300+
status |= TP_STATUS_GSO_TCP;
22992301

23002302
if (snaplen > res)
23012303
snaplen = res;
@@ -3522,6 +3524,8 @@ static int packet_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
35223524
else if (skb->pkt_type != PACKET_OUTGOING &&
35233525
skb_csum_unnecessary(skb))
35243526
aux.tp_status |= TP_STATUS_CSUM_VALID;
3527+
if (skb_is_gso(skb) && skb_is_gso_tcp(skb))
3528+
aux.tp_status |= TP_STATUS_GSO_TCP;
35253529

35263530
aux.tp_len = origlen;
35273531
aux.tp_snaplen = skb->len;

0 commit comments

Comments
 (0)