* wireguard-go bug with IPv6-less kernels
@ 2018-09-07 16:12 Kent Friis
0 siblings, 0 replies; only message in thread
From: Kent Friis @ 2018-09-07 16:12 UTC (permalink / raw)
To: wireguard
I've been setting up wireguard-go on an old Linux kernel (no module),
and hit a bug with ipv6-less kernels. The create6() function returns 0
as the port number when an error occurs, so even though CreateBind
checks for EAFNOSUPPORT, it still ends up with port getting set to zero,
resulting in a random port.
I solved it by returning port instead of zero - as far as I can see
this shouldn't break anything, as CreateBind will return 0 anyway on
errors other than EAFNOSUPPORT.
I did not check whether the same bug exists in conn_default.go
- Kent
--- conn_linux.go.old 2018-09-05 23:11:19.407372785 +0200
+++ conn_linux.go 2018-09-07 16:58:28.971914271 +0200
@@ -335,7 +335,7 @@
)
if err != nil {
- return -1, 0, err
+ return -1, port, err
}
addr := unix.SockaddrInet4{
@@ -366,7 +366,7 @@
return unix.Bind(fd, &addr)
}(); err != nil {
unix.Close(fd)
- return -1, 0, err
+ return -1, port, err
}
return fd, uint16(addr.Port), err
@@ -383,7 +383,7 @@
)
if err != nil {
- return -1, 0, err
+ return -1, port, err
}
// set sockopts and bind
@@ -425,7 +425,7 @@
}(); err != nil {
unix.Close(fd)
- return -1, 0, err
+ return -1, port, err
}
return fd, uint16(addr.Port), err
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-09-07 16:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-07 16:12 wireguard-go bug with IPv6-less kernels Kent Friis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).