summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/link/sharedmem/tx.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-10-28 00:30:40 +0000
committergVisor bot <gvisor-bot@google.com>2021-10-28 00:30:40 +0000
commit56cb3487c737c7ab6de68d27185b678968682e7c (patch)
tree3096bb5d26e2c48d2a1b7a65f46e1938314cda22 /pkg/tcpip/link/sharedmem/tx.go
parentd909cd18a7be8ebb2145414645ce796dcf46bb58 (diff)
parent8acc3a9bb2225a5af9e5bf587d2a2baad0e5f841 (diff)
Merge release-20211019.0-48-g8acc3a9bb (automated)
Diffstat (limited to 'pkg/tcpip/link/sharedmem/tx.go')
-rw-r--r--pkg/tcpip/link/sharedmem/tx.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/pkg/tcpip/link/sharedmem/tx.go b/pkg/tcpip/link/sharedmem/tx.go
index d6c61afee..a74fc012b 100644
--- a/pkg/tcpip/link/sharedmem/tx.go
+++ b/pkg/tcpip/link/sharedmem/tx.go
@@ -34,6 +34,7 @@ type tx struct {
ids idManager
bufs bufferManager
eventFD eventfd.Eventfd
+ sharedData []byte
sharedDataFD int
}
@@ -62,13 +63,22 @@ func (t *tx) init(mtu uint32, c *QueueConfig) error {
return err
}
+ sharedData, err := getBuffer(c.SharedDataFD)
+ if err != nil {
+ unix.Munmap(txPipe)
+ unix.Munmap(rxPipe)
+ unix.Munmap(data)
+ }
+
// Initialize state based on buffers.
- t.q.Init(txPipe, rxPipe)
+ t.q.Init(txPipe, rxPipe, sharedDataPointer(sharedData))
t.ids.init()
t.bufs.init(0, len(data), int(mtu))
t.data = data
t.eventFD = c.EventFD
t.sharedDataFD = c.SharedDataFD
+ t.sharedData = sharedData
+
return nil
}
@@ -149,7 +159,9 @@ func (t *tx) transmit(bufs ...buffer.View) bool {
// notify writes to the tx.eventFD to indicate to the peer that there is data to
// be read.
func (t *tx) notify() {
- t.eventFD.Notify()
+ if t.q.NotificationsEnabled() {
+ t.eventFD.Notify()
+ }
}
// idDescriptor is used by idManager to either point to a tx buffer (in case