MCPcopy Create free account
hub / github.com/FDio/vpp / _get_capture

Method _get_capture

test/vpp_pg_interface.py:279–317  ·  view source on GitHub ↗

Helper method to get capture and filter it

(self, filter_out_fn=is_ipv6_misc)

Source from the content-addressed store, hash-verified

277 self._out_assert_counter += 1
278
279 def _get_capture(self, filter_out_fn=is_ipv6_misc):
280 """Helper method to get capture and filter it"""
281 try:
282 self.wait_for_pg_stop()
283 # "show packet-generator" CLI is not mp_safe, so VPP parks all
284 # worker threads at a barrier before executing it. By the time
285 # the CLI returns "stopped", every packet that was injected by
286 # the packet-generator has fully traversed the graph (run to
287 # completion). If any of those packets reached a pg output
288 # interface, VPP's pg_output node has already called
289 # pcap_write() which issues a write() syscall — making the
290 # capture file visible in the kernel VFS immediately (no fsync
291 # needed; stat() checks the dentry cache, not the block
292 # device). Therefore a single os.path.isfile() after pg stop
293 # is sufficient: the file is either here now or no packets
294 # were captured.
295 if not os.path.isfile(self.out_path):
296 self.test.logger.debug(
297 "Capture file %s not found after pg stop" % self.out_path
298 )
299 return None
300 self.link_pcap_file(self.out_path, "out", self.out_history_counter)
301 output = rdpcap(self.out_path)
302 self.test.logger.debug(f"Capture has {len(output.res)} packets")
303 except:
304 self.test.logger.debug(
305 "Exception in scapy.rdpcap (%s): %s" % (self.out_path, format_exc())
306 )
307 return None
308 before = len(output.res)
309 if filter_out_fn:
310 output.res = [p for p in output.res if not filter_out_fn(p)]
311 removed = before - len(output.res)
312 if removed:
313 self.test.logger.debug(
314 "Filtered out %s packets from capture (returning %s)"
315 % (removed, len(output.res))
316 )
317 return output
318
319 def get_capture(
320 self, expected_count=None, remark=None, timeout=None, filter_out_fn=is_ipv6_misc

Callers 15

get_captureMethod · 0.95
test_ip_ecmpMethod · 0.80
test_ip6_ecmpMethod · 0.80
test_timeout_inlineMethod · 0.80
test_timeout_cleanupMethod · 0.80
test_mpls_ibgp_picMethod · 0.80
test_mpls_ebgp_picMethod · 0.80
test_mpls_v6_ebgp_picMethod · 0.80
send_and_expect_someMethod · 0.80
test_mldMethod · 0.80
test_ip_puntMethod · 0.80

Calls 2

wait_for_pg_stopMethod · 0.95
link_pcap_fileMethod · 0.95

Tested by 13

test_ip_ecmpMethod · 0.64
test_ip6_ecmpMethod · 0.64
test_timeout_inlineMethod · 0.64
test_timeout_cleanupMethod · 0.64
test_mpls_ibgp_picMethod · 0.64
test_mpls_ebgp_picMethod · 0.64
test_mpls_v6_ebgp_picMethod · 0.64
test_mldMethod · 0.64
test_ip_puntMethod · 0.64
test_ip6_puntMethod · 0.64
_run_jumbo_ring_fullMethod · 0.64
test_ip_puntMethod · 0.64