Re: [PATCH v4 3/4] selftests: net: add flag to force zerocopy mode in xdp_helper

Jakub Kicinski
2025-04-23T01:34:23Z

On Thu, 17 Apr 2025 14:28:05 +0700 Bui Quang Minh wrote:
> + if (argc == 4 && strcmp(argv[3], "-z")) {
> + fprintf(stderr, "Usage: %s ifindex queue_id [-z]\n\n"
> + "where:\n\t-z: force zerocopy mode\n", argv[0]);
> + return 1;
> + } else if (argc == 4) {
> + sxdp.sxdp_flags = XDP_ZEROCOPY;
> + }

I've applied the fix, the tests need a couple touch ups, so please
repost just the tests for net-next?

Here I think it'd be cleaner to write the change as:

static void print_usage(const char *bin)
{
fprintf(stderr, "Usage: %s ifindex queue_id [-z]\n\n"
"where:\n\t-z: force zerocopy mode\n", bin);
}

[...]

if (argc > 3) {
if (!strcmp(argv[3], "-z")) {
sxdp.sxdp_flags |= XDP_ZEROCOPY;
} else {
print_usage(argv[0]);
return 1;
}
}