Skip to content

Commit

Permalink
Add IP to MPLS traffiic forwarding test. (openconfig#2531)
Browse files Browse the repository at this point in the history
* * (A) Add IP to MPLS traffiic forwarding test.
  - Add traffic validation to IP forwarding test.

* removing calls to SetChoice
  • Loading branch information
alshabib authored and frasieroh committed Jan 30, 2024
1 parent a68eed1 commit 80d9076
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 22 deletions.
53 changes: 33 additions & 20 deletions feature/gribi/mplsutil/mplsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,53 +377,66 @@ const (
// type on the ATE device provided.
func (g *GRIBIMPLSTest) ConfigureFlows(t *testing.T, ate *ondatra.ATEDevice) {
t.Helper()

t.Logf("looking on interface %s_ETH for %s", ATESrc.Name, DUTSrc.IPv4)
var dstMAC string
gnmi.WatchAll(t, ate.OTG(), gnmi.OTG().Interface(ATESrc.Name+"_ETH").Ipv4NeighborAny().LinkLayerAddress().State(), time.Minute, func(val *ygnmi.Value[string]) bool {
dstMAC, _ = val.Val()
return val.IsPresent()
}).Await(t)
t.Logf("MAC discovered was %s", dstMAC)

g.otgConfig.Flows().Clear().Items()
flow := g.otgConfig.Flows().Add().SetName(flowName)
flow.Metrics().SetEnable(true)
flow.TxRx().Port().SetTxName(ATESrc.Name).SetRxName(ATEDst.Name)
flow.Rate().SetPps(1)
flow.Rate().SetPps(1)

switch g.mode {
case PushToMPLS:
t.Logf("looking on interface %s_ETH for %s", ATESrc.Name, DUTSrc.IPv4)
var dstMAC string
gnmi.WatchAll(t, ate.OTG(), gnmi.OTG().Interface(ATESrc.Name+"_ETH").Ipv4NeighborAny().LinkLayerAddress().State(), time.Minute, func(val *ygnmi.Value[string]) bool {
dstMAC, _ = val.Val()
return val.IsPresent()
}).Await(t)
t.Logf("MAC discovered was %s", dstMAC)

g.otgConfig.Flows().Clear().Items()
mplsFlow := g.otgConfig.Flows().Add().SetName(flowName)
mplsFlow.Metrics().SetEnable(true)
mplsFlow.TxRx().Port().SetTxName(ATESrc.Name).SetRxName(ATEDst.Name)
mplsFlow.Rate().SetPps(1)

// Set up ethernet layer.
eth := mplsFlow.Packet().Add().Ethernet()
eth := flow.Packet().Add().Ethernet()
eth.Src().SetValue(ATESrc.MAC)
eth.Dst().SetValue(dstMAC)

// Set up MPLS layer with destination label 100.
mpls := mplsFlow.Packet().Add().Mpls()
mpls := flow.Packet().Add().Mpls()
mpls.Label().SetValue(staticMPLSToATE)
mpls.BottomOfStack().SetValue(0)

mplsInner := mplsFlow.Packet().Add().Mpls()
mplsInner := flow.Packet().Add().Mpls()
mplsInner.Label().SetValue(innerLabel)
mplsInner.BottomOfStack().SetValue(1)

ip4 := mplsFlow.Packet().Add().Ipv4()
ip4 := flow.Packet().Add().Ipv4()
ip4.Src().SetValue("198.18.1.1")
ip4.Dst().SetValue("198.18.2.1")
ip4.Version().SetValue(4)
case PushToIP:
// Set up ethernet layer.
eth := flow.Packet().Add().Ethernet()
eth.Src().SetValue(ATESrc.MAC)
eth.Dst().SetValue(dstMAC)

ip4 := flow.Packet().Add().Ipv4()
ip4.Src().SetValue("198.18.2.0")
ip4.Dst().SetValue("198.18.1.1")
ip4.Version().SetValue(4)

ate.OTG().PushConfig(t, g.otgConfig)
default:
t.Fatalf("unspecified flow for test type %v", g.mode)
}

ate.OTG().PushConfig(t, g.otgConfig)
}

// RunFlows validates that traffic is forwarded by the DUT by running the
// flows required by the specified test.
func (g *GRIBIMPLSTest) RunFlows(t *testing.T, ate *ondatra.ATEDevice, runtime time.Duration, tolerableLostPackets uint64) {
t.Helper()
switch g.mode {
case PushToMPLS:
case PushToMPLS, PushToIP:
t.Logf("Starting MPLS traffic...")
ate.OTG().StartTraffic(t)
t.Logf("Sleeping for %s...", runtime)
Expand Down
20 changes: 18 additions & 2 deletions feature/gribi/otg_tests/mpls_forwarding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,30 @@ behaviour on the DUT.

* Configure DUT `port-1` to be connected to ATE `port-1`, and DUT `port-2` to
be connected to ATE `port-2`. ATE `port-2` is configured to have an assigned
address of `192.0.2.2`, and the interface is enabled.
address of `198.18.2.2`, and the interface is enabled.
* For label stack depths beginning at `baseLabel`, with `numLabels` addition
labels:
- Program a `LabelEntry` matching outer label 100 pointing to a NHG
containing a single NH.
- Program a `NextHopEntry` which points to `192.0.2.2` pushing `[baseLabel,
- Program a `NextHopEntry` which points to `192.18.2.2` pushing `[baseLabel,
..., baseLabel+numLabels]` onto the MPLS label stack.
* Run an MPLS flow matching label 100's forwarding entry and validate that is
received at the destination port.

### TE-10.2: Push MPLS Labels to IP payload

* Configure DUT `port-1` to be connected to ATE `port-1`, and DUT `port-2` to
be connected to ATE `port-2`. ATE `port-2` is configured to have an assigned
address of `198.18.2.2`, and the interface is enabled.
* For label stack depth beginning at `baseLabel`, with `numLabels` addition
labels:
- Program a IPv4Entry matcing IP Prefix `192.168.0.0/24` pointing to a NHG
containing a single NH.
- Program a `NextHopEntry` which points to `192.18.2.2` pushing `[baseLabel,
..., baseLabel+numLabels]` onto the MPLS label stack.
* Run an IP flow matching IP Prefix `192.168.0.0/24` and validate that it is
received at the destination port.

## Protocol/RPC Parameter coverage

* gRIBI:
Expand All @@ -30,6 +44,8 @@ behaviour on the DUT.
* `id`
* `network_instance`
* `op`: `ADD`
* `ip`
* `next_hop_group`
* `mpls`
* `next_hop_group`
* `next_hop_group`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,31 @@ func TestMPLSLabelPushDepth(t *testing.T) {
})
}
}

// TestMPLSPushToIP validates the gRIBI actions that are used to push N labels onto
// on IP Packet.
func TestMPLSPushToIP(t *testing.T) {
gribic := ondatra.DUT(t, "dut").RawAPIs().GRIBI(t)
c := fluent.NewClient()
c.Connection().WithStub(gribic)

for numLabels := 1; numLabels <= maximumStackDepth; numLabels++ {
t.Run(fmt.Sprintf("TE-10.2: Push MPLS labels to IP: Push %d labels", numLabels), func(t *testing.T) {
labels := []uint32{}
for i := 0; i < numLabels; i++ {
labels = append(labels, uint32(baseLabel+i))
}

mplsT := mplsutil.New(c, mplsutil.PushToIP, deviations.DefaultNetworkInstance(ondatra.DUT(t, "dut")), &mplsutil.Args{
LabelsToPush: labels,
})

mplsT.ConfigureDevices(t, ondatra.DUT(t, "dut"), ondatra.ATE(t, "ate"))
mplsT.ProgramGRIBI(t)
mplsT.ValidateProgramming(t)
mplsT.ConfigureFlows(t, ondatra.ATE(t, "ate"))
mplsT.RunFlows(t, ondatra.ATE(t, "ate"), 10*time.Second, lossTolerance)
mplsT.Cleanup(t)
})
}
}

0 comments on commit 80d9076

Please sign in to comment.