mirror of
https://github.com/slackhq/nebula.git
synced 2026-08-15 09:57:00 +02:00
checkpt
This commit is contained in:
+3
-16
@@ -31,9 +31,6 @@ type tun struct {
|
||||
routeTree atomic.Pointer[bart.Table[routing.Gateways]]
|
||||
linkAddr *netroute.LinkAddr
|
||||
l *slog.Logger
|
||||
|
||||
readBuf []byte
|
||||
batchRet [1]tio.Packet
|
||||
}
|
||||
|
||||
type ifReq struct {
|
||||
@@ -129,7 +126,6 @@ func newTun(c *config.C, l *slog.Logger, vpnNetworks []netip.Prefix, _ bool) (*t
|
||||
vpnNetworks: vpnNetworks,
|
||||
DefaultMTU: c.GetInt("tun.mtu", DefaultMTU),
|
||||
l: l,
|
||||
readBuf: make([]byte, defaultBatchBufSize),
|
||||
}
|
||||
|
||||
err = t.reload(c, true)
|
||||
@@ -519,9 +515,9 @@ func tunWritev(fd int, iovecs []unix.Iovec) (n int, err error)
|
||||
//go:noescape
|
||||
func tunReadv(fd int, iovecs []unix.Iovec) (n int, err error)
|
||||
|
||||
// readOne pulls one IP packet off the utun device, scattering the 4 byte protocol header away from
|
||||
// Read pulls one IP packet off the utun device, scattering the 4 byte protocol header away from
|
||||
// the packet so the payload lands directly in to.
|
||||
func (t *tun) readOne(to []byte) (int, error) {
|
||||
func (t *tun) Read(to []byte) (int, error) {
|
||||
var head [4]byte
|
||||
|
||||
rc, err := t.f.SyscallConn()
|
||||
@@ -554,15 +550,6 @@ func (t *tun) readOne(to []byte) (int, error) {
|
||||
return n - 4, nil
|
||||
}
|
||||
|
||||
func (t *tun) Read() ([]tio.Packet, error) {
|
||||
n, err := t.readOne(t.readBuf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
t.batchRet[0] = tio.Packet{Bytes: t.readBuf[:n]}
|
||||
return t.batchRet[:], nil
|
||||
}
|
||||
|
||||
// Write pushes one IP packet onto the utun device. Only valid for single threaded use.
|
||||
func (t *tun) Write(from []byte) (int, error) {
|
||||
if len(from) == 0 {
|
||||
@@ -628,5 +615,5 @@ func (t *tun) NewMultiQueueReader() error {
|
||||
}
|
||||
|
||||
func (t *tun) Readers() []tio.Queue {
|
||||
return []tio.Queue{t}
|
||||
return []tio.Queue{tio.NewSingleQueue(t, defaultBatchBufSize)}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user