From patchwork Wed Jan 4 12:17:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Karlsson X-Patchwork-Id: 13088528 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF9B2C4332F for ; Wed, 4 Jan 2023 12:19:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239215AbjADMS5 (ORCPT ); Wed, 4 Jan 2023 07:18:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230249AbjADMSr (ORCPT ); Wed, 4 Jan 2023 07:18:47 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 956DAF5AA; Wed, 4 Jan 2023 04:18:46 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id ja17so25407131wmb.3; Wed, 04 Jan 2023 04:18:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=huOhL7D9Jyth4UUa2iSMii1CNgBq5CuBgEOXmYynEqw=; b=X92Gf432GifAD3o8wsxpEEe2ins9lDlQxQdJPm9cleFoWXQAg0pd/XDJJbdHGgzFtA 12pGm71EU5MeHHVdEhNlvVAGdmUzVdDjc5BgKF8TW52QRYWJ3pzYC5Ye+ozqcCyBZhQL 1bzpD4WhX9NrsNKiLzS1xfr6lLjz2nbe1mwxE2NM7j63husn10k/Kz8ia6/bjez8oLe2 a/6yy4rTwJTtm9Qh+AU6q1HsXmjNORFv/7BcbIiezJeU6nqFAIo2hXdsOPMFUlwwpEUX rcuh7yzurD7dI1IOfD5qEJDu6Jil29MQPPHhACiDy+u4k1tM8N13ysVWM/CWZ12AhVPg BbEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=huOhL7D9Jyth4UUa2iSMii1CNgBq5CuBgEOXmYynEqw=; b=YD3DFvFPSrcotxRYxRAbTWx9XgViii+Z5OCsgUa1LjZT8nk2YBdbRYlk11YcDcp+hD vgUEEf10TIYcFfePlOPuhixawDqWBbqLCLxovhnYTtq5VFWUM8Y4EiXOq0r/kXiGduAY /zpGDXap/SzUO1Oo83RUfgOk01J3vMASioD3DbT3fWC7B3pfh/MMAZ9bBHXtxRMr5ISh CXQhhouG54Xv0q0M8TX0zhpsQq4NQmrrdYn4BNHCiAgtBvYTrtsGbFSpQD8wfztaVPJu hPqYMLvDrjjuqmq+1RnJSTJL5mUIM5uB6L3W5Oqy0Kc9BiU52PghGQbQiIRTijTQF1SV 6TUg== X-Gm-Message-State: AFqh2kpz4LPdccZBwWG0dQwwj35Mmmzdg1NTrHNAGt9j7JGevR0LsHKm 3RG4IjPHKK4t/QMm1Na+ioc= X-Google-Smtp-Source: AMrXdXuWwKo+NWybJwZNHTnMmB1OHb42oKBym7atK8oZiOxowZdwIBUvexmG8pJ27YEDYH7wTBqFRQ== X-Received: by 2002:a05:600c:556f:b0:3d2:2a74:3a90 with SMTP id ja15-20020a05600c556f00b003d22a743a90mr35890746wmb.22.1672834725022; Wed, 04 Jan 2023 04:18:45 -0800 (PST) Received: from localhost.localdomain (h-176-10-254-193.A165.priv.bahnhof.se. [176.10.254.193]) by smtp.gmail.com with ESMTPSA id w12-20020a05600c474c00b003d04e4ed873sm35013749wmo.22.2023.01.04.04.18.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Jan 2023 04:18:44 -0800 (PST) From: Magnus Karlsson To: magnus.karlsson@intel.com, bjorn@kernel.org, ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, maciej.fijalkowski@intel.com, bpf@vger.kernel.org, yhs@fb.com, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, tirthendu.sarkar@intel.com Cc: jonathan.lemon@gmail.com Subject: [PATCH bpf-next v2 04/15] selftests/xsk: print correct error codes when exiting Date: Wed, 4 Jan 2023 13:17:33 +0100 Message-Id: <20230104121744.2820-5-magnus.karlsson@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104121744.2820-1-magnus.karlsson@gmail.com> References: <20230104121744.2820-1-magnus.karlsson@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Magnus Karlsson Print the correct error codes when exiting the test suite due to some terminal error. Some of these had a switched sign and some of them printed zero instead of errno. Fixes: facb7cb2e909 ("selftests/bpf: Xsk selftests - SKB POLL, NOPOLL") Acked-by: Maciej Fijalkowski Signed-off-by: Magnus Karlsson --- tools/testing/selftests/bpf/xskxceiver.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index a239e975ab66..72578cebfbf7 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -350,7 +350,7 @@ static bool ifobj_zc_avail(struct ifobject *ifobject) umem = calloc(1, sizeof(struct xsk_umem_info)); if (!umem) { munmap(bufs, umem_sz); - exit_with_error(-ENOMEM); + exit_with_error(ENOMEM); } umem->frame_size = XSK_UMEM__DEFAULT_FRAME_SIZE; ret = xsk_configure_umem(umem, bufs, umem_sz); @@ -936,7 +936,7 @@ static int receive_pkts(struct test_spec *test, struct pollfd *fds) if (ifobj->use_poll) { ret = poll(fds, 1, POLL_TMOUT); if (ret < 0) - exit_with_error(-ret); + exit_with_error(errno); if (!ret) { if (!is_umem_valid(test->ifobj_tx)) @@ -963,7 +963,7 @@ static int receive_pkts(struct test_spec *test, struct pollfd *fds) if (xsk_ring_prod__needs_wakeup(&umem->fq)) { ret = poll(fds, 1, POLL_TMOUT); if (ret < 0) - exit_with_error(-ret); + exit_with_error(errno); } ret = xsk_ring_prod__reserve(&umem->fq, rcvd, &idx_fq); } @@ -1015,7 +1015,7 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb, struct pollfd *fd if (timeout) { if (ret < 0) { ksft_print_msg("ERROR: [%s] Poll error %d\n", - __func__, ret); + __func__, errno); return TEST_FAILURE; } if (ret == 0) @@ -1024,7 +1024,7 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb, struct pollfd *fd } if (ret <= 0) { ksft_print_msg("ERROR: [%s] Poll error %d\n", - __func__, ret); + __func__, errno); return TEST_FAILURE; } } @@ -1323,18 +1323,18 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject) if (ifobject->xdp_flags & XDP_FLAGS_SKB_MODE) { if (opts.attach_mode != XDP_ATTACHED_SKB) { ksft_print_msg("ERROR: [%s] XDP prog not in SKB mode\n"); - exit_with_error(-EINVAL); + exit_with_error(EINVAL); } } else if (ifobject->xdp_flags & XDP_FLAGS_DRV_MODE) { if (opts.attach_mode != XDP_ATTACHED_DRV) { ksft_print_msg("ERROR: [%s] XDP prog not in DRV mode\n"); - exit_with_error(-EINVAL); + exit_with_error(EINVAL); } } ret = xsk_socket__update_xskmap(ifobject->xsk->xsk, ifobject->xsk_map_fd); if (ret) - exit_with_error(-ret); + exit_with_error(errno); } static void *worker_testapp_validate_tx(void *arg) @@ -1541,7 +1541,7 @@ static void swap_xsk_resources(struct ifobject *ifobj_tx, struct ifobject *ifobj ret = xsk_socket__update_xskmap(ifobj_rx->xsk->xsk, ifobj_rx->xsk_map_fd); if (ret) - exit_with_error(-ret); + exit_with_error(errno); } static void testapp_bpf_res(struct test_spec *test)