summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/stack/stack.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-02-11 12:58:13 -0800
committergVisor bot <gvisor-bot@google.com>2020-02-11 12:59:11 -0800
commitb8e22e241cab625d2809034c74d0ff808b948b4c (patch)
treebcb750ceb1341495e22bb3fa1ad2110a0b215ddc /pkg/tcpip/stack/stack.go
parent9be46e55c2aadcf40c9abd4b515c3fe899d9fa08 (diff)
Disallow duplicate NIC names.
PiperOrigin-RevId: 294500858
Diffstat (limited to 'pkg/tcpip/stack/stack.go')
-rw-r--r--pkg/tcpip/stack/stack.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pkg/tcpip/stack/stack.go b/pkg/tcpip/stack/stack.go
index b793f1d74..6eac16e16 100644
--- a/pkg/tcpip/stack/stack.go
+++ b/pkg/tcpip/stack/stack.go
@@ -890,6 +890,15 @@ func (s *Stack) CreateNICWithOptions(id tcpip.NICID, ep LinkEndpoint, opts NICOp
return tcpip.ErrDuplicateNICID
}
+ // Make sure name is unique, unless unnamed.
+ if opts.Name != "" {
+ for _, n := range s.nics {
+ if n.Name() == opts.Name {
+ return tcpip.ErrDuplicateNICID
+ }
+ }
+ }
+
n := newNIC(s, id, opts.Name, ep, opts.Context)
s.nics[id] = n