diff --git a/pkg/tcpip/sample/tun_tcp_echo/main.go b/pkg/tcpip/sample/tun_tcp_echo/main.go index 205f3abfa..67615214c 100644 --- a/pkg/tcpip/sample/tun_tcp_echo/main.go +++ b/pkg/tcpip/sample/tun_tcp_echo/main.go @@ -87,8 +87,8 @@ func echo(wq *waiter.Queue, ep tcpip.Endpoint) { } for { - _, err := ep.Read(&w, tcpip.ReadOptions{}) - if err != nil { + var buf bytes.Buffer + if _, err := ep.Read(&buf, tcpip.ReadOptions{}); err != nil { if _, ok := err.(*tcpip.ErrWouldBlock); ok { <-notifyCh continue @@ -96,6 +96,10 @@ func echo(wq *waiter.Queue, ep tcpip.Endpoint) { return } + + if _, err := w.Write(buf.Bytes()); err != nil { + return + } } }