diff --git a/pkg/tap/switch.go b/pkg/tap/switch.go index 10fe59e3b..5f1d16f35 100644 --- a/pkg/tap/switch.go +++ b/pkg/tap/switch.go @@ -7,6 +7,7 @@ import ( "net" "sync" "sync/atomic" + "syscall" "github.com/containers/gvisor-tap-vsock/pkg/types" "github.com/google/gopacket" @@ -167,18 +168,21 @@ func (e *Switch) txBuf(id int, conn protocolConn, buf []byte) error { if conn.protocolImpl.Stream() { size := conn.protocolImpl.(streamProtocol).Buf() conn.protocolImpl.(streamProtocol).Write(size, len(buf)) - - if _, err := conn.Write(append(size, buf...)); err != nil { - e.disconnect(id, conn) - return err - } - } else { + buf = append(size, buf...) + } + for { if _, err := conn.Write(buf); err != nil { + if errors.Is(err, syscall.ENOBUFS) { + // socket buffer can be full keep retrying sending the same data + // again until it works or we get a different error + // https://github.com/containers/gvisor-tap-vsock/issues/367 + continue + } e.disconnect(id, conn) return err } + return nil } - return nil } func (e *Switch) disconnect(id int, conn net.Conn) { diff --git a/test/basic_test.go b/test/basic_test.go index e51864f00..a3db89e7e 100644 --- a/test/basic_test.go +++ b/test/basic_test.go @@ -74,10 +74,10 @@ var _ = ginkgo.Describe("dns", func() { gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) gomega.Expect(string(out)).To(gomega.ContainSubstring(`_ldap._tcp.google.com service = 5 0 389 ldap.google.com.`)) }) - ginkgo.It("should resolve TXT for wikipedia.org", func() { - out, err := sshExec("nslookup -query=txt wikipedia.org") + ginkgo.It("should resolve TXT for crc.dev", func() { + out, err := sshExec("nslookup -query=txt crc.dev") gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) - gomega.Expect(string(out)).To(gomega.ContainSubstring(`"v=spf1 -all"`)) + gomega.Expect(string(out)).To(gomega.ContainSubstring(`text = "v=spf1`)) }) ginkgo.It("should resolve gateway.containers.internal", func() {