diff options
author | Eyal Soha <eyalsoha@google.com> | 2020-01-09 13:06:24 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-09 13:07:53 -0800 |
commit | 8643933d6e58492cbe9d5c78124873ab40f65feb (patch) | |
tree | 75323a2be79e5e0a67ee8af490478d3fa7129ae7 /pkg/tcpip/stack/stack.go | |
parent | e752ddbb72d89b19863a6b50d99814149a08d5fe (diff) |
Change BindToDeviceOption to store NICID
This makes it possible to call the sockopt from go even when the NIC has no
name.
PiperOrigin-RevId: 288955236
Diffstat (limited to 'pkg/tcpip/stack/stack.go')
-rw-r--r-- | pkg/tcpip/stack/stack.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pkg/tcpip/stack/stack.go b/pkg/tcpip/stack/stack.go index e2a2edb2c..41bf9fd9b 100644 --- a/pkg/tcpip/stack/stack.go +++ b/pkg/tcpip/stack/stack.go @@ -901,6 +901,14 @@ type NICInfo struct { Context NICContext } +// HasNIC returns true if the NICID is defined in the stack. +func (s *Stack) HasNIC(id tcpip.NICID) bool { + s.mu.RLock() + _, ok := s.nics[id] + s.mu.RUnlock() + return ok +} + // NICInfo returns a map of NICIDs to their associated information. func (s *Stack) NICInfo() map[tcpip.NICID]NICInfo { s.mu.RLock() |