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 <Jason@zx2c4.com>
This commit is contained in:
parent
f41f474466
commit
7d327ed35a
@ -38,7 +38,7 @@ func Test_setSrcControl(t *testing.T) {
|
|||||||
if hdr.Type != unix.IP_PKTINFO {
|
if hdr.Type != unix.IP_PKTINFO {
|
||||||
t.Errorf("unexpected type: %d", hdr.Type)
|
t.Errorf("unexpected type: %d", hdr.Type)
|
||||||
}
|
}
|
||||||
if hdr.Len != uint64(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet4Pktinfo{})))) {
|
if uint(hdr.Len) != uint(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet4Pktinfo{})))) {
|
||||||
t.Errorf("unexpected length: %d", hdr.Len)
|
t.Errorf("unexpected length: %d", hdr.Len)
|
||||||
}
|
}
|
||||||
info := (*unix.Inet4Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
|
info := (*unix.Inet4Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
|
||||||
@ -68,7 +68,7 @@ func Test_setSrcControl(t *testing.T) {
|
|||||||
if hdr.Type != unix.IPV6_PKTINFO {
|
if hdr.Type != unix.IPV6_PKTINFO {
|
||||||
t.Errorf("unexpected type: %d", hdr.Type)
|
t.Errorf("unexpected type: %d", hdr.Type)
|
||||||
}
|
}
|
||||||
if hdr.Len != uint64(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet6Pktinfo{})))) {
|
if uint(hdr.Len) != uint(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet6Pktinfo{})))) {
|
||||||
t.Errorf("unexpected length: %d", hdr.Len)
|
t.Errorf("unexpected length: %d", hdr.Len)
|
||||||
}
|
}
|
||||||
info := (*unix.Inet6Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
|
info := (*unix.Inet6Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
|
||||||
@ -101,7 +101,7 @@ func Test_getSrcFromControl(t *testing.T) {
|
|||||||
hdr := (*unix.Cmsghdr)(unsafe.Pointer(&control[0]))
|
hdr := (*unix.Cmsghdr)(unsafe.Pointer(&control[0]))
|
||||||
hdr.Level = unix.IPPROTO_IP
|
hdr.Level = unix.IPPROTO_IP
|
||||||
hdr.Type = unix.IP_PKTINFO
|
hdr.Type = unix.IP_PKTINFO
|
||||||
hdr.Len = uint64(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet4Pktinfo{}))))
|
hdr.SetLen(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet4Pktinfo{}))))
|
||||||
info := (*unix.Inet4Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
|
info := (*unix.Inet4Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
|
||||||
info.Spec_dst = [4]byte{127, 0, 0, 1}
|
info.Spec_dst = [4]byte{127, 0, 0, 1}
|
||||||
info.Ifindex = 5
|
info.Ifindex = 5
|
||||||
@ -121,7 +121,7 @@ func Test_getSrcFromControl(t *testing.T) {
|
|||||||
hdr := (*unix.Cmsghdr)(unsafe.Pointer(&control[0]))
|
hdr := (*unix.Cmsghdr)(unsafe.Pointer(&control[0]))
|
||||||
hdr.Level = unix.IPPROTO_IPV6
|
hdr.Level = unix.IPPROTO_IPV6
|
||||||
hdr.Type = unix.IPV6_PKTINFO
|
hdr.Type = unix.IPV6_PKTINFO
|
||||||
hdr.Len = uint64(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet6Pktinfo{}))))
|
hdr.SetLen(unix.CmsgLen(int(unsafe.Sizeof(unix.Inet6Pktinfo{}))))
|
||||||
info := (*unix.Inet6Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
|
info := (*unix.Inet6Pktinfo)(unsafe.Pointer(&control[unix.CmsgLen(0)]))
|
||||||
info.Addr = [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
|
info.Addr = [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
|
||||||
info.Ifindex = 5
|
info.Ifindex = 5
|
||||||
|
Loading…
Reference in New Issue
Block a user