Ignore padding bytes in the received packet when the length of the
expected packet is less than the minimum Ethernet frame size (60 bytes)
diff --git a/src/python/oftest/dataplane.py b/src/python/oftest/dataplane.py
index 7ce2738..252726a 100644
--- a/src/python/oftest/dataplane.py
+++ b/src/python/oftest/dataplane.py
@@ -31,6 +31,19 @@
ETH_P_ALL = 0x03
RCV_TIMEOUT = 10000
+def match_exp_pkt(exp_pkt, pkt):
+ """
+ Compare the string value of pkt with the string value of exp_pkt,
+ and return True iff they are identical. If the length of exp_pkt is
+ less than the minimum Ethernet frame size (60 bytes), then padding
+ bytes in pkt are ignored.
+ """
+ e = str(exp_pkt)
+ p = str(pkt)
+ if len(e) < 60:
+ p = p[:len(e)]
+ return e == p
+
class DataPlanePort(Thread):
"""
Class defining a port monitoring object.
@@ -140,7 +153,7 @@
if (not self.parent.want_pkt_port or
self.parent.want_pkt_port == self.port_number):
if self.parent.exp_pkt:
- if str(self.parent.exp_pkt) != str(rcvmsg):
+ if not match_exp_pkt(self.parent.exp_pkt, rcvmsg):
drop_pkt = True
if not drop_pkt:
self.parent.got_pkt_port = self.port_number
@@ -331,7 +344,7 @@
pkt, time = self.port_list[port_number].dequeue(use_lock=False)
if not exp_pkt:
break
- if str(pkt) == str(exp_pkt):
+ if match_exp_pkt(exp_pkt, pkt):
break
pkt = None # Discard silently
if pkt: