Skip to content

Commit 7d327ed

Browse files
committed
conn: use right cmsghdr len types on 32-bit in sticky test
Cmsghdr uses uint32 and uint64 on 32-bit and 64-bit respectively for the Len member, which makes assignments and comparisons slightly more irksome than usual. Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent f41f474 commit 7d327ed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

conn/sticky_linux_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func Test_setSrcControl(t *testing.T) {
3838
if hdr.Type != unix.IP_PKTINFO {
3939
t.Errorf("unexpected type: %d", hdr.Type)
4040
}
41-
if hdr.Len != uint64(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet4Pktinfo{})))) {
41+
if uint(hdr.Len) != uint(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet4Pktinfo{})))) {
4242
t.Errorf("unexpected length: %d", hdr.Len)
4343
}
4444
info := (*unix.Inet4Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
@@ -68,7 +68,7 @@ func Test_setSrcControl(t *testing.T) {
6868
if hdr.Type != unix.IPV6_PKTINFO {
6969
t.Errorf("unexpected type: %d", hdr.Type)
7070
}
71-
if hdr.Len != uint64(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet6Pktinfo{})))) {
71+
if uint(hdr.Len) != uint(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet6Pktinfo{})))) {
7272
t.Errorf("unexpected length: %d", hdr.Len)
7373
}
7474
info := (*unix.Inet6Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
@@ -101,7 +101,7 @@ func Test_getSrcFromControl(t *testing.T) {
101101
hdr := (*unix.Cmsghdr)(unsafe.Pointer(&control[0]))
102102
hdr.Level = unix.IPPROTO_IP
103103
hdr.Type = unix.IP_PKTINFO
104-
hdr.Len = uint64(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet4Pktinfo{}))))
104+
hdr.SetLen(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet4Pktinfo{}))))
105105
info := (*unix.Inet4Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
106106
info.Spec_dst = [4]byte{127, 0, 0, 1}
107107
info.Ifindex = 5
@@ -121,7 +121,7 @@ func Test_getSrcFromControl(t *testing.T) {
121121
hdr := (*unix.Cmsghdr)(unsafe.Pointer(&control[0]))
122122
hdr.Level = unix.IPPROTO_IPV6
123123
hdr.Type = unix.IPV6_PKTINFO
124-
hdr.Len = uint64(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet6Pktinfo{}))))
124+
hdr.SetLen(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet6Pktinfo{}))))
125125
info := (*unix.Inet6Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
126126
info.Addr = [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
127127
info.Ifindex = 5

0 commit comments

Comments
 (0)