MCPcopy Index your code
hub / github.com/google/gvisor / RemoveInterface

Method RemoveInterface

pkg/sentry/socket/netstack/stack.go:150–172  ·  view source on GitHub ↗

RemoveInterface implements inet.Stack.RemoveInterface.

(ctx context.Context, idx int32)

Source from the content-addressed store, hash-verified

148
149// RemoveInterface implements inet.Stack.RemoveInterface.
150func (s *Stack) RemoveInterface(ctx context.Context, idx int32) error {
151 s.linkMu.Lock()
152 defer s.linkMu.Unlock()
153
154 nic := tcpip.NICID(idx)
155
156 nicInfo, ok := s.Stack.SingleNICInfo(nic)
157 if !ok {
158 return syserr.ErrUnknownNICID.ToError()
159 }
160
161 // Don't allow removing the loopback interface.
162 if nicInfo.Flags.Loopback {
163 return syserr.ErrNotSupported.ToError()
164 }
165
166 if err := syserr.TranslateNetstackError(s.Stack.RemoveNIC(nic)); err != nil {
167 return err.ToError()
168 }
169 s.sendDeleteEvent(ctx, nic, nicInfo)
170 return nil
171
172}
173
174// SetInterface implements inet.Stack.SetInterface.
175func (s *Stack) SetInterface(ctx context.Context, msg *nlmsg.Message) *syserr.Error {

Callers

nothing calls this directly

Calls 8

sendDeleteEventMethod · 0.95
NICIDTypeAlias · 0.92
TranslateNetstackErrorFunction · 0.92
SingleNICInfoMethod · 0.80
ToErrorMethod · 0.80
RemoveNICMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected