device.go 870 B

12345678910111213141516171819202122232425262728
  1. package overlay
  2. import (
  3. "io"
  4. "net/netip"
  5. "github.com/slackhq/nebula/overlay/tio"
  6. "github.com/slackhq/nebula/routing"
  7. )
  8. // defaultBatchBufSize is the per-Queue scratch size for Read. 65535 covers
  9. // any single IP packet.
  10. const defaultBatchBufSize = 65535
  11. type Device interface {
  12. io.Closer
  13. Activate() error
  14. Networks() []netip.Prefix
  15. Name() string
  16. RoutesFor(netip.Addr) routing.Gateways
  17. // Queues returns the device's packet queues, opening additional ones as
  18. // needed until there are n. Platforms without multiqueue support return
  19. // their single queue regardless of n, so callers must size reader loops
  20. // to len(result), not n; implementations never return more than n. An
  21. // error means a queue that should have opened could not; the caller owns
  22. // cleanup via Close. Called once, during interface activation.
  23. Queues(n int) ([]tio.Queue, error)
  24. }