Skip to content

Commit

Permalink
use a forked version of j-keck/arping that fixes a threading issue
Browse files Browse the repository at this point in the history
here is the PR for the upstream version j-keck/arping#17

'
using sock.deinitialize() outside of the goroutine that is using the socket leaves the potential for erroneous and
unexpected behavior. When calling Ping() very quickly the socket fd can be reused while a goroutine is still trying to read
from it and cause the goroutine to deadlock.

Additionally removing the timeout from the select case because that will/cannot work as intended. In linux close() does not
cause system calls using the socket to return. This contributes to the file descriptor reuse issue mentioned above and with
the defered sock.deinitialize() can lead to double closing the socket.
'

Signed-off-by: Jacob Tanenbaum <jtanenba@redhat.com>
  • Loading branch information
JacobTanenbaum committed Feb 1, 2024
1 parent 6c1417b commit 03d94ec
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 36 deletions.
1 change: 1 addition & 0 deletions go-controller/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,5 @@ require (
replace (
github.com/Microsoft/hcsshim => github.com/Microsoft/hcsshim v0.8.20
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
github.com/j-keck/arping => github.com/JacobTanenbaum/arping v0.0.0-20240201170955-b972757e2245
)
5 changes: 2 additions & 3 deletions go-controller/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbt
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/JacobTanenbaum/arping v0.0.0-20240201170955-b972757e2245 h1:ldJiBqmgJXyVsYcKKZZP/JgdlRVAlwVRVibhp+/kB5Y=
github.com/JacobTanenbaum/arping v0.0.0-20240201170955-b972757e2245/go.mod h1:aJbELhR92bSk7tp79AWM/ftfc90EfEi2bQJrbBFOsPw=
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
Expand Down Expand Up @@ -460,9 +462,6 @@ github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA=
github.com/j-keck/arping v1.0.2 h1:hlLhuXgQkzIJTZuhMigvG/CuSkaspeaD9hRDk2zuiMI=
github.com/j-keck/arping v1.0.2/go.mod h1:aJbELhR92bSk7tp79AWM/ftfc90EfEi2bQJrbBFOsPw=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
Expand Down
5 changes: 1 addition & 4 deletions go-controller/vendor/github.com/j-keck/arping/arping.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions go-controller/vendor/github.com/j-keck/arping/arping_bsd.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions go-controller/vendor/github.com/j-keck/arping/arping_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 0 additions & 28 deletions go-controller/vendor/github.com/j-keck/arping/arping_windows.go

This file was deleted.

3 changes: 2 additions & 1 deletion go-controller/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ github.com/gorilla/mux
# github.com/imdario/mergo v0.3.12
## explicit; go 1.13
github.com/imdario/mergo
# github.com/j-keck/arping v1.0.2
# github.com/j-keck/arping v1.0.2 => github.com/JacobTanenbaum/arping v0.0.0-20240201170955-b972757e2245
## explicit; go 1.12
github.com/j-keck/arping
# github.com/josharian/intern v1.0.0
Expand Down Expand Up @@ -1166,3 +1166,4 @@ sigs.k8s.io/structured-merge-diff/v4/value
sigs.k8s.io/yaml
# github.com/Microsoft/hcsshim => github.com/Microsoft/hcsshim v0.8.20
# github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
# github.com/j-keck/arping => github.com/JacobTanenbaum/arping v0.0.0-20240201170955-b972757e2245

0 comments on commit 03d94ec

Please sign in to comment.