From patchwork Tue Jul 23 18:24:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kui-Feng Lee X-Patchwork-Id: 13740286 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 120AF1581EB for ; Tue, 23 Jul 2024 18:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721759087; cv=none; b=V+e69nxfy2xJFH6Q/YKFFzQgpp+lDEDwwr186AnN6q2QgieJR4M6JqlRQlR2tiWkrRmpt3pbtpR6AV7lfw899wMfHhvkTXHnSg2R4OyfkLfvOWPD/WUvXvNhl+8/SBpYJSWfi2dO4SeqJRLEhKFgjAsc2pA4oBb/ejwVxxj0H7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721759087; c=relaxed/simple; bh=nvIcnh2E8f7dFrFhBEhkqGT+vmhcW1Csl2uu8oUZsFI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Zbwo0XglX/gB0qNVbJv/JbraIbsLHaNNe4cEAehLXVYErJ8h6IkNRMpueyT9hiD21rympgvyYclAFTJjrD5ewpSzqPEAwIi3puQvw+IXp+3gnsNfTfoWVNpc8p3moUxDXeEJ+B+nec7ngBrhIn4UeCfk7wgCy5Os5T6gfE85O5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kHFJFuOY; arc=none smtp.client-ip=209.85.128.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kHFJFuOY" Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-664b4589b1aso929757b3.1 for ; Tue, 23 Jul 2024 11:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721759084; x=1722363884; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eMVfRwutfef2Q9BR3ChJW1oC0AgSMTROQ0q1Xl3rlb8=; b=kHFJFuOY3eYB4g02pXwOOo9fpUF7+e4ZYQrNwtjtNLOVEu6m/d7OIciZTSrqptZbHq D8PRq+asJG3+FARDPEl6t/yWbgp9RCyhEdzqDhR2rEsaZ7Hee4/4RGBLW2RDBY/ZPQPs pVTAVoV4L+xo7p0SEUyFUcdAxipVBNEljhC7cpyTzW2V8xUrJe4qf1njtJU3n8JVEdXQ bD84MSQmOg8bXMDGl6USxaLPl9DlpnJfh6IC+riMG1vWB8WbntxNjb+bmOYnGA04f7k+ KMYvy5QgKrWbDc6HUlYrzkyuPKDAuDy+ykxWyppPLRNIrV7GrTAxCon/F5h+OGTIotcx DXLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721759084; x=1722363884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eMVfRwutfef2Q9BR3ChJW1oC0AgSMTROQ0q1Xl3rlb8=; b=phLEdaDcV/mJQ37nzUVZG+38k1Ss6vnX+yiX33ag0p0GCzjtAXQGysDrCMZ9bC8xw4 5FhEGIe42aPE66Kz62rsPtnS7k4gzWNxqg3HKFFIA0gCv7zrFg8hIZujVhSn9xbvqekz UaTOisRGMCtie/SsHmZFmyvy6pNzAupgTipdpF+o2JG8/WMRSNSusYsKzzevgN6waI3u D9Fg1ruIhGGr5bJtDUgv/AGUg0QdBCdG42rPNT+NncmiO0oBHWEsLc/tbzo5zhs0K5z2 JD4UM5rh8e0WiOiKJnJkDRR1cVU6nHJJfEVRIxoO/BA4hzLI1b3ZcX/Iq0DudluDqX6f jEyQ== X-Gm-Message-State: AOJu0Yzu7f4UyW+dzKVM6O9H44eLGWrHs4ZT0TuQCoiJgwHOXrRE+IY7 XmXsoFqIvUzeTFnxZRJcmlo3S5a/iFutaYUV1eDeNsqpJxetpwrODOq4CPlm X-Google-Smtp-Source: AGHT+IG58PXXI5R0bAebyikGGUKV+5hwkcQWrKeeCEdsyg85EKbf0CJb/WrGlvNliI54VzgmEtec6A== X-Received: by 2002:a05:690c:f:b0:640:aec2:101c with SMTP id 00721157ae682-66e8ff97af4mr29605667b3.2.1721759083852; Tue, 23 Jul 2024 11:24:43 -0700 (PDT) Received: from kickker.attlocal.net ([2600:1700:6cf8:1240:e02a:b5d8:6984:234c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695293fd9csm20637577b3.69.2024.07.23.11.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 11:24:43 -0700 (PDT) From: Kui-Feng Lee To: bpf@vger.kernel.org, ast@kernel.org, martin.lau@linux.dev, song@kernel.org, kernel-team@meta.com, andrii@kernel.org, sdf@fomichev.me Cc: sinquersw@gmail.com, kuifeng@meta.com, Kui-Feng Lee Subject: [PATCH bpf-next v2 1/4] selftests/bpf: Add traffic monitor functions. Date: Tue, 23 Jul 2024 11:24:36 -0700 Message-Id: <20240723182439.1434795-2-thinker.li@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723182439.1434795-1-thinker.li@gmail.com> References: <20240723182439.1434795-1-thinker.li@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Add functions that capture packets and print log in the background. They are supposed to be used for debugging flaky network test cases. A monitored test case should call traffic_monitor_start() to start a thread to capture packets in the background for a given namespace and call traffic_monitor_stop() to stop capturing. IPv4 TCP packet: 127.0.0.1:48165 -> 127.0.0.1:36707, len 68, ifindex 1, SYN IPv4 TCP packet: 127.0.0.1:36707 -> 127.0.0.1:48165, len 60, ifindex 1, SYN, ACK IPv4 TCP packet: 127.0.0.1:48165 -> 127.0.0.1:36707, len 60, ifindex 1, ACK IPv4 TCP packet: 127.0.0.1:36707 -> 127.0.0.1:48165, len 52, ifindex 1, ACK IPv4 TCP packet: 127.0.0.1:48165 -> 127.0.0.1:36707, len 52, ifindex 1, FIN, ACK IPv4 TCP packet: 127.0.0.1:36707 -> 127.0.0.1:48165, len 52, ifindex 1, RST, ACK Packet file: packets-2172-86.log #280/87 select_reuseport/sockhash IPv4/TCP LOOPBACK test_detach_bpf:OK The above is the output of an example. It shows the packets of a connection and the name of the file that contains captured packets in the directory /tmp/tmon_pcap. The file can be loaded by tcpdump or wireshark. This feature only works if TRAFFIC_MONITOR variable has been passed to build BPF selftests. For example, make TRAFFIC_MONITOR=1 -C tools/testing/selftests/bpf This command will build BPF selftests with this feature enabled. Signed-off-by: Kui-Feng Lee --- tools/testing/selftests/bpf/Makefile | 5 + tools/testing/selftests/bpf/network_helpers.c | 382 ++++++++++++++++++ tools/testing/selftests/bpf/network_helpers.h | 16 + 3 files changed, 403 insertions(+) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index dd49c1d23a60..9dfe17588689 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -41,6 +41,11 @@ CFLAGS += -g $(OPT_FLAGS) -rdynamic \ LDFLAGS += $(SAN_LDFLAGS) LDLIBS += $(LIBELF_LIBS) -lz -lrt -lpthread +ifneq ($(TRAFFIC_MONITOR),) +LDLIBS += -lpcap +CFLAGS += -DTRAFFIC_MONITOR=1 +endif + # The following tests perform type punning and they may break strict # aliasing rules, which are exploited by both GCC and clang by default # while optimizing. This can lead to broken programs. diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index e0cba4178e41..c881f53c8218 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -18,6 +19,14 @@ #include #include +#include + +#include +/* Prevent pcap.h from including pcap/bpf.h and causing conflicts */ +#define PCAP_DONT_INCLUDE_PCAP_BPF_H 1 +#include +#include + #include "bpf_util.h" #include "network_helpers.h" #include "test_progs.h" @@ -575,6 +584,379 @@ int set_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param) return 0; } +#ifdef TRAFFIC_MONITOR +struct tmonitor_ctx { + pcap_t *pcap; + pcap_dumper_t *dumper; + pthread_t thread; + int wake_fd_r; + int wake_fd_w; + + bool done; + char pkt_fname[PATH_MAX]; + int pcap_fd; +}; + +/* Is this packet captured with a Ethernet protocol type? */ +static bool is_ethernet(const u_char *packet) +{ + u16 arphdr_type; + + memcpy(&arphdr_type, packet + 8, 2); + arphdr_type = ntohs(arphdr_type); + + /* Except the following cases, the protocol type contains the + * Ethernet protocol type for the packet. + * + * https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL2.html + */ + switch (arphdr_type) { + case 770: /* ARPHRD_FRAD */ + case 778: /* ARPHDR_IPGRE */ + case 803: /* ARPHRD_IEEE80211_RADIOTAP */ + return false; + } + return true; +} + +/* Show the information of the transport layer in the packet */ +static void show_transport(const u_char *packet, u16 len, u32 ifindex, + const char *src_addr, const char *dst_addr, + u16 proto, bool ipv6) +{ + struct udphdr *udp; + struct tcphdr *tcp; + u16 src_port, dst_port; + const char *transport_str; + + if (proto == IPPROTO_UDP) { + udp = (struct udphdr *)packet; + src_port = ntohs(udp->source); + dst_port = ntohs(udp->dest); + transport_str = "UDP"; + } else if (proto == IPPROTO_TCP) { + tcp = (struct tcphdr *)packet; + src_port = ntohs(tcp->source); + dst_port = ntohs(tcp->dest); + transport_str = "TCP" +; + } else { + printf("%s (proto %d): %s -> %s, ifindex %d\n", + ipv6 ? "IPv6" : "IPv4", proto, src_addr, dst_addr, ifindex); + return; + } + + if (ipv6) + printf("IPv6 %s packet: [%s]:%d -> [%s]:%d, len %d, ifindex %d", + transport_str, src_addr, src_port, + dst_addr, dst_port, len, ifindex); + else + printf("IPv4 %s packet: %s:%d -> %s:%d, len %d, ifindex %d", + transport_str, src_addr, src_port, + dst_addr, dst_port, len, ifindex); + + if (proto == IPPROTO_TCP) { + if (tcp->fin) + printf(", FIN"); + if (tcp->syn) + printf(", SYN"); + if (tcp->rst) + printf(", RST"); + if (tcp->ack) + printf(", ACK"); + } + + printf("\n"); +} + +static void show_ipv6_packet(const u_char *packet, u32 ifindex) +{ + struct ipv6hdr *pkt = (struct ipv6hdr *)packet; + struct in6_addr src; + struct in6_addr dst; + char src_str[INET6_ADDRSTRLEN], dst_str[INET6_ADDRSTRLEN]; + u_char proto; + + memcpy(&src, &pkt->saddr, sizeof(src)); + memcpy(&dst, &pkt->daddr, sizeof(dst)); + inet_ntop(AF_INET6, &src, src_str, sizeof(src_str)); + inet_ntop(AF_INET6, &dst, dst_str, sizeof(dst_str)); + proto = pkt->nexthdr; + show_transport(packet + sizeof(struct ipv6hdr), + ntohs(pkt->payload_len), + ifindex, src_str, dst_str, proto, true); +} + +static void show_ipv4_packet(const u_char *packet, u32 ifindex) +{ + struct iphdr *pkt = (struct iphdr *)packet; + struct in_addr src; + struct in_addr dst; + u_char proto; + char src_str[INET_ADDRSTRLEN], dst_str[INET_ADDRSTRLEN]; + + memcpy(&src, &pkt->saddr, sizeof(src)); + memcpy(&dst, &pkt->daddr, sizeof(dst)); + inet_ntop(AF_INET, &src, src_str, sizeof(src_str)); + inet_ntop(AF_INET, &dst, dst_str, sizeof(dst_str)); + proto = pkt->protocol; + show_transport(packet + sizeof(struct iphdr), + ntohs(pkt->tot_len), + ifindex, src_str, dst_str, proto, false); +} + +static void *traffic_monitor_thread(void *arg) +{ + const u_char *packet, *payload; + struct tmonitor_ctx *ctx = arg; + struct pcap_pkthdr header; + pcap_t *pcap = ctx->pcap; + pcap_dumper_t *dumper = ctx->dumper; + int fd = ctx->pcap_fd; + int wake_fd = ctx->wake_fd_r; + u16 proto; + u32 ifindex; + fd_set fds; + int nfds, r; + + nfds = (fd > wake_fd ? fd : wake_fd) + 1; + FD_ZERO(&fds); + + while (!ctx->done) { + FD_SET(fd, &fds); + FD_SET(wake_fd, &fds); + r = select(nfds, &fds, NULL, NULL, NULL); + if (!r) + continue; + if (r < 0) { + if (errno == EINTR) + continue; + log_err("Fail to select on pcap fd and wake fd: %s", strerror(errno)); + break; + } + + packet = pcap_next(pcap, &header); + if (!packet) + continue; + + /* According to the man page of pcap_dump(), first argument + * is the pcap_dumper_t pointer even it's argument type is + * u_char *. + */ + pcap_dump((u_char *)dumper, &header, packet); + + /* Not sure what other types of packets look like. Here, we + * parse only Ethernet and compatible packets. + */ + if (!is_ethernet(packet)) { + printf("Packet captured\n"); + continue; + } + + /* Skip SLL2 header + * https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL2.html + * + * Although the document doesn't mention that, the payload + * doesn't include the Ethernet header. The payload starts + * from the first byte of the network layer header. + */ + payload = packet + 20; + + memcpy(&proto, packet, 2); + proto = ntohs(proto); + memcpy(&ifindex, packet + 4, 4); + ifindex = ntohl(ifindex); + + if (proto == ETH_P_IPV6) + show_ipv6_packet(payload, ifindex); + else if (proto == ETH_P_IP) + show_ipv4_packet(payload, ifindex); + else + printf("Unknown network protocol type %x, ifindex %d\n", proto, ifindex); + } + + return NULL; +} + +/* Prepare the pcap handle to capture packets. + * + * This pcap is non-blocking and immediate mode is enabled to receive + * captured packets as soon as possible. The snaplen is set to 1024 bytes + * to limit the size of captured content. The format of the link-layer + * header is set to DLT_LINUX_SLL2 to enable handling various link-layer + * technologies. + */ +static pcap_t *traffic_monitor_prepare_pcap(void) +{ + char errbuf[PCAP_ERRBUF_SIZE]; + pcap_t *pcap; + int r; + + /* Listen on all NICs in the namespace */ + pcap = pcap_create("any", errbuf); + if (!pcap) { + log_err("Failed to open pcap: %s", errbuf); + return NULL; + } + /* Limit the size of the packet (first N bytes) */ + r = pcap_set_snaplen(pcap, 1024); + if (r) { + log_err("Failed to set snaplen: %s", pcap_geterr(pcap)); + goto error; + } + /* To receive packets as fast as possible */ + r = pcap_set_immediate_mode(pcap, 1); + if (r) { + log_err("Failed to set immediate mode: %s", pcap_geterr(pcap)); + goto error; + } + r = pcap_setnonblock(pcap, 1, errbuf); + if (r) { + log_err("Failed to set nonblock: %s", errbuf); + goto error; + } + r = pcap_activate(pcap); + if (r) { + log_err("Failed to activate pcap: %s", pcap_geterr(pcap)); + goto error; + } + /* Determine the format of the link-layer header */ + r = pcap_set_datalink(pcap, DLT_LINUX_SLL2); + if (r) { + log_err("Failed to set datalink: %s", pcap_geterr(pcap)); + goto error; + } + + return pcap; +error: + pcap_close(pcap); + return NULL; +} + +#define PCAP_DIR "/tmp/tmon_pcap" + +/* Start to monitor the network traffic in the given network namespace. + * + * netns: the name of the network namespace to monitor. If NULL, the + * current network namespace is monitored. + * + * This function will start a thread to capture packets going through NICs + * in the give network namespace. + */ +struct tmonitor_ctx *traffic_monitor_start(const char *netns) +{ + struct tmonitor_ctx *ctx = NULL; + struct nstoken *nstoken = NULL; + int pipefd[2] = {-1, -1}; + static int tmon_seq; + int r; + + if (netns) { + nstoken = open_netns(netns); + if (!nstoken) + return NULL; + } + ctx = malloc(sizeof(*ctx)); + if (!ctx) { + log_err("Failed to malloc ctx"); + goto fail_ctx; + } + memset(ctx, 0, sizeof(*ctx)); + + snprintf(ctx->pkt_fname, sizeof(ctx->pkt_fname), + PCAP_DIR "/packets-%d-%d.log", getpid(), tmon_seq++); + + r = mkdir(PCAP_DIR, 0755); + if (r && errno != EEXIST) { + log_err("Failed to create " PCAP_DIR); + goto fail_pcap; + } + + ctx->pcap = traffic_monitor_prepare_pcap(); + if (!ctx->pcap) + goto fail_pcap; + ctx->pcap_fd = pcap_get_selectable_fd(ctx->pcap); + if (ctx->pcap_fd < 0) { + log_err("Failed to get pcap fd"); + goto fail_dumper; + } + + /* Create a packet file */ + ctx->dumper = pcap_dump_open(ctx->pcap, ctx->pkt_fname); + if (!ctx->dumper) { + log_err("Failed to open pcap dump"); + goto fail_dumper; + } + + /* Create a pipe to wake up the monitor thread */ + r = pipe(pipefd); + if (r) { + log_err("Failed to create pipe: %s", strerror(errno)); + goto fail; + } + ctx->wake_fd_r = pipefd[0]; + ctx->wake_fd_w = pipefd[1]; + + r = pthread_create(&ctx->thread, NULL, traffic_monitor_thread, ctx); + if (r) { + log_err("Failed to create thread: %s", strerror(r)); + goto fail; + } + + close_netns(nstoken); + + return ctx; + +fail: + close(pipefd[0]); + close(pipefd[1]); + + pcap_dump_close(ctx->dumper); + unlink(ctx->pkt_fname); + +fail_dumper: + pcap_close(ctx->pcap); + +fail_pcap: + free(ctx); + +fail_ctx: + close_netns(nstoken); + + return NULL; +} + +static void traffic_monitor_release(struct tmonitor_ctx *ctx) +{ + pcap_close(ctx->pcap); + pcap_dump_close(ctx->dumper); + + close(ctx->wake_fd_r); + close(ctx->wake_fd_w); + + free(ctx); +} + +/* Stop the network traffic monitor. + * + * ctx: the context returned by traffic_monitor_start() + */ +void traffic_monitor_stop(struct tmonitor_ctx *ctx) +{ + if (!ctx) + return; + + /* Stop the monitor thread */ + ctx->done = true; + write(ctx->wake_fd_w, "x", 1); + pthread_join(ctx->thread, NULL); + + printf("Packet file: %s\n", strrchr(ctx->pkt_fname, '/') + 1); + + traffic_monitor_release(ctx); +} +#endif /* TRAFFIC_MONITOR */ + struct send_recv_arg { int fd; uint32_t bytes; diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h index aac5b94d6379..a4067f33a800 100644 --- a/tools/testing/selftests/bpf/network_helpers.h +++ b/tools/testing/selftests/bpf/network_helpers.h @@ -82,6 +82,22 @@ int get_socket_local_port(int sock_fd); int get_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param); int set_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param); +struct tmonitor_ctx; + +#ifdef TRAFFIC_MONITOR +struct tmonitor_ctx *traffic_monitor_start(const char *netns); +void traffic_monitor_stop(struct tmonitor_ctx *ctx); +#else +static inline struct tmonitor_ctx *traffic_monitor_start(const char *netns) +{ + return (struct tmonitor_ctx *)-1; +} + +static inline void traffic_monitor_stop(struct tmonitor_ctx *ctx) +{ +} +#endif + struct nstoken; /** * open_netns() - Switch to specified network namespace by name. From patchwork Tue Jul 23 18:24:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kui-Feng Lee X-Patchwork-Id: 13740287 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B25C1157A4F for ; Tue, 23 Jul 2024 18:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721759088; cv=none; b=Fo3qvk3rJxUrUHc8eYt3Oq36IC5Xi+kEwhK/eoh3vCMXS29iz6vmEnhBB3vGL62ASN/BH4OdAPKjrO5k5w2CGpO7+h5FApkdrXKSZvlgn2kmT5cH2stzrUHZ0tqESShR0G2kDabFq4XjJMpkmtotSqmPV854tvLgrpN/t2rIsFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721759088; c=relaxed/simple; bh=mRd/DAFv2kIkDKHiswXD1hckOvS0HpTJ03EG5ls+H8M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DL4JT7MGZ1xgeLvErX0Ue9PMVjKvgL2n7kp95RIe/MKOhCaI0heGcR9n6IxiEBRFxyw44xMVbad0q+oxj8ScVGe7u2iZAx6hqcwYJBeZLI14f+0brgefvzD+HE7rM0jOgiJJ2pPEHbmNlRZ+6DuAVeBLX1iV2Jn7qnZVxJ3XZuY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kIYAwb1l; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kIYAwb1l" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-66108213e88so57968937b3.1 for ; Tue, 23 Jul 2024 11:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721759085; x=1722363885; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DtLewEWhfeG+Lijjiylaf3g6jdonnBYABUF3GI1qKZc=; b=kIYAwb1l+odpgBn418QNKKP3rofuRo7Jqy6xH/VN2XEKgoyX4pFl1sVLNbvvfrldxF mFXODc0E3crs2rFJI0swWv9abqQz7oBoKDy7yzJDXEECInit7o2tx5w4E1QJ8wxyE92s 0aoG2/LH16+/cVaFSnq1Iw72xOm8vA7PFtCyQL47xhb1EM6gzXD1zwz0fmCBXZdOpCCy vAF+3JltOcf2jbJzAC70olnwLDucb/gaNSR+3/hBiRRUi3z71h7qQhkcWmLmjqWj8PLf Uc8HtMM7TJQfFb2GofTDQR7l1rheZ//dl08VwLaxsQcMcO/Kf43w5a6M7b2IRcUx7K3J zCiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721759085; x=1722363885; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DtLewEWhfeG+Lijjiylaf3g6jdonnBYABUF3GI1qKZc=; b=rLWu8++271SuEyOjl0yUTsylgH6Xhzjq5moK2oKYZDONxP8JTK40eYOx9c5k76pGiH KsNfvO8ksjUApjjs5ls4svmvAP8ZkcpP4OPFHVBiM1RErh1zrQd7EaECInwj7aQVYjGE ogMpYnlm6iG3raLL7N+QmqqPNoDCZoioGle/DeSCKxH74kPXAyjyAcj0diQnXvCQKk3x y4LY7IrnKExTv4/qhR8lt+Yi9Psb+R2O5km5Zl3CUVD4x1Ts2minEkLXVJz0Oh8m3IBE D5s25Y9J5uoydMTlBHqJctdLLe12xG1T+tI6xsZglx6YKLtWs2jZTPRgirccVKmDc2M0 TWVQ== X-Gm-Message-State: AOJu0YyO+Y5g5esMRnTTnlHLW/d4PqukP4GgCe9SgU6PHPJIsUNqUAIp H+HuWVq5Cd2JlD1SgE5LCK4JJ62HwtRzaxkRrzhgxSRj0pS0cvG+2aAU1ngH X-Google-Smtp-Source: AGHT+IH//MqkZJHOhyOeSXzzPf3teXefBgYR/ZM4lkQFGhPHPt7Iw1O6BmBL0r2w5NuHP5urDrcuAg== X-Received: by 2002:a05:690c:2fc9:b0:62f:2553:d3b3 with SMTP id 00721157ae682-671f447347fmr6223167b3.29.1721759084904; Tue, 23 Jul 2024 11:24:44 -0700 (PDT) Received: from kickker.attlocal.net ([2600:1700:6cf8:1240:e02a:b5d8:6984:234c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695293fd9csm20637577b3.69.2024.07.23.11.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 11:24:44 -0700 (PDT) From: Kui-Feng Lee To: bpf@vger.kernel.org, ast@kernel.org, martin.lau@linux.dev, song@kernel.org, kernel-team@meta.com, andrii@kernel.org, sdf@fomichev.me Cc: sinquersw@gmail.com, kuifeng@meta.com, Kui-Feng Lee Subject: [PATCH bpf-next v2 2/4] selftests/bpf: Monitor traffic for tc_redirect/tc_redirect_dtime. Date: Tue, 23 Jul 2024 11:24:37 -0700 Message-Id: <20240723182439.1434795-3-thinker.li@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723182439.1434795-1-thinker.li@gmail.com> References: <20240723182439.1434795-1-thinker.li@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Enable traffic monitoring for the test case tc_redirect/tc_redirect_dtime. Signed-off-by: Kui-Feng Lee --- tools/testing/selftests/bpf/prog_tests/tc_redirect.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c index 327d51f59142..1be6ea8d6c64 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c @@ -900,6 +900,7 @@ static void test_udp_dtime(struct test_tc_dtime *skel, int family, bool bpf_fwd) static void test_tc_redirect_dtime(struct netns_setup_result *setup_result) { struct test_tc_dtime *skel; + struct tmonitor_ctx *tmon = NULL; struct nstoken *nstoken; int hold_tstamp_fd, err; @@ -934,6 +935,9 @@ static void test_tc_redirect_dtime(struct netns_setup_result *setup_result) if (!ASSERT_OK(err, "disable forwarding")) goto done; + tmon = traffic_monitor_start(NS_DST); + ASSERT_NEQ(tmon, NULL, "traffic_monitor_start"); + test_tcp_clear_dtime(skel); test_tcp_dtime(skel, AF_INET, true); @@ -958,6 +962,7 @@ static void test_tc_redirect_dtime(struct netns_setup_result *setup_result) test_udp_dtime(skel, AF_INET6, false); done: + traffic_monitor_stop(tmon); test_tc_dtime__destroy(skel); close(hold_tstamp_fd); } From patchwork Tue Jul 23 18:24:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kui-Feng Lee X-Patchwork-Id: 13740288 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1C8815884A for ; Tue, 23 Jul 2024 18:24:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721759088; cv=none; b=F+ik8I+7Yy3I4xOvGL2/y0M2aQU6I8KXUQt3DEy4uBVeNfCoW+i7oFJkgnHIdl4fC5flyXn+3vNtXUnipLDSJAZgsGVV7uljlLxCkEGYH8voOuBiiebZE8gto9IyGFyJx4O503Ni0OajHThG0nhQXbweFeGybiqp65RK0d7Qz10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721759088; c=relaxed/simple; bh=ihYgw4M2lkyecXhJKCD3eO5cq80OgeHQK0kthDOzV/A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CstDRRPaFTlGspIJf6YQE4sWa80JDEFnEMperoVrtFUGWrcOz+lXxNia44AQTp8/4qohdSKf2dzhk2qcRCQJxlxIL17BPjazQDuHGzIRHeEmD0ePrzZ4jtvM8zTKMqAZN3B5zri/Leyl0ZR5F8dwFySaNwc0dgvve42kvx+hrv0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Xmh70Lht; arc=none smtp.client-ip=209.85.128.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xmh70Lht" Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-66526e430e0so60426857b3.2 for ; Tue, 23 Jul 2024 11:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721759086; x=1722363886; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R54fpFcr6bpu9R3suSzipHUdpjYomaDR25zuQ/wjsFM=; b=Xmh70LhtxGHPtnDK0ksQMS7NhNPovWk1GWU6J5GJb9NGknDK8AvFvdxr+tBY90BBpK 4s2o0GDCfymH+xpqNcxiOAIp7BnzjRQsf8SE7F9HnvAnbPI88kyyY3dZUQgtiRZvDwwb MHzhn4sG7Cvx+Ff4BkAe0skbTV3ePp9taDaVQLCF1CWXyaw35xp9EMTBU9xOcmUdmHu8 CwUIepm6y/lcunz/1V/SADaDwdRWWdi/Dkm54S/jTujjSgr6GgLr4pR+fHtCnIBHiNBb iehll3FfKwKm8i0KDUNGvIFrGhY9zMHaYmpYMK8HNadQ9w7A7nppDV8A1WsRKYtTVwgW JN0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721759086; x=1722363886; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R54fpFcr6bpu9R3suSzipHUdpjYomaDR25zuQ/wjsFM=; b=COBGFJ1uf5fCFLOS2Cb9ZR06DAHE9gomhRJHH96xvNp5G2U3aWbYQ9WZWDL5XqqRwH fkIrnT0sEQ07C6f5V362FDxXZiLPKO4J8qe67VefF+cI3uiMe7KNdwn3679lZ2jqb1dO xlg6mWPk1ifgJPL6QFPzOcLW67+H+RD1xxe5vBuEEOE1wZjQEUNxlEAMUrzqVtajTuVB C45P2nqB6F4y05xge64T5nQodQ7QfFoPK7fEUMc5KYef62fb9g088htjFMl2nkzROOmP LM2wh3O5w6EajHGV6O/sLV7J4wQjobZpv+D1Nu5SsBpFbdDnyFJmYMI8uDXMTSWmD7rT rsew== X-Gm-Message-State: AOJu0YwlcCg5Y536xt6XdKHlJ4YlKbUa70qWOCmvCxYri+XvEpC5dGTN KoQirLkQsBFTLkm+msWVJDu/z+Ah1f9qwH/dxdLCXjqLiShlbYY0iN2yZZIw X-Google-Smtp-Source: AGHT+IEd0h+eG1INJlCr/NJY0mW72QjGeVhIqQ1gDAK7XENGQvgTm2sP73vYrtuWqKDOkNwlhtuS/Q== X-Received: by 2002:a05:690c:318e:b0:64a:4161:4f91 with SMTP id 00721157ae682-66ad8cc880dmr108327307b3.14.1721759085920; Tue, 23 Jul 2024 11:24:45 -0700 (PDT) Received: from kickker.attlocal.net ([2600:1700:6cf8:1240:e02a:b5d8:6984:234c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695293fd9csm20637577b3.69.2024.07.23.11.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 11:24:45 -0700 (PDT) From: Kui-Feng Lee To: bpf@vger.kernel.org, ast@kernel.org, martin.lau@linux.dev, song@kernel.org, kernel-team@meta.com, andrii@kernel.org, sdf@fomichev.me Cc: sinquersw@gmail.com, kuifeng@meta.com, Kui-Feng Lee Subject: [PATCH bpf-next v2 3/4] selftests/bpf: Monitor traffic for sockmap_listen. Date: Tue, 23 Jul 2024 11:24:38 -0700 Message-Id: <20240723182439.1434795-4-thinker.li@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723182439.1434795-1-thinker.li@gmail.com> References: <20240723182439.1434795-1-thinker.li@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Enable traffic monitor for each subtest of sockmap_listen. Signed-off-by: Kui-Feng Lee --- tools/testing/selftests/bpf/prog_tests/sockmap_listen.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c index e91b59366030..62683ccb6d56 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c @@ -28,6 +28,7 @@ #include "test_sockmap_listen.skel.h" #include "sockmap_helpers.h" +#include "network_helpers.h" static void test_insert_invalid(struct test_sockmap_listen *skel __always_unused, int family, int sotype, int mapfd) @@ -1893,14 +1894,21 @@ static void test_udp_unix_redir(struct test_sockmap_listen *skel, struct bpf_map { const char *family_name, *map_name; char s[MAX_TEST_NAME]; + struct tmonitor_ctx *tmon; family_name = family_str(family); map_name = map_type_str(map); snprintf(s, sizeof(s), "%s %s %s", map_name, family_name, __func__); if (!test__start_subtest(s)) return; + + tmon = traffic_monitor_start(NULL); + ASSERT_TRUE(tmon, "traffic_monitor_start"); + inet_unix_skb_redir_to_connected(skel, map, family); unix_inet_skb_redir_to_connected(skel, map, family); + + traffic_monitor_stop(tmon); } static void run_tests(struct test_sockmap_listen *skel, struct bpf_map *map, From patchwork Tue Jul 23 18:24:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kui-Feng Lee X-Patchwork-Id: 13740289 X-Patchwork-Delegate: bpf@iogearbox.net Received: from mail-yw1-f171.google.com (mail-yw1-f171.google.com [209.85.128.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7C0E1581EB for ; Tue, 23 Jul 2024 18:24:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721759089; cv=none; b=aiJo1cx1hBniMRKfpM3P2BtTUIy5xB9x7mY32cY/0I6ZCLxmFRUD59DAXAPTMdq5Xw4JRk4gl3xV/mBh2xJbgCW5xNUZfs/KPoZ/isgX0GBhtKnpKOsl8xPUQxc+2/CamX7Us/fS3WErrLAZKbMbUpqd1tdhXa17WxgdV9ZTfAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721759089; c=relaxed/simple; bh=+ecSUDmOVWFQ+PWWZMaU1MOuCodvCRs6CB6kwv/0+c4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bKrgsrvJceIv9UEMc7iyDbtmKLj7TUOEbRn5eQxkJT2uQ0n1VSm8G3daMZXlpx59MVwqrxPgFk4wTuerUjutrg8fR1Ve8Sy0/PkfTO+wuT7/69amMTxN/Up7nW/yJ3ElKNV5CPNDVLcYDWXSvEUSs0Eso7KxCc2IuNftNivhERg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gQw9oKM0; arc=none smtp.client-ip=209.85.128.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gQw9oKM0" Received: by mail-yw1-f171.google.com with SMTP id 00721157ae682-65f880c56b1so58439207b3.3 for ; Tue, 23 Jul 2024 11:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721759087; x=1722363887; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TzRxzWttvw4subNZHdn4qVZZ7tmthLLbteDrOCq8TDQ=; b=gQw9oKM04H4QNsi4fK2LD3S8+cp0cuAKHUtLH3orMIGO7w1btuU+PtmE0hCeOx589L DVRHBhpp9sSKxQyJPNNZNBrkc82xOYKeWD5Pp6Eah6i7ccbwdx0VfhHZW/r85Vp6c1r7 v7dGnYpldeKw/29hfaRxkl/7+dvUmasb8IEiz2nHh5mrydtGBHhHIUJsSxnT9+WClI8n 7aRUQixyyx+PN+I4uLhzq1A6PWuJyWXM7UINOodvaZKAYUz8njdt6msi4jjv1K3OVdA4 fKHJ1PpMMbiWXifA8nymshMm97+hOkT+GppZS+PnKDTM46elv8NbnqhzLYza+e3RBv4H hPAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721759087; x=1722363887; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TzRxzWttvw4subNZHdn4qVZZ7tmthLLbteDrOCq8TDQ=; b=vBWksG4ycmEcGzE+O/XqqjfaGvK+wi+zPXr4EhT9HE5kpk5x+qNC4MA2bwRZ0yLSo+ o5/nhMtL8EOHfdKApbWNKuJLhR/6ODukf2JAWy4jbDwplVMAa7CgvG9mFCkstDq/vzvN oxv3jmJKOAWpd2dLXUb5aAwYkBQfOxRQVHvgNq6z6ETwoGPri+0bDYV/IbcXAIG7PVFN rP9MLvWa6i1Bqhxoe7udnw7Mzj0E2Y3+QFruU1FUR+eqE8Aio/dKnNo+c7oYZKf2pSrf vEk6IQmEQjuIwAePOd3b7GahDrMev9lcaAeBrYouhqhMdvbOYG5KZqG74co1Fo/9lKeI 4Lfw== X-Gm-Message-State: AOJu0YzA2T3bpkLwyF+BBM7uwP3CNgvy4C83XClhMWkfZXOvxuD5fD5/ fP9m9uf30utJ3nnvna3LXZgUXjNUxFm8jtJAXIAjA09L/CTxfnXJhOQYDZjL X-Google-Smtp-Source: AGHT+IGOEBC4SytOUkVXoTONv8NUGvpt9zhm5/nxGjzsPC9uK8hSeOeaKJrUmrnc+lTJuC8aOk6k+g== X-Received: by 2002:a05:690c:d87:b0:648:baba:542f with SMTP id 00721157ae682-66ad5de0462mr141095807b3.0.1721759086987; Tue, 23 Jul 2024 11:24:46 -0700 (PDT) Received: from kickker.attlocal.net ([2600:1700:6cf8:1240:e02a:b5d8:6984:234c]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6695293fd9csm20637577b3.69.2024.07.23.11.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 11:24:46 -0700 (PDT) From: Kui-Feng Lee To: bpf@vger.kernel.org, ast@kernel.org, martin.lau@linux.dev, song@kernel.org, kernel-team@meta.com, andrii@kernel.org, sdf@fomichev.me Cc: sinquersw@gmail.com, kuifeng@meta.com, Kui-Feng Lee Subject: [PATCH bpf-next v2 4/4] selftests/bpf: Monitor traffic for select_reuseport. Date: Tue, 23 Jul 2024 11:24:39 -0700 Message-Id: <20240723182439.1434795-5-thinker.li@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240723182439.1434795-1-thinker.li@gmail.com> References: <20240723182439.1434795-1-thinker.li@gmail.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Enable traffic monitoring for the subtests of select_reuseport. Signed-off-by: Kui-Feng Lee --- tools/testing/selftests/bpf/prog_tests/select_reuseport.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c index 64c5f5eb2994..d3039957ee94 100644 --- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c +++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c @@ -22,6 +22,7 @@ #include "test_progs.h" #include "test_select_reuseport_common.h" +#include "network_helpers.h" #define MAX_TEST_NAME 80 #define MIN_TCPHDR_LEN 20 @@ -795,6 +796,7 @@ static void test_config(int sotype, sa_family_t family, bool inany) }; char s[MAX_TEST_NAME]; const struct test *t; + struct tmonitor_ctx *tmon; for (t = tests; t < tests + ARRAY_SIZE(tests); t++) { if (t->need_sotype && t->need_sotype != sotype) @@ -808,9 +810,14 @@ static void test_config(int sotype, sa_family_t family, bool inany) if (!test__start_subtest(s)) continue; + tmon = traffic_monitor_start(NULL); + ASSERT_TRUE(tmon, "traffic_monitor_start"); + setup_per_test(sotype, family, inany, t->no_inner_map); t->fn(sotype, family); cleanup_per_test(t->no_inner_map); + + traffic_monitor_stop(tmon); } }