mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Do not use a stack-wide queue of pending packets
Packets may be pending on link resolution to complete before being sent. Link resolution is performed for neighbors which are unique to a NIC so hold link resolution related state under the NIC, not the stack. Note, this change may result in more queued packets but that is okay as RFC 4861 section 7.2.2 recommends that the stack maintain a queue of packets for each neighbor that is waiting for link resolution to complete, not a fixed limit per stack. PiperOrigin-RevId: 352322155
This commit is contained in:
committed by
gVisor bot
parent
cd75bb163f
commit
f5736fa2bf
@@ -49,6 +49,10 @@ type NIC struct {
|
||||
// Must be accessed using atomic operations.
|
||||
enabled uint32
|
||||
|
||||
// linkResQueue holds packets that are waiting for link resolution to
|
||||
// complete.
|
||||
linkResQueue packetsPendingLinkResolution
|
||||
|
||||
mu struct {
|
||||
sync.RWMutex
|
||||
spoofing bool
|
||||
@@ -134,6 +138,7 @@ func newNIC(stack *Stack, id tcpip.NICID, name string, ep LinkEndpoint, ctx NICC
|
||||
stats: makeNICStats(),
|
||||
networkEndpoints: make(map[tcpip.NetworkProtocolNumber]NetworkEndpoint),
|
||||
}
|
||||
nic.linkResQueue.init()
|
||||
nic.mu.packetEPs = make(map[tcpip.NetworkProtocolNumber]*packetEndpointList)
|
||||
|
||||
// Check for Neighbor Unreachability Detection support.
|
||||
@@ -315,7 +320,7 @@ func (n *NIC) WritePacket(r *Route, gso *GSO, protocol tcpip.NetworkProtocolNumb
|
||||
if ch, err := r.Resolve(nil); err != nil {
|
||||
if err == tcpip.ErrWouldBlock {
|
||||
r.Acquire()
|
||||
n.stack.linkResQueue.enqueue(ch, r, protocol, pkt)
|
||||
n.linkResQueue.enqueue(ch, r, protocol, pkt)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
||||
@@ -440,10 +440,6 @@ type Stack struct {
|
||||
// uniqueIDGenerator is a generator of unique identifiers.
|
||||
uniqueIDGenerator UniqueID
|
||||
|
||||
// linkResQueue holds packets that are waiting for link resolution to
|
||||
// complete.
|
||||
linkResQueue packetsPendingLinkResolution
|
||||
|
||||
// randomGenerator is an injectable pseudo random generator that can be
|
||||
// used when a random number is required.
|
||||
randomGenerator *mathrand.Rand
|
||||
@@ -664,7 +660,6 @@ func New(opts Options) *Stack {
|
||||
Max: DefaultMaxBufferSize,
|
||||
},
|
||||
}
|
||||
s.linkResQueue.init()
|
||||
|
||||
// Add specified network protocols.
|
||||
for _, netProtoFactory := range opts.NetworkProtocols {
|
||||
|
||||
Reference in New Issue
Block a user