nlwrap

package
v27.5.0-rc.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

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.

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.

Jump to

Keyboard shortcuts

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