Skip to content

Commit

Permalink
p4rt-6.1: small fixes (openconfig#1702)
Browse files Browse the repository at this point in the history
A couple of minor fixes:

Fix LLDP & GDP packet counters in PacketIn scenario; previously they counted only frames matched on the second switch case statement [metadata egress port id]
Add a short sleep timer (3 s) before ATE stats retrieval for PacketOut test cases
Additionally, removed a few unused parameters and code paths:

icmp6 traceroute packet structs (since icmp6 is not used in this case)
submitIngress bool flag from submitIngress() func (unused)
args param from newTrafficFlow func (unused)
This code is a Contribution to the OpenConfig Feature Profiles project ("Work") made under the Google Software Grant and Corporate Contributor License Agreement ("CLA") and governed by the Apache License 2.0. No other rights or licenses in or to any of Nokia’s intellectual property are granted for any other purpose. This code is provided on an "as is" basis without any warranties of any kind.
  • Loading branch information
LimeHat authored Jul 28, 2023
1 parent 6794ca9 commit 1e6edf4
Showing 1 changed file with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func testPktInPktOut(t *testing.T, args *testArgs) {
port := sortPorts(args.ate.Ports())[0].Name()
counter0 := gnmi.Get(t, args.ate, gnmi.OC().Interface(port).Counters().InPkts().State())

packets, err := newPacketOut(portID, false)
packets, err := newPacketOut(portID)
if err != nil {
t.Fatalf("Unexpected error creating packet out packets: %v", err)
}
Expand All @@ -265,7 +265,7 @@ func testPktInPktOut(t *testing.T, args *testArgs) {
streamName, qSize, qSizeRead)
}
// Create the flows for Packetin.
flows := newTrafficFlow(args, args.ate)
flows := newTrafficFlow(args.ate)
pktIn := 0
// Run Packetin and packetout traffic in parallel.
var wg sync.WaitGroup
Expand Down Expand Up @@ -304,6 +304,7 @@ func testPktInPktOut(t *testing.T, args *testArgs) {
time.Sleep(1 * time.Minute)

// Check packet counters after packet out
time.Sleep(3 * time.Second)
counter1 := gnmi.Get(t, args.ate, gnmi.OC().Interface(port).Counters().InPkts().State())

// Verify Packetout stats to check P4RT stream
Expand Down Expand Up @@ -349,9 +350,11 @@ func testPktInPktOut(t *testing.T, args *testArgs) {
if string(data.GetValue()) != portData {
t.Fatalf("Egress Port Id is not matching expectation for GDP.")
}
gdpIncount++
default:
t.Fatalf("Missing packet metadata for GDP PacketIn")
}
}
gdpIncount++
}
}
}
Expand All @@ -369,9 +372,11 @@ func testPktInPktOut(t *testing.T, args *testArgs) {
if string(data.GetValue()) != portData {
t.Fatalf("Egress Port Id is not matching expectation for LLDP.")
}
lldpIncount++
default:
t.Fatalf("Missing packet metadata for LLDP PacketIn")
}
}
lldpIncount++
}
}
}
Expand Down Expand Up @@ -717,18 +722,6 @@ func packetTracerouteRequestGet(ttl uint8, seq int) ([]byte, error) {
Seq: uint16(seq),
}

pktIpv6 := &layers.IPv6{
Version: 6,
HopLimit: ttl,
NextHeader: layers.IPProtocolICMPv6,
SrcIP: net.ParseIP(dutPort1.IPv6).To16(),
DstIP: net.ParseIP(atePort1.IPv6).To16(),
}
pktICMP6 := &layers.ICMPv6{
TypeCode: layers.CreateICMPv6TypeCode(layers.ICMPv6TypeEchoRequest, 0),
}
pktICMP6.SetNetworkLayerForChecksum(pktIpv6)

for i := 0; i < payLoadLen; i++ {
payload = append(payload, byte(i))
}
Expand Down Expand Up @@ -810,7 +803,7 @@ func newTableEntry(actionType p4v1pb.Update_Type) []*p4rtutils.ACLWbbIngressTabl
}

// newPacketOut generates 3 PacketOut messages with payload as GDP, LLDP and, traceroute.
func newPacketOut(portID uint32, submitIngress bool) ([]*p4v1pb.PacketOut, error) {
func newPacketOut(portID uint32) ([]*p4v1pb.PacketOut, error) {
p, err := packetGDPRequestGet()
if err != nil {
return nil, err
Expand Down Expand Up @@ -865,7 +858,7 @@ func newPacketOut(portID uint32, submitIngress bool) ([]*p4v1pb.PacketOut, error
}

// newTrafficFlow generates ATE traffic flows for LLDP.
func newTrafficFlow(args *testArgs, ate *ondatra.ATEDevice) []*ondatra.Flow {
func newTrafficFlow(ate *ondatra.ATEDevice) []*ondatra.Flow {
ethHeader1 := ondatra.NewEthernetHeader()
ethHeader1.WithSrcAddress(pktInSrcMAC)
ethHeader1.WithDstAddress(lldpInDstMAC)
Expand Down

0 comments on commit 1e6edf4

Please sign in to comment.