package nlwrap

import "github.com/dotcloud/docker/internal/nlwrap"

Package nlwrap wraps vishvandanda/netlink functions that may return EINTR.

A Handle instantiated using NewHandle or NewHandleAt can be used in place of a netlink.Handle, it's a wrapper that replaces methods that need to be wrapped. Functions that use the package handle need to be called as "nlwrap.X" instead of "netlink.X".

When netlink.ErrDumpInterrupted is returned, the wrapped functions retry up to maxAttempts times. This error means NLM_F_DUMP_INTR was flagged in a netlink response, meaning something changed during the dump so results may be incomplete or inconsistent.

To avoid retrying indefinitely, if netlink.ErrDumpInterrupted is still returned after maxAttempts, the wrapped functions will discard the error, log a stack trace to make the issue visible and aid in debugging, and return the possibly inconsistent results. Returning possibly inconsistent results matches the behaviour of vishvananda/netlink versions prior to 1.2.1, in which the NLM_F_DUMP_INTR flag was ignored.

Index

Functions

func AddrList

func AddrList(link netlink.Link, family int) (addrs []netlink.Addr, err error)

AddrList calls netlink.AddrList, retrying if necessary.

func ConntrackTableList

func ConntrackTableList(
	table netlink.ConntrackTableType,
	family netlink.InetFamily,
) (flows []*netlink.ConntrackFlow, err error)

ConntrackTableList calls netlink.ConntrackTableList, retrying if necessary.

func LinkByName

func LinkByName(name string) (link netlink.Link, err error)

LinkByName calls netlink.LinkByName, retrying if necessary. The netlink function doesn't normally ask the kernel for a dump of links. But, on an old kernel, it will do as a fallback and that dump may get inconsistent results.

func LinkList() (links []netlink.Link, err error)

LinkList calls netlink.Handle.LinkList, retrying if necessary.

func LinkSubscribeWithOptions

func LinkSubscribeWithOptions(ch chan<- netlink.LinkUpdate, done <-chan struct{}, options netlink.LinkSubscribeOptions) (err error)

LinkSubscribeWithOptions calls netlink.LinkSubscribeWithOptions, retrying if necessary. Close the done channel when done (rather than just sending on it), so that goroutines started by the netlink package are all stopped.

Types

type Handle

type Handle struct {
	*netlink.Handle
}

func NewHandle

func NewHandle(nlFamilies ...int) (Handle, error)

func NewHandleAt

func NewHandleAt(ns netns.NsHandle, nlFamilies ...int) (Handle, error)

func (Handle) AddrList

func (nlh Handle) AddrList(link netlink.Link, family int) (addrs []netlink.Addr, err error)

AddrList calls nlh.Handle.AddrList, retrying if necessary.

func (Handle) Close

func (h Handle) Close()

func (Handle) ConntrackDeleteFilters

func (nlh Handle) ConntrackDeleteFilters(
	table netlink.ConntrackTableType,
	family netlink.InetFamily,
	filters ...netlink.CustomConntrackFilter,
) (matched uint, err error)

ConntrackDeleteFilters calls nlh.Handle.ConntrackDeleteFilters, retrying if necessary.

func (Handle) LinkByName

func (nlh Handle) LinkByName(name string) (link netlink.Link, err error)

LinkByName calls nlh.Handle.LinkByName, retrying if necessary. The netlink function doesn't normally ask the kernel for a dump of links. But, on an old kernel, it will do as a fallback and that dump may get inconsistent results.

func (nlh Handle) LinkList() (links []netlink.Link, err error)

LinkList calls nlh.Handle.LinkList, retrying if necessary.

func (Handle) RouteList

func (nlh Handle) RouteList(link netlink.Link, family int) (routes []netlink.Route, err error)

RouteList calls nlh.Handle.RouteList, retrying if necessary.

func (Handle) XfrmPolicyList

func (nlh Handle) XfrmPolicyList(family int) (policies []netlink.XfrmPolicy, err error)

XfrmPolicyList calls nlh.Handle.XfrmPolicyList, retrying if necessary.

func (Handle) XfrmStateList

func (nlh Handle) XfrmStateList(family int) (states []netlink.XfrmState, err error)

XfrmStateList calls nlh.Handle.XfrmStateList, retrying if necessary.

Source Files

nlwrap_linux.go

Version
v28.1.1+incompatible (latest)
Published
Apr 18, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
20 minutes ago

Tools for package owners.