mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-27 20:36:31 -04:00
unix: rename XDPUmemReg field back to Size
When the Linux-specific XDPUmemReg struct was originally added (CL 136695) the only field with a prefix was chunk_size, so cgo rewrote the field to Size. Later Linux added a tx_metadata_len field, which caused cgo to to leave the chunk_size field as Chunk_size (CL 577975). However, existing code, specifically gvisor, refers to the field as Size. So go back to Size so that existing code will continue to work. This does unfortunately mean that people who used the struct since CL 577975 in April, 2024 will have to adapt. There doesn't seem to be a perfect solution here. But we've had Size since September, 2018, so let's stick with that. Change-Id: Ib11edfbf98ce3a9e1a909194f200a39ddfe6f8e0 Reviewed-on: https://go-review.googlesource.com/c/sys/+/607876 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
committed by
Gopher Robot
parent
59665e5b43
commit
a8c5219b5e
@@ -202,6 +202,20 @@ func main() {
|
||||
spareFieldsRegex := regexp.MustCompile(`X__spare\S*`)
|
||||
b = spareFieldsRegex.ReplaceAll(b, []byte("_"))
|
||||
|
||||
// Rename chunk_size field in XDPUmemReg.
|
||||
// When the struct was originally added (CL 136695) the only
|
||||
// field with a prefix was chunk_size, so cgo rewrote the
|
||||
// field to Size. Later Linux added a tx_metadata_len field,
|
||||
// so cgo left chunk_size as Chunk_size (CL 577975).
|
||||
// Go back to Size so that packages like gvisor don't have
|
||||
// to adjust.
|
||||
xdpUmemRegType := regexp.MustCompile(`type XDPUmemReg struct {[^}]*}`)
|
||||
xdpUmemRegStructs := xdpUmemRegType.FindAll(b, -1)
|
||||
for _, s := range xdpUmemRegStructs {
|
||||
newName := bytes.Replace(s, []byte("Chunk_size"), []byte("Size"), 1)
|
||||
b = bytes.Replace(b, s, newName, 1)
|
||||
}
|
||||
|
||||
// Remove cgo padding fields
|
||||
removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`)
|
||||
b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_"))
|
||||
|
||||
@@ -2486,7 +2486,7 @@ type XDPMmapOffsets struct {
|
||||
type XDPUmemReg struct {
|
||||
Addr uint64
|
||||
Len uint64
|
||||
Chunk_size uint32
|
||||
Size uint32
|
||||
Headroom uint32
|
||||
Flags uint32
|
||||
Tx_metadata_len uint32
|
||||
|
||||
Reference in New Issue
Block a user