From patchwork Tue Nov 15 08:05:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Karlsson X-Patchwork-Id: 13043306 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 E2950C43219 for ; Tue, 15 Nov 2022 08:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232560AbiKOIGE (ORCPT ); Tue, 15 Nov 2022 03:06:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232569AbiKOIGC (ORCPT ); Tue, 15 Nov 2022 03:06:02 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85C6C140EB; Tue, 15 Nov 2022 00:06:01 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id z14so22689176wrn.7; Tue, 15 Nov 2022 00:06:01 -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=Rw+qA6J1D1NyQ++JwfxDQ83Mz+tZaKarkxCeUc7QZ1A=; b=WEaRQh733IrM035SiDcpAg2KpFRVynjynZjPmzCvJfUzjqrqawR2aFNkHazKpuVxr5 KgAGMoB75W3t/GhJ9cpYjnT5Vt74glUFLJ75tscDEtEnhF/IXPpagf+Aq+7T7pBKNvUH 8dw+ITdJOY/n8te7nhzsJ6ceFvXb8nNXfCcpxV25QiTl82+wjFwLZnszu/mO2qXcfHc/ pL+NhK8nuqaeGpcvHW3KfVq69joa12LJt7xnhbSiHfhiPOylsxHXL2wCXPPGQLcla+65 KRdPfHcwSALnPhmNPr/M583ty4gpnkDV2wdBEFLWp1K2cTLt2uqfsLZhcBU50cjfa5Ru z+aA== 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=Rw+qA6J1D1NyQ++JwfxDQ83Mz+tZaKarkxCeUc7QZ1A=; b=IQ82fYGUDeAqNHQ12q1bEo4FhhipLfj1tYcFeVS5GUjHFUDW22P1LkN8JH73CarMLr nwooVkhudpONtUpuoqtm4r4VB+fpM7AnxWygv23AIh1z9KezqQfaJYI0BS8OUFW+/zIZ gaDREjGssbGILO32dfG1rnT2atO7zPo0R5uKdedGNvGPYhpNsCu3q4CLA6hj3GCs7ZLN XZ6BuU9+GP6O8KEv7Rxckl60ki1pMgbCOpOA10EHfM+qe3oMyv2MS4PQMq68/F9zbY35 ojEOUo0bOJtDCwvHxtWq5ICNJwrZqPP0u3FVeemjHnnYXyWrpLQxXvQ8cCiYryU3dz/d 11iA== X-Gm-Message-State: ANoB5pllL4HLnc4TcKEmgDVwTFnMpP4VJyDY9w50b0bs8dEIRnzOcVK6 FEe8kqtf8sDMiwtuGk9RFr8= X-Google-Smtp-Source: AA0mqf6EOaiTglODbKHLxV+1e1UaJ2SWlog/esN76N2EZhAUN/e7IAkiE+WF38WMcEzikGfA+0N+jA== X-Received: by 2002:a5d:538e:0:b0:236:71fe:c9c6 with SMTP id d14-20020a5d538e000000b0023671fec9c6mr9306803wrv.501.1668499559932; Tue, 15 Nov 2022 00:05:59 -0800 (PST) Received: from localhost.localdomain (h-46-59-47-246.A165.priv.bahnhof.se. [46.59.47.246]) by smtp.gmail.com with ESMTPSA id cy6-20020a056000400600b002416ecb8c33sm11464190wrb.105.2022.11.15.00.05.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2022 00:05:59 -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 Cc: jonathan.lemon@gmail.com, bpf@vger.kernel.org Subject: [PATCH bpf 1/3] selftests/xsk: print correct payload for packet dump Date: Tue, 15 Nov 2022 09:05:36 +0100 Message-Id: <20221115080538.18503-2-magnus.karlsson@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221115080538.18503-1-magnus.karlsson@gmail.com> References: <20221115080538.18503-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 payload when the packet dump option is selected. The network to host conversion was forgotten and the payload was erronously declared to be an int instead of an unsigned int. Changed the loop index i too, as it does not need to be an int and was declared on the same row. The printout looks something like this after the fix: DEBUG>> L2: dst mac: 000A569EEE62 DEBUG>> L2: src mac: 000A569EEE61 DEBUG>> L3: ip_hdr->ihl: 05 DEBUG>> L3: ip_hdr->saddr: 192.168.100.161 DEBUG>> L3: ip_hdr->daddr: 192.168.100.162 DEBUG>> L4: udp_hdr->src: 2121 DEBUG>> L4: udp_hdr->dst: 2020 DEBUG>> L5: payload: 4 --------------------------------------- Fixes: facb7cb2e909 ("selftests/bpf: Xsk selftests - SKB POLL, NOPOLL") Signed-off-by: Magnus Karlsson Acked-by: Maciej Fijalkowski --- tools/testing/selftests/bpf/xskxceiver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 681a5db80dae..51e693318b3f 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -767,7 +767,7 @@ static void pkt_dump(void *pkt, u32 len) struct ethhdr *ethhdr; struct udphdr *udphdr; struct iphdr *iphdr; - int payload, i; + u32 payload, i; ethhdr = pkt; iphdr = pkt + sizeof(*ethhdr); @@ -792,7 +792,7 @@ static void pkt_dump(void *pkt, u32 len) fprintf(stdout, "DEBUG>> L4: udp_hdr->src: %d\n", ntohs(udphdr->source)); fprintf(stdout, "DEBUG>> L4: udp_hdr->dst: %d\n", ntohs(udphdr->dest)); /*extract L5 frame */ - payload = *((uint32_t *)(pkt + PKT_HDR_SIZE)); + payload = ntohl(*((u32 *)(pkt + PKT_HDR_SIZE))); fprintf(stdout, "DEBUG>> L5: payload: %d\n", payload); fprintf(stdout, "---------------------------------------\n"); From patchwork Tue Nov 15 08:05:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Karlsson X-Patchwork-Id: 13043307 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 EB3F7C4332F for ; Tue, 15 Nov 2022 08:06:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232597AbiKOIGF (ORCPT ); Tue, 15 Nov 2022 03:06:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232636AbiKOIGD (ORCPT ); Tue, 15 Nov 2022 03:06:03 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E14371D318; Tue, 15 Nov 2022 00:06:02 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id bs21so22841495wrb.4; Tue, 15 Nov 2022 00:06:02 -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=R4MreCSI5ZRqggTXhx8hY2RP6JDPW+WxWqfQy+yqcNY=; b=p0On+zMFWQjL5cmqUOR12b8Dx4ffotrsxuGpim1rK847NyPwEXOtFmyMaCgSxDqWjj 2MGQ5AmY6ppgZTam8p01le5s3/58MKtroT55sxjRrfqsrplEJFM0tovswwLemqUa4CgX m5o5SvIiqeOBRRx0PgEFDzW5ZETWiSjh1v0LFmoD7kHFZCf4BINdQjohMT9AFWI/O00y c2MU76Ky2329Vi31irnd41rQkgb6TqYlLZqte8h+SuQHCgySW8VU9ZU38vNWrd7Nlw5s ni6B8xZYnIquGDVyL07ocBnYlhXc05EegPC9j0stinue1IErxwHeaFP1sFEmH6OtvmJ/ GveQ== 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=R4MreCSI5ZRqggTXhx8hY2RP6JDPW+WxWqfQy+yqcNY=; b=3Edy+ApAgkFXHehgmWKL7/kd4hlGUAO7nDAF/cZyDYMlpa81b27V8URnJEKOZLwIlC ANtDfJoz+vCQMN1Xm8AYytP1m2GWMVWRWKLD25nCgV8dCIt9+AxOmAIIp9Qoit+vsWtE JokYh8PX0QAXyECHS/a4+W4B9o/kHo3jTl60OG7Fp4GQoHQjdeOqxdWpdWe0NEtru0/M 4HEoLfQIYakR9aqkuZgepEbZdMhRRs8eMgoLeQN+JWsv4JNOIRZLxN4U+7emt0qL0X59 +zBhELnuYUne6RnS3yE/6vbVBSSQbmu5+ZQQDxAOKLRukIezszIfv6MOpVhhXQBTxdfr Fkhg== X-Gm-Message-State: ANoB5pmnaHCxFaIAEfub0PXcO6EEHWTV+WyqcYDIHnOK6OwRT+SbJot6 vwRqYc4joBRSMus28rIWZy8= X-Google-Smtp-Source: AA0mqf505FwDXsNDs5+8TQimlQgipWkl+0+R4+iMsZeVgq4PS+IOIyGkFG1E5JsSD2CMsBTuIkTKWA== X-Received: by 2002:adf:e74c:0:b0:22e:387:a7ba with SMTP id c12-20020adfe74c000000b0022e0387a7bamr9854289wrn.260.1668499561470; Tue, 15 Nov 2022 00:06:01 -0800 (PST) Received: from localhost.localdomain (h-46-59-47-246.A165.priv.bahnhof.se. [46.59.47.246]) by smtp.gmail.com with ESMTPSA id cy6-20020a056000400600b002416ecb8c33sm11464190wrb.105.2022.11.15.00.06.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2022 00:06:00 -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 Cc: jonathan.lemon@gmail.com, bpf@vger.kernel.org Subject: [PATCH bpf 2/3] selftests/xsk: do not close unused file descriptors Date: Tue, 15 Nov 2022 09:05:37 +0100 Message-Id: <20221115080538.18503-3-magnus.karlsson@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221115080538.18503-1-magnus.karlsson@gmail.com> References: <20221115080538.18503-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 Do not close descriptors that have never been used. File descriptor fields that are not in use are erroneously marked with the number 0, which is a valid fd. Mark unused fds with -1 instead and do not close these when deleting the socket. Fixes: f36600634282 ("libbpf: move xsk.{c,h} into selftests/bpf") Signed-off-by: Magnus Karlsson --- tools/testing/selftests/bpf/xsk.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/xsk.c b/tools/testing/selftests/bpf/xsk.c index 0b3ff49c740d..bea4cd076cd4 100644 --- a/tools/testing/selftests/bpf/xsk.c +++ b/tools/testing/selftests/bpf/xsk.c @@ -34,6 +34,8 @@ #include #include "xsk.h" +#define FD_NOT_USED (-1) + #ifndef SOL_XDP #define SOL_XDP 283 #endif @@ -601,6 +603,9 @@ static void xsk_delete_bpf_maps(struct xsk_socket *xsk) { struct xsk_ctx *ctx = xsk->ctx; + if (ctx->xsks_map_fd == FD_NOT_USED) + return; + bpf_map_delete_elem(ctx->xsks_map_fd, &ctx->queue_id); close(ctx->xsks_map_fd); } @@ -959,6 +964,9 @@ static struct xsk_ctx *xsk_create_ctx(struct xsk_socket *xsk, ctx->umem = umem; ctx->queue_id = queue_id; libbpf_strlcpy(ctx->ifname, ifname, IFNAMSIZ); + ctx->prog_fd = FD_NOT_USED; + ctx->link_fd = FD_NOT_USED; + ctx->xsks_map_fd = FD_NOT_USED; ctx->fill = fill; ctx->comp = comp; @@ -1239,8 +1247,9 @@ void xsk_socket__delete(struct xsk_socket *xsk) if (ctx->refcount == 1) { xsk_delete_bpf_maps(xsk); - close(ctx->prog_fd); - if (ctx->has_bpf_link) + if (ctx->prog_fd != FD_NOT_USED) + close(ctx->prog_fd); + if (ctx->has_bpf_link && ctx->link_fd != FD_NOT_USED) close(ctx->link_fd); } From patchwork Tue Nov 15 08:05:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Karlsson X-Patchwork-Id: 13043308 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 4299AC433FE for ; Tue, 15 Nov 2022 08:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232643AbiKOIGN (ORCPT ); Tue, 15 Nov 2022 03:06:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbiKOIGE (ORCPT ); Tue, 15 Nov 2022 03:06:04 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82014140EB; Tue, 15 Nov 2022 00:06:03 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id z14so22689389wrn.7; Tue, 15 Nov 2022 00:06:03 -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=UoMU+4yZcZN+gfBDaItl56pGrFzYvJvRENXDGoVmMTE=; b=b4e/3LG6pAPB3l5Jxr1K2nfs/u0lybcM5/1YSpwpWP5560ka4TbtZojmiXs3+HYNEw /hiYritDdY+orW5IKtQcAmk4jykKQ4XRGdbyWGbvpWhyhVakh+/3qjH13cKklJJOBrlu qZx/WwxFbHLNeFbUziZtJ3lRU8pcDn9XCotGfJtJsiLF3IyQ665Lt+tUZKJqfBDgYEFZ 4yr/TtcJQRrw4wVYqnZmyRrBwPH5qQmof0bjFsFT3Wrjhuupo1V3DTsbq2y3vCSPUneF G5iqIs9z0WldGSDUUkvARq1fe4nqLVIglBAeba4WclDC9LGfQ6VwVJF5tqFykHB3MoUZ LAbw== 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=UoMU+4yZcZN+gfBDaItl56pGrFzYvJvRENXDGoVmMTE=; b=IIINdNhngRTM+cE7fTOVoHVvcQg0qCOrtfyelbJwbGPgNlNDvoVgz3Wir4nvZknxvl 4kY/gSTr75/PSC8180cAIGD4yuphibfL8FQ7g3WMs6hT4vWMYS2LJzVsNjjXolIKy9tN vRRoRZFU6SyC8Ljqw3k5fZ+u4SS8D4Oyr8WV9bdKF6N8HpL6xN2f813iiNvCO48ikq9x LAdYKmf6mW5iC+7pQe2srYSoqRDr5JEosNzDeF29C8OARWB4IYZidEycAIPsA06L4gFL AhViu8+BVxHx+eBaS0SdKfQ4mi1re1dm/jankyEfY1zxdi7EqZpiBXrsYC5r+QA9InIa YXsA== X-Gm-Message-State: ANoB5pncwPt1UXhA9ywmV/5ACoPKfoyYy8hMXHdQ/4wXSdvXsYjTqg/M by7YR/cu6VLz9h1NEguvUKI= X-Google-Smtp-Source: AA0mqf4vwS6mvqKxMO+YnvJHgBDUPds/xwnvnQ1tIkdsAPqI8LX99/jXbNNcarfT8/APVzVubII6RA== X-Received: by 2002:adf:f94a:0:b0:236:6b51:73bc with SMTP id q10-20020adff94a000000b002366b5173bcmr9868026wrr.707.1668499563041; Tue, 15 Nov 2022 00:06:03 -0800 (PST) Received: from localhost.localdomain (h-46-59-47-246.A165.priv.bahnhof.se. [46.59.47.246]) by smtp.gmail.com with ESMTPSA id cy6-20020a056000400600b002416ecb8c33sm11464190wrb.105.2022.11.15.00.06.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2022 00:06:02 -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 Cc: jonathan.lemon@gmail.com, bpf@vger.kernel.org Subject: [PATCH bpf 3/3] selftests/xsk: print correct error codes when exiting Date: Tue, 15 Nov 2022 09:05:38 +0100 Message-Id: <20221115080538.18503-4-magnus.karlsson@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221115080538.18503-1-magnus.karlsson@gmail.com> References: <20221115080538.18503-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") Signed-off-by: Magnus Karlsson --- tools/testing/selftests/bpf/xskxceiver.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 51e693318b3f..507dd28801fa 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); } @@ -1014,7 +1014,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) @@ -1023,7 +1023,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; } } @@ -1317,23 +1317,23 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject) ret = bpf_xdp_query(ifindex, ifobject->xdp_flags, &opts); if (ret) - exit_with_error(-ret); + exit_with_error(errno); 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) @@ -1540,7 +1540,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)