Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp490788yba; Thu, 16 May 2019 04:23:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEAyFNdRexgJlktdfcpc4sLPCTkJ/AjtN221Lk+JgRuKx4ZpunwygYFLlQum2ho4TVmirz X-Received: by 2002:aa7:93ba:: with SMTP id x26mr53288456pff.238.1558005795455; Thu, 16 May 2019 04:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558005795; cv=none; d=google.com; s=arc-20160816; b=udL+mih3yyKQY/6eUdxpYtTa3KdDdm0FxrL/iWiM6lZn7Ba82bKCP9F0hAVAtoi4vo giECcoNkQrgITVtnkeWbzkxrSCm0jJZf8f1QfhWoKRLJuiDIiI/os4lVJqg/nWpGG+UW QfsY5DLBdtK5tZG671ycMbLEPE2Y5rlyVlIcQouns6E6UOYKLrqX2hIW02BMcOS931m8 XNlRMzRqfsEjluYuBnZHL8S9WU6V9UV2g7FAEi97Xyvka+dtRmLx3K5pVoJWnoWE3QoR 4NG9IsO/X2HFQJ+1F2K9qVDisrmd3i8T1KB5ZW+xtcB5GxVIgqpdL+7mGP3ONt0h0UtE 4bCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=63AK6u0DWnoY591pj3GOlysGkvkc1eODBEuJ/s4JVZI=; b=qeKwA1oJcUTr94vhtLh//zChFI1K34j9zEKyYWdxJGvhhhHvt4i6GhxqDlCklTaOM+ z+NvWvaRJNAZDSMj1wy6TPuMzJtU8rpMDYgXXsi+ltZix9k9T/660sZEXWLs9bCag9aA /MF8rH1TxmBiWhoDUJOSAj8tivplByp+Kuj8hbgvYh5jNiY8ZjVQQ4YzHRX9fRngMmca xSabuwBPAA8ERD+beGjUXbNwID7ZQ3gaPvuMQ3ameFErfFkNa/Vpngg36rRf9smhw2kp pybQZQu12vy9yzIav5c3q0oizgid7VEIqRDOmD/COVYCChTg1n8ybEED3EdoxTWdEAij BJ4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z5si4615986pgv.146.2019.05.16.04.23.00; Thu, 16 May 2019 04:23:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727257AbfEPLVm (ORCPT + 99 others); Thu, 16 May 2019 07:21:42 -0400 Received: from mx2.suse.de ([195.135.220.15]:33980 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726383AbfEPLVl (ORCPT ); Thu, 16 May 2019 07:21:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 43DE8AF25; Thu, 16 May 2019 11:21:39 +0000 (UTC) From: Michal Rostecki Cc: Michal Rostecki , Shuah Khan , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Jiong Wang , Mathieu Xhonneux , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, xdp-newbies@vger.kernel.org Subject: [PATCH bpf-next 1/2] selftests: bpf: Move bpf_printk to bpf_helpers.h Date: Thu, 16 May 2019 13:20:57 +0200 Message-Id: <20190516112105.12887-2-mrostecki@opensuse.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190516112105.12887-1-mrostecki@opensuse.org> References: <20190516112105.12887-1-mrostecki@opensuse.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bpf_printk is a macro which is commonly used to print out debug messages in BPF programs and it was copied in many selftests and samples. Since all of them include bpf_helpers.h, this change moves the macro there. Signed-off-by: Michal Rostecki --- tools/testing/selftests/bpf/bpf_helpers.h | 8 ++++++++ tools/testing/selftests/bpf/progs/sockmap_parse_prog.c | 7 ------- tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c | 7 ------- tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c | 7 ------- tools/testing/selftests/bpf/progs/test_lwt_seg6local.c | 7 ------- tools/testing/selftests/bpf/progs/test_xdp_noinline.c | 7 ------- tools/testing/selftests/bpf/test_sockmap_kern.h | 7 ------- 7 files changed, 8 insertions(+), 42 deletions(-) diff --git a/tools/testing/selftests/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h index 6e80b66d7fb1..f1c23fc05bce 100644 --- a/tools/testing/selftests/bpf/bpf_helpers.h +++ b/tools/testing/selftests/bpf/bpf_helpers.h @@ -8,6 +8,14 @@ */ #define SEC(NAME) __attribute__((section(NAME), used)) +/* helper macro to print out debug messages */ +#define bpf_printk(fmt, ...) \ +({ \ + char ____fmt[] = fmt; \ + bpf_trace_printk(____fmt, sizeof(____fmt), \ + ##__VA_ARGS__); \ +}) + /* helper functions called from eBPF programs written in C */ static void *(*bpf_map_lookup_elem)(void *map, const void *key) = (void *) BPF_FUNC_map_lookup_elem; diff --git a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c index 0f92858f6226..ed3e4a551c57 100644 --- a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c +++ b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c @@ -5,13 +5,6 @@ int _version SEC("version") = 1; -#define bpf_printk(fmt, ...) \ -({ \ - char ____fmt[] = fmt; \ - bpf_trace_printk(____fmt, sizeof(____fmt), \ - ##__VA_ARGS__); \ -}) - SEC("sk_skb1") int bpf_prog1(struct __sk_buff *skb) { diff --git a/tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c b/tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c index 12a7b5c82ed6..65fbfdb6cd3a 100644 --- a/tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c +++ b/tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c @@ -5,13 +5,6 @@ int _version SEC("version") = 1; -#define bpf_printk(fmt, ...) \ -({ \ - char ____fmt[] = fmt; \ - bpf_trace_printk(____fmt, sizeof(____fmt), \ - ##__VA_ARGS__); \ -}) - SEC("sk_msg1") int bpf_prog1(struct sk_msg_md *msg) { diff --git a/tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c b/tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c index 2ce7634a4012..bdc22be46f2e 100644 --- a/tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c +++ b/tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c @@ -5,13 +5,6 @@ int _version SEC("version") = 1; -#define bpf_printk(fmt, ...) \ -({ \ - char ____fmt[] = fmt; \ - bpf_trace_printk(____fmt, sizeof(____fmt), \ - ##__VA_ARGS__); \ -}) - struct bpf_map_def SEC("maps") sock_map_rx = { .type = BPF_MAP_TYPE_SOCKMAP, .key_size = sizeof(int), diff --git a/tools/testing/selftests/bpf/progs/test_lwt_seg6local.c b/tools/testing/selftests/bpf/progs/test_lwt_seg6local.c index 0575751bc1bc..7c7cb3177463 100644 --- a/tools/testing/selftests/bpf/progs/test_lwt_seg6local.c +++ b/tools/testing/selftests/bpf/progs/test_lwt_seg6local.c @@ -6,13 +6,6 @@ #include "bpf_helpers.h" #include "bpf_endian.h" -#define bpf_printk(fmt, ...) \ -({ \ - char ____fmt[] = fmt; \ - bpf_trace_printk(____fmt, sizeof(____fmt), \ - ##__VA_ARGS__); \ -}) - /* Packet parsing state machine helpers. */ #define cursor_advance(_cursor, _len) \ ({ void *_tmp = _cursor; _cursor += _len; _tmp; }) diff --git a/tools/testing/selftests/bpf/progs/test_xdp_noinline.c b/tools/testing/selftests/bpf/progs/test_xdp_noinline.c index 5e4aac74f9d0..4fe6aaad22a4 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_noinline.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_noinline.c @@ -15,13 +15,6 @@ #include #include "bpf_helpers.h" -#define bpf_printk(fmt, ...) \ -({ \ - char ____fmt[] = fmt; \ - bpf_trace_printk(____fmt, sizeof(____fmt), \ - ##__VA_ARGS__); \ -}) - static __u32 rol32(__u32 word, unsigned int shift) { return (word << shift) | (word >> ((-shift) & 31)); diff --git a/tools/testing/selftests/bpf/test_sockmap_kern.h b/tools/testing/selftests/bpf/test_sockmap_kern.h index e7639f66a941..4e7d3da21357 100644 --- a/tools/testing/selftests/bpf/test_sockmap_kern.h +++ b/tools/testing/selftests/bpf/test_sockmap_kern.h @@ -28,13 +28,6 @@ * are established and verdicts are decided. */ -#define bpf_printk(fmt, ...) \ -({ \ - char ____fmt[] = fmt; \ - bpf_trace_printk(____fmt, sizeof(____fmt), \ - ##__VA_ARGS__); \ -}) - struct bpf_map_def SEC("maps") sock_map = { .type = TEST_MAP_TYPE, .key_size = sizeof(int), -- 2.21.0