Hi!
When using CT samples, I was testing both the origin and reply direction match. According to my tests, the reply direction does not match.
The testing consisted of running flow_ct_udp_query
sample, and sending specially crafted packets in scapy. The only modification to the abovementioned sample that was done is to extend sleep duration at line 617 in flow_ct_udp_query_sample.c
from 5 to 10 seconds to give more time for sending packets.
First, I start the sample and right after run a scapy script that sends one UDP packet with sample sport and dport to create a CT session, then 10 packets with the same src IP, dst IP, sport and dport. The output in the sample is correct - the counters registered 10 packets in the origin direction.
However, if I change to first send the single packet as previously, but then change to send 10 packets with same sport and dport, and then another 10 with sport reversed with dport, the application says there still only 10 packets received in the origin, and 0 in reply.
Is this a possible bug in CT sample(s), or my misunderstanding of the behavior the sample(s) should do or the origin/reply matching.
For reference, here is the scapy script:
#!/usr/bin/env python3
from scapy.all import *
import sys
import os
from time import sleep
dst_ip = "1.1.1.1"
# src_ip = "1.1.255.255"
dst_mac0 = "a0:88:c2:c3:8b:6c"
dst_mac1 = "a0:88:c2:c3:8b:6d"
src_mac = "a0:88:c2:a1:84:6c"
pkt_arr = []
pkt_arr.append(Ether(src=src_mac, dst=dst_mac0) / IP(src=dst_ip, dst=dst_ip) / UDP(sport=30000, dport=43) / Raw(load=os.urandom(128)))
pkt_arr.append(Ether(src=src_mac, dst=dst_mac0) / IP(src=dst_ip, dst=dst_ip) / UDP(sport=30000, dport=43) / Raw(load=os.urandom(128)))
pkt_arr.append(Ether(src=src_mac, dst=dst_mac0) / IP(src=dst_ip, dst=dst_ip) / UDP(sport=43, dport=30000) / Raw(load=os.urandom(128)))
sendp(pkt_arr[0], iface='enp202s0f0np0', verbose=True, count=1)
sleep(10)
sendp(pkt_arr[1], iface='enp202s0f0np0', verbose=True, count=10)
sendp(pkt_arr[2], iface='enp202s0f0np0', verbose=True, count=10)
$ sudo ./doca_flow_ct_udp_query -- -p 03:00.0 -l 60
[19:48:21:215071][740184][DOCA][INF][flow_ct_udp_query_main.c:77][main] Starting the sample
EAL: Detected CPU lcores: 8
EAL: Detected NUMA nodes: 1
EAL: Detected shared linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
TELEMETRY: No legacy callbacks, legacy socket not created
EAL: Probe PCI driver: mlx5_pci (15b3:a2d6) device: 0000:03:00.0 (socket -1)
mlx5_net: port 0 cannot enable promiscuous mode in flow isolation mode
[19:48:22:094984][740184][DOCA][INF][dpdk_utils.c:406][port_init] Ingress traffic on port 0 is in isolated mode
mlx5_net: port 0 cannot enable promiscuous mode in flow isolation mode
[19:48:22:894188][740184][DOCA][DBG][dpdk_utils.c:417][port_init] Port 0 MAC: a0 88 c2 c3 8b 6c
[19:48:22:894281][740184][DOCA][INF][dpdk_utils.c:311][port_init] Skip represent port 1 init in switch mode
[19:48:22:894364][740184][DOCA][WRN][engine_model.c:92][adapt_queue_depth] adapting queue depth to 128.
mlx5_net: port 0 cannot enable promiscuous mode in flow isolation mode
[19:48:25:116209][740184][DOCA][INF][flow_ct_udp_query_sample.c:607][flow_ct_udp_query] Wait few seconds for packets to arrive
[19:48:30:116358][740184][DOCA][INF][flow_ct_udp_query_sample.c:448][process_packets] Sample received 1 packets
[19:48:33:116549][740184][DOCA][INF][flow_ct_udp_query_sample.c:616][flow_ct_udp_query] Same UDP packet should be resent
[19:48:38:117225][740184][DOCA][INF][flow_ct_udp_query_sample.c:642][flow_ct_udp_query] Port 0:
[19:48:38:117276][740184][DOCA][INF][flow_ct_udp_query_sample.c:643][flow_ct_udp_query] Origin Total bytes: 1740
[19:48:38:117291][740184][DOCA][INF][flow_ct_udp_query_sample.c:644][flow_ct_udp_query] Origin Total packets: 10
[19:48:38:117303][740184][DOCA][INF][flow_ct_udp_query_sample.c:645][flow_ct_udp_query] Reply Total bytes: 0
[19:48:38:117314][740184][DOCA][INF][flow_ct_udp_query_sample.c:646][flow_ct_udp_query] Reply Total packets: 0
[19:48:38:117325][740184][DOCA][INF][flow_ct_udp_query_sample.c:647][flow_ct_udp_query] Last hit since Epoch (sec) : 1735847316
Device with port_id=1 already stopped
[19:48:39:567684][740184][DOCA][WRN][doca_dpdk.cpp:299][detach_port] DPDK dev already detached: 1
[19:48:39:567751][740184][DOCA][WRN][doca_dpdk.cpp:299][detach_port] DPDK dev already detached: 0
[19:48:39:570870][740184][DOCA][DBG][dpdk_utils.c:928][dpdk_fini] DPDK fini is done
[19:48:39:570933][740184][DOCA][INF][flow_ct_udp_query_main.c:135][main] Sample finished successfully