mirror of
https://github.com/slackhq/nebula.git
synced 2026-05-16 04:47:38 +02:00
clean up a comment a bit
This commit is contained in:
20
interface.go
20
interface.go
@@ -285,7 +285,7 @@ func (f *Interface) activate() error {
|
|||||||
// is on, everything else (and either lane disabled) falls
|
// is on, everything else (and either lane disabled) falls
|
||||||
// through to passthrough so non-IP / non-TCP-UDP traffic still
|
// through to passthrough so non-IP / non-TCP-UDP traffic still
|
||||||
// reaches the TUN.
|
// reaches the TUN.
|
||||||
f.batchers[i] = batch.NewMultiCoalescer(f.readers[i], caps.TSO, caps.USO)
|
f.batchers[i] = batch.NewMultiCoalescer(f.readers[i], f.l, caps.TSO, caps.USO)
|
||||||
} else {
|
} else {
|
||||||
f.batchers[i] = batch.NewPassthrough(f.readers[i])
|
f.batchers[i] = batch.NewPassthrough(f.readers[i])
|
||||||
}
|
}
|
||||||
@@ -372,18 +372,8 @@ func (f *Interface) listenOut(i int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Interface) listenIn(reader tio.Queue, i int) {
|
func (f *Interface) listenIn(reader tio.Queue, i int) {
|
||||||
// Pin this goroutine to one CPU. LockOSThread alone keeps the goroutine
|
// Pinning this thread (and goroutine) to a single CPU keeps every sendmmsg from this goroutine going through the
|
||||||
// on a single OS thread but the kernel can still migrate that thread
|
// same TX ring on the nic, so the wire sees per-flow order.
|
||||||
// across CPUs — XPS reads smp_processor_id() at sendmmsg time and picks
|
|
||||||
// the TX ring from the current CPU's xps_cpus map, so an unpinned
|
|
||||||
// thread bouncing between CPUs spreads one nebula flow's packets across
|
|
||||||
// multiple TX rings, which the rings then drain at independent rates
|
|
||||||
// and the wire delivers reordered.
|
|
||||||
//
|
|
||||||
// Pinning keeps every sendmmsg from this goroutine going through the
|
|
||||||
// same TX ring, so the wire sees per-flow order. Cost: less scheduler
|
|
||||||
// flexibility — if i % NumCPU collides between two TUN reader
|
|
||||||
// goroutines they share a CPU.
|
|
||||||
cpu := i % runtime.NumCPU()
|
cpu := i % runtime.NumCPU()
|
||||||
if n := len(f.cpuAffinity); n > 0 {
|
if n := len(f.cpuAffinity); n > 0 {
|
||||||
cpu = f.cpuAffinity[i%n]
|
cpu = f.cpuAffinity[i%n]
|
||||||
@@ -391,8 +381,10 @@ func (f *Interface) listenIn(reader tio.Queue, i int) {
|
|||||||
if err := util.PinThreadToCPU(cpu); err != nil {
|
if err := util.PinThreadToCPU(cpu); err != nil {
|
||||||
f.l.Warn("failed to pin tun reader to CPU", "queue", i, "cpu", cpu, "err", err)
|
f.l.Warn("failed to pin tun reader to CPU", "queue", i, "cpu", cpu, "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rejectBuf := make([]byte, mtu)
|
rejectBuf := make([]byte, mtu)
|
||||||
sb := batch.NewSendBatch(f.writers[i], batch.SendBatchCap, udp.MTU+32)
|
arenaSize := batch.SendBatchCap * (udp.MTU + 32)
|
||||||
|
sb := batch.NewSendBatch(f.writers[i], batch.SendBatchCap, arenaSize)
|
||||||
fwPacket := &firewall.Packet{}
|
fwPacket := &firewall.Packet{}
|
||||||
nb := make([]byte, 12, 12)
|
nb := make([]byte, 12, 12)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user