Skip to content

Commit e54fc56

Browse files
committed
write only the data we receive
Change-Id: I290d289dacece0b00b18b3d90f2d1807f0ada636
1 parent d494889 commit e54fc56

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/loadbalancer/tunnel.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func (t *tunnel) handleUDPConnection(conn *net.UDPConn) error {
211211
}
212212
defer remoteConn.Close()
213213

214-
nWrite, err := remoteConn.Write(buf)
214+
nWrite, err := remoteConn.Write(buf[:nRead])
215215
if err != nil {
216216
return fmt.Errorf("fail to write to remote %s: %s", remoteConn.RemoteAddr(), err)
217217
} else if nWrite < nRead {
@@ -230,7 +230,7 @@ func (t *tunnel) handleUDPConnection(conn *net.UDPConn) error {
230230
}
231231
klog.V(4).Infof("Read %d bytes from %s", nRead, remoteConn.RemoteAddr().String())
232232

233-
_, err = conn.WriteToUDP(buf, srcAddr)
233+
_, err = conn.WriteToUDP(buf[:nRead], srcAddr)
234234

235235
return err
236236
}

0 commit comments

Comments
 (0)