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

Method SetNICStack

pkg/tcpip/stack/stack.go:2524–2550  ·  view source on GitHub ↗

SetNICStack moves the network device to the specified network namespace.

(id tcpip.NICID, peer *Stack)

Source from the content-addressed store, hash-verified

2522
2523// SetNICStack moves the network device to the specified network namespace.
2524func (s *Stack) SetNICStack(id tcpip.NICID, peer *Stack) (tcpip.NICID, tcpip.Error) {
2525 s.mu.Lock()
2526 nic, ok := s.nics[id]
2527 if !ok {
2528 s.mu.Unlock()
2529 return 0, &tcpip.ErrUnknownNICID{}
2530 }
2531 if s == peer {
2532 s.mu.Unlock()
2533 return id, nil
2534 }
2535
2536 linkEp := nic.NetworkLinkEndpoint.(LinkEndpoint)
2537 name := nic.Name()
2538
2539 deferAct, err := s.removeNICLocked(id, false /* closeLinkEndpoint */)
2540 s.mu.Unlock()
2541 if deferAct != nil {
2542 deferAct()
2543 }
2544 if err != nil {
2545 return 0, err
2546 }
2547
2548 id = tcpip.NICID(peer.NextNICID())
2549 return id, peer.CreateNICWithOptions(id, linkEp, NICOptions{Name: name})
2550}
2551
2552// SetRemoveConf sets the removeConf in stack to the given value.
2553func (s *Stack) SetRemoveConf(removeConf bool) {

Callers 2

setLinkLockedMethod · 0.80

Calls 7

removeNICLockedMethod · 0.95
NICIDTypeAlias · 0.92
NextNICIDMethod · 0.80
CreateNICWithOptionsMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
NameMethod · 0.65

Tested by 1