summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/udp
diff options
context:
space:
mode:
authorBhasker Hariharan <bhaskerh@google.com>2021-01-26 12:07:16 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-26 12:09:10 -0800
commita90661654d14e77b6442c4a34ced900e2cd9953e (patch)
tree1345192618a15d5e832f2380e286bd556c2a18d6 /pkg/tcpip/transport/udp
parent96bd076e8a002ccacc414e92c83dedf2e35ca07b (diff)
Fix couple of potential route leaks.
connect() can be invoked multiple times on UDP/RAW sockets and in such a case we should release the cached route from the previous connect. Fixes #5359 PiperOrigin-RevId: 353919891
Diffstat (limited to 'pkg/tcpip/transport/udp')
-rw-r--r--pkg/tcpip/transport/udp/endpoint.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/tcpip/transport/udp/endpoint.go b/pkg/tcpip/transport/udp/endpoint.go
index ea8a7017e..a3e513ff7 100644
--- a/pkg/tcpip/transport/udp/endpoint.go
+++ b/pkg/tcpip/transport/udp/endpoint.go
@@ -1009,6 +1009,11 @@ func (e *endpoint) Connect(addr tcpip.FullAddress) *tcpip.Error {
e.ID = id
e.boundBindToDevice = btd
+ if e.route != nil {
+ // If the endpoint was already connected then make sure we release the
+ // previous route.
+ e.route.Release()
+ }
e.route = r
e.dstPort = addr.Port
e.RegisterNICID = nicID