From patchwork Thu Jul 25 10:35:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 814676 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 7AFA214D457; Thu, 25 Jul 2024 10:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903953; cv=none; b=dM3XfyWtsIhQUH7eevki37xRbe8IvtkA++9dlbWQ7jk2bdEX2chfO7SmSMuIV6b5+GpIYdNAWEp1NUHPzoKiu4uCbh9B0nrHSz9AQtU2KZq+LkY3u5e9UHZc/Cn+hC7JdkAFDJPq/z9x8amTw0BHIJs9NeQnCOyKEDLcQB9/hwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903953; c=relaxed/simple; bh=FhhULHJSRQRfqOkOSBVfyHqLgWbWh8s2Lych3idzotM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Sv9W3hP8VorFMoxtCqSeEG083hqjqgSH2K2ekh829iOTqbX+uqXXZpFCrN8TOMz4PxrMEXjUjq/YzevM+mGO8MKj9N/ftqNZoIE0dKoP0rV5+qsiZvnuT45IsiO1wCjfOkqr6m/ehSe2O9oPGsdBpudOCV30YSaOOq2uh2XUqZQ= 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=d2lL6Qwr; arc=none smtp.client-ip=209.85.214.174 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="d2lL6Qwr" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-1fd9e6189d5so6498795ad.3; Thu, 25 Jul 2024 03:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721903952; x=1722508752; 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=Ghp88PrF1o/2mzcoM7JfrRTyuYzOPJ40TUi0UK8SVqA=; b=d2lL6Qwrcr6Bu+xuhiByTGZ72SwEHoxl5hR4pzOlcimEGeovCxVFxc91TVhVeeazkd PEP0raLrCxaVm6G4OvggGAT22+hVbVXxoPsGcN+QXGUjqGjYI4W48+qdLlkDVy7t5qhh QaJ0EYWedLbVraBp3Hk7nByvJqGNl1MXs2m647dd81IZQ/ejzevpc4uulWUVnKfXJgRG Dktf/F8ZYO8r5tNqVO3ECX5hKyFDfAVggErKY3qVZ9bIeyJYxPpsT//+nWYnwdTgCYyB TUKuesq0eyo6SewdDhDIk0o1ZyvlzJGe7XIj66ganUujgdSy2XnJmub2qnPFDPQhxH6L 1Lmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721903952; x=1722508752; 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=Ghp88PrF1o/2mzcoM7JfrRTyuYzOPJ40TUi0UK8SVqA=; b=iaKvdVqOLJkjzDS0iUEIQnpOs5xmSDWJZdeyZG/7Z/fmTH6pt8PEY3pEqk8Ua3Nrb7 SCKHu7oG2dmOT/9pHtxyc+kQFXYJtaXeVsUXAzmqo002z94sl6Fy3qIOEnd90S7IF59e Qt85UJo9qbj38LrbJ9b0ECIsQR4BqCmy2nsCdpueP0JmBkuufKmpltSRx5l3XS/H08GF 1IYgzNWBvJ4BhaTwhRvnfxFvRZtTSiSjcxz7q2RWDurM5IQ3E9AkRRXEY1g/hC4E3x0G LwLhbUeEjTThd3LDAgG62ucjIkWz6UgNF8RfG5ktr3qe/s5/SG3mnhbxGxtCVZ/EwYI5 zk2g== X-Forwarded-Encrypted: i=1; AJvYcCWwxknLXr8kCZ+s2ShnGLumdZdZ0ZV/M6gjEcRH7eZFyU27dqj22NPscOnnUEMaVNs6z85ZJL5mGelHLmkAfAkp7GyXBC2rWI1sfZf2Novngg/MFgK0ZXJ1X5Drhbs6TpNlQGrJnSqZ X-Gm-Message-State: AOJu0Yzl192NToem0SqnfayoUtRd1QbSjw3vrqtQA+xD2PMgWtbmxLoB WpdOP/BBHGB/k5F81uTGxiriruhU/Cp0CNzsH+SvELl/KH+t56DB6o13KVYi X-Google-Smtp-Source: AGHT+IHIy/VccFzu/PejmYfYrlXyVUe0mollB6ADsyNs+yD+o6XPQfOPVqoASrMH/7qtfhA6eLZ3Ww== X-Received: by 2002:a17:903:228a:b0:1fd:6848:bc2d with SMTP id d9443c01a7336-1fed9257af7mr13548175ad.20.1721903951607; Thu, 25 Jul 2024 03:39:11 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f78491sm10991075ad.244.2024.07.25.03.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 03:39:11 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v1 1/8] selftests/bpf: Use portable POSIX basename() Date: Thu, 25 Jul 2024 03:35:53 -0700 Message-Id: <570a059b3db60199028e0a36896be0f1b472b9cf.1721903630.git.tony.ambardar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tony Ambardar Use the POSIX version of basename() to allow compilation against non-gnu libc (e.g. musl). Include ahead of to enable using functions from the latter while preferring POSIX over GNU basename(). In veristat.c, rely on strdupa() to avoid basename() altering the passed "const char" argument. This is not needed in xskxceiver.c since the arg is mutable and the program exits immediately after usage. Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/veristat.c | 8 +++++--- tools/testing/selftests/bpf/xskxceiver.c | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c index b2854238d4a0..11ec1190d582 100644 --- a/tools/testing/selftests/bpf/veristat.c +++ b/tools/testing/selftests/bpf/veristat.c @@ -2,6 +2,7 @@ /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */ #define _GNU_SOURCE #include +#include #include #include #include @@ -988,8 +989,8 @@ static void fixup_obj(struct bpf_object *obj, struct bpf_program *prog, const ch static int process_prog(const char *filename, struct bpf_object *obj, struct bpf_program *prog) { + const char *base_filename = basename(strdupa(filename)); const char *prog_name = bpf_program__name(prog); - const char *base_filename = basename(filename); char *buf; int buf_sz, log_level; struct verif_stats *stats; @@ -1056,13 +1057,14 @@ static int process_prog(const char *filename, struct bpf_object *obj, struct bpf static int process_obj(const char *filename) { + const char *base_filename = basename(strdupa(filename)); struct bpf_object *obj = NULL, *tobj; struct bpf_program *prog, *tprog, *lprog; libbpf_print_fn_t old_libbpf_print_fn; LIBBPF_OPTS(bpf_object_open_opts, opts); int err = 0, prog_cnt = 0; - if (!should_process_file_prog(basename(filename), NULL)) { + if (!should_process_file_prog(base_filename, NULL)) { if (env.verbose) printf("Skipping '%s' due to filters...\n", filename); env.files_skipped++; @@ -1076,7 +1078,7 @@ static int process_obj(const char *filename) } if (!env.quiet && env.out_fmt == RESFMT_TABLE) - printf("Processing '%s'...\n", basename(filename)); + printf("Processing '%s'...\n", base_filename); old_libbpf_print_fn = libbpf_set_print(libbpf_print_fn); obj = bpf_object__open_file(filename, &opts); diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c index 8144fd145237..92af633faea8 100644 --- a/tools/testing/selftests/bpf/xskxceiver.c +++ b/tools/testing/selftests/bpf/xskxceiver.c @@ -90,6 +90,7 @@ #include #include #include +#include #include #include #include From patchwork Thu Jul 25 10:35:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 814496 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 B8F8F14D457; Thu, 25 Jul 2024 10:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903959; cv=none; b=iVff/yybWXGUr/fW8zR1oGWRLW+UB7Hvz67f65T9eGD178Bb6nF/2SExkk2XgP26Q4wr3QHCCZ0syDIy8u9qDvPgHMlxR4Xu3wgMN25oz7j5MLbnedAi3FABrZRWAC2s7tDH+uzRAN/sXkiIZ13l4DWkUYUB3CXZl331xkn76hY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903959; c=relaxed/simple; bh=spduKz3MG08ysTbjR+T3/W9hmuI0dpTQAjF2pWukz6U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BkmJyF1MmDQbHLLHH0Fcc45E+ohjeqrO8TAJkmfhp0unC7KBx1MCQOezT498CtF5p2Df6JHSYH8eZ3EklBEWBr62XP6wQK7+fzwjzW2dgOjYj+exwch7MRdk87ZkG4PnYeyxfQ18UB2VeTsHP3NUtHBQ6ZjTN5HQ8u0DrRurZIA= 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=juWPshJA; arc=none smtp.client-ip=209.85.215.178 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="juWPshJA" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7a0b2924e52so510127a12.2; Thu, 25 Jul 2024 03:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721903956; x=1722508756; 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=LWKiNJXsPoK3DXrf/1mQJ65mXagc2GxO27bBCQyvS1E=; b=juWPshJApTno6/8/owTwwkzziBNyuzCjvFSWtWyonHoDqBwwyABR2FHW3L3HLqz1xE zzhQcvxz+Ydi//SOWhsGdUUnnpH1JilRzULk2G4JR7DvRvB8kMt7s2gbxqZTBSOIY8FO 0pwxra3UTpzR+oULlX/6S+Y0S7KMN4xRMSvkZV//rMe6g72LXcuA5FQGOTCDrvgAwz46 gVhytqw55CC573a5iQgg4nq2gipvxxrewaZhsvZtxd/FcKKuqZ9l2iArsdrexOgyqrzE g1aZ6nbj/dBFqln1UdYwLY9VEY1FxjdpdYvpVShlKu7SRB0cfw+JmuvejcjNMySFb/IX ZYCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721903956; x=1722508756; 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=LWKiNJXsPoK3DXrf/1mQJ65mXagc2GxO27bBCQyvS1E=; b=YtyioW1aaGrbMPNjZdSPQ79xVAOZbqcZ0cCpIboG1ozaup80WM8Sz8G5d0tPCBr3NE sySUqKgOEx594FhHBmVKmvRUViV7ZEspFe/7pNRjjCx3CEXL/uAMOia/Gg4QCUIqfzVK P1QDsq88YsoIoD5uUh7cHn4gOOmqB8WoC57s7gNjVXBqGJw5gtlDjuqlP8ikfHlwYyNB Bawdm+UT/ptUna+GytbX2FWqFvnvhIp+RmPOpcizo0NUqMbJsQ4WT9fOgUglX+e7ncNf B7gHlb7Bj236wbSwFn/Xdd4dVWP5DEYayJ+AYk9diCOgovgsf/6xs66f3AKQR59NB4hH FfIQ== X-Forwarded-Encrypted: i=1; AJvYcCUT4lCTQD6UXlCVZbUeteOJ22fFMtrX9J0Z+3qCSaAD7zwhvyBcxGhWO4V2xBEAUE6X5pqIy73cCBiyVj4FpFPKwyqmZXPYu/BneDzP6vQcTAuMuiBwC/hu50LXIFkfP8EzGZwlp41j X-Gm-Message-State: AOJu0YyG+So+CIEjNwI4HOTspfcE4r3Jz5OWcpJOSmMDWBPbar3EkvJ9 fYYammfC31ql0pU/Q5eXW53tVV31j141TF5gUImlX2QuVFj1S7p28Ki19zxQ X-Google-Smtp-Source: AGHT+IHPgjFCpbUHKZfZG8MIHeQRMA2ox/NTTKbs4wYPznMHuq5r+zlurWLe2r2hANNpk7Ca03CVYQ== X-Received: by 2002:a05:6a20:3d87:b0:1c2:8cf4:7656 with SMTP id adf61e73a8af0-1c4727aad6dmr3324941637.10.1721903956411; Thu, 25 Jul 2024 03:39:16 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f78491sm10991075ad.244.2024.07.25.03.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 03:39:16 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v1 2/8] selftests/bpf: Fix arg parsing in veristat, test_progs Date: Thu, 25 Jul 2024 03:35:54 -0700 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tony Ambardar Current code parses arguments with strtok_r() using a construct like char *state = NULL; while ((next = strtok_r(state ? NULL : input, ",", &state))) { ... } where logic assumes the 'state' var can distinguish between first and subsequent strtok_r() calls, and adjusts parameters accordingly. However, 'state' is strictly internal context for strtok_r() and no such assumptions are supported in the man page. Moreover, the exact behaviour of 'state' depends on the libc implementation, making the above code fragile. Indeed, invoking "./test_progs -t " on mips64el/musl will hang, with the above code in an infinite loop. Similarly, we see strange behaviour running 'veristat' on mips64el/musl: $ ./veristat -e file,prog,verdict,insns -C two-ok add-failure Can't specify more than 9 stats Rewrite code using a 'for' loop without logic dependent on var 'state', the same approach already used in cgroup_helpers.c. Fixes: 61ddff373ffa ("selftests/bpf: Improve by-name subtest selection logic in prog_tests") Fixes: 394169b079b5 ("selftests/bpf: add comparison mode to veristat") Fixes: c8bc5e050976 ("selftests/bpf: Add veristat tool for mass-verifying BPF object files") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/testing_helpers.c | 2 +- tools/testing/selftests/bpf/veristat.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c index ac7c66f4fc7b..2a73b72feb18 100644 --- a/tools/testing/selftests/bpf/testing_helpers.c +++ b/tools/testing/selftests/bpf/testing_helpers.c @@ -227,7 +227,7 @@ int parse_test_list(const char *s, if (!input) return -ENOMEM; - while ((test_spec = strtok_r(state ? NULL : input, ",", &state))) { + for (test_spec = strtok_r(input, ",", &state); test_spec; test_spec = strtok_r(NULL, ",", &state)) { err = insert_test(set, test_spec, is_glob_pattern); if (err) break; diff --git a/tools/testing/selftests/bpf/veristat.c b/tools/testing/selftests/bpf/veristat.c index 11ec1190d582..6808679827ac 100644 --- a/tools/testing/selftests/bpf/veristat.c +++ b/tools/testing/selftests/bpf/veristat.c @@ -791,7 +791,7 @@ static int parse_stats(const char *stats_str, struct stat_specs *specs) if (!input) return -ENOMEM; - while ((next = strtok_r(state ? NULL : input, ",", &state))) { + for (next = strtok_r(input, ",", &state); next; next = strtok_r(NULL, ",", &state)) { err = parse_stat(next, specs); if (err) { free(input); @@ -1513,7 +1513,7 @@ static int parse_stats_csv(const char *filename, struct stat_specs *specs, *stat_cntp += 1; } - while ((next = strtok_r(state ? NULL : input, ",\n", &state))) { + for (next = strtok_r(input, ",\n", &state); next; next = strtok_r(NULL, ",\n", &state)) { if (header) { /* for the first line, set up spec stats */ err = parse_stat(next, specs); From patchwork Thu Jul 25 10:35:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 814675 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 1790E198E80; Thu, 25 Jul 2024 10:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903963; cv=none; b=CknqxZy0IHBN8RFPba+Lj2uGjTBAgsIaqtOYQ+0kL00LFbTMIVvdv7RI71+tDWjcCa4VPi2G7I5CNUgjtOpemeP+VpABMOUSyew5d4a0FvUKH/LfTyj64kC+MLJ+nYRuZoCbpjSvgpUwT7ppJkPnM5jleqrvSxVbofgbrX5FbU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903963; c=relaxed/simple; bh=b2eopH9P05jws6B3FttawjClEaNYLSZjTY6eEAmx1IY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p/XfDLkNGstZJUWZexlfFZYP+ZzvAIUFM4v4icnjIsYQQQu5zTDEUYTK46IWCEXeBaWorI26RdjRB7cSyKdfAmEND1YxRo0virTiicFvx2BuxJ5RBHIEIgCVgaU2zx//FNrDSDvIbPL0s9Sx6kowLsYxpDWkIxkGoTnHxG7/o5Q= 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=Iwf0swFr; arc=none smtp.client-ip=209.85.214.178 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="Iwf0swFr" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1fd640a6454so7096035ad.3; Thu, 25 Jul 2024 03:39:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721903961; x=1722508761; 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=aPj4UrGFYxLYkSohWfAYYA0VUXQB0pTvzNeY+UOm5uo=; b=Iwf0swFrInIzC1KLglwfm8fvdeEv553HT4OGyWs/6Lkd48VUiu7sRQKqud8a1UhYXy +1KFON+sxKD5VwKpO+TD3FYkxUMjO13/NvQ2YjJIRJ4H56/B4OVv9A6kZsIBzQZ3AtUq iX/8ZfruqBDv1ecULtiMGxGRg39ontQvjPE0GRyD7ENHi6tFriwDg/rss1/3odQJ4fqn ImOf9GDYnO7PIRnQcmlMy/tzXY+ZRYVvzpfRlBnlgNWy8F48rMebp3o1LqtreKjRbd6N 4csEuCk2ilJn1uWCaaAHiuTPdHouuzN4V8uTOacU6gUeXewqTpb2WDTxPjri91Jm4lNs +aMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721903961; x=1722508761; 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=aPj4UrGFYxLYkSohWfAYYA0VUXQB0pTvzNeY+UOm5uo=; b=tlaZ5kYbbROmVOqQzQoXYMHd8kI9uc3/AUYT+aHFMUqDlm78HxVPxrzHYELtGOkyEo FwDjQrXog/NHAZJRdN3Zkp5osH14PP50kpFwLEqZsQkum6eyHKGUb7+XlBZI/46TQoWj SRkxSxWI+CoRzN4Dq4a+3kXW/7WLqJBB0otUjYEuJJ3PewokgX4WVP2R+kdjvUc+qFxT K6/+Qq+Ld7Mf7Vg+577VQHvpczFbELPeaQBJx64+hZLk/V7gRYwwQ+eT3FdlFuq7SBKM 3nQxLjrz7PU6oCpadiSnxzxk3oeDw1AB9qQLhB8B6T9DvhK3gl+7FLt8LIiUNkkNv4YN Ib/g== X-Forwarded-Encrypted: i=1; AJvYcCXeVKOhDjAgXQ21b+LrWhGXLZJQc56BNRD35Y+y7wafVW5J397XfUCOOgXy6+aX4wKwnInnOXAJGGwU6uJ9VEWqDlxunSBKy2Pv2kCRlac9l2i52SHe/Ar60L36MZ0843Q7FIXDVXp7 X-Gm-Message-State: AOJu0YxMCQBP/0rxpX5Zoluj1DIPVif5jbIys7emxZACss1wiUXjYdQD Jxx8d979B+NMgRchEx7b5gCuEe1IYawpGvpHhgsLezKxsvIXi98A0ckeMDC2 X-Google-Smtp-Source: AGHT+IFomPSqd48Y8JT/fht4rfbWgYahdQgdWbH5Bbu1k5axGHfLIFiOdBetRUJKvS3XBZ/mJjp6Lg== X-Received: by 2002:a17:903:41c8:b0:1fc:6a81:c5a1 with SMTP id d9443c01a7336-1fed35360demr29712495ad.12.1721903961235; Thu, 25 Jul 2024 03:39:21 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f78491sm10991075ad.244.2024.07.25.03.39.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 03:39:21 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v1 3/8] selftests/bpf: Fix error compiling test_lru_map.c Date: Thu, 25 Jul 2024 03:35:55 -0700 Message-Id: <13890669483d34ef1c89a3c79b726f6dba442bf9.1721903630.git.tony.ambardar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tony Ambardar Although the post-increment in macro 'CPU_SET(next++, &cpuset)' seems safe, the sequencing can raise compile errors, so move the increment outside the macro. This avoids an error seen using gcc 12.3.0 for mips64el/musl-libc: In file included from test_lru_map.c:11: test_lru_map.c: In function 'sched_next_online': test_lru_map.c:129:29: error: operation on 'next' may be undefined [-Werror=sequence-point] 129 | CPU_SET(next++, &cpuset); | ^ cc1: all warnings being treated as errors Fixes: 3fbfadce6012 ("bpf: Fix test_lru_sanity5() in test_lru_map.c") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_lru_map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_lru_map.c b/tools/testing/selftests/bpf/test_lru_map.c index 4d0650cfb5cd..fda7589c5023 100644 --- a/tools/testing/selftests/bpf/test_lru_map.c +++ b/tools/testing/selftests/bpf/test_lru_map.c @@ -126,7 +126,8 @@ static int sched_next_online(int pid, int *next_to_try) while (next < nr_cpus) { CPU_ZERO(&cpuset); - CPU_SET(next++, &cpuset); + CPU_SET(next, &cpuset); + next++; if (!sched_setaffinity(pid, sizeof(cpuset), &cpuset)) { ret = 0; break; From patchwork Thu Jul 25 10:35:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 814495 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 1D740198E80; Thu, 25 Jul 2024 10:39:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903967; cv=none; b=PI3Xk7xalJWtBs4yZ9vm8V4T2w0y3eDUNEH68YPIMTRASWLpfb5S6OTWVRD7yvLMaHOPi6+VZEslBpPk94/UMKLt/kGORX6LhqVRDPd90EJffJzA5OiThiFq491yJd4cV4+d7Ou4XmFE5I7HHDwpwPNpvEF5ws1/RW0QmlKe1f8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903967; c=relaxed/simple; bh=dpEwF1Cqkmhw2dlPnlRWZ6TZAxaZdsaXm+4K0XPeYKI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lwdGdHa4fHKXu3Ip1tLDler9EZlU+goxKfFe7R1K1Votd3R8/TSvrkpT7Xy415JTgCwwieTEkfcSrOFarvF/4PBi6TXiu/7hHG3gEG9fCZiSjPK1c4SZDVPuBITGF0n9kV0GMUXhjEHUpeGRmzwhcp4e2o9le5hPUI9264ofUps= 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=mDRdYgwP; arc=none smtp.client-ip=209.85.214.178 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="mDRdYgwP" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1fd69e44596so5859025ad.1; Thu, 25 Jul 2024 03:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721903965; x=1722508765; 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=W/aaV17KP26bQPkrsuL+XRw6Nra50MTDjCsVlM0bqEk=; b=mDRdYgwPOQ+Wg2rSQyAQN2AWkkXovsY9TUXmwOWB0jxasyfqy8wUmQ9wVIV2Bgb2Kp JMb5B58Pm9iv4k17MnaFaYoHAaOHy/QpRQ7TvA4l1LncivJK094MaXy484el1GgnhVFE FTdfc8sWOz0ttGYywKXv3EEfHpQCCHu3rQhXG6P7Gfwx7bdmReojFwGt5X5G9EZ6/h/i GK6oj0ZNFBaRxtl/kRooodEFldEP2UTVZ3i9kXm/bWrUfvXI4WlCZ8ZOBX7MS8H0+l5v SPGvKUGDfj7MlCbguybOK1HjpU2Wd+DF+klkdmCEjzkazC57IKGYyHhiQ4KwDHMoN939 CUoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721903965; x=1722508765; 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=W/aaV17KP26bQPkrsuL+XRw6Nra50MTDjCsVlM0bqEk=; b=g+5MyK0xcUiviKmNmovM9ZVVei6eXucRx9c2+aqPsysQzTkpOoInep43iP4gA4kzti 6cP7V+I6bs4DUnmQQ8jrMdMzTzoTVXTHrxXKOpdtLfXM7TjhfYzFSKTwpjB88TXRZJeh 5+b7TOEmSXWn95BpbTkpwEEstiOaz/SzgvwSR4Vblm2LmkU7cnCq10YbaBXsp6EwuXdc cUnAxNV2iv3/eF01OMmWc1Zm8KA5AOLmeEf9gP9kSNjjvk8mNiBJamYIO1nRzF6jCWPX tGwaGiH0RcpnsZdrZE2JURUOTxmvAHwTgbU7rTPUaP7KZXOtKz0pT4c6TIosTEjTdydK zCUg== X-Forwarded-Encrypted: i=1; AJvYcCUwNy19g71vd0S2Zddo8cRSZMhu3iP9m/XkI38P48IowggOJrA4HQKqW8cECobGOT0Ne87JM2bCsInnyZUot04Z46uvH/7RCso/lBGpDTUPjl93IPk+iZ+xgs2la8+RXA0L/69jBcYb X-Gm-Message-State: AOJu0YxOMYgbUZ6MtiqFl7TAyw5pDFzsSrBoLpGixmrBNNjl/UmfvaLH 8Iq9FCUrYfbX8tLgSIZNm2g7XqjPeuRIWC/EuqRTwCAmFU5MUN21WTb4wB0W X-Google-Smtp-Source: AGHT+IFoGGfrWX4G6uu4Ef18RliZIoXj2QSHAb/E+hdF3XX4s5OytOk02DSczzI2jQRJb7/ofzC9Rg== X-Received: by 2002:a17:903:2308:b0:1fb:9b91:d7d9 with SMTP id d9443c01a7336-1fed2854b27mr41183435ad.26.1721903965132; Thu, 25 Jul 2024 03:39:25 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f78491sm10991075ad.244.2024.07.25.03.39.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 03:39:24 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v1 4/8] selftests/bpf: Fix C++ compile error from missing _Bool type Date: Thu, 25 Jul 2024 03:35:56 -0700 Message-Id: <2637cf3bfed4d550d2a6340ce052a8ce88426260.1721903630.git.tony.ambardar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tony Ambardar While building, bpftool makes a skeleton from test_core_extern.c, which itself includes and uses the 'bool' type. However, the skeleton test_core_extern.skel.h generated *does not* include or use the 'bool' type, instead using the C-only '_Bool' type. Compiling test_cpp.cpp with g++ 12.3 for mips64el/musl-libc then fails with error: In file included from test_cpp.cpp:9: test_core_extern.skel.h:45:17: error: '_Bool' does not name a type 45 | _Bool CONFIG_BOOL; | ^~~~~ This was likely missed previously because glibc uses a GNU extension for with C++ (#define _Bool bool), not supported by musl libc. Normally, a C fragment would include and use the 'bool' type, and thus cleanly work after import by C++. The ideal fix would be for 'bpftool gen skeleton' to output the correct type/include supporting C++, but in the meantime add a conditional define as above. Fixes: 7c8dce4b1661 ("bpftool: Make skeleton C code compilable with C++ compiler") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_cpp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/bpf/test_cpp.cpp b/tools/testing/selftests/bpf/test_cpp.cpp index dde0bb16e782..abc2a56ab261 100644 --- a/tools/testing/selftests/bpf/test_cpp.cpp +++ b/tools/testing/selftests/bpf/test_cpp.cpp @@ -6,6 +6,10 @@ #include #include #include + +#ifndef _Bool +#define _Bool bool +#endif #include "test_core_extern.skel.h" #include "struct_ops_module.skel.h" From patchwork Thu Jul 25 10:35:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 814674 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 420C8198E80; Thu, 25 Jul 2024 10:39:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903970; cv=none; b=g+Baa8fL7+eEkBcnj1HciRh5O3nhl8n03qAN53ro1HkohgFP9d1K54pnqkOLjlc8LfVkQ9PYjF8g4omeoWwWO4V7OD8KNAIDuuE2t/sMfBkzhJ+6VKP9Bz1H6AHIQ0TcrouJvAPLVTQ+s/ATTOgaHFkGNojpPs3JseOCl+NnSEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903970; c=relaxed/simple; bh=39nKO2W4H+sgYTYoUr8Abgv9UryPtz4B2rZa5OoJ8Sg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=GdztwnyXU3Xf1V6kf1zRf8Rm9ibh2XucB9If3txfNtwinzEnv7xhDhzMgJigL9KYIJ03IyDPQPmFAY2NQ7s2nG02+Ni9zHCzsi+Yw0vCvslnpIfOWBdkUwN1bw7dtedcuz7K9zqbho6JGF7miJsEsWByGeYnlR4MvD8pPljXCWI= 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=Uo5aYEqd; arc=none smtp.client-ip=209.85.214.176 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="Uo5aYEqd" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1fb3b7d0d3aso4429115ad.2; Thu, 25 Jul 2024 03:39:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721903968; x=1722508768; 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=nL0sjHyHqIUzlhJaqk3CKYqlb9x5c6RFGvSzNLbJ438=; b=Uo5aYEqdu91tGiWYe/pturskjKsSRYnw9ZS2bKsS8HwXjj6wOgCCvKI0s9Dgmf0CDE s+ErM4C6+MYdIwvbpWmdkgOW+gTb4PCIDuUpYft7cXTLhLWZu0cb/lvBM1cSdWy9H5hg 9rzbo6/vFEluuzMgVeS1xiKq+0ZjR2XwyKkICzwVMfKj4qc+VIQu9Z+GaOze3N0roumL 5BrpZ1EKspeuwtB5j0oCyY8BvlE7x9NGqXkMGbvZIIjG6KEPN1eXfV6qyAkwqz0YzwiZ uYqDk7NvtiKhAkLadpeUt1QvaW6Uz8RZD0V2OAdMNQ/q5o71EzkZdDqJiLSxgiO/SRsB mQqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721903968; x=1722508768; 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=nL0sjHyHqIUzlhJaqk3CKYqlb9x5c6RFGvSzNLbJ438=; b=orKApl5Y/QteUOoAV2Y0c08HgsGD6RCkc2ZlBRuTEVHjICJu1uNKCF40LEm/HDTfyJ F0Ugrl9v9LY1IIkzvAlnzPjR5uUoi8TfomWEjv1iBN46cSREc9oe7EkPENruoPegTvyD 7SnZub3K0cp+thlacrje7MnhGnF5+JDDgMIy5oie2l3E81p7Opno8ncSVFQgePvojw9G rAxGtRw2/FlXhtopHfLs9wP2/oWbsmwSnihK3BowiESm/9TwRDqa1IwvNksxD7sIb8Vn HS/vrVus40i7N/XkBmivp8pVbzQIBoUVQya4QkYssXRXJ8OYMUeNbkdB6EDHj2pEA+8B 1HAA== X-Forwarded-Encrypted: i=1; AJvYcCX98N3Bg6ua7ADTwLVC6hSMCI8WbsuwljV67H9uXQKegBhdjp6AS86M17uujWPg9UBx6RDLemnnSkTneAb5yIsg80nRuFVg9ajmGtL/5VuXqtKKsdRLk8WXoiNHJvsXOmgU1jTvNR3U X-Gm-Message-State: AOJu0YxJg9aay9AulHgpIVRCYUisKrGNe/Cvh3ihOBkLd0SasC7v2fh0 p/lILbh6ZdrXmOk+bWv4yuy39Ee0ZvGE6id4qSeTo8fz5Qdo4Ou4cakKuONx X-Google-Smtp-Source: AGHT+IHOuWQPI4ziMbe1Qd8cyoyl2rI6CGk7S+SEEfxlimmcwkOKjax3YOSjrNCYy9tu0W+ThQHmyw== X-Received: by 2002:a17:902:dace:b0:1fb:1cc3:646d with SMTP id d9443c01a7336-1fed9284dbcmr14989155ad.29.1721903968280; Thu, 25 Jul 2024 03:39:28 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f78491sm10991075ad.244.2024.07.25.03.39.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 03:39:28 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v1 5/8] selftests/bpf: Fix order-of-include compile errors in lwt_reroute.c Date: Thu, 25 Jul 2024 03:35:57 -0700 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tony Ambardar Fix redefinition errors seen compiling lwt_reroute.c for mips64el/musl-libc by adjusting the order of includes in lwt_helpers.h. The ordering required is: --> (from "test_progs.h") --> . Because of the complexity and large number of includes, ordering appears to be fragile however. Previously, with "test_progs.h" at the end of this sequence, compiling with GCC 12.3 for mips64el/musl-libc yields errors: In file included from .../include/arpa/inet.h:9, from ./test_progs.h:18, from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:11, from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52: .../include/netinet/in.h:23:8: error: redefinition of 'struct in6_addr' 23 | struct in6_addr { | ^~~~~~~~ In file included from .../include/linux/icmp.h:24, from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:9: .../include/linux/in6.h:33:8: note: originally defined here 33 | struct in6_addr { | ^~~~~~~~ .../include/netinet/in.h:34:8: error: redefinition of 'struct sockaddr_in6' 34 | struct sockaddr_in6 { | ^~~~~~~~~~~~ .../include/linux/in6.h:50:8: note: originally defined here 50 | struct sockaddr_in6 { | ^~~~~~~~~~~~ .../include/netinet/in.h:42:8: error: redefinition of 'struct ipv6_mreq' 42 | struct ipv6_mreq { | ^~~~~~~~~ .../include/linux/in6.h:60:8: note: originally defined here 60 | struct ipv6_mreq { | ^~~~~~~~~ Similarly, with "test_progs.h" at the beginning of this sequence, compiling with GCC 12.3 for x86_64 using glibc would fail like this: In file included from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:8, from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52: /usr/include/linux/if.h:83:9: error: redeclaration of enumerator ‘IFF_UP’ 83 | IFF_UP = 1<<0, /* sysfs */ | ^~~~~~ /usr/include/net/if.h:44:5: note: previous definition of ‘IFF_UP’ with type ‘enum ’ 44 | IFF_UP = 0x1, /* Interface is up. */ | ^~~~~~ /usr/include/linux/if.h:84:9: error: redeclaration of enumerator ‘IFF_BROADCAST’ 84 | IFF_BROADCAST = 1<<1, /* __volatile__ */ | ^~~~~~~~~~~~~ /usr/include/net/if.h:46:5: note: previous definition of ‘IFF_BROADCAST’ with type ‘enum ’ 46 | IFF_BROADCAST = 0x2, /* Broadcast address valid. */ | ^~~~~~~~~~~~~ ... In file included from /usr/include/linux/icmp.h:23, from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:10, from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52: /usr/include/linux/if.h:194:8: error: redefinition of ‘struct ifmap’ 194 | struct ifmap { | ^~~~~ In file included from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:8, from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52: /usr/include/net/if.h:111:8: note: originally defined here 111 | struct ifmap | ^~~~~ In file included from /usr/include/linux/icmp.h:23, from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:10, from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52: /usr/include/linux/if.h:232:8: error: redefinition of ‘struct ifreq’ 232 | struct ifreq { | ^~~~~ In file included from tools/testing/selftests/bpf/prog_tests/lwt_helpers.h:8, from tools/testing/selftests/bpf/prog_tests/lwt_reroute.c:52: /usr/include/net/if.h:126:8: note: originally defined here 126 | struct ifreq | ^~~~~ Fixes: 43a7c3ef8a15 ("selftests/bpf: Add lwt_xmit tests for BPF_REDIRECT") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/lwt_helpers.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h b/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h index fb1eb8c67361..8e5e28af03c5 100644 --- a/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h +++ b/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h @@ -6,10 +6,9 @@ #include #include #include +#include "test_progs.h" /* between and or errors */ #include -#include "test_progs.h" - #define log_err(MSG, ...) \ fprintf(stderr, "(%s:%d: errno: %s) " MSG "\n", \ __FILE__, __LINE__, strerror(errno), ##__VA_ARGS__) From patchwork Thu Jul 25 10:35:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 814494 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 49BEF198E80; Thu, 25 Jul 2024 10:39:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903973; cv=none; b=gBbaDvNfDqoa3cwnAmXoPUnW4B3s6b3ExBxIBgSlgigYO3tj9moShqFQRPXHG3pydfZPpu+Z7hBb2U8vQjzKv5SObRN4pWRGVN6UQl8V879o0flkXzALdmxNc3lKXR2Cn4sQsSpem7ncwUjBQ4onMsba4NfBPgaXOoZeQWFo7kI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903973; c=relaxed/simple; bh=ufi1u+2GjL41iAT6/Y6az0ws4bZBF2sCFl2jBCNqkiI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZNBTdboTjqbxkT3BBh30JikswjjCh8XaZpO8VZjRiCCWy+UlFCq2k7aSIE6sVzuZgPqUjFPNt7zwFdwMMuLrbmVZGOktlSnWt3+uhb4NjlMEge8o4TqSmbjvtYJ7xp2nICBTToZdEWOwli4svOBCy1nEacnYkgboX4tkua3qg/Q= 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=P2YTQ3RB; arc=none smtp.client-ip=209.85.210.180 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="P2YTQ3RB" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-70eae5896bcso371729b3a.2; Thu, 25 Jul 2024 03:39:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721903971; x=1722508771; 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=yHKVyWTDcnB+HXRDPNPGBu8CijBpCmOJA9/1QhMQ58E=; b=P2YTQ3RByoKr4kdNVEITItYkNvzY11eHbr8EhrxgxL0hGnytnqpJkVaBpepJoLJ3DQ bOUuKMP83IQ8AcsQ5NkogrEv5u3OYloyb+tuw08qzPthU9jJHe5poPF3OZgl9pWFENNf 9IIi4sKM8ggVmHxRQ+gySdNEQ1J6X2Sn4123f/KBQB7oyZRTnFV3yMzPAGDAAGfnlfrX YgI1pHPHaVx1A/zYdwXLqX6rzw4mJXnvhmEzDR4nfDeEyM+gD8EVvrlyhayguxQEhMlz /CudYDE9xtuP4Wm1UiaDy35XtQN2m6JhcYZuYA0tBtW9n4sv77qzorEYGmTqNlPGLLoC OkzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721903971; x=1722508771; 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=yHKVyWTDcnB+HXRDPNPGBu8CijBpCmOJA9/1QhMQ58E=; b=hpcgWrBLZgUrhp3yuXPUPuDgA4BVOTPGvSmsWGVwtcJAWDb8gd/0q/WKqm1ZBCGj7L S/gI35ZoKtJbcf8uQ8DLjcJkNv3dyT7yTcOFcbxne8+VcXzTj39qXO7vbr7x+4NGh30k DaujsJFTqJFMFyzGqxeeqzgkmkL1HzOYzezdfyZuoKGMl78pZjRvKAOIszry0ZcZ8ZPJ VKGvZZFHMlurKcPiMvYcxcq57Z7f6O0JZzHmH3vg7dj1q4qmHbWR6e+BRqt3zQ98QHSE HCVvDVQe5zOj9IGtf0/j8gbmfN4vn78K7LWnCm/DMDptanTN9WdMdrCNTZKuWw9Itf9W kpTw== X-Forwarded-Encrypted: i=1; AJvYcCUnxpUFITFavSXzlrjye29RrVyrPBX8esGYZEZJrjiQqOpn0OSuRK3TnUhbCbSvb+4S6Kjky+1W/iM1qQ7oM9Kk7f7tDf3pJMS4UaTORXhTlIJWKA/ryGMWYNTDAE0zv/zDsW1t07o0 X-Gm-Message-State: AOJu0YxqU2RHXpGHA5KlH0Fx6jceyEp6vAL3wY4DLGGFlxQwgvKygX7b xc6OI7qHhzDXLrAVndOPDWjuw2J0MCDRJR9EinV+INyijcUA8v2877Z74rhD X-Google-Smtp-Source: AGHT+IH5l0RpFxREWyJ/JFlGvGcl8GjgZ0eumXvnjpC7zYH7OPJua00045dwkDPLHbVMRNe1OH/3Aw== X-Received: by 2002:a05:6a20:12d3:b0:1bd:18ee:f145 with SMTP id adf61e73a8af0-1c472803abdmr3462337637.1.1721903971327; Thu, 25 Jul 2024 03:39:31 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f78491sm10991075ad.244.2024.07.25.03.39.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 03:39:31 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v1 6/8] selftests/bpf: Fix compile if backtrace support missing in libc Date: Thu, 25 Jul 2024 03:35:58 -0700 Message-Id: <472c94bd42cda20154a26ef384b73488abf026c0.1721903630.git.tony.ambardar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tony Ambardar Use backtrace functions only with glibc and otherwise provide stubs in test_progs.c. This avoids compile errors (e.g. with musl libc) like: test_progs.c:13:10: fatal error: execinfo.h: No such file or directory 13 | #include /* backtrace */ | ^~~~~~~~~~~~ test_progs.c: In function 'crash_handler': test_progs.c:1034:14: error: implicit declaration of function 'backtrace' [-Werror=implicit-function-declaration] 1034 | sz = backtrace(bt, ARRAY_SIZE(bt)); | ^~~~~~~~~ test_progs.c:1045:9: error: implicit declaration of function 'backtrace_symbols_fd' [-Werror=implicit-function-declaration] 1045 | backtrace_symbols_fd(bt, sz, STDERR_FILENO); | ^~~~~~~~~~~~~~~~~~~~ Fixes: 9fb156bb82a3 ("selftests/bpf: Print backtrace on SIGSEGV in test_progs") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_progs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index 60c5ec0f6abf..f6cfc6a8e8f0 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -10,7 +10,6 @@ #include #include #include -#include /* backtrace */ #include /* get_nprocs */ #include #include @@ -19,6 +18,14 @@ #include #include "json_writer.h" +#ifdef __GLIBC__ +#include /* backtrace */ +#else +#define backtrace(...) (0) +#define backtrace_symbols_fd(bt, sz, fd) \ + dprintf(fd, "\n", bt, sz) +#endif + static bool verbose(void) { return env.verbosity > VERBOSE_NONE; From patchwork Thu Jul 25 10:35:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 814673 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 9D0F71990A7; Thu, 25 Jul 2024 10:39:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903978; cv=none; b=QjioE/mOOk7RSWT0Al0J1Yc5DKf6Hyu8Xe7Y57RJy1Y1mOMYDvFW1s9mgrvr90zw4PhVGqhxxb+0wJhP1+ae6MvWOO3jzpPqCx6QlcYpOmp8uBsXoydnnBGwslLy83O+xUXxSdsfLKT/Om9wzDwBC/jzU6HAtOLtq+5oVopvul0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903978; c=relaxed/simple; bh=GZ5RRY21h24jL/MH55jDljpE7BmhCJG7SyVeynN+I+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dcpziIAAnrNsLMh9/0+/o6pYo8DOemGcw7ztrSwwZ95tco9aT9NNKlxpQzMPAGsWYqaqcNdNvuIPEktkq6h9oPh8t/RS4UyUr8r3RH1htFf7LVHUnq+aehW3GEqh0MYQAydizGN/xQ8L8+6DOeB0lQcGiBmytNzD7GchH287R9I= 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=f1dESBVT; arc=none smtp.client-ip=209.85.214.181 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="f1dESBVT" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fd78c165eeso6672315ad.2; Thu, 25 Jul 2024 03:39:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721903976; x=1722508776; 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=Z4ccqQjN7NhIQMSexCsKHuErOhtfNopH+5UHx/am59M=; b=f1dESBVTL0SWUn9fswlnmuylzLK2ozlFh+jebnsK1Nf+wKx8LqHF3zVrFClgoYNZLn YuAYRVAgcbzNYF5cdrfzXjlrYBqLx8tJvti9i8MwXI1vbHDdW7erDMOfaqP4qLkofC0Q CuDhpL/8T0u5iwW79dcoY6ya2PvdlNzMXnuqH2tqM4/Fbp3bH6SVtT0PJTmQCkPrDz4F nVflU0NjHMqs+UjGAn7Z9k0XjCueWSRVNi9ZtTwnquL2r+1ZbJ1GEL95TzlUzIsCZUPU FiPtxpBRl3CzUu0soq1JeiSOfwr/PmLQuFJLVvIAOovSBLxVddaQ6T3P7zqdJbwkabYF W6fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721903976; x=1722508776; 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=Z4ccqQjN7NhIQMSexCsKHuErOhtfNopH+5UHx/am59M=; b=peS2b5JlGT14u4QpowWuABHnERUKZnO1Z8zEy1/1Kg9E3r5HxkmtF6AU9fDvCwoOct ib+5+TpWMm9pHUnhJRfk3AnbZGu1yLZLza9IbxPfH+8xEeEmlYjH/NQwHaSgiheEBZWm yCR7bdTik/+SGj3atTl/lzopFkXVPUojOS4JxKq+Dm2IYVoKG38hJUe9DI1f32pZaaxD Licn1mtXNTkhv+G+iAYy5lpem2GCDc7o95sAqeew6aztYG7SoAUkFJw706q7nN+fKzI4 tbppdmkfoRdJIwxYZQ8nHN4s9FqiH72hhNHfjiaTR1YzaPylIbRjw5UDwB0RtzI+NKOw Ueag== X-Forwarded-Encrypted: i=1; AJvYcCUwYWazY43p2cOUNz5sO6jamWi8UlJ+L2+kxLHWeufbvhPvEnNwvAIN2p2f1AIXalmKAHEyndFBnkSL4U34U5Y5hCj5AVWpOh5F5cLOa2E7shQ7yhjOYkXlR69PBKQQ3lVkYG4Tzgzh X-Gm-Message-State: AOJu0YyXEs6pz85cyU6wJpJb5J5P/GVVLtoa3fq9AmfBgaxF9JgYlDsI mWIRhoi3ssZ8zBZrjJ63n12MgaeW1DU89kMduscDKlwseVMoz2u42jvkLO0g X-Google-Smtp-Source: AGHT+IHlJ6dcJBHqoftYkUAqPskxOGx1GUaYoF3yx4XSuHLU/eCcWaGWQJAko0Oi9DsIMm2rcE81cw== X-Received: by 2002:a17:902:e84f:b0:1fd:8c25:4145 with SMTP id d9443c01a7336-1fed91d95acmr18470625ad.17.1721903975722; Thu, 25 Jul 2024 03:39:35 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f78491sm10991075ad.244.2024.07.25.03.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 03:39:35 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v1 7/8] selftests/bpf: Fix using stdout, stderr as struct field names Date: Thu, 25 Jul 2024 03:35:59 -0700 Message-Id: <847a5b798f24e81b9dec4e8d9eb3eb1e602a909e.1721903630.git.tony.ambardar@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tony Ambardar Typically stdin, stdout, stderr are treated as reserved identifiers under ISO/ANSI C, and a libc implementation is free to define these as macros. This is the case in musl libc and results in compile errors when these names are reused as struct fields, as with 'struct test_env' and related usage in test_progs.[ch] and reg_bounds.c. Rename the fields to _stdout and _stderr to avoid many errors seen building against musl, e.g.: In file included from test_progs.h:6, from test_progs.c:5: test_progs.c: In function 'print_test_result': test_progs.c:237:21: error: expected identifier before '(' token 237 | fprintf(env.stdout, "#%-*d %s:", TEST_NUM_WIDTH, test->test_num, test->test_name); | ^~~~~~ test_progs.c:237:9: error: too few arguments to function 'fprintf' 237 | fprintf(env.stdout, "#%-*d %s:", TEST_NUM_WIDTH, test->test_num, test->test_name); | ^~~~~~~ Signed-off-by: Tony Ambardar --- .../selftests/bpf/prog_tests/reg_bounds.c | 2 +- tools/testing/selftests/bpf/test_progs.c | 66 +++++++++---------- tools/testing/selftests/bpf/test_progs.h | 8 +-- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/reg_bounds.c b/tools/testing/selftests/bpf/prog_tests/reg_bounds.c index 0da4225749bd..ff4ebc9eaf3f 100644 --- a/tools/testing/selftests/bpf/prog_tests/reg_bounds.c +++ b/tools/testing/selftests/bpf/prog_tests/reg_bounds.c @@ -1487,7 +1487,7 @@ static int verify_case_opt(struct ctx *ctx, enum num_t init_t, enum num_t cond_t u64 elapsed_ns = get_time_ns() - ctx->start_ns; double remain_ns = elapsed_ns / progress * (1 - progress); - fprintf(env.stderr, "PROGRESS (%s): %d/%d (%.2lf%%), " + fprintf(env._stderr, "PROGRESS (%s): %d/%d (%.2lf%%), " "elapsed %llu mins (%.2lf hrs), " "ETA %.0lf mins (%.2lf hrs)\n", ctx->progress_ctx, diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index f6cfc6a8e8f0..091b49bf671a 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c @@ -44,15 +44,15 @@ static void stdio_hijack_init(char **log_buf, size_t *log_cnt) stdout = open_memstream(log_buf, log_cnt); if (!stdout) { - stdout = env.stdout; + stdout = env._stdout; perror("open_memstream"); return; } if (env.subtest_state) - env.subtest_state->stdout = stdout; + env.subtest_state->_stdout = stdout; else - env.test_state->stdout = stdout; + env.test_state->_stdout = stdout; stderr = stdout; #endif @@ -66,8 +66,8 @@ static void stdio_hijack(char **log_buf, size_t *log_cnt) return; } - env.stdout = stdout; - env.stderr = stderr; + env._stdout = stdout; + env._stderr = stderr; stdio_hijack_init(log_buf, log_cnt); #endif @@ -84,13 +84,13 @@ static void stdio_restore_cleanup(void) fflush(stdout); if (env.subtest_state) { - fclose(env.subtest_state->stdout); - env.subtest_state->stdout = NULL; - stdout = env.test_state->stdout; - stderr = env.test_state->stdout; + fclose(env.subtest_state->_stdout); + env.subtest_state->_stdout = NULL; + stdout = env.test_state->_stdout; + stderr = env.test_state->_stdout; } else { - fclose(env.test_state->stdout); - env.test_state->stdout = NULL; + fclose(env.test_state->_stdout); + env.test_state->_stdout = NULL; } #endif } @@ -103,13 +103,13 @@ static void stdio_restore(void) return; } - if (stdout == env.stdout) + if (stdout == env._stdout) return; stdio_restore_cleanup(); - stdout = env.stdout; - stderr = env.stderr; + stdout = env._stdout; + stderr = env._stderr; #endif } @@ -237,25 +237,25 @@ static void print_test_result(const struct prog_test_def *test, const struct tes int skipped_cnt = test_state->skip_cnt; int subtests_cnt = test_state->subtest_num; - fprintf(env.stdout, "#%-*d %s:", TEST_NUM_WIDTH, test->test_num, test->test_name); + fprintf(env._stdout, "#%-*d %s:", TEST_NUM_WIDTH, test->test_num, test->test_name); if (test_state->error_cnt) - fprintf(env.stdout, "FAIL"); + fprintf(env._stdout, "FAIL"); else if (!skipped_cnt) - fprintf(env.stdout, "OK"); + fprintf(env._stdout, "OK"); else if (skipped_cnt == subtests_cnt || !subtests_cnt) - fprintf(env.stdout, "SKIP"); + fprintf(env._stdout, "SKIP"); else - fprintf(env.stdout, "OK (SKIP: %d/%d)", skipped_cnt, subtests_cnt); + fprintf(env._stdout, "OK (SKIP: %d/%d)", skipped_cnt, subtests_cnt); - fprintf(env.stdout, "\n"); + fprintf(env._stdout, "\n"); } static void print_test_log(char *log_buf, size_t log_cnt) { log_buf[log_cnt] = '\0'; - fprintf(env.stdout, "%s", log_buf); + fprintf(env._stdout, "%s", log_buf); if (log_buf[log_cnt - 1] != '\n') - fprintf(env.stdout, "\n"); + fprintf(env._stdout, "\n"); } static void print_subtest_name(int test_num, int subtest_num, @@ -266,14 +266,14 @@ static void print_subtest_name(int test_num, int subtest_num, snprintf(test_num_str, sizeof(test_num_str), "%d/%d", test_num, subtest_num); - fprintf(env.stdout, "#%-*s %s/%s", + fprintf(env._stdout, "#%-*s %s/%s", TEST_NUM_WIDTH, test_num_str, test_name, subtest_name); if (result) - fprintf(env.stdout, ":%s", result); + fprintf(env._stdout, ":%s", result); - fprintf(env.stdout, "\n"); + fprintf(env._stdout, "\n"); } static void jsonw_write_log_message(json_writer_t *w, char *log_buf, size_t log_cnt) @@ -458,7 +458,7 @@ bool test__start_subtest(const char *subtest_name) memset(subtest_state, 0, sub_state_size); if (!subtest_name || !subtest_name[0]) { - fprintf(env.stderr, + fprintf(env._stderr, "Subtest #%d didn't provide sub-test name!\n", state->subtest_num); return false; @@ -466,7 +466,7 @@ bool test__start_subtest(const char *subtest_name) subtest_state->name = strdup(subtest_name); if (!subtest_state->name) { - fprintf(env.stderr, + fprintf(env._stderr, "Subtest #%d: failed to copy subtest name!\n", state->subtest_num); return false; @@ -1036,7 +1036,7 @@ void crash_handler(int signum) sz = backtrace(bt, ARRAY_SIZE(bt)); - if (env.stdout) + if (env._stdout) stdio_restore(); if (env.test) { env.test_state->error_cnt++; @@ -1352,7 +1352,7 @@ static void calculate_summary_and_print_errors(struct test_env *env) if (env->json) { w = jsonw_new(env->json); if (!w) - fprintf(env->stderr, "Failed to create new JSON stream."); + fprintf(env->_stderr, "Failed to create new JSON stream."); } if (w) { @@ -1701,8 +1701,8 @@ int main(int argc, char **argv) return -1; } - env.stdout = stdout; - env.stderr = stderr; + env._stdout = stdout; + env._stderr = stderr; env.has_testmod = true; if (!env.list_test_names) { @@ -1710,7 +1710,7 @@ int main(int argc, char **argv) unload_bpf_testmod(verbose()); if (load_bpf_testmod(verbose())) { - fprintf(env.stderr, "WARNING! Selftests relying on bpf_testmod.ko will be skipped.\n"); + fprintf(env._stderr, "WARNING! Selftests relying on bpf_testmod.ko will be skipped.\n"); env.has_testmod = false; } } @@ -1788,7 +1788,7 @@ int main(int argc, char **argv) } if (env.list_test_names) { - fprintf(env.stdout, "%s\n", test->test_name); + fprintf(env._stdout, "%s\n", test->test_name); env.succ_cnt++; continue; } diff --git a/tools/testing/selftests/bpf/test_progs.h b/tools/testing/selftests/bpf/test_progs.h index b1e949fb16cf..f42f1ae59c6e 100644 --- a/tools/testing/selftests/bpf/test_progs.h +++ b/tools/testing/selftests/bpf/test_progs.h @@ -75,7 +75,7 @@ struct subtest_state { bool skipped; bool filtered; - FILE *stdout; + FILE *_stdout; }; struct test_state { @@ -92,7 +92,7 @@ struct test_state { size_t log_cnt; char *log_buf; - FILE *stdout; + FILE *_stdout; }; struct test_env { @@ -111,8 +111,8 @@ struct test_env { struct test_state *test_state; /* current running test state */ struct subtest_state *subtest_state; /* current running subtest state */ - FILE *stdout; - FILE *stderr; + FILE *_stdout; + FILE *_stderr; int nr_cpus; FILE *json; From patchwork Thu Jul 25 10:36:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Ambardar X-Patchwork-Id: 814493 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.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 EBC3E198E88; Thu, 25 Jul 2024 10:39:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903984; cv=none; b=ANJhDjkxTpc4B/VcWDF0QkSMKi6gFWRT8GyqnbAnlG+C/L217S4THdtsyPXrx7+B2mF/FTqY/q+2AQLlOUfLezNahU7ASKNN6AYmuglyHCKNbMeryKUJOtfqZiZkP9syJ8fqHyQPcRha/PWp6TBOLsDQbwWgRf4T53MQAc4cCMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721903984; c=relaxed/simple; bh=vqWRPZxXZr1VXaBlAPOEaWlSc5Dw8PsBqeRFINNfCZo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mNk3WPBIHUsdCkl5M9pkW80Ne8mQESySMD1g5Hzu8yOqA2Y0hLvSVzW8LCqKaOu2wJfDAtlBzp/nSpR7DnxVLgsOK94arcDYmQOoC3JNQ8hvWJC4PYHTwSMilwjFsvuxvkISJBw3vlnUDgWbf8GW/EdzUdPFpSXhAfceXYbmtQI= 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=U1Vr8XWE; arc=none smtp.client-ip=209.85.214.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="U1Vr8XWE" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1fc49c0aaffso5862985ad.3; Thu, 25 Jul 2024 03:39:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721903982; x=1722508782; 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=jABdSH5QlIuuR/rILejtAmyHlYiiAj61Ro1QLo3FSvI=; b=U1Vr8XWESjG1nBMQLMiVQxqo81E3b30pYB9lLHJD6nF6fUp+NO6s84yDH7T9snTV2S SDDVlib3kk6Dh4kbS0b2dLRzRbPvkN5CYeboChOMeRDBF4X/IbhwoFuk4OFL+eED/3WW XwmHX/Wik4KZJdhwSI4QFh9jI8uRafq0ttw2F0dk9gFB1h9g7T+pudbSoks9WDnJrm8D 3JcBicEDWW0TG07Vz99oeC5gFdgyJmkb1/UwmYLj5QldD3/MxthfIVDDeXS/ZnLHSnj0 lGMYlin83gvkvKN3E/9K/jf5YKg+bU+zdWM3f2OemWw7mfPwNvv+PD6O9X+hlxkfpx/5 qv9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721903982; x=1722508782; 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=jABdSH5QlIuuR/rILejtAmyHlYiiAj61Ro1QLo3FSvI=; b=hzh3p8iaensTEdxJt70ihtxSkXXTs6Foya1UiK13r4LwYVo7lIB4dux7ADUhqE4RTC IdYtvDPhSzQezWlqzzH/1y/dJ4URn/6zmC8Idb9qL0Zww/J8tbDeTRFO60ih4+C676XZ uVxx6tpiBGqQHY8m1aBFu6Y1xMboKw85XNfruqjjh09+po6I7BAKcnEWVOD5TgbS4EKK mtfuZOg4//gCjD2FTc4jWjgJRIDEhj88Zi2zXJk1cnWatlEOZ6+ZKThi9prnM+53oO5T a2y5kZpIUUWxNZn+fmsYxduE8gtcrsIot1lI+zJZCIZHnZOvMv/HQwVs6jYSNiEVbfgR CMCA== X-Forwarded-Encrypted: i=1; AJvYcCXy0XliRx1gSItH03c47j2SfZEcYN/FtuTux8YyCeZ7dlvCQGKDTVVogeDylgYiUvy+oQVLQFe/+MsNxfUnoHtVjFZwpyzwAaYi2C03oumdB3w+HHScU2eX//xpj+w9O2i7Bf2uR/zr X-Gm-Message-State: AOJu0Ywly+glrEBqgqslLgSwu5JY94mni8rpR7jdlmjklORVVPY3E62Y qUJtUT+Kni9CatkSZ3QRYFAoy5TBQxTLUrN0OJmbCeJGe6PXjnH6VBoDJm4h X-Google-Smtp-Source: AGHT+IHM/iy3oTk9jcUWwFLWMu5qhksN0SWwCn+FsQdEito6OPiJkIz7QTPIOK4gtgl94neCWiJpEg== X-Received: by 2002:a17:902:c941:b0:1fd:709a:2978 with SMTP id d9443c01a7336-1fed92753e8mr15190155ad.38.1721903981809; Thu, 25 Jul 2024 03:39:41 -0700 (PDT) Received: from localhost.localdomain (69-172-146-21.cable.teksavvy.com. [69.172.146.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fed7f78491sm10991075ad.244.2024.07.25.03.39.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jul 2024 03:39:41 -0700 (PDT) From: Tony Ambardar X-Google-Original-From: Tony Ambardar To: bpf@vger.kernel.org Cc: Tony Ambardar , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S. Miller" , Yan Zhai Subject: [PATCH bpf-next v1 8/8] selftests/bpf: Fix error compiling tc_redirect.c with musl libc Date: Thu, 25 Jul 2024 03:36:00 -0700 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Tony Ambardar Linux 5.1 implemented 64-bit time types and related syscalls to address the Y2038 problem generally across archs. Userspace handling of Y2038 varies with the libc however. While musl libc uses 64-bit time across all 32-bit and 64-bit platforms, GNU glibc uses 64-bit time on 64-bit platforms but defaults to 32-bit time on 32-bit platforms unless they "opt-in" to 64-bit time or explicitly use 64-bit syscalls and time structures. One specific area is the standard setsockopt() call, SO_TIMESTAMPNS option used for timestamping, and the related output 'struct timespec'. GNU glibc defaults as above, also exposing the SO_TIMESTAMPNS_NEW flag to explicitly use a 64-bit call and 'struct __kernel_timespec'. Since these are not exposed or needed with musl libc, their use in tc_redirect.c leads to compile errors building for mips64el/musl: tc_redirect.c: In function 'rcv_tstamp': tc_redirect.c:425:32: error: 'SO_TIMESTAMPNS_NEW' undeclared (first use in this function); did you mean 'SO_TIMESTAMPNS'? 425 | cmsg->cmsg_type == SO_TIMESTAMPNS_NEW) | ^~~~~~~~~~~~~~~~~~ | SO_TIMESTAMPNS tc_redirect.c:425:32: note: each undeclared identifier is reported only once for each function it appears in tc_redirect.c: In function 'test_inet_dtime': tc_redirect.c:491:49: error: 'SO_TIMESTAMPNS_NEW' undeclared (first use in this function); did you mean 'SO_TIMESTAMPNS'? 491 | err = setsockopt(listen_fd, SOL_SOCKET, SO_TIMESTAMPNS_NEW, | ^~~~~~~~~~~~~~~~~~ | SO_TIMESTAMPNS However, using SO_TIMESTAMPNS_NEW isn't strictly needed, nor is Y2038 being explicitly tested. The timestamp checks in tc_redirect.c are simple: the packet receive timestamp is non-zero and processed/handled in less than 5 seconds. Switch to using the standard setsockopt() call and SO_TIMESTAMPNS option to ensure compatibility across glibc and musl libc. In the worst-case, there is a 5-second window 14 years from now where tc_redirect tests may fail on 32-bit systems. However, we should reasonably expect glibc to adopt a 64-bit mandate rather than the current "opt-in" policy before the Y2038 roll-over. Fixes: ce6f6cffaeaa ("selftests/bpf: Wait for the netstamp_needed_key static key to be turned on") Fixes: c803475fd8dd ("bpf: selftests: test skb->tstamp in redirect_neigh") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/tc_redirect.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c index 327d51f59142..53b8ffc943dc 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_redirect.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_redirect.c @@ -471,7 +471,7 @@ static int set_forwarding(bool enable) static int __rcv_tstamp(int fd, const char *expected, size_t s, __u64 *tstamp) { - struct __kernel_timespec pkt_ts = {}; + struct timespec pkt_ts = {}; char ctl[CMSG_SPACE(sizeof(pkt_ts))]; struct timespec now_ts; struct msghdr msg = {}; @@ -495,7 +495,7 @@ static int __rcv_tstamp(int fd, const char *expected, size_t s, __u64 *tstamp) cmsg = CMSG_FIRSTHDR(&msg); if (cmsg && cmsg->cmsg_level == SOL_SOCKET && - cmsg->cmsg_type == SO_TIMESTAMPNS_NEW) + cmsg->cmsg_type == SO_TIMESTAMPNS) memcpy(&pkt_ts, CMSG_DATA(cmsg), sizeof(pkt_ts)); pkt_ns = pkt_ts.tv_sec * NSEC_PER_SEC + pkt_ts.tv_nsec; @@ -537,9 +537,9 @@ static int wait_netstamp_needed_key(void) if (!ASSERT_GE(srv_fd, 0, "start_server")) goto done; - err = setsockopt(srv_fd, SOL_SOCKET, SO_TIMESTAMPNS_NEW, + err = setsockopt(srv_fd, SOL_SOCKET, SO_TIMESTAMPNS, &opt, sizeof(opt)); - if (!ASSERT_OK(err, "setsockopt(SO_TIMESTAMPNS_NEW)")) + if (!ASSERT_OK(err, "setsockopt(SO_TIMESTAMPNS)")) goto done; cli_fd = connect_to_fd(srv_fd, TIMEOUT_MILLIS); @@ -621,9 +621,9 @@ static void test_inet_dtime(int family, int type, const char *addr, __u16 port) return; /* Ensure the kernel puts the (rcv) timestamp for all skb */ - err = setsockopt(listen_fd, SOL_SOCKET, SO_TIMESTAMPNS_NEW, + err = setsockopt(listen_fd, SOL_SOCKET, SO_TIMESTAMPNS, &opt, sizeof(opt)); - if (!ASSERT_OK(err, "setsockopt(SO_TIMESTAMPNS_NEW)")) + if (!ASSERT_OK(err, "setsockopt(SO_TIMESTAMPNS)")) goto done; if (type == SOCK_STREAM) {