ptf
ptf copied to clipboard
[Bug report] dataplane poll with default port_number doesn't work when there are multiple ptf nn agents
trafficstars
Source code: #https://github.com/p4lang/ptf/blob/c554f83685186be4cfa9387eb5d6d700d2bbd7c0/src/ptf/dataplane.py#L900
Simplified code:
def poll(
self, device_number=0, port_number=None, timeout=None, exp_pkt=None, filters=[]
):
def grab():
self.logger.debug("Grabbing packet")
for rcv_port_number, pkt, time in self.packets(device_number, port_number):
rcv_device_number = device_number
if not exp_pkt or match_exp_pkt(exp_pkt, pkt):
return DataPlane.PollSuccess(
rcv_device_number, rcv_port_number, pkt, exp_pkt, time
)
return None
with self.cvar:
ret = ptfutils.timed_wait(self.cvar, grab, timeout=timeout)
return ret
The problem is: when there are multiple ptf nn agents connecting the dataplane, there will be equvilent count of "device numbers", however, when we call poll with port_number=None, it will only poll packet from the device with number 0.
That doesn't make sense, when exp_pkt is not none and port number is none, we should poll packets from all devices.