bridge

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

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

The "dummy" network interfaces created by this package 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 BridgePrefix = "bri-"

BridgePrefix is the name prefix used for transient bridge (network interfaces). Note that we don't want to interfere with Docker's “br-” namespace.

Variables

This section is empty.

Functions

func AddPort

func AddPort(br netlink.Link, port netlink.Link)

AddPort adds the specified “port” link to the passed “br” bridge, failing the current test in case the link cannot be added as a port to the bridge.

func NewTransient

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

NewTransient creates and returns a new (and transient) VLAN network interface with VLAN ID passed in vid, and attached to the specified network interface. NewTransient automatically defers proper automatic removal of the VLAN network interface.

Types

type Opt

type Opt func(*link.Link) error

Opt is a configuration option when creating a new bridge (network interface).

func InNamespace

func InNamespace(fdref int) Opt

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

func WithAgeing

func WithAgeing(d time.Duration) Opt

WithAgeing configures the bridge's FDB entries ageing time (duration). Please note that this duration is rounded down to the corresponding USER_HZ-granular duration. The default duration is 300s.

func WithHello

func WithHello(d time.Duration) Opt

WithHello configures the time (duration) between hello packets sent by the bridge. Please note that this duration is rounded down to the corresponding USER_HZ-granular duration. The default duration is 2s.

func WithLinkNamespace

func WithLinkNamespace(fdref int) Opt

WithLinkNamespace specifies the “reference” or “link” network namespace other than the current network namespace when creating a new network interface.

func WithMulticastSnooping

func WithMulticastSnooping() Opt

WithMulticastSnooping configures multicast snooping. The default is for multicast snooping to be turned on.

func WithVLANFiltering

func WithVLANFiltering() Opt

WithVLANFiltering configures the bridge with VLAN filtering.

func WithoutMulticastSnooping

func WithoutMulticastSnooping() Opt

WithoutMulticastSnooping configures multicast snooping to be turned off.

func WithoutVLANFiltering

func WithoutVLANFiltering() Opt

WithoutVLANFiltering configures the bridge to not use VLAN filtering.

Jump to

Keyboard shortcuts

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