Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,13 @@ func gueDecapInnerIpv4Traffic(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra
stopCapture(t, ate)
if trafficValidation {
verifyTrafficFlow(t, ate, trafficID, true)
verifyCaptureDscpTtlValue(t, ate, "port2", int(innerDscpValue), int(innerTTL-1))
if verifyCounters {
// PF-1.4.1 / PF-1.4.2: decapsulate — verify inner DSCP and TTL
verifyCaptureDscpTtlValue(t, ate, "port2", int(innerDscpValue), int(innerTTL-1))
} else {
// PF-1.4.5 / PF-1.4.6: pass-through — verify outer packet unmodified (no decap)
verifyPassThroughGuePacket(t, ate, "port2")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pass the expected UDP port to verifyPassThroughGuePacket to ensure more robust verification of the GUE packet. This aligns with the practice of using parameterized functions to improve code maintainability and reuse.

Suggested change
verifyPassThroughGuePacket(t, ate, "port2")
verifyPassThroughGuePacket(t, ate, "port2", ateUdpPort)
References
  1. Refactor functions to use parameterized versions to reduce code duplication.

}
} else {
verifyTrafficFlow(t, ate, trafficID, false)
}
Expand All @@ -501,7 +507,13 @@ func gueDecapInnerIpv6Traffic(t *testing.T, dut *ondatra.DUTDevice, ate *ondatra
stopCapture(t, ate)
if trafficValidation {
verifyTrafficFlow(t, ate, trafficID, true)
verifyCaptureDscpTtlValue(t, ate, "port2", int(innerDscpValue), int(innerTTL-1))
if verifyCounters {
// PF-1.4.1 / PF-1.4.2: decapsulate — verify inner DSCP and TTL
verifyCaptureDscpTtlValue(t, ate, "port2", int(innerDscpValue), int(innerTTL-1))
} else {
// PF-1.4.5 / PF-1.4.6: pass-through — verify outer packet unmodified (no decap)
verifyPassThroughGuePacket(t, ate, "port2")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pass the expected UDP port to verifyPassThroughGuePacket to ensure more robust verification of the GUE packet. This aligns with the practice of using parameterized functions to improve code maintainability and reuse.

Suggested change
verifyPassThroughGuePacket(t, ate, "port2")
verifyPassThroughGuePacket(t, ate, "port2", ateUdpPort)
References
  1. Refactor functions to use parameterized versions to reduce code duplication.

}
} else {
verifyTrafficFlow(t, ate, trafficID, false)
}
Expand Down Expand Up @@ -613,7 +625,7 @@ func verifyCaptureDscpTtlValue(t *testing.T, ate *ondatra.ATEDevice, port string
if ip6Layer := packet.Layer(layers.LayerTypeIPv6); ip6Layer != nil {
ip6, _ := ip6Layer.(*layers.IPv6)
if ip6.SrcIP.Equal(net.ParseIP(ipv6Src)) {
dscpValue := ip6.TrafficClass >> 2
dscpValue := ip6.TrafficClass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The removal of the bit shift (>> 2) for the IPv6 Traffic Class creates an inconsistency with the IPv4 verification logic (line 615) and deviates from the standard definition of DSCP (the 6 most significant bits). This change likely masks an issue in configureIPv6Traffic (line 593) where the raw Traffic Class byte is set instead of the DSCP value. It is recommended to update configureIPv6Traffic to use the DSCP setter (e.g., .Dscp().Phb().SetValue(innerDscpValue)) and revert this change to maintain consistent and correct DSCP verification.

ttlVal := ip6.HopLimit
if int(dscpValue) == dscp && int(ttlVal) == ttl {
t.Logf("PASS: IPv6 DSCP value %v and TTL value %v are Preserved", dscp, ttl)
Expand Down Expand Up @@ -657,3 +669,26 @@ func waitForBGPSession(t *testing.T, dut *ondatra.DUTDevice, wantEstablished boo
}
}
}
func verifyPassThroughGuePacket(t *testing.T, ate *ondatra.ATEDevice, port string) {
pcapfilename := processCapture(t, ate, port)
handle, err := pcap.OpenOffline(pcapfilename)
if err != nil {
t.Fatal(err)
}
defer handle.Close()
packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
for packet := range packetSource.Packets() {
if ip6Layer := packet.Layer(layers.LayerTypeIPv6); ip6Layer != nil {
ip6, _ := ip6Layer.(*layers.IPv6)
if ip6.SrcIP.Equal(net.ParseIP(atePort1.IPv6)) {
expectedTTL := uint8(outerTTL - 1)
if ip6.HopLimit == expectedTTL {
t.Logf("PASS: GUE pass-through packet verified: outer src=%s, TTL=%d (decremented by 1)", atePort1.IPv6, ip6.HopLimit)
return
}
t.Fatalf("ERROR: Outer TTL mismatch in pass-through. Expected: %d, Got: %d", expectedTTL, ip6.HopLimit)
}
}
}
t.Fatalf("ERROR: Could not find GUE pass-through packet with outer src IP (%s) in capture", atePort1.IPv6)
}
Comment on lines +672 to +694
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Refactor verifyPassThroughGuePacket to include UDP port verification and improve efficiency by parsing the IP address outside the loop. Using parameters for values like the expected port improves the function's maintainability.

func verifyPassThroughGuePacket(t *testing.T, ate *ondatra.ATEDevice, port string, expectedPort int) {
	pcapfilename := processCapture(t, ate, port)
	handle, err := pcap.OpenOffline(pcapfilename)
	if err != nil {
		t.Fatal(err)
	}
	defer handle.Close()
	packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
	srcIP := net.ParseIP(atePort1.IPv6)
	for packet := range packetSource.Packets() {
		if ip6Layer := packet.Layer(layers.LayerTypeIPv6); ip6Layer != nil {
			ip6, _ := ip6Layer.(*layers.IPv6)
			if ip6.SrcIP.Equal(srcIP) {
				if udpLayer := packet.Layer(layers.LayerTypeUDP); udpLayer != nil {
					udp, _ := udpLayer.(*layers.UDP)
					if int(udp.DstPort) == expectedPort {
						expectedTTL := uint8(outerTTL - 1)
						if ip6.HopLimit == expectedTTL {
							t.Logf("PASS: GUE pass-through packet verified: outer src=%s, port=%d, TTL=%d (decremented by 1)", atePort1.IPv6, expectedPort, ip6.HopLimit)
							return
						}
						t.Fatalf("ERROR: Outer TTL mismatch in pass-through. Expected: %d, Got: %d", expectedTTL, ip6.HopLimit)
					}
				}
			}
		}
	}
	t.Fatalf("ERROR: Could not find GUE pass-through packet with outer src IP (%s) and UDP port (%d) in capture", atePort1.IPv6, expectedPort)
}
References
  1. Refactor functions to use parameterized versions to reduce code duplication.

Loading