mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-16 04:47:38 +02:00
Remove WriteFromSelf
This commit is contained in:
@@ -38,7 +38,7 @@ func (f *Interface) consumeInsidePacket(packet []byte, fwPacket *firewall.Packet
|
||||
// routes packets from the Nebula addr to the Nebula addr through the Nebula
|
||||
// TUN device.
|
||||
if immediatelyForwardToSelf {
|
||||
_, err := f.readers[q].WriteFromSelf(packet)
|
||||
_, err := f.readers[q].Write(packet)
|
||||
if err != nil {
|
||||
f.l.Error("Failed to forward to tun", "error", err)
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func (f *Interface) rejectInside(packet []byte, out []byte, q int) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err := f.readers[q].WriteFromSelf(out)
|
||||
_, err := f.readers[q].Write(out)
|
||||
if err != nil {
|
||||
f.l.Error("Failed to write to tun", "error", err)
|
||||
}
|
||||
|
||||
@@ -39,10 +39,6 @@ func (NoopTun) Write([]byte) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (NoopTun) WriteFromSelf(p []byte) (int, error) {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
func (NoopTun) SupportsMultiqueue() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -23,21 +23,12 @@ type Queue interface {
|
||||
// Read returns one or more packets. The returned slices are borrowed
|
||||
// from the Queue's internal buffer and are only valid until the next
|
||||
// Read or Close on this Queue - callers must encrypt or copy each
|
||||
// slice before the next call. Not safe for concurrent Reads; exactly
|
||||
// one goroutine per Queue reads.
|
||||
// slice before the next call. Not safe for concurrent Reads.
|
||||
Read() ([][]byte, error)
|
||||
|
||||
// Write emits a single packet on the plaintext (outside→inside)
|
||||
// delivery path. May run concurrently with WriteFromSelf on the same
|
||||
// Queue, but not with itself.
|
||||
// delivery path. Not safe for concurrent Writes.
|
||||
Write(p []byte) (int, error)
|
||||
|
||||
// WriteFromSelf writes a single packet that originated from the inside
|
||||
// path (reject replies or self-forward) using scratch state distinct
|
||||
// from Write, so it can run concurrently with Write on the same Queue
|
||||
// without a data race. On backends without a shared-scratch Write, a
|
||||
// trivial delegation to Write is acceptable.
|
||||
WriteFromSelf(p []byte) (int, error)
|
||||
}
|
||||
|
||||
// GSOWriter is implemented by Queues that can emit a TCP TSO superpacket
|
||||
|
||||
@@ -162,7 +162,3 @@ func (t *Poll) Close() error {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *Poll) WriteFromSelf(p []byte) (int, error) {
|
||||
return t.Write(p)
|
||||
}
|
||||
|
||||
@@ -43,10 +43,6 @@ func (t *tun) Write(p []byte) (int, error) {
|
||||
return t.rwc.Write(p)
|
||||
}
|
||||
|
||||
func (t *tun) WriteFromSelf(p []byte) (int, error) {
|
||||
return t.rwc.Write(p)
|
||||
}
|
||||
|
||||
func (t *tun) Close() error {
|
||||
return t.rwc.Close()
|
||||
}
|
||||
|
||||
@@ -525,10 +525,6 @@ func (t *tun) Read() ([][]byte, error) {
|
||||
return t.batchRet[:], nil
|
||||
}
|
||||
|
||||
func (t *tun) WriteFromSelf(p []byte) (int, error) {
|
||||
return t.Write(p)
|
||||
}
|
||||
|
||||
// Write is only valid for single threaded use
|
||||
func (t *tun) Write(from []byte) (int, error) {
|
||||
buf := t.out
|
||||
|
||||
@@ -108,10 +108,6 @@ func (t *disabledTun) Write(b []byte) (int, error) {
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
func (t *disabledTun) WriteFromSelf(b []byte) (int, error) {
|
||||
return t.Write(b)
|
||||
}
|
||||
|
||||
func (t *disabledTun) SupportsMultiqueue() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -168,10 +168,6 @@ func (t *tun) Read() ([][]byte, error) {
|
||||
return t.batchRet[:], nil
|
||||
}
|
||||
|
||||
func (t *tun) WriteFromSelf(p []byte) (int, error) {
|
||||
return t.Write(p)
|
||||
}
|
||||
|
||||
func (t *tun) readOne(to []byte) (int, error) {
|
||||
// first 4 bytes is protocol family, in network byte order
|
||||
var head [4]byte
|
||||
|
||||
@@ -45,10 +45,6 @@ func (t *tun) Write(p []byte) (int, error) {
|
||||
return t.rwc.Write(p)
|
||||
}
|
||||
|
||||
func (t *tun) WriteFromSelf(p []byte) (int, error) {
|
||||
return t.rwc.Write(p)
|
||||
}
|
||||
|
||||
func (t *tun) Close() error {
|
||||
return t.rwc.Close()
|
||||
}
|
||||
|
||||
@@ -80,10 +80,6 @@ func (t *tun) Read() ([][]byte, error) {
|
||||
return t.batchRet[:], nil
|
||||
}
|
||||
|
||||
func (t *tun) WriteFromSelf(p []byte) (int, error) {
|
||||
return t.Write(p)
|
||||
}
|
||||
|
||||
func (t *tun) Readers() []tio.Queue {
|
||||
return []tio.Queue{t}
|
||||
}
|
||||
|
||||
@@ -73,10 +73,6 @@ func (t *tun) Read() ([][]byte, error) {
|
||||
return t.batchRet[:], nil
|
||||
}
|
||||
|
||||
func (t *tun) WriteFromSelf(p []byte) (int, error) {
|
||||
return t.Write(p)
|
||||
}
|
||||
|
||||
var deviceNameRE = regexp.MustCompile(`^tun[0-9]+$`)
|
||||
|
||||
func newTunFromFd(_ *config.C, _ *slog.Logger, _ int, _ []netip.Prefix) (*tun, error) {
|
||||
|
||||
@@ -128,10 +128,6 @@ func (t *TestTun) Write(b []byte) (n int, err error) {
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
func (t *TestTun) WriteFromSelf(b []byte) (int, error) {
|
||||
return t.Write(b)
|
||||
}
|
||||
|
||||
func (t *TestTun) Close() error {
|
||||
if t.closed.CompareAndSwap(false, true) {
|
||||
close(t.rxPackets)
|
||||
|
||||
@@ -50,10 +50,6 @@ func (t *winTun) Read() ([][]byte, error) {
|
||||
return t.batchRet[:], nil
|
||||
}
|
||||
|
||||
func (t *winTun) WriteFromSelf(p []byte) (int, error) {
|
||||
return t.Write(p)
|
||||
}
|
||||
|
||||
func newTunFromFd(_ *config.C, _ *slog.Logger, _ int, _ []netip.Prefix) (Device, error) {
|
||||
return nil, fmt.Errorf("newTunFromFd not supported in Windows")
|
||||
}
|
||||
|
||||
@@ -88,9 +88,7 @@ func (d *UserDevice) Pipe() (*io.PipeReader, *io.PipeWriter) {
|
||||
func (d *UserDevice) Write(p []byte) (n int, err error) {
|
||||
return d.inboundWriter.Write(p)
|
||||
}
|
||||
func (d *UserDevice) WriteFromSelf(p []byte) (n int, err error) {
|
||||
return d.Write(p)
|
||||
}
|
||||
|
||||
func (d *UserDevice) Close() error {
|
||||
d.inboundWriter.Close()
|
||||
d.outboundWriter.Close()
|
||||
|
||||
Reference in New Issue
Block a user