From 80d9076ef76c61bdebeebd14ced6aa08790a812e Mon Sep 17 00:00:00 2001 From: Ali Al-Shabibi Date: Tue, 30 Jan 2024 17:28:30 +0100 Subject: [PATCH] Add IP to MPLS traffiic forwarding test. (#2531) * * (A) Add IP to MPLS traffiic forwarding test. - Add traffic validation to IP forwarding test. * removing calls to SetChoice --- feature/gribi/mplsutil/mplsutil.go | 53 ++++++++++++------- .../gribi/otg_tests/mpls_forwarding/README.md | 20 ++++++- .../gribi_mpls_forwarding_test.go | 28 ++++++++++ 3 files changed, 79 insertions(+), 22 deletions(-) diff --git a/feature/gribi/mplsutil/mplsutil.go b/feature/gribi/mplsutil/mplsutil.go index 8b385560b87..5e8b8261129 100644 --- a/feature/gribi/mplsutil/mplsutil.go +++ b/feature/gribi/mplsutil/mplsutil.go @@ -377,45 +377,58 @@ 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 @@ -423,7 +436,7 @@ func (g *GRIBIMPLSTest) ConfigureFlows(t *testing.T, ate *ondatra.ATEDevice) { 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) diff --git a/feature/gribi/otg_tests/mpls_forwarding/README.md b/feature/gribi/otg_tests/mpls_forwarding/README.md index 1bc17d692c6..170e6a6da7f 100644 --- a/feature/gribi/otg_tests/mpls_forwarding/README.md +++ b/feature/gribi/otg_tests/mpls_forwarding/README.md @@ -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: @@ -30,6 +44,8 @@ behaviour on the DUT. * `id` * `network_instance` * `op`: `ADD` + * `ip` + * `next_hop_group` * `mpls` * `next_hop_group` * `next_hop_group` diff --git a/feature/gribi/otg_tests/mpls_forwarding/gribi_mpls_forwarding_test.go b/feature/gribi/otg_tests/mpls_forwarding/gribi_mpls_forwarding_test.go index be09c573d94..1c124f4d247 100644 --- a/feature/gribi/otg_tests/mpls_forwarding/gribi_mpls_forwarding_test.go +++ b/feature/gribi/otg_tests/mpls_forwarding/gribi_mpls_forwarding_test.go @@ -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) + }) + } +}