Skip to content

Commit

Permalink
TE-16.1 Basic Encap Test - fix for using l2 rules and sequenceID (#2885)
Browse files Browse the repository at this point in the history
* fixing issues

* added deviation for sequential rules under policy

* added vendor.CISCO check in PMD check
  • Loading branch information
singh-prem authored Apr 24, 2024
1 parent 3803614 commit b9729af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
29 changes: 21 additions & 8 deletions feature/gribi/otg_tests/basic_encap_test/basic_encap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ const (
// observing on IXIA OTG: Cannot start capture on more than one port belonging to the
// same resource group or on more than one port behind the same front panel port in the chassis
otgMutliPortCaptureSupported = false
seqIDBase = uint32(10)
)

var (
Expand Down Expand Up @@ -588,6 +589,16 @@ func getPbrRules(dut *ondatra.DUTDevice, clusterFacing bool) []pbrRule {
return pbrRules
}

// seqIDOffset returns sequence ID offset added with seqIDBase (10), to avoid sequences
// like 1, 10, 11, 12,..., 2, 21, 22, ... while being sent by Ondatra to the DUT.
// It now generates sequences like 11, 12, 13, ..., 19, 20, 21,..., 99.
func seqIDOffset(dut *ondatra.DUTDevice, i uint32) uint32 {
if deviations.PfRequireSequentialOrderPbrRules(dut) {
return i + seqIDBase
}
return i
}

// configDefaultRoute configures a static route in DEFAULT network-instance.
func configDefaultRoute(t *testing.T, dut *ondatra.DUTDevice, v4Prefix, v4NextHop, v6Prefix, v6NextHop string) {
t.Logf("Configuring static route in DEFAULT network-instance")
Expand Down Expand Up @@ -630,7 +641,7 @@ func getPbrPolicy(dut *ondatra.DUTDevice, name string, clusterFacing bool) *oc.N
p.SetType(oc.Policy_Type_VRF_SELECTION_POLICY)

for _, pRule := range getPbrRules(dut, clusterFacing) {
r := p.GetOrCreateRule(pRule.sequence)
r := p.GetOrCreateRule(seqIDOffset(dut, pRule.sequence))
r4 := r.GetOrCreateIpv4()

if pRule.dscpSet != nil {
Expand All @@ -654,6 +665,11 @@ func getPbrPolicy(dut *ondatra.DUTDevice, name string, clusterFacing bool) *oc.N
ra.PostDecapNetworkInstance = ygot.String(pRule.decapVrfSet[1])
ra.DecapFallbackNetworkInstance = ygot.String(pRule.decapVrfSet[2])
}
if deviations.PfRequireMatchDefaultRule(dut) {
if pRule.etherType != nil {
r.GetOrCreateL2().Ethertype = pRule.etherType
}
}

if pRule.encapVrf != "" {
r.GetOrCreateAction().SetNetworkInstance(pRule.encapVrf)
Expand Down Expand Up @@ -775,7 +791,7 @@ func configureDUT(t *testing.T, dut *ondatra.DUTDevice) {
for idx, a := range []attrs.Attributes{dutPort1, dutPort2, dutPort3, dutPort4, dutPort5} {
p := portList[idx]
intf := a.NewOCInterface(p.Name(), dut)
if p.PMD() == ondatra.PMD100GBASEFR {
if p.PMD() == ondatra.PMD100GBASEFR && dut.Vendor() != ondatra.CISCO {
e := intf.GetOrCreateEthernet()
e.AutoNegotiate = ygot.Bool(false)
e.DuplexMode = oc.Ethernet_DuplexMode_FULL
Expand Down Expand Up @@ -896,9 +912,6 @@ func (fa *flowAttr) getFlow(flowType string, name string, dscp uint32) gosnappi.
v4.Dst().SetValue(fa.dst)
v4.TimeToLive().SetValue(ttl)
v4.Priority().Dscp().Phb().SetValue(dscp)
udp := flow.Packet().Add().Udp()
udp.SrcPort().SetValues(randRange(50001, 10000))
udp.DstPort().SetValues(randRange(50001, 10000))

// add inner ipv4 headers
if flowType == "ipv4in4" {
Expand All @@ -919,10 +932,10 @@ func (fa *flowAttr) getFlow(flowType string, name string, dscp uint32) gosnappi.
v6.Dst().SetValue(fa.dst)
v6.HopLimit().SetValue(ttl)
v6.TrafficClass().SetValue(dscp << 2)
udp := flow.Packet().Add().Udp()
udp.SrcPort().SetValues(randRange(50001, 10000))
udp.DstPort().SetValues(randRange(50001, 10000))
}
udp := flow.Packet().Add().Udp()
udp.SrcPort().SetValues(randRange(50001, 10000))
udp.DstPort().SetValues(randRange(50001, 10000))

return flow
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ platform_exceptions: {
interface_ref_interface_id_format: true
ttl_copy_unsupported: true
pf_require_match_default_rule: true
pf_require_sequential_order_pbr_rules: true
}
}
platform_exceptions: {
Expand Down

0 comments on commit b9729af

Please sign in to comment.