瀏覽代碼

unix: add missing tpacket block (sub)header

This adds the missing tpacket_hdr_v1 struct, which is needed to read
tpacket_block_desc (hdr member, which is a union and therfore defined as
[40]byte). This doesn't modify block_desc so existing implementations
keep working.
Caveat: Although TpacketBDTS has a usec member, this will contain nsec
in case of tpacket v2 or v3.

Change-Id: I772939fe56cf56fc09cf4acf4013b23beb6e03c7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/174861
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Gernot Vormayr 6 年之前
父節點
當前提交
a43fa875dd

+ 4 - 0
unix/linux/types.go

@@ -1160,6 +1160,10 @@ type TpacketHdrVariant1 C.struct_tpacket_hdr_variant1
 
 type TpacketBlockDesc C.struct_tpacket_block_desc
 
+type TpacketBDTS C.struct_tpacket_bd_ts
+
+type TpacketHdrV1 C.struct_tpacket_hdr_v1
+
 type TpacketReq C.struct_tpacket_req
 
 type TpacketReq3 C.struct_tpacket_req3

+ 15 - 0
unix/ztypes_linux_386.go

@@ -1452,6 +1452,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_amd64.go

@@ -1464,6 +1464,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_arm.go

@@ -1442,6 +1442,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_arm64.go

@@ -1443,6 +1443,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_mips.go

@@ -1448,6 +1448,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_mips64.go

@@ -1445,6 +1445,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_mips64le.go

@@ -1445,6 +1445,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_mipsle.go

@@ -1448,6 +1448,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_ppc64.go

@@ -1453,6 +1453,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_ppc64le.go

@@ -1453,6 +1453,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_riscv64.go

@@ -1470,6 +1470,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_s390x.go

@@ -1467,6 +1467,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32

+ 15 - 0
unix/ztypes_linux_sparc64.go

@@ -1448,6 +1448,21 @@ type TpacketBlockDesc struct {
 	Hdr     [40]byte
 }
 
+type TpacketBDTS struct {
+	Sec  uint32
+	Usec uint32
+}
+
+type TpacketHdrV1 struct {
+	Block_status        uint32
+	Num_pkts            uint32
+	Offset_to_first_pkt uint32
+	Blk_len             uint32
+	Seq_num             uint64
+	Ts_first_pkt        TpacketBDTS
+	Ts_last_pkt         TpacketBDTS
+}
+
 type TpacketReq struct {
 	Block_size uint32
 	Block_nr   uint32