kernel

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package kernel is the service.Backend that drives interfaces through the AmneziaWG (or plain WireGuard) kernel module over netlink — RTM_NEWLINK to create the link, address/MTU/up on it, RTM_DELLINK to remove it. It's what the standard awg-agent binary wires in via service.SetBackend. Keeping it in its own package confines the vishvananda/netlink dependency to the kernel build, so the userspace agent (agent/internal/userspace) doesn't pull it in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct{}

Backend implements service.Backend against the kernel module via netlink.

func New

func New() Backend

New returns the kernel backend.

func (Backend) Add

func (Backend) Add(iface string, amnezia bool) error

Add creates the interface's link with the kind the config asks for: a plain WireGuard interface (amnezia false) is created as kind "wireguard" directly. An AmneziaWG interface (amnezia true) is created as kind "amneziawg" so the obfuscation params are honored, falling back to a plain "wireguard" link on hosts that only have the mainline module — or whose amnezia module doesn't allow creating a link over netlink (EINVAL/EOPNOTSUPP). That fallback is logged at warn level because obfuscation silently won't apply there.

func (Backend) AddrAdd

func (Backend) AddrAdd(iface, s string) error

func (Backend) Delete

func (Backend) Delete(iface string) error

func (Backend) Down

func (Backend) Down(iface string) error

func (Backend) Exists

func (Backend) Exists(iface string) bool

func (Backend) Info

func (Backend) Info() service.BackendInfo

Info reports the kernel backend's capabilities on this host. A plain WireGuard interface is always listed — kernel WireGuard support is a prerequisite for running this build at all. An AmneziaWG interface is listed only when the amneziawg kernel module is available (see amneziaModuleAvailable), since without it Add falls back to a plain WireGuard link and obfuscation wouldn't apply.

func (Backend) SetMTU

func (Backend) SetMTU(iface string, mtu int) error

func (Backend) SyncAddr

func (Backend) SyncAddr(iface, s string) error

SyncAddr makes s the interface's only address, removing every other address already assigned to it first. netlink's AddrReplace only adds-or-updates the one address it's given — it has nothing to do with whatever *other* addresses are already on the link, so calling it alone after an admin edits an interface's addr leaves the old one still assigned alongside the new one.

func (Backend) Up

func (Backend) Up(iface string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL