macvlan

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package macvlan helps with creating transient MACVLAN network interfaces for testing purposes. It leverages the Ginkgo testing framework and matching (erm, sic!) Gomega matchers.

These MACVLAN network interfaces are transient because they automatically get removed at the end of the a test (spec, block/group, suite, et cetera) using Ginkgo's DeferCleanup.

Index

Constants

View Source
const MacvlanPrefix = "mcvl-"

MacvlanPrefix is the name prefix used for transient MACVLAN network interfaces.

Variables

This section is empty.

Functions

func CreateTransient deprecated

func CreateTransient(parent netlink.Link) netlink.Link

CreateTransient creates and returns a new (and transient) MACVLAN network interface attached to the specified parent network interface (which must be a hardware network interface, including the dummy kind).

Deprecated: use NewTransient instead.

func LocateHWParent

func LocateHWParent() netlink.Link

LocateHWParent locates a “hardware” network interface in the current network namespace that is operationally up and returns it. If no suitable network interface can be found, then the current test is failed. If multiple suitable network interfaces are found, a random one of them is returned.

Please consider using a “dummy” network interface instead as a MACVLAN parent unless it's absolutely necessary to use a hardware network interface. Dummy network interfaces can be created using [dummy.NewTransient].

func NewTransient added in v1.0.2

func NewTransient(parent netlink.Link, opts ...Opt) netlink.Link

NewTransient creates and returns a new (and transient) MACVLAN network interface attached to the specified parent network interface (which must be a hardware network interface, including the dummy kind). CreateTransient automatically defers proper automatic removal of the MACVLAN network interface.

Types

type Opt added in v1.5.0

type Opt func(netlink.Link) error

Opt is a configuration option when creating a new MACVLAN network interface.

func InNamespace added in v1.5.0

func InNamespace(fdref int) Opt

InNamespace configures a MACVLAN network interface to be created in the network namespace referenced by fdref, instead of creating it in the current network namespace.

func WithMode added in v1.5.0

func WithMode(mode netlink.MacvlanMode) Opt

WithMode configures the MACVLAN mode.

See also: netlink.MacvlanMode.

Jump to

Keyboard shortcuts

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