summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/socketops.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-05-27 23:53:10 +0000
committergVisor bot <gvisor-bot@google.com>2021-05-27 23:53:10 +0000
commitaf4555903fb57e400777b4c6502608686b18d55c (patch)
treefa0fd1686fe3ed5576372140549e8c7974a2a3d4 /pkg/tcpip/socketops.go
parent965e1415f06bfe9b5ed7cbeb8413005e9b44e40d (diff)
parent121af37738525a629ecc11863b7454b67c0f4117 (diff)
Merge release-20210518.0-59-g121af3773 (automated)
Diffstat (limited to 'pkg/tcpip/socketops.go')
-rw-r--r--pkg/tcpip/socketops.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/tcpip/socketops.go b/pkg/tcpip/socketops.go
index b7c2de652..0ea85f9ed 100644
--- a/pkg/tcpip/socketops.go
+++ b/pkg/tcpip/socketops.go
@@ -601,9 +601,10 @@ func (so *SocketOptions) GetBindToDevice() int32 {
return atomic.LoadInt32(&so.bindToDevice)
}
-// SetBindToDevice sets value for SO_BINDTODEVICE option.
+// SetBindToDevice sets value for SO_BINDTODEVICE option. If bindToDevice is
+// zero, the socket device binding is removed.
func (so *SocketOptions) SetBindToDevice(bindToDevice int32) Error {
- if !so.handler.HasNIC(bindToDevice) {
+ if bindToDevice != 0 && !so.handler.HasNIC(bindToDevice) {
return &ErrUnknownDevice{}
}