package port

import "gvisor.dev/gvisor/pkg/sentry/socket/netlink/port"

Package port provides port ID allocation for netlink sockets.

A netlink port is any int32 value. Positive ports are typically equivalent to the PID of the binding process. If that port is unavailable, negative ports are searched to find a free port that will not conflict with other PIDS.

Index

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager allocates netlink port IDs.

+stateify savable

func New

func New() *Manager

New creates a new Manager.

func (*Manager) Allocate

func (m *Manager) Allocate(protocol int, hint int32) (int32, bool)

Allocate reserves a new port ID for protocol. hint will be taken if available.

func (*Manager) Release

func (m *Manager) Release(protocol int, port int32)

Release frees the specified port for protocol.

Preconditions: port is already allocated.

Source Files

port.go

Version
v0.0.0-20250605235530-a6711d1e1dc6 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
4 hours ago

Tools for package owners.