MCPcopy
hub / github.com/google/gvisor / SetNICCoordinator

Method SetNICCoordinator

pkg/tcpip/stack/stack.go:1099–1124  ·  view source on GitHub ↗

SetNICCoordinator sets a coordinator device.

(id tcpip.NICID, mid tcpip.NICID)

Source from the content-addressed store, hash-verified

1097
1098// SetNICCoordinator sets a coordinator device.
1099func (s *Stack) SetNICCoordinator(id tcpip.NICID, mid tcpip.NICID) tcpip.Error {
1100 s.mu.Lock()
1101 defer s.mu.Unlock()
1102
1103 nic, ok := s.nics[id]
1104 if !ok {
1105 return &tcpip.ErrUnknownNICID{}
1106 }
1107 // Setting a coordinator for a coordinator NIC is not allowed.
1108 if _, ok := nic.NetworkLinkEndpoint.(CoordinatorNIC); ok {
1109 return &tcpip.ErrNoSuchFile{}
1110 }
1111 m, ok := s.nics[mid]
1112 if !ok {
1113 return &tcpip.ErrUnknownNICID{}
1114 }
1115 b, ok := m.NetworkLinkEndpoint.(CoordinatorNIC)
1116 if !ok {
1117 return &tcpip.ErrNotSupported{}
1118 }
1119 if err := b.AddNIC(nic); err != nil {
1120 return err
1121 }
1122 nic.Primary = m
1123 return nil
1124}
1125
1126// SetNICAddress sets the hardware address which is identified by the nic ID.
1127func (s *Stack) SetNICAddress(id tcpip.NICID, addr tcpip.LinkAddress) tcpip.Error {

Callers 6

setLinkLockedMethod · 0.80
TestBridgeFDBFunction · 0.80
TestSetCoordinatorFunction · 0.80

Calls 3

LockMethod · 0.65
UnlockMethod · 0.65
AddNICMethod · 0.65

Tested by 5

TestBridgeFDBFunction · 0.64
TestSetCoordinatorFunction · 0.64