mplsutil

package
v0.0.0-...-37ae75e Latest Latest
Warning

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

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

Documentation

Overview

Package mplsutil implements a set of helper utility to run common gRIBI MPLS test scenarios against an ATE and DUT.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ATESrc describes the configuration parameters for the ATE port sourcing
	// a flow.
	ATESrc = &attrs.Attributes{
		Name:    "port1",
		Desc:    "ATE_SRC_PORT",
		IPv4:    "192.0.2.0",
		IPv4Len: 31,
		MAC:     "02:00:01:01:01:01",
		IPv6:    "2001:db8::0",
		IPv6Len: 127,
	}
	// DUTSrc describes the configuration parameters for the DUT port connected
	// to the ATE src port.
	DUTSrc = &attrs.Attributes{
		Desc:    "DUT_SRC_PORT",
		IPv4:    "192.0.2.1",
		IPv4Len: 31,
		IPv6:    "2001:db8::1",
		IPv6Len: 127,
	}
	// ATEDst describes the configuration parameters for the ATE port that acts
	// as the traffic sink.
	ATEDst = &attrs.Attributes{
		Name:    "port2",
		Desc:    "ATE_DST_PORT",
		IPv4:    "192.0.2.2",
		IPv4Len: 31,
		MAC:     "02:00:02:01:01:01",
		IPv6:    "2001:db8::2",
		IPv6Len: 127,
	}
	// DUTDst describes the configuration parameters for the DUT port that is
	// connected to the ate destination port.
	DUTDst = &attrs.Attributes{
		Desc:    "DUT_DST_PORT",
		IPv4:    "192.0.2.3",
		IPv4Len: 31,
		IPv6:    "2001:db8::3",
		IPv6Len: 127,
	}
)

Tests initialised by the GRIBIMPLSTest helper rely on a specific topology of the form:

 -----         2001:db8::0/127      -----
|     |-port1--192.0.2.0/31--port1-|     |
| ate |                            | dut |
|     |-port2--192.0.2.2/31--port2-|     |
 -----         2001:db8::2/127      -----

The following variables set up the device configurations for this topology.

Functions

This section is empty.

Types

type Args

type Args struct {
	// LabelsToPop specifies the set of labels that should be popped from
	// an incoming MPLS packet.
	LabelsToPop []uint32
	// LabelsToPush specifies the set of labels that should be pushed to
	// an incoming MPLS packet.
	LabelsToPush []uint32
}

Args specifies a set of arguments that can be handed to specific gRIBI tests to control the specific payload that they create.

type GRIBIMPLSTest

type GRIBIMPLSTest struct {
	// contains filtered or unexported fields
}

GRIBIMPLSTest is a wrapper around a specific gRIBI MPLS test scenario, the test has a specific mode that is used to control its underlying functionality. The modes are enumerated by the mplsutil.Mode type described in detail above.

func New

func New(c *fluent.GRIBIClient, m Mode, defName string, args *Args) *GRIBIMPLSTest

New returns a new GRIBIMPLSTest initialised with the specified client, mode and default network instance name (defName). The supplied args are used to determine the behaviour of specific tests that require additional configuration.

func (*GRIBIMPLSTest) Cleanup

func (g *GRIBIMPLSTest) Cleanup(t *testing.T)

Cleanup cleans up the underlying gRIBI server to remove any entries.

func (*GRIBIMPLSTest) ConfigureDevices

func (g *GRIBIMPLSTest) ConfigureDevices(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra.ATEDevice)

ConfigureDevices configures the DUT and ATE with their base configurations such the test topology is set up. This uses a constant topology as described in topo.go.

func (*GRIBIMPLSTest) ConfigureFlows

func (g *GRIBIMPLSTest) ConfigureFlows(t *testing.T, ate *ondatra.ATEDevice)

ConfigureFlows sets up the flows that are required for the specified test type on the ATE device provided.

func (*GRIBIMPLSTest) ProgramGRIBI

func (g *GRIBIMPLSTest) ProgramGRIBI(t *testing.T)

ProgramGRIBI performs the programming operations specified by the mode of the test.

func (*GRIBIMPLSTest) RunFlows

func (g *GRIBIMPLSTest) RunFlows(t *testing.T, ate *ondatra.ATEDevice, runtime time.Duration, tolerableLostPackets uint64)

RunFlows validates that traffic is forwarded by the DUT by running the flows required by the specified test.

func (*GRIBIMPLSTest) ValidateProgramming

func (g *GRIBIMPLSTest) ValidateProgramming(t *testing.T)

ValidateProgramming validates whether the programming for the specific scenario was accepted at the DUT.

type Mode

type Mode int64

Mode is an enumerated value fting the type of tests supported by the gRIBI MPLS util.

const (

	// PushToMPLS defines a test that programs a DUT via gRIBI with a
	// label forwarding entry within defaultNIName, with a label stack with
	// numLabels in it, starting at baseLabel, if trafficFunc is non-nil it is run
	// to validate the dataplane.
	//
	// The DUT is expected to have a next-hop of 192.0.2.2 that is resolvable.
	PushToMPLS Mode
	// PushToIP programs a gRIBI entry for an ingress LER function whereby MPLS labels are
	// pushed to an IP packet. The entries are programmed into defaultNIName, with the stack
	// imposed being a stack of numLabels labels, starting with baseLabel. After the programming
	// has been verified trafficFunc is run to allow validation of the dataplane.
	//
	// The DUT is expected to be within a topology where 192.0.2.2 is a valid next-hop.
	PushToIP
	// PopTopLabel creates a test whereby the top label of an input packet is popped.
	// The DUT is expected to be in a topology where 192.0.2.2 is a valid next-hop. Packets
	// with label 100 will have this label popped from the stack.
	PopTopLabel
	// PopNLabels programs a gRIBI server with a LFIB entry matching label 100
	// that pops the labels specified in popLabels from the stack. If trafficFunc
	// is non-nil it is called after the gRIBI programming is verified.
	//
	// The DUT is expected to be in a topology where 192.0.2.2 resolves to
	// a valid next-hop.
	PopNLabels
	// PopOnePushN implements a test whereby one (the top) label is popped, and N labels as specified
	// by pushLabels are pushed to the stack for an input MPLS packet. Two LFIB entries (100 and 200)
	// are created. If trafficFunc is non-nil it is called after the gRIBI programming has been validated.
	//
	// The DUT is expected to be in a topology where 192.0.2.2 is a resolvable next-hop.
	PopOnePushN
)

Jump to

Keyboard shortcuts

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