package netlinksafe

import "github.com/containernetworking/plugins/pkg/netlinksafe"

Package netlinksafe 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 "netlinksafe.X" instead of "netlink.X".

The wrapped functions currently return EINTR when NLM_F_DUMP_INTR flagged in a netlink response, meaning something changed during the dump so results may be incomplete or inconsistent.

At present, the possibly incomplete/inconsistent results are not returned by netlink functions along with the EINTR. So, it's not possible to do anything but retry. After maxAttempts the EINTR will be returned to the caller.

Index

Functions

func AddrList

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

AddrList calls netlink.AddrList, retrying if necessary.

func BridgeVlanList

func BridgeVlanList() (map[int32][]*nl.BridgeVlanInfo, error)

BridgeVlanList calls netlink.BridgeVlanList, retrying if necessary.

func ConntrackDeleteFilters

func ConntrackDeleteFilters(table netlink.ConntrackTableType, family netlink.InetFamily, filters ...netlink.CustomConntrackFilter) (uint, error)

ConntrackDeleteFilters calls netlink.ConntrackDeleteFilters, retrying if necessary.

func FilterList

func FilterList(link netlink.Link, parent uint32) ([]netlink.Filter, error)

FilterList calls netlink.FilterList, retrying if necessary.

func LinkByName

func LinkByName(name string) (netlink.Link, 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 LinkGetProtinfo

func LinkGetProtinfo(link netlink.Link) (netlink.Protinfo, error)

LinkGetProtinfo calls netlink.LinkGetProtinfo, retrying if necessary.

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

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

func QdiscList

func QdiscList(link netlink.Link) ([]netlink.Qdisc, error)

QdiscList calls netlink.QdiscList, retrying if necessary.

func RouteList

func RouteList(link netlink.Link, family int) ([]netlink.Route, error)

RouteList calls netlink.RouteList, retrying if necessary.

func RouteListFiltered

func RouteListFiltered(family int, filter *netlink.Route, filterMask uint64) ([]netlink.Route, error)

RouteListFiltered calls netlink.RouteListFiltered, retrying if necessary.

func RuleList

func RuleList(family int) ([]netlink.Rule, error)

RuleList calls netlink.RuleList, retrying if necessary.

func RuleListFiltered

func RuleListFiltered(family int, filter *netlink.Rule, filterMask uint64) ([]netlink.Rule, error)

RuleListFiltered calls netlink.RuleListFiltered, 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) Close

func (h Handle) Close()

func (*Handle) ConntrackDeleteFilters

func (h *Handle) ConntrackDeleteFilters(table netlink.ConntrackTableType, family netlink.InetFamily, filters ...netlink.CustomConntrackFilter) (uint, error)

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

func (*Handle) FilterList

func (h *Handle) FilterList(link netlink.Link, parent uint32) ([]netlink.Filter, error)

FilterList calls h.Handle.FilterList, retrying if necessary.

func (Handle) LinkByName

func (h Handle) LinkByName(name string) (netlink.Link, error)

LinkByName calls h.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 (*Handle) LinkGetProtinfo

func (h *Handle) LinkGetProtinfo(link netlink.Link) (netlink.Protinfo, error)

LinkGetProtinfo calls h.Handle.LinkGetProtinfo, retrying if necessary.

func (h Handle) LinkList() ([]netlink.Link, error)

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

func (*Handle) QdiscList

func (h *Handle) QdiscList(link netlink.Link) ([]netlink.Qdisc, error)

QdiscList calls h.Handle.QdiscList, retrying if necessary.

func (Handle) RouteList

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

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

func (Handle) RouteListFiltered

func (h Handle) RouteListFiltered(family int, filter *netlink.Route, filterMask uint64) ([]netlink.Route, error)

RouteListFiltered calls h.Handle.RouteListFiltered, retrying if necessary.

func (*Handle) RuleList

func (h *Handle) RuleList(family int) ([]netlink.Rule, error)

RuleList calls h.Handle.RuleList, retrying if necessary.

func (*Handle) RuleListFiltered

func (h *Handle) RuleListFiltered(family int, filter *netlink.Rule, filterMask uint64) ([]netlink.Rule, error)

RuleListFiltered calls h.Handle.RuleListFiltered, retrying if necessary.

Source Files

netlink.go

Version
v1.7.1 (latest)
Published
Apr 25, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
13 hours ago

Tools for package owners.