From patchwork Mon Jul 18 13:29:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pu Lehui X-Patchwork-Id: 12921234 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 62D97CCA479 for ; Mon, 18 Jul 2022 12:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234487AbiGRM7Z (ORCPT ); Mon, 18 Jul 2022 08:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234250AbiGRM7Y (ORCPT ); Mon, 18 Jul 2022 08:59:24 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A151463DF; Mon, 18 Jul 2022 05:59:22 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lmhnw1n0CzlVlh; Mon, 18 Jul 2022 20:57:40 +0800 (CST) Received: from dggpemm500019.china.huawei.com (7.185.36.180) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:20 +0800 Received: from k04.huawei.com (10.67.174.115) by dggpemm500019.china.huawei.com (7.185.36.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:20 +0800 From: Pu Lehui To: , , CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Quentin Monnet , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "Jean-Philippe Brucker" , Pu Lehui Subject: [PATCH bpf-next v2 1/5] bpf: Unify memory address casting operation style Date: Mon, 18 Jul 2022 21:29:34 +0800 Message-ID: <20220718132938.1031864-2-pulehui@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220718132938.1031864-1-pulehui@huawei.com> References: <20220718132938.1031864-1-pulehui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.115] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500019.china.huawei.com (7.185.36.180) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Memory addresses are conceptually unsigned, (unsigned long) casting makes more sense, so let's make a change for conceptual uniformity and there is no functional change. Signed-off-by: Pu Lehui Acked-by: Yonghong Song --- kernel/bpf/core.c | 2 +- kernel/bpf/helpers.c | 6 +++--- kernel/bpf/syscall.c | 2 +- kernel/bpf/verifier.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index cfb8a50a9f12..e14b399dd408 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -1954,7 +1954,7 @@ static u64 ___bpf_prog_run(u64 *regs, const struct bpf_insn *insn) CONT; \ LDX_PROBE_MEM_##SIZEOP: \ bpf_probe_read_kernel(&DST, sizeof(SIZE), \ - (const void *)(long) (SRC + insn->off)); \ + (const void *)(unsigned long) (SRC + insn->off)); \ DST = *((SIZE *)&DST); \ CONT; diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index a1c84d256f83..92c01dd007a6 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -903,7 +903,7 @@ int bpf_bprintf_prepare(char *fmt, u32 fmt_size, const u64 *raw_args, err = snprintf(tmp_buf, (tmp_buf_end - tmp_buf), "%pB", - (void *)(long)raw_args[num_spec]); + (void *)(unsigned long)raw_args[num_spec]); tmp_buf += (err + 1); } @@ -929,7 +929,7 @@ int bpf_bprintf_prepare(char *fmt, u32 fmt_size, const u64 *raw_args, goto out; } - unsafe_ptr = (char *)(long)raw_args[num_spec]; + unsafe_ptr = (char *)(unsigned long)raw_args[num_spec]; err = copy_from_kernel_nofault(cur_ip, unsafe_ptr, sizeof_cur_ip); if (err < 0) @@ -966,7 +966,7 @@ int bpf_bprintf_prepare(char *fmt, u32 fmt_size, const u64 *raw_args, goto out; } - unsafe_ptr = (char *)(long)raw_args[num_spec]; + unsafe_ptr = (char *)(unsigned long)raw_args[num_spec]; err = bpf_trace_copy_string(tmp_buf, unsafe_ptr, fmt_ptype, tmp_buf_end - tmp_buf); diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 83c7136c5788..d1380473e620 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -5108,7 +5108,7 @@ BPF_CALL_3(bpf_sys_bpf, int, cmd, union bpf_attr *, attr, u32, attr_size) bpf_prog_put(prog); return -EBUSY; } - attr->test.retval = bpf_prog_run(prog, (void *) (long) attr->test.ctx_in); + attr->test.retval = bpf_prog_run(prog, (void *) (unsigned long) attr->test.ctx_in); __bpf_prog_exit_sleepable(prog, 0 /* bpf_prog_run does runtime stats */, &run_ctx); bpf_prog_put(prog); return 0; diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index c59c3df0fea6..d91f17598833 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -4445,7 +4445,7 @@ static int bpf_map_direct_read(struct bpf_map *map, int off, int size, u64 *val) err = map->ops->map_direct_value_addr(map, &addr, off); if (err) return err; - ptr = (void *)(long)addr + off; + ptr = (void *)(unsigned long)addr + off; switch (size) { case sizeof(u8): @@ -6113,7 +6113,7 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, return err; } - str_ptr = (char *)(long)(map_addr); + str_ptr = (char *)(unsigned long)(map_addr); if (!strnchr(str_ptr + map_off, map->value_size - map_off, 0)) { verbose(env, "string is not zero-terminated\n"); return -EINVAL; @@ -7099,7 +7099,7 @@ static int check_bpf_snprintf_call(struct bpf_verifier_env *env, verbose(env, "verifier bug\n"); return -EFAULT; } - fmt = (char *)(long)fmt_addr + fmt_map_off; + fmt = (char *)(unsigned long)fmt_addr + fmt_map_off; /* We are also guaranteed that fmt+fmt_map_off is NULL terminated, we * can focus on validating the format specifiers. From patchwork Mon Jul 18 13:29:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pu Lehui X-Patchwork-Id: 12921236 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 90D78CCA485 for ; Mon, 18 Jul 2022 12:59:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234649AbiGRM7Z (ORCPT ); Mon, 18 Jul 2022 08:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234222AbiGRM7Y (ORCPT ); Mon, 18 Jul 2022 08:59:24 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A4A563C1; Mon, 18 Jul 2022 05:59:22 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lmhn86dkJzkX7K; Mon, 18 Jul 2022 20:57:00 +0800 (CST) Received: from dggpemm500019.china.huawei.com (7.185.36.180) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:20 +0800 Received: from k04.huawei.com (10.67.174.115) by dggpemm500019.china.huawei.com (7.185.36.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:20 +0800 From: Pu Lehui To: , , CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Quentin Monnet , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "Jean-Philippe Brucker" , Pu Lehui Subject: [PATCH bpf-next v2 2/5] libbpf: Unify memory address casting operation style Date: Mon, 18 Jul 2022 21:29:35 +0800 Message-ID: <20220718132938.1031864-3-pulehui@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220718132938.1031864-1-pulehui@huawei.com> References: <20220718132938.1031864-1-pulehui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.115] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500019.china.huawei.com (7.185.36.180) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Memory addresses are conceptually unsigned, (unsigned long) casting makes more sense, so let's make a change for conceptual uniformity and there is no functional change. Signed-off-by: Pu Lehui --- tools/lib/bpf/bpf_prog_linfo.c | 8 ++++---- tools/lib/bpf/btf.c | 7 ++++--- tools/lib/bpf/skel_internal.h | 4 ++-- tools/lib/bpf/usdt.c | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/lib/bpf/bpf_prog_linfo.c b/tools/lib/bpf/bpf_prog_linfo.c index 5c503096ef43..5cf41a563ef5 100644 --- a/tools/lib/bpf/bpf_prog_linfo.c +++ b/tools/lib/bpf/bpf_prog_linfo.c @@ -127,7 +127,7 @@ struct bpf_prog_linfo *bpf_prog_linfo__new(const struct bpf_prog_info *info) prog_linfo->raw_linfo = malloc(data_sz); if (!prog_linfo->raw_linfo) goto err_free; - memcpy(prog_linfo->raw_linfo, (void *)(long)info->line_info, data_sz); + memcpy(prog_linfo->raw_linfo, (void *)(unsigned long)info->line_info, data_sz); nr_jited_func = info->nr_jited_ksyms; if (!nr_jited_func || @@ -148,7 +148,7 @@ struct bpf_prog_linfo *bpf_prog_linfo__new(const struct bpf_prog_info *info) if (!prog_linfo->raw_jited_linfo) goto err_free; memcpy(prog_linfo->raw_jited_linfo, - (void *)(long)info->jited_line_info, data_sz); + (void *)(unsigned long)info->jited_line_info, data_sz); /* Number of jited_line_info per jited func */ prog_linfo->nr_jited_linfo_per_func = malloc(nr_jited_func * @@ -166,8 +166,8 @@ struct bpf_prog_linfo *bpf_prog_linfo__new(const struct bpf_prog_info *info) goto err_free; if (dissect_jited_func(prog_linfo, - (__u64 *)(long)info->jited_ksyms, - (__u32 *)(long)info->jited_func_lens)) + (__u64 *)(unsigned long)info->jited_ksyms, + (__u32 *)(unsigned long)info->jited_func_lens)) goto err_free; return prog_linfo; diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index 2d14f1a52d7a..61e2ac2b6891 100644 --- a/tools/lib/bpf/btf.c +++ b/tools/lib/bpf/btf.c @@ -1568,7 +1568,7 @@ static int btf_rewrite_str(__u32 *str_off, void *ctx) return 0; if (p->str_off_map && - hashmap__find(p->str_off_map, (void *)(long)*str_off, &mapped_off)) { + hashmap__find(p->str_off_map, (void *)(unsigned long)*str_off, &mapped_off)) { *str_off = (__u32)(long)mapped_off; return 0; } @@ -1581,7 +1581,8 @@ static int btf_rewrite_str(__u32 *str_off, void *ctx) * performing expensive string comparisons. */ if (p->str_off_map) { - err = hashmap__append(p->str_off_map, (void *)(long)*str_off, (void *)(long)off); + err = hashmap__append(p->str_off_map, (void *)(unsigned long)*str_off, + (void *)(unsigned long)off); if (err) return err; } @@ -3133,7 +3134,7 @@ static long hash_combine(long h, long value) static int btf_dedup_table_add(struct btf_dedup *d, long hash, __u32 type_id) { return hashmap__append(d->dedup_table, - (void *)hash, (void *)(long)type_id); + (void *)hash, (void *)(unsigned long)type_id); } static int btf_dedup_hypot_map_add(struct btf_dedup *d, diff --git a/tools/lib/bpf/skel_internal.h b/tools/lib/bpf/skel_internal.h index bd6f4505e7b1..e2803e7cd6d9 100644 --- a/tools/lib/bpf/skel_internal.h +++ b/tools/lib/bpf/skel_internal.h @@ -146,7 +146,7 @@ static inline void *skel_finalize_map_data(__u64 *init_val, size_t mmap_sz, int struct bpf_map *map; void *addr = NULL; - kvfree((void *) (long) *init_val); + kvfree((void *) (unsigned long) *init_val); *init_val = ~0ULL; /* At this point bpf_load_and_run() finished without error and @@ -197,7 +197,7 @@ static inline void *skel_finalize_map_data(__u64 *init_val, size_t mmap_sz, int { void *addr; - addr = mmap((void *) (long) *init_val, mmap_sz, flags, MAP_SHARED | MAP_FIXED, fd, 0); + addr = mmap((void *) (unsigned long) *init_val, mmap_sz, flags, MAP_SHARED | MAP_FIXED, fd, 0); if (addr == (void *) -1) return NULL; return addr; diff --git a/tools/lib/bpf/usdt.c b/tools/lib/bpf/usdt.c index d18e37982344..3e54b47f9e1b 100644 --- a/tools/lib/bpf/usdt.c +++ b/tools/lib/bpf/usdt.c @@ -915,7 +915,7 @@ static int allocate_spec_id(struct usdt_manager *man, struct hashmap *specs_hash *spec_id = man->free_spec_ids[man->free_spec_cnt - 1]; /* cache spec ID for current spec string for future lookups */ - err = hashmap__add(specs_hash, target->spec_str, (void *)(long)*spec_id); + err = hashmap__add(specs_hash, target->spec_str, (void *)(unsigned long)*spec_id); if (err) return err; @@ -928,7 +928,7 @@ static int allocate_spec_id(struct usdt_manager *man, struct hashmap *specs_hash *spec_id = man->next_free_spec_id; /* cache spec ID for current spec string for future lookups */ - err = hashmap__add(specs_hash, target->spec_str, (void *)(long)*spec_id); + err = hashmap__add(specs_hash, target->spec_str, (void *)(unsigned long)*spec_id); if (err) return err; From patchwork Mon Jul 18 13:29:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pu Lehui X-Patchwork-Id: 12921239 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 E9D8CCCA47F for ; Mon, 18 Jul 2022 12:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234975AbiGRM7f (ORCPT ); Mon, 18 Jul 2022 08:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234760AbiGRM70 (ORCPT ); Mon, 18 Jul 2022 08:59:26 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7440563D4; Mon, 18 Jul 2022 05:59:22 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lmhnw4tg7zlVrx; Mon, 18 Jul 2022 20:57:40 +0800 (CST) Received: from dggpemm500019.china.huawei.com (7.185.36.180) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:20 +0800 Received: from k04.huawei.com (10.67.174.115) by dggpemm500019.china.huawei.com (7.185.36.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:20 +0800 From: Pu Lehui To: , , CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Quentin Monnet , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "Jean-Philippe Brucker" , Pu Lehui Subject: [PATCH bpf-next v2 3/5] selftests: bpf: Unify memory address casting operation style Date: Mon, 18 Jul 2022 21:29:36 +0800 Message-ID: <20220718132938.1031864-4-pulehui@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220718132938.1031864-1-pulehui@huawei.com> References: <20220718132938.1031864-1-pulehui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.115] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500019.china.huawei.com (7.185.36.180) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Memory addresses are conceptually unsigned, (unsigned long) casting makes more sense, so let's make a change for conceptual uniformity and there is no functional change. Signed-off-by: Pu Lehui Acked-by: Yonghong Song --- tools/testing/selftests/bpf/bench.c | 4 +-- .../selftests/bpf/prog_tests/bpf_obj_id.c | 10 +++---- .../selftests/bpf/prog_tests/bpf_tcp_ca.c | 2 +- tools/testing/selftests/bpf/prog_tests/btf.c | 4 +-- .../bpf/prog_tests/core_read_macros.c | 8 +++--- .../selftests/bpf/prog_tests/hashmap.c | 8 +++--- .../selftests/bpf/prog_tests/ringbuf.c | 4 +-- .../selftests/bpf/prog_tests/ringbuf_multi.c | 4 +-- .../bpf/prog_tests/sockopt_inherit.c | 2 +- tools/testing/selftests/bpf/progs/bpf_flow.c | 10 +++---- tools/testing/selftests/bpf/progs/core_kern.c | 4 +-- .../selftests/bpf/progs/fexit_bpf2bpf.c | 8 +++--- tools/testing/selftests/bpf/progs/pyperf.h | 4 +-- .../testing/selftests/bpf/progs/skb_pkt_end.c | 4 +-- .../selftests/bpf/progs/sockmap_parse_prog.c | 8 +++--- .../bpf/progs/sockmap_verdict_prog.c | 4 +-- .../bpf/progs/test_btf_skc_cls_ingress.c | 8 +++--- .../selftests/bpf/progs/test_check_mtu.c | 16 +++++------ .../selftests/bpf/progs/test_cls_redirect.c | 8 +++--- tools/testing/selftests/bpf/progs/test_l4lb.c | 6 ++-- .../selftests/bpf/progs/test_l4lb_noinline.c | 6 ++-- .../selftests/bpf/progs/test_lwt_seg6local.c | 10 +++---- .../bpf/progs/test_migrate_reuseport.c | 4 +-- .../selftests/bpf/progs/test_pkt_access.c | 8 +++--- .../bpf/progs/test_queue_stack_map.h | 4 +-- .../selftests/bpf/progs/test_seg6_loop.c | 8 +++--- .../selftests/bpf/progs/test_sk_assign.c | 8 +++--- .../selftests/bpf/progs/test_sk_lookup_kern.c | 4 +-- .../selftests/bpf/progs/test_sockmap_kern.h | 12 ++++---- .../selftests/bpf/progs/test_tc_dtime.c | 2 +- .../testing/selftests/bpf/progs/test_tc_edt.c | 6 ++-- .../selftests/bpf/progs/test_tc_neigh.c | 2 +- .../selftests/bpf/progs/test_tc_neigh_fib.c | 2 +- .../bpf/progs/test_tcp_check_syncookie_kern.c | 8 +++--- .../selftests/bpf/progs/test_tunnel_kern.c | 12 ++++---- .../selftests/bpf/progs/test_verif_scale1.c | 4 +-- .../selftests/bpf/progs/test_verif_scale2.c | 4 +-- .../selftests/bpf/progs/test_verif_scale3.c | 4 +-- tools/testing/selftests/bpf/progs/test_xdp.c | 20 ++++++------- .../bpf/progs/test_xdp_adjust_tail_grow.c | 4 +-- .../bpf/progs/test_xdp_adjust_tail_shrink.c | 4 +-- .../selftests/bpf/progs/test_xdp_bpf2bpf.c | 4 +-- .../bpf/progs/test_xdp_context_test_run.c | 4 +-- .../bpf/progs/test_xdp_devmap_helpers.c | 4 +-- .../bpf/progs/test_xdp_do_redirect.c | 14 +++++----- .../selftests/bpf/progs/test_xdp_loop.c | 20 ++++++------- .../selftests/bpf/progs/test_xdp_noinline.c | 28 +++++++++---------- .../bpf/progs/test_xdp_update_frags.c | 4 +-- .../selftests/bpf/progs/test_xdp_vlan.c | 16 +++++------ .../bpf/progs/test_xdp_with_devmap_helpers.c | 4 +-- .../bpf/progs/xdp_redirect_multi_kern.c | 8 +++--- .../selftests/bpf/progs/xdp_synproxy_kern.c | 16 +++++------ .../testing/selftests/bpf/progs/xdping_kern.c | 12 ++++---- tools/testing/selftests/bpf/progs/xdpwall.c | 4 +-- 54 files changed, 200 insertions(+), 200 deletions(-) diff --git a/tools/testing/selftests/bpf/bench.c b/tools/testing/selftests/bpf/bench.c index c1f20a147462..d896521e1141 100644 --- a/tools/testing/selftests/bpf/bench.c +++ b/tools/testing/selftests/bpf/bench.c @@ -567,7 +567,7 @@ static void setup_benchmark() for (i = 0; i < env.consumer_cnt; i++) { err = pthread_create(&state.consumers[i], NULL, - bench->consumer_thread, (void *)(long)i); + bench->consumer_thread, (void *)(unsigned long)i); if (err) { fprintf(stderr, "failed to create consumer thread #%d: %d\n", i, -errno); @@ -586,7 +586,7 @@ static void setup_benchmark() for (i = 0; i < env.producer_cnt; i++) { err = pthread_create(&state.producers[i], NULL, - bench->producer_thread, (void *)(long)i); + bench->producer_thread, (void *)(unsigned long)i); if (err) { fprintf(stderr, "failed to create producer thread #%d: %d\n", i, -errno); diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c b/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c index dbe56fa8582d..dbf526242ae4 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_obj_id.c @@ -133,7 +133,7 @@ void serial_test_bpf_obj_id(void) load_time < now - 60 || load_time > now + 60 || prog_infos[i].created_by_uid != my_uid || prog_infos[i].nr_map_ids != 1 || - *(int *)(long)prog_infos[i].map_ids != map_infos[i].id || + *(int *)(unsigned long)prog_infos[i].map_ids != map_infos[i].id || strcmp((char *)prog_infos[i].name, expected_prog_name), "get-prog-info(fd)", "err %d errno %d i %d type %d(%d) info_len %u(%zu) " @@ -152,7 +152,7 @@ void serial_test_bpf_obj_id(void) load_time, now, prog_infos[i].created_by_uid, my_uid, prog_infos[i].nr_map_ids, 1, - *(int *)(long)prog_infos[i].map_ids, map_infos[i].id, + *(int *)(unsigned long)prog_infos[i].map_ids, map_infos[i].id, prog_infos[i].name, expected_prog_name)) goto done; @@ -225,7 +225,7 @@ void serial_test_bpf_obj_id(void) bzero(&prog_info, sizeof(prog_info)); info_len = sizeof(prog_info); - saved_map_id = *(int *)((long)prog_infos[i].map_ids); + saved_map_id = *(int *)((unsigned long)prog_infos[i].map_ids); prog_info.map_ids = prog_infos[i].map_ids; prog_info.nr_map_ids = 2; err = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &info_len); @@ -233,12 +233,12 @@ void serial_test_bpf_obj_id(void) prog_infos[i].xlated_prog_insns = 0; CHECK(err || info_len != sizeof(struct bpf_prog_info) || memcmp(&prog_info, &prog_infos[i], info_len) || - *(int *)(long)prog_info.map_ids != saved_map_id, + *(int *)(unsigned long)prog_info.map_ids != saved_map_id, "get-prog-info(next_id->fd)", "err %d errno %d info_len %u(%zu) memcmp %d map_id %u(%u)\n", err, errno, info_len, sizeof(struct bpf_prog_info), memcmp(&prog_info, &prog_infos[i], info_len), - *(int *)(long)prog_info.map_ids, saved_map_id); + *(int *)(unsigned long)prog_info.map_ids, saved_map_id); close(prog_fd); } CHECK(nr_id_found != nr_iters, diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c index 2959a52ced06..ba0f3f7381be 100644 --- a/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c +++ b/tools/testing/selftests/bpf/prog_tests/bpf_tcp_ca.c @@ -140,7 +140,7 @@ static void do_test(const char *tcp_ca, const struct bpf_map *sk_stg_map) goto done; } - err = pthread_create(&srv_thread, NULL, server, (void *)(long)lfd); + err = pthread_create(&srv_thread, NULL, server, (void *)(unsigned long)lfd); if (CHECK(err != 0, "pthread_create", "err:%d errno:%d\n", err, errno)) goto done; diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c index 941b0100bafa..e852a9df779d 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf.c +++ b/tools/testing/selftests/bpf/prog_tests/btf.c @@ -6564,8 +6564,8 @@ static int test_get_linfo(const struct prog_info_raw_test *test, info.nr_jited_line_info, jited_cnt, info.line_info_rec_size, rec_size, info.jited_line_info_rec_size, jited_rec_size, - (void *)(long)info.line_info, - (void *)(long)info.jited_line_info)) { + (void *)(unsigned long)info.line_info, + (void *)(unsigned long)info.jited_line_info)) { err = -1; goto done; } diff --git a/tools/testing/selftests/bpf/prog_tests/core_read_macros.c b/tools/testing/selftests/bpf/prog_tests/core_read_macros.c index 96f5cf3c6fa2..1f51c00e8931 100644 --- a/tools/testing/selftests/bpf/prog_tests/core_read_macros.c +++ b/tools/testing/selftests/bpf/prog_tests/core_read_macros.c @@ -35,15 +35,15 @@ void test_core_read_macros(void) bss->my_pid = getpid(); /* next pointers have to be set from the kernel side */ - bss->k_probe_in.func = (void *)(long)0x1234; - bss->k_core_in.func = (void *)(long)0xabcd; + bss->k_probe_in.func = (void *)(unsigned long)0x1234; + bss->k_core_in.func = (void *)(unsigned long)0xabcd; u_probe_in.next = &u_probe_in; - u_probe_in.func = (void *)(long)0x5678; + u_probe_in.func = (void *)(unsigned long)0x5678; bss->u_probe_in = &u_probe_in; u_core_in.next = &u_core_in; - u_core_in.func = (void *)(long)0xdbca; + u_core_in.func = (void *)(unsigned long)0xdbca; bss->u_core_in = &u_core_in; err = test_core_read_macros__attach(skel); diff --git a/tools/testing/selftests/bpf/prog_tests/hashmap.c b/tools/testing/selftests/bpf/prog_tests/hashmap.c index 4747ab18f97f..799d4cc147f6 100644 --- a/tools/testing/selftests/bpf/prog_tests/hashmap.c +++ b/tools/testing/selftests/bpf/prog_tests/hashmap.c @@ -52,8 +52,8 @@ static void test_hashmap_generic(void) return; for (i = 0; i < ELEM_CNT; i++) { - const void *oldk, *k = (const void *)(long)i; - void *oldv, *v = (void *)(long)(1024 + i); + const void *oldk, *k = (const void *)(unsigned long)i; + void *oldv, *v = (void *)(unsigned long)(1024 + i); err = hashmap__update(map, k, v, &oldk, &oldv); if (CHECK(err != -ENOENT, "hashmap__update", @@ -104,8 +104,8 @@ static void test_hashmap_generic(void) goto cleanup; for (i = 0; i < ELEM_CNT; i++) { - const void *oldk, *k = (const void *)(long)i; - void *oldv, *v = (void *)(long)(256 + i); + const void *oldk, *k = (const void *)(unsigned long)i; + void *oldv, *v = (void *)(unsigned long)(256 + i); err = hashmap__add(map, k, v); if (CHECK(err != -EEXIST, "hashmap__add", diff --git a/tools/testing/selftests/bpf/prog_tests/ringbuf.c b/tools/testing/selftests/bpf/prog_tests/ringbuf.c index 9a80fe8a6427..57e8e6b4d223 100644 --- a/tools/testing/selftests/bpf/prog_tests/ringbuf.c +++ b/tools/testing/selftests/bpf/prog_tests/ringbuf.c @@ -78,7 +78,7 @@ static void *poll_thread(void *input) { long timeout = (long)input; - return (void *)(long)ring_buffer__poll(ringbuf, timeout); + return (void *)(unsigned long)ring_buffer__poll(ringbuf, timeout); } void test_ringbuf(void) @@ -208,7 +208,7 @@ void test_ringbuf(void) CHECK(cnt != 2, "cnt", "exp %d samples, got %d\n", 2, cnt); /* start poll in background w/ long timeout */ - err = pthread_create(&thread, NULL, poll_thread, (void *)(long)10000); + err = pthread_create(&thread, NULL, poll_thread, (void *)(unsigned long)10000); if (CHECK(err, "bg_poll", "pthread_create failed: %d\n", err)) goto cleanup; diff --git a/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c b/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c index eb5f7f5aa81a..867f8b6f27d7 100644 --- a/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c +++ b/tools/testing/selftests/bpf/prog_tests/ringbuf_multi.c @@ -69,12 +69,12 @@ void test_ringbuf_multi(void) skel->bss->pid = getpid(); ringbuf = ring_buffer__new(bpf_map__fd(skel->maps.ringbuf1), - process_sample, (void *)(long)1, NULL); + process_sample, (void *)(unsigned long)1, NULL); if (CHECK(!ringbuf, "ringbuf_create", "failed to create ringbuf\n")) goto cleanup; err = ring_buffer__add(ringbuf, bpf_map__fd(skel->maps.ringbuf2), - process_sample, (void *)(long)2); + process_sample, (void *)(unsigned long)2); if (CHECK(err, "ringbuf_add", "failed to add another ring\n")) goto cleanup; diff --git a/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c b/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c index 8ed78a9383ba..c87611e1dc12 100644 --- a/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c +++ b/tools/testing/selftests/bpf/prog_tests/sockopt_inherit.c @@ -97,7 +97,7 @@ static void *server_thread(void *arg) close(client_fd); - return (void *)(long)err; + return (void *)(unsigned long)err; } static int start_server(void) diff --git a/tools/testing/selftests/bpf/progs/bpf_flow.c b/tools/testing/selftests/bpf/progs/bpf_flow.c index f266c757b3df..9cad8867d5e0 100644 --- a/tools/testing/selftests/bpf/progs/bpf_flow.c +++ b/tools/testing/selftests/bpf/progs/bpf_flow.c @@ -91,8 +91,8 @@ static __always_inline void *bpf_flow_dissect_get_header(struct __sk_buff *skb, __u16 hdr_size, void *buffer) { - void *data_end = (void *)(long)skb->data_end; - void *data = (void *)(long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; __u16 thoff = skb->flow_keys->thoff; __u8 *hdr; @@ -150,7 +150,7 @@ int _dissect(struct __sk_buff *skb) static __always_inline int parse_ip_proto(struct __sk_buff *skb, __u8 proto) { struct bpf_flow_keys *keys = skb->flow_keys; - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; struct icmphdr *icmp, _icmp; struct gre_hdr *gre, _gre; struct ethhdr *eth, _eth; @@ -259,9 +259,9 @@ static __always_inline int parse_ipv6_proto(struct __sk_buff *skb, __u8 nexthdr) PROG(IP)(struct __sk_buff *skb) { - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; struct bpf_flow_keys *keys = skb->flow_keys; - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct iphdr *iph, _iph; bool done = false; diff --git a/tools/testing/selftests/bpf/progs/core_kern.c b/tools/testing/selftests/bpf/progs/core_kern.c index 2715fe27d4cf..c7b4417ce0b6 100644 --- a/tools/testing/selftests/bpf/progs/core_kern.c +++ b/tools/testing/selftests/bpf/progs/core_kern.c @@ -74,8 +74,8 @@ struct bpf_testmod_test_read_ctx /* it exists in bpf_testmod */ { SEC("tc") int balancer_ingress(struct __sk_buff *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; void *ptr; int ret = 0, nh_off, i = 0; diff --git a/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c b/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c index 48cd14b43741..ddbf0e46b81e 100644 --- a/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c +++ b/tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c @@ -116,8 +116,8 @@ __u64 test_get_skb_ifindex = 0; SEC("freplace/get_skb_ifindex") int new_get_skb_ifindex(int val, struct __sk_buff *skb, int var) { - void *data_end = (void *)(long)skb->data_end; - void *data = (void *)(long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; struct ipv6hdr ip6, *ip6p; int ifindex = skb->ifindex; __u32 eth_proto; @@ -159,8 +159,8 @@ SEC("freplace/test_pkt_write_access_subprog") int new_test_pkt_write_access_subprog(struct __sk_buff *skb, __u32 off) { - void *data = (void *)(long)skb->data; - void *data_end = (void *)(long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; struct tcphdr *tcp; if (off > sizeof(struct ethhdr) + sizeof(struct ipv6hdr)) diff --git a/tools/testing/selftests/bpf/progs/pyperf.h b/tools/testing/selftests/bpf/progs/pyperf.h index 6c7b1fb268d6..8f70a7d53282 100644 --- a/tools/testing/selftests/bpf/progs/pyperf.h +++ b/tools/testing/selftests/bpf/progs/pyperf.h @@ -77,7 +77,7 @@ static void *get_thread_state(void *tls_base, PidData *pidData) void* thread_state; int key; - bpf_probe_read_user(&key, sizeof(key), (void*)(long)pidData->tls_key_addr); + bpf_probe_read_user(&key, sizeof(key), (void *)(unsigned long)pidData->tls_key_addr); bpf_probe_read_user(&thread_state, sizeof(thread_state), tls_base + 0x310 + key * 0x10 + 0x08); return thread_state; @@ -241,7 +241,7 @@ int __on_event(struct bpf_raw_tracepoint_args *ctx) void* thread_state_current = (void*)0; bpf_probe_read_user(&thread_state_current, sizeof(thread_state_current), - (void*)(long)pidData->current_state_addr); + (void *)(unsigned long)pidData->current_state_addr); struct task_struct* task = (struct task_struct*)bpf_get_current_task(); void* tls_base = (void*)task; diff --git a/tools/testing/selftests/bpf/progs/skb_pkt_end.c b/tools/testing/selftests/bpf/progs/skb_pkt_end.c index 992b7861003a..83475f1ba65f 100644 --- a/tools/testing/selftests/bpf/progs/skb_pkt_end.c +++ b/tools/testing/selftests/bpf/progs/skb_pkt_end.c @@ -6,7 +6,7 @@ #define INLINE __always_inline -#define skb_shorter(skb, len) ((void *)(long)(skb)->data + (len) > (void *)(long)skb->data_end) +#define skb_shorter(skb, len) ((void *)(unsigned long)(skb)->data + (len) > (void *)(unsigned long)skb->data_end) #define ETH_IPV4_TCP_SIZE (14 + sizeof(struct iphdr) + sizeof(struct tcphdr)) @@ -18,7 +18,7 @@ static INLINE struct iphdr *get_iphdr(struct __sk_buff *skb) if (skb_shorter(skb, ETH_IPV4_TCP_SIZE)) goto out; - eth = (void *)(long)skb->data; + eth = (void *)(unsigned long)skb->data; ip = (void *)(eth + 1); out: diff --git a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c index c9abfe3a11af..85f0bbb5b63b 100644 --- a/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c +++ b/tools/testing/selftests/bpf/progs/sockmap_parse_prog.c @@ -5,8 +5,8 @@ SEC("sk_skb1") int bpf_prog1(struct __sk_buff *skb) { - void *data_end = (void *)(long) skb->data_end; - void *data = (void *)(long) skb->data; + void *data_end = (void *)(unsigned long) skb->data_end; + void *data = (void *)(unsigned long) skb->data; __u8 *d = data; int err; @@ -15,8 +15,8 @@ int bpf_prog1(struct __sk_buff *skb) if (err) return SK_DROP; - data_end = (void *)(long)skb->data_end; - data = (void *)(long)skb->data; + data_end = (void *)(unsigned long)skb->data_end; + data = (void *)(unsigned long)skb->data; if (data + 10 > data_end) return SK_DROP; } diff --git a/tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c b/tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c index e2468a6d01a5..5f1b156d46bc 100644 --- a/tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c +++ b/tools/testing/selftests/bpf/progs/sockmap_verdict_prog.c @@ -33,8 +33,8 @@ struct { SEC("sk_skb2") int bpf_prog2(struct __sk_buff *skb) { - void *data_end = (void *)(long) skb->data_end; - void *data = (void *)(long) skb->data; + void *data_end = (void *)(unsigned long) skb->data_end; + void *data = (void *)(unsigned long) skb->data; __u32 lport = skb->local_port; __u32 rport = skb->remote_port; __u8 *d = data; diff --git a/tools/testing/selftests/bpf/progs/test_btf_skc_cls_ingress.c b/tools/testing/selftests/bpf/progs/test_btf_skc_cls_ingress.c index e2bea4da194b..d0437b888d1a 100644 --- a/tools/testing/selftests/bpf/progs/test_btf_skc_cls_ingress.c +++ b/tools/testing/selftests/bpf/progs/test_btf_skc_cls_ingress.c @@ -32,7 +32,7 @@ static void test_syncookie_helper(struct ipv6hdr *ip6h, struct tcphdr *th, __s64 mss_cookie; void *data_end; - data_end = (void *)(long)(skb->data_end); + data_end = (void *)(unsigned long)(skb->data_end); if (th->doff * 4 != 40) { LOG(); @@ -74,7 +74,7 @@ static int handle_ip6_tcp(struct ipv6hdr *ip6h, struct __sk_buff *skb) struct tcphdr *th; void *data_end; - data_end = (void *)(long)(skb->data_end); + data_end = (void *)(unsigned long)(skb->data_end); th = (struct tcphdr *)(ip6h + 1); if (th + 1 > data_end) @@ -152,9 +152,9 @@ int cls_ingress(struct __sk_buff *skb) struct ethhdr *eth; void *data_end; - data_end = (void *)(long)(skb->data_end); + data_end = (void *)(unsigned long)(skb->data_end); - eth = (struct ethhdr *)(long)(skb->data); + eth = (struct ethhdr *)(unsigned long)(skb->data); if (eth + 1 > data_end) return TC_ACT_OK; diff --git a/tools/testing/selftests/bpf/progs/test_check_mtu.c b/tools/testing/selftests/bpf/progs/test_check_mtu.c index 2ec1de11a3ae..de13327f33b1 100644 --- a/tools/testing/selftests/bpf/progs/test_check_mtu.c +++ b/tools/testing/selftests/bpf/progs/test_check_mtu.c @@ -58,8 +58,8 @@ int xdp_use_helper(struct xdp_md *ctx) SEC("xdp") int xdp_exceed_mtu(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; __u32 ifindex = GLOBAL_USER_IFINDEX; __u32 data_len = data_end - data; int retval = XDP_ABORTED; /* Fail */ @@ -85,8 +85,8 @@ SEC("xdp") int xdp_minus_delta(struct xdp_md *ctx) { int retval = XDP_PASS; /* Expected retval on successful test */ - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; __u32 ifindex = GLOBAL_USER_IFINDEX; __u32 data_len = data_end - data; __u32 mtu_len = 0; @@ -109,8 +109,8 @@ SEC("xdp") int xdp_input_len(struct xdp_md *ctx) { int retval = XDP_PASS; /* Expected retval on successful test */ - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; __u32 ifindex = GLOBAL_USER_IFINDEX; __u32 data_len = data_end - data; @@ -200,8 +200,8 @@ SEC("tc") int tc_exceed_mtu_da(struct __sk_buff *ctx) { /* SKB Direct-Access variant */ - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; __u32 ifindex = GLOBAL_USER_IFINDEX; __u32 data_len = data_end - data; int retval = BPF_DROP; /* Fail */ diff --git a/tools/testing/selftests/bpf/progs/test_cls_redirect.c b/tools/testing/selftests/bpf/progs/test_cls_redirect.c index 2833ad722cb7..0d7a55e5a260 100644 --- a/tools/testing/selftests/bpf/progs/test_cls_redirect.c +++ b/tools/testing/selftests/bpf/progs/test_cls_redirect.c @@ -501,8 +501,8 @@ static INLINING ret_t forward_with_gre(struct __sk_buff *skb, encap_headers_t *e buf_t pkt = { .skb = skb, - .head = (uint8_t *)(long)skb->data, - .tail = (uint8_t *)(long)skb->data_end, + .head = (uint8_t *)(unsigned long)skb->data, + .tail = (uint8_t *)(unsigned long)skb->data_end, }; encap_gre_t *encap_gre = buf_assign(&pkt, sizeof(encap_gre_t), NULL); @@ -956,8 +956,8 @@ int cls_redirect(struct __sk_buff *skb) buf_t pkt = { .skb = skb, - .head = (uint8_t *)(long)skb->data, - .tail = (uint8_t *)(long)skb->data_end, + .head = (uint8_t *)(unsigned long)skb->data, + .tail = (uint8_t *)(unsigned long)skb->data_end, }; encap = buf_assign(&pkt, sizeof(*encap), NULL); diff --git a/tools/testing/selftests/bpf/progs/test_l4lb.c b/tools/testing/selftests/bpf/progs/test_l4lb.c index c26057ec46dc..6b9b26af0b16 100644 --- a/tools/testing/selftests/bpf/progs/test_l4lb.c +++ b/tools/testing/selftests/bpf/progs/test_l4lb.c @@ -322,7 +322,7 @@ static __always_inline bool parse_tcp(void *data, __u64 off, void *data_end, static __always_inline int process_packet(void *data, __u64 off, void *data_end, bool is_ipv6, struct __sk_buff *skb) { - void *pkt_start = (void *)(long)skb->data; + void *pkt_start = (void *)(unsigned long)skb->data; struct packet_description pckt = {}; struct eth_hdr *eth = pkt_start; struct bpf_tunnel_key tkey = {}; @@ -451,8 +451,8 @@ static __always_inline int process_packet(void *data, __u64 off, void *data_end, SEC("tc") int balancer_ingress(struct __sk_buff *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct eth_hdr *eth = data; __u32 eth_proto; __u32 nh_off; diff --git a/tools/testing/selftests/bpf/progs/test_l4lb_noinline.c b/tools/testing/selftests/bpf/progs/test_l4lb_noinline.c index c8bc0c6947aa..43cab9da4d5d 100644 --- a/tools/testing/selftests/bpf/progs/test_l4lb_noinline.c +++ b/tools/testing/selftests/bpf/progs/test_l4lb_noinline.c @@ -321,7 +321,7 @@ static __noinline bool parse_tcp(void *data, __u64 off, void *data_end, static __noinline int process_packet(void *data, __u64 off, void *data_end, bool is_ipv6, struct __sk_buff *skb) { - void *pkt_start = (void *)(long)skb->data; + void *pkt_start = (void *)(unsigned long)skb->data; struct packet_description pckt = {}; struct eth_hdr *eth = pkt_start; struct bpf_tunnel_key tkey = {}; @@ -450,8 +450,8 @@ static __noinline int process_packet(void *data, __u64 off, void *data_end, SEC("tc") int balancer_ingress(struct __sk_buff *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct eth_hdr *eth = data; __u32 eth_proto; __u32 nh_off; diff --git a/tools/testing/selftests/bpf/progs/test_lwt_seg6local.c b/tools/testing/selftests/bpf/progs/test_lwt_seg6local.c index 48ff2b2ad5e7..6702d9ed8f5d 100644 --- a/tools/testing/selftests/bpf/progs/test_lwt_seg6local.c +++ b/tools/testing/selftests/bpf/progs/test_lwt_seg6local.c @@ -57,8 +57,8 @@ static __always_inline struct ip6_srh_t *get_srh(struct __sk_buff *skb) struct ip6_t *ip; uint8_t *ipver; - data_end = (void *)(long)skb->data_end; - cursor = (void *)(long)skb->data; + data_end = (void *)(unsigned long)skb->data_end; + cursor = (void *)(unsigned long)skb->data; ipver = (uint8_t *)cursor; if ((void *)ipver + sizeof(*ipver) > data_end) @@ -123,7 +123,7 @@ int is_valid_tlv_boundary(struct __sk_buff *skb, struct ip6_srh_t *srh, int offset_valid = 0; int err; - srh_off = (char *)srh - (char *)(long)skb->data; + srh_off = (char *)srh - (char *)(unsigned long)skb->data; // cur_off = end of segments, start of possible TLVs cur_off = srh_off + sizeof(*srh) + sizeof(struct ip6_addr_t) * (srh->first_segment + 1); @@ -177,7 +177,7 @@ static __always_inline int add_tlv(struct __sk_buff *skb, struct ip6_srh_t *srh, uint32_t tlv_off, struct sr6_tlv_t *itlv, uint8_t tlv_size) { - uint32_t srh_off = (char *)srh - (char *)(long)skb->data; + uint32_t srh_off = (char *)srh - (char *)(unsigned long)skb->data; uint8_t len_remaining, new_pad; uint32_t pad_off = 0; uint32_t pad_size = 0; @@ -221,7 +221,7 @@ static __always_inline int delete_tlv(struct __sk_buff *skb, struct ip6_srh_t *srh, uint32_t tlv_off) { - uint32_t srh_off = (char *)srh - (char *)(long)skb->data; + uint32_t srh_off = (char *)srh - (char *)(unsigned long)skb->data; uint8_t len_remaining, new_pad; uint32_t partial_srh_len; uint32_t pad_off = 0; diff --git a/tools/testing/selftests/bpf/progs/test_migrate_reuseport.c b/tools/testing/selftests/bpf/progs/test_migrate_reuseport.c index 27df571abf5b..b76663ea5c33 100644 --- a/tools/testing/selftests/bpf/progs/test_migrate_reuseport.c +++ b/tools/testing/selftests/bpf/progs/test_migrate_reuseport.c @@ -44,8 +44,8 @@ __be16 server_port; SEC("xdp") int drop_ack(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct ethhdr *eth = data; struct tcphdr *tcp = NULL; diff --git a/tools/testing/selftests/bpf/progs/test_pkt_access.c b/tools/testing/selftests/bpf/progs/test_pkt_access.c index 5cd7c096f62d..dd3fbadcd5eb 100644 --- a/tools/testing/selftests/bpf/progs/test_pkt_access.c +++ b/tools/testing/selftests/bpf/progs/test_pkt_access.c @@ -79,8 +79,8 @@ int get_skb_ifindex(int val, struct __sk_buff *skb, int var) __attribute__ ((noinline)) int test_pkt_write_access_subprog(struct __sk_buff *skb, __u32 off) { - void *data = (void *)(long)skb->data; - void *data_end = (void *)(long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; struct tcphdr *tcp = NULL; if (off > sizeof(struct ethhdr) + sizeof(struct ipv6hdr)) @@ -97,8 +97,8 @@ int test_pkt_write_access_subprog(struct __sk_buff *skb, __u32 off) SEC("tc") int test_pkt_access(struct __sk_buff *skb) { - void *data_end = (void *)(long)skb->data_end; - void *data = (void *)(long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; struct ethhdr *eth = (struct ethhdr *)(data); struct tcphdr *tcp = NULL; __u8 proto = 255; diff --git a/tools/testing/selftests/bpf/progs/test_queue_stack_map.h b/tools/testing/selftests/bpf/progs/test_queue_stack_map.h index 648e8cab7a23..d22d89a096b0 100644 --- a/tools/testing/selftests/bpf/progs/test_queue_stack_map.h +++ b/tools/testing/selftests/bpf/progs/test_queue_stack_map.h @@ -27,8 +27,8 @@ struct { SEC("tc") int _test(struct __sk_buff *skb) { - void *data_end = (void *)(long)skb->data_end; - void *data = (void *)(long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; struct ethhdr *eth = (struct ethhdr *)(data); __u32 value; int err; diff --git a/tools/testing/selftests/bpf/progs/test_seg6_loop.c b/tools/testing/selftests/bpf/progs/test_seg6_loop.c index a7278f064368..001423c58e8f 100644 --- a/tools/testing/selftests/bpf/progs/test_seg6_loop.c +++ b/tools/testing/selftests/bpf/progs/test_seg6_loop.c @@ -57,8 +57,8 @@ static __always_inline struct ip6_srh_t *get_srh(struct __sk_buff *skb) struct ip6_t *ip; uint8_t *ipver; - data_end = (void *)(long)skb->data_end; - cursor = (void *)(long)skb->data; + data_end = (void *)(unsigned long)skb->data_end; + cursor = (void *)(unsigned long)skb->data; ipver = (uint8_t *)cursor; if ((void *)ipver + sizeof(*ipver) > data_end) @@ -124,7 +124,7 @@ static __always_inline int is_valid_tlv_boundary(struct __sk_buff *skb, int offset_valid = 0; int err; - srh_off = (char *)srh - (char *)(long)skb->data; + srh_off = (char *)srh - (char *)(unsigned long)skb->data; // cur_off = end of segments, start of possible TLVs cur_off = srh_off + sizeof(*srh) + sizeof(struct ip6_addr_t) * (srh->first_segment + 1); @@ -180,7 +180,7 @@ static __always_inline int add_tlv(struct __sk_buff *skb, struct ip6_srh_t *srh, uint32_t tlv_off, struct sr6_tlv_t *itlv, uint8_t tlv_size) { - uint32_t srh_off = (char *)srh - (char *)(long)skb->data; + uint32_t srh_off = (char *)srh - (char *)(unsigned long)skb->data; uint8_t len_remaining, new_pad; uint32_t pad_off = 0; uint32_t pad_size = 0; diff --git a/tools/testing/selftests/bpf/progs/test_sk_assign.c b/tools/testing/selftests/bpf/progs/test_sk_assign.c index 98c6493d9b91..c15daf8503f6 100644 --- a/tools/testing/selftests/bpf/progs/test_sk_assign.c +++ b/tools/testing/selftests/bpf/progs/test_sk_assign.c @@ -42,8 +42,8 @@ char _license[] SEC("license") = "GPL"; static inline struct bpf_sock_tuple * get_tuple(struct __sk_buff *skb, bool *ipv4, bool *tcp) { - void *data_end = (void *)(long)skb->data_end; - void *data = (void *)(long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; struct bpf_sock_tuple *result; struct ethhdr *eth; __u64 tuple_len; @@ -96,7 +96,7 @@ handle_udp(struct __sk_buff *skb, struct bpf_sock_tuple *tuple, bool ipv4) int ret; tuple_len = ipv4 ? sizeof(tuple->ipv4) : sizeof(tuple->ipv6); - if ((void *)tuple + tuple_len > (void *)(long)skb->data_end) + if ((void *)tuple + tuple_len > (void *)(unsigned long)skb->data_end) return TC_ACT_SHOT; sk = bpf_sk_lookup_udp(skb, tuple, tuple_len, BPF_F_CURRENT_NETNS, 0); @@ -127,7 +127,7 @@ handle_tcp(struct __sk_buff *skb, struct bpf_sock_tuple *tuple, bool ipv4) int ret; tuple_len = ipv4 ? sizeof(tuple->ipv4) : sizeof(tuple->ipv6); - if ((void *)tuple + tuple_len > (void *)(long)skb->data_end) + if ((void *)tuple + tuple_len > (void *)(unsigned long)skb->data_end) return TC_ACT_SHOT; sk = bpf_skc_lookup_tcp(skb, tuple, tuple_len, BPF_F_CURRENT_NETNS, 0); diff --git a/tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c b/tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c index b502e5c92e33..058df49340b4 100644 --- a/tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c +++ b/tools/testing/selftests/bpf/progs/test_sk_lookup_kern.c @@ -55,8 +55,8 @@ static struct bpf_sock_tuple *get_tuple(void *data, __u64 nh_off, SEC("?tc") int sk_lookup_success(struct __sk_buff *skb) { - void *data_end = (void *)(long)skb->data_end; - void *data = (void *)(long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; struct ethhdr *eth = (struct ethhdr *)(data); struct bpf_sock_tuple *tuple; struct bpf_sock *sk; diff --git a/tools/testing/selftests/bpf/progs/test_sockmap_kern.h b/tools/testing/selftests/bpf/progs/test_sockmap_kern.h index 6c85b00f27b2..afc2015674b6 100644 --- a/tools/testing/selftests/bpf/progs/test_sockmap_kern.h +++ b/tools/testing/selftests/bpf/progs/test_sockmap_kern.h @@ -140,8 +140,8 @@ static inline void bpf_write_pass(struct __sk_buff *skb, int offset) if (err) return; - c = (char *)(long)skb->data; - data_end = (void *)(long)skb->data_end; + c = (char *)(unsigned long)skb->data; + data_end = (void *)(unsigned long)skb->data_end; if (c + 5 + offset < data_end) memcpy(c + offset, "PASS", 4); @@ -309,8 +309,8 @@ int bpf_prog6(struct sk_msg_md *msg) SEC("sk_msg3") int bpf_prog8(struct sk_msg_md *msg) { - void *data_end = (void *)(long) msg->data_end; - void *data = (void *)(long) msg->data; + void *data_end = (void *)(unsigned long) msg->data_end; + void *data = (void *)(unsigned long) msg->data; int ret = 0, *bytes, zero = 0; bytes = bpf_map_lookup_elem(&sock_apply_bytes, &zero); @@ -326,8 +326,8 @@ int bpf_prog8(struct sk_msg_md *msg) SEC("sk_msg4") int bpf_prog9(struct sk_msg_md *msg) { - void *data_end = (void *)(long) msg->data_end; - void *data = (void *)(long) msg->data; + void *data_end = (void *)(unsigned long) msg->data_end; + void *data = (void *)(unsigned long) msg->data; int ret = 0, *bytes, zero = 0; bytes = bpf_map_lookup_elem(&sock_cork_bytes, &zero); diff --git a/tools/testing/selftests/bpf/progs/test_tc_dtime.c b/tools/testing/selftests/bpf/progs/test_tc_dtime.c index b596479a9ebe..8391b855f0be 100644 --- a/tools/testing/selftests/bpf/progs/test_tc_dtime.c +++ b/tools/testing/selftests/bpf/progs/test_tc_dtime.c @@ -25,7 +25,7 @@ * ns_fwd: Fowarding namespace */ -#define ctx_ptr(field) (void *)(long)(field) +#define ctx_ptr(field) (void *)(unsigned long)(field) #define ip4_src __bpf_htonl(0xac100164) /* 172.16.1.100 */ #define ip4_dst __bpf_htonl(0xac100264) /* 172.16.2.100 */ diff --git a/tools/testing/selftests/bpf/progs/test_tc_edt.c b/tools/testing/selftests/bpf/progs/test_tc_edt.c index 950a70b61e74..1fa9dd6c4d03 100644 --- a/tools/testing/selftests/bpf/progs/test_tc_edt.c +++ b/tools/testing/selftests/bpf/progs/test_tc_edt.c @@ -64,7 +64,7 @@ static inline int throttle_flow(struct __sk_buff *skb) static inline int handle_tcp(struct __sk_buff *skb, struct tcphdr *tcp) { - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; /* drop malformed packets */ if ((void *)(tcp + 1) > data_end) @@ -78,8 +78,8 @@ static inline int handle_tcp(struct __sk_buff *skb, struct tcphdr *tcp) static inline int handle_ipv4(struct __sk_buff *skb) { - void *data_end = (void *)(long)skb->data_end; - void *data = (void *)(long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; struct iphdr *iph; uint32_t ihl; diff --git a/tools/testing/selftests/bpf/progs/test_tc_neigh.c b/tools/testing/selftests/bpf/progs/test_tc_neigh.c index 3e32ea375ab4..6f0be523fcfb 100644 --- a/tools/testing/selftests/bpf/progs/test_tc_neigh.c +++ b/tools/testing/selftests/bpf/progs/test_tc_neigh.c @@ -15,7 +15,7 @@ #include #ifndef ctx_ptr -# define ctx_ptr(field) (void *)(long)(field) +# define ctx_ptr(field) (void *)(unsigned long)(field) #endif #define ip4_src 0xac100164 /* 172.16.1.100 */ diff --git a/tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c b/tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c index ec4cce19362d..62bc341def8e 100644 --- a/tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c +++ b/tools/testing/selftests/bpf/progs/test_tc_neigh_fib.c @@ -15,7 +15,7 @@ #include #ifndef ctx_ptr -# define ctx_ptr(field) (void *)(long)(field) +# define ctx_ptr(field) (void *)(unsigned long)(field) #endif #define AF_INET 2 diff --git a/tools/testing/selftests/bpf/progs/test_tcp_check_syncookie_kern.c b/tools/testing/selftests/bpf/progs/test_tcp_check_syncookie_kern.c index 6edebce563b5..075ca11e9216 100644 --- a/tools/testing/selftests/bpf/progs/test_tcp_check_syncookie_kern.c +++ b/tools/testing/selftests/bpf/progs/test_tcp_check_syncookie_kern.c @@ -151,16 +151,16 @@ static __always_inline void check_syncookie(void *ctx, void *data, SEC("tc") int check_syncookie_clsact(struct __sk_buff *skb) { - check_syncookie(skb, (void *)(long)skb->data, - (void *)(long)skb->data_end); + check_syncookie(skb, (void *)(unsigned long)skb->data, + (void *)(unsigned long)skb->data_end); return TC_ACT_OK; } SEC("xdp") int check_syncookie_xdp(struct xdp_md *ctx) { - check_syncookie(ctx, (void *)(long)ctx->data, - (void *)(long)ctx->data_end); + check_syncookie(ctx, (void *)(unsigned long)ctx->data, + (void *)(unsigned long)ctx->data_end); return XDP_PASS; } diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c index 17f2f325b3f3..cdf00915668c 100644 --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c @@ -623,9 +623,9 @@ SEC("tc") int ipip_set_tunnel(struct __sk_buff *skb) { struct bpf_tunnel_key key = {}; - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct iphdr *iph = data; - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; int ret; /* single length check */ @@ -668,9 +668,9 @@ SEC("tc") int ipip6_set_tunnel(struct __sk_buff *skb) { struct bpf_tunnel_key key = {}; - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct iphdr *iph = data; - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; int ret; /* single length check */ @@ -717,9 +717,9 @@ SEC("tc") int ip6ip6_set_tunnel(struct __sk_buff *skb) { struct bpf_tunnel_key key = {}; - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct ipv6hdr *iph = data; - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; int ret; /* single length check */ diff --git a/tools/testing/selftests/bpf/progs/test_verif_scale1.c b/tools/testing/selftests/bpf/progs/test_verif_scale1.c index d38153dab3dd..dacf09ea9a91 100644 --- a/tools/testing/selftests/bpf/progs/test_verif_scale1.c +++ b/tools/testing/selftests/bpf/progs/test_verif_scale1.c @@ -8,8 +8,8 @@ SEC("scale90_noinline") int balancer_ingress(struct __sk_buff *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; void *ptr; int ret = 0, nh_off, i = 0; diff --git a/tools/testing/selftests/bpf/progs/test_verif_scale2.c b/tools/testing/selftests/bpf/progs/test_verif_scale2.c index f90ffcafd1e8..a537149900be 100644 --- a/tools/testing/selftests/bpf/progs/test_verif_scale2.c +++ b/tools/testing/selftests/bpf/progs/test_verif_scale2.c @@ -8,8 +8,8 @@ SEC("tc") int balancer_ingress(struct __sk_buff *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; void *ptr; int ret = 0, nh_off, i = 0; diff --git a/tools/testing/selftests/bpf/progs/test_verif_scale3.c b/tools/testing/selftests/bpf/progs/test_verif_scale3.c index 9beb5bf80373..ce360b20e0e6 100644 --- a/tools/testing/selftests/bpf/progs/test_verif_scale3.c +++ b/tools/testing/selftests/bpf/progs/test_verif_scale3.c @@ -8,8 +8,8 @@ SEC("scale90_noinline32") int balancer_ingress(struct __sk_buff *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; void *ptr; int ret = 0, nh_off, i = 0; diff --git a/tools/testing/selftests/bpf/progs/test_xdp.c b/tools/testing/selftests/bpf/progs/test_xdp.c index d7a9a74b7245..0681e27aec70 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp.c +++ b/tools/testing/selftests/bpf/progs/test_xdp.c @@ -77,8 +77,8 @@ static __always_inline void set_ethhdr(struct ethhdr *new_eth, static __always_inline int handle_ipv4(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct iptnl_info *tnl; struct ethhdr *new_eth; struct ethhdr *old_eth; @@ -111,8 +111,8 @@ static __always_inline int handle_ipv4(struct xdp_md *xdp) if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct iphdr))) return XDP_DROP; - data = (void *)(long)xdp->data; - data_end = (void *)(long)xdp->data_end; + data = (void *)(unsigned long)xdp->data; + data_end = (void *)(unsigned long)xdp->data_end; new_eth = data; iph = data + sizeof(*new_eth); @@ -150,8 +150,8 @@ static __always_inline int handle_ipv4(struct xdp_md *xdp) static __always_inline int handle_ipv6(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct iptnl_info *tnl; struct ethhdr *new_eth; struct ethhdr *old_eth; @@ -181,8 +181,8 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp) if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct ipv6hdr))) return XDP_DROP; - data = (void *)(long)xdp->data; - data_end = (void *)(long)xdp->data_end; + data = (void *)(unsigned long)xdp->data; + data_end = (void *)(unsigned long)xdp->data_end; new_eth = data; ip6h = data + sizeof(*new_eth); @@ -211,8 +211,8 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp) SEC("xdp") int _xdp_tx_iptunnel(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct ethhdr *eth = data; __u16 h_proto; diff --git a/tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_grow.c b/tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_grow.c index 53b64c999450..737eb7c06d7c 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_grow.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_grow.c @@ -5,8 +5,8 @@ SEC("xdp") int _xdp_adjust_tail_grow(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; int data_len = bpf_xdp_get_buff_len(xdp); int offset = 0; diff --git a/tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_shrink.c b/tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_shrink.c index ca68c038357c..bcfe23707783 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_shrink.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_shrink.c @@ -12,8 +12,8 @@ SEC("xdp") int _xdp_adjust_tail_shrink(struct xdp_md *xdp) { - __u8 *data_end = (void *)(long)xdp->data_end; - __u8 *data = (void *)(long)xdp->data; + __u8 *data_end = (void *)(unsigned long)xdp->data_end; + __u8 *data = (void *)(unsigned long)xdp->data; int offset = 0; switch (bpf_xdp_get_buff_len(xdp)) { diff --git a/tools/testing/selftests/bpf/progs/test_xdp_bpf2bpf.c b/tools/testing/selftests/bpf/progs/test_xdp_bpf2bpf.c index 3379d303f41a..28ac5b9740e6 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_bpf2bpf.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_bpf2bpf.c @@ -45,8 +45,8 @@ SEC("fentry/FUNC") int BPF_PROG(trace_on_entry, struct xdp_buff *xdp) { struct meta meta; - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; meta.ifindex = xdp->rxq->dev->ifindex; meta.pkt_len = bpf_xdp_get_buff_len((struct xdp_md *)xdp); diff --git a/tools/testing/selftests/bpf/progs/test_xdp_context_test_run.c b/tools/testing/selftests/bpf/progs/test_xdp_context_test_run.c index d7b88cd05afd..928cb1a5c27b 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_context_test_run.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_context_test_run.c @@ -5,8 +5,8 @@ SEC("xdp") int xdp_context(struct xdp_md *xdp) { - void *data = (void *)(long)xdp->data; - __u32 *metadata = (void *)(long)xdp->data_meta; + void *data = (void *)(unsigned long)xdp->data; + __u32 *metadata = (void *)(unsigned long)xdp->data_meta; __u32 ret; if (metadata + 1 > data) diff --git a/tools/testing/selftests/bpf/progs/test_xdp_devmap_helpers.c b/tools/testing/selftests/bpf/progs/test_xdp_devmap_helpers.c index 807bf895f42c..449a98c48510 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_devmap_helpers.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_devmap_helpers.c @@ -9,8 +9,8 @@ SEC("xdp") int xdpdm_devlog(struct xdp_md *ctx) { char fmt[] = "devmap redirect: dev %u -> dev %u len %u\n"; - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; unsigned int len = data_end - data; bpf_trace_printk(fmt, sizeof(fmt), diff --git a/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c b/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c index 77a123071940..859fe17f46cb 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c @@ -15,9 +15,9 @@ volatile int retcode = XDP_REDIRECT; SEC("xdp") int xdp_redirect(struct xdp_md *xdp) { - __u32 *metadata = (void *)(long)xdp->data_meta; - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + __u32 *metadata = (void *)(unsigned long)xdp->data_meta; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; __u8 *payload = data + HDR_SZ; int ret = retcode; @@ -72,8 +72,8 @@ static bool check_pkt(void *data, void *data_end) SEC("xdp") int xdp_count_pkts(struct xdp_md *xdp) { - void *data = (void *)(long)xdp->data; - void *data_end = (void *)(long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; if (check_pkt(data, data_end)) pkts_seen_xdp++; @@ -88,8 +88,8 @@ int xdp_count_pkts(struct xdp_md *xdp) SEC("tc") int tc_count_pkts(struct __sk_buff *skb) { - void *data = (void *)(long)skb->data; - void *data_end = (void *)(long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; if (check_pkt(data, data_end)) pkts_seen_tc++; diff --git a/tools/testing/selftests/bpf/progs/test_xdp_loop.c b/tools/testing/selftests/bpf/progs/test_xdp_loop.c index c98fb44156f0..0a441452d656 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_loop.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_loop.c @@ -73,8 +73,8 @@ static __always_inline void set_ethhdr(struct ethhdr *new_eth, static __always_inline int handle_ipv4(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct iptnl_info *tnl; struct ethhdr *new_eth; struct ethhdr *old_eth; @@ -107,8 +107,8 @@ static __always_inline int handle_ipv4(struct xdp_md *xdp) if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct iphdr))) return XDP_DROP; - data = (void *)(long)xdp->data; - data_end = (void *)(long)xdp->data_end; + data = (void *)(unsigned long)xdp->data; + data_end = (void *)(unsigned long)xdp->data_end; new_eth = data; iph = data + sizeof(*new_eth); @@ -146,8 +146,8 @@ static __always_inline int handle_ipv4(struct xdp_md *xdp) static __always_inline int handle_ipv6(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct iptnl_info *tnl; struct ethhdr *new_eth; struct ethhdr *old_eth; @@ -177,8 +177,8 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp) if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct ipv6hdr))) return XDP_DROP; - data = (void *)(long)xdp->data; - data_end = (void *)(long)xdp->data_end; + data = (void *)(unsigned long)xdp->data; + data_end = (void *)(unsigned long)xdp->data_end; new_eth = data; ip6h = data + sizeof(*new_eth); @@ -207,8 +207,8 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp) SEC("xdp") int _xdp_tx_iptunnel(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct ethhdr *eth = data; __u16 h_proto; diff --git a/tools/testing/selftests/bpf/progs/test_xdp_noinline.c b/tools/testing/selftests/bpf/progs/test_xdp_noinline.c index ba48fcb98ab2..a5976a470aa8 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_noinline.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_noinline.c @@ -288,8 +288,8 @@ bool encap_v6(struct xdp_md *xdp, struct ctl_value *cval, if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct ipv6hdr))) return false; - data = (void *)(long)xdp->data; - data_end = (void *)(long)xdp->data_end; + data = (void *)(unsigned long)xdp->data; + data_end = (void *)(unsigned long)xdp->data_end; new_eth = data; ip6h = data + sizeof(struct eth_hdr); old_eth = data + sizeof(struct ipv6hdr); @@ -336,8 +336,8 @@ bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval, ip_suffix ^= pckt->flow.src; if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct iphdr))) return false; - data = (void *)(long)xdp->data; - data_end = (void *)(long)xdp->data_end; + data = (void *)(unsigned long)xdp->data; + data_end = (void *)(unsigned long)xdp->data_end; new_eth = data; iph = data + sizeof(struct eth_hdr); old_eth = data + sizeof(struct iphdr); @@ -387,8 +387,8 @@ bool decap_v6(struct xdp_md *xdp, void **data, void **data_end, bool inner_v4) new_eth->eth_proto = 56710; if (bpf_xdp_adjust_head(xdp, (int)sizeof(struct ipv6hdr))) return false; - *data = (void *)(long)xdp->data; - *data_end = (void *)(long)xdp->data_end; + *data = (void *)(unsigned long)xdp->data; + *data_end = (void *)(unsigned long)xdp->data_end; return true; } @@ -405,8 +405,8 @@ bool decap_v4(struct xdp_md *xdp, void **data, void **data_end) new_eth->eth_proto = 8; if (bpf_xdp_adjust_head(xdp, (int)sizeof(struct iphdr))) return false; - *data = (void *)(long)xdp->data; - *data_end = (void *)(long)xdp->data_end; + *data = (void *)(unsigned long)xdp->data; + *data_end = (void *)(unsigned long)xdp->data_end; return true; } @@ -789,8 +789,8 @@ static int process_packet(void *data, __u64 off, void *data_end, data_stats->v1 += 1; data_stats->v2 += pkt_bytes; - data = (void *)(long)xdp->data; - data_end = (void *)(long)xdp->data_end; + data = (void *)(unsigned long)xdp->data; + data_end = (void *)(unsigned long)xdp->data_end; if (data + 4 > data_end) return XDP_DROP; *(u32 *)data = dst->dst; @@ -800,8 +800,8 @@ static int process_packet(void *data, __u64 off, void *data_end, SEC("xdp") int balancer_ingress_v4(struct xdp_md *ctx) { - void *data = (void *)(long)ctx->data; - void *data_end = (void *)(long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; struct eth_hdr *eth = data; __u32 eth_proto; __u32 nh_off; @@ -819,8 +819,8 @@ int balancer_ingress_v4(struct xdp_md *ctx) SEC("xdp") int balancer_ingress_v6(struct xdp_md *ctx) { - void *data = (void *)(long)ctx->data; - void *data_end = (void *)(long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; struct eth_hdr *eth = data; __u32 eth_proto; __u32 nh_off; diff --git a/tools/testing/selftests/bpf/progs/test_xdp_update_frags.c b/tools/testing/selftests/bpf/progs/test_xdp_update_frags.c index 2a3496d8e327..68621125bf86 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_update_frags.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_update_frags.c @@ -13,8 +13,8 @@ int _version SEC("version") = 1; SEC("xdp.frags") int xdp_adjust_frags(struct xdp_md *xdp) { - __u8 *data_end = (void *)(long)xdp->data_end; - __u8 *data = (void *)(long)xdp->data; + __u8 *data_end = (void *)(unsigned long)xdp->data_end; + __u8 *data = (void *)(unsigned long)xdp->data; __u8 val[16] = {}; __u32 offset; int err; diff --git a/tools/testing/selftests/bpf/progs/test_xdp_vlan.c b/tools/testing/selftests/bpf/progs/test_xdp_vlan.c index 134768f6b788..7dde447de0c4 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_vlan.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_vlan.c @@ -105,8 +105,8 @@ bool parse_eth_frame(struct ethhdr *eth, void *data_end, struct parse_pkt *pkt) SEC("xdp_drop_vlan_4011") int xdp_prognum0(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct parse_pkt pkt = { 0 }; if (!parse_eth_frame(data, data_end, &pkt)) @@ -147,8 +147,8 @@ Load prog with ip tool: SEC("xdp_vlan_change") int xdp_prognum1(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct parse_pkt pkt = { 0 }; if (!parse_eth_frame(data, data_end, &pkt)) @@ -181,8 +181,8 @@ int xdp_prognum1(struct xdp_md *ctx) SEC("xdp_vlan_remove_outer") int xdp_prognum2(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct parse_pkt pkt = { 0 }; char *dest; @@ -240,8 +240,8 @@ void shift_mac_4bytes_32bit(void *data) SEC("xdp_vlan_remove_outer2") int xdp_prognum3(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct ethhdr *orig_eth = data; struct parse_pkt pkt = { 0 }; diff --git a/tools/testing/selftests/bpf/progs/test_xdp_with_devmap_helpers.c b/tools/testing/selftests/bpf/progs/test_xdp_with_devmap_helpers.c index 4139a14f9996..536fcad4c0c9 100644 --- a/tools/testing/selftests/bpf/progs/test_xdp_with_devmap_helpers.c +++ b/tools/testing/selftests/bpf/progs/test_xdp_with_devmap_helpers.c @@ -31,8 +31,8 @@ SEC("xdp/devmap") int xdp_dummy_dm(struct xdp_md *ctx) { char fmt[] = "devmap redirect: dev %u -> dev %u len %u\n"; - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; unsigned int len = data_end - data; bpf_trace_printk(fmt, sizeof(fmt), diff --git a/tools/testing/selftests/bpf/progs/xdp_redirect_multi_kern.c b/tools/testing/selftests/bpf/progs/xdp_redirect_multi_kern.c index 97b26a30b59a..91847e37e182 100644 --- a/tools/testing/selftests/bpf/progs/xdp_redirect_multi_kern.c +++ b/tools/testing/selftests/bpf/progs/xdp_redirect_multi_kern.c @@ -37,8 +37,8 @@ struct { SEC("xdp") int xdp_redirect_map_multi_prog(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; int if_index = ctx->ingress_ifindex; struct ethhdr *eth = data; __u16 h_proto; @@ -73,8 +73,8 @@ int xdp_redirect_map_all_prog(struct xdp_md *ctx) SEC("xdp/devmap") int xdp_devmap_prog(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; __u32 key = ctx->egress_ifindex; struct ethhdr *eth = data; __u64 nh_off; diff --git a/tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c b/tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c index 736686e903f6..ae1563ba4af0 100644 --- a/tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c +++ b/tools/testing/selftests/bpf/progs/xdp_synproxy_kern.c @@ -799,8 +799,8 @@ static __always_inline int syncookie_part2(void *ctx, void *data, void *data_end SEC("xdp") int syncookie_xdp(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct header_pointers hdr; int ret; @@ -808,8 +808,8 @@ int syncookie_xdp(struct xdp_md *ctx) if (ret != XDP_TX) return ret; - data_end = (void *)(long)ctx->data_end; - data = (void *)(long)ctx->data; + data_end = (void *)(unsigned long)ctx->data_end; + data = (void *)(unsigned long)ctx->data; return syncookie_part2(ctx, data, data_end, &hdr, true); } @@ -817,8 +817,8 @@ int syncookie_xdp(struct xdp_md *ctx) SEC("tc") int syncookie_tc(struct __sk_buff *skb) { - void *data_end = (void *)(long)skb->data_end; - void *data = (void *)(long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; struct header_pointers hdr; int ret; @@ -826,8 +826,8 @@ int syncookie_tc(struct __sk_buff *skb) if (ret != XDP_TX) return ret == XDP_PASS ? TC_ACT_OK : TC_ACT_SHOT; - data_end = (void *)(long)skb->data_end; - data = (void *)(long)skb->data; + data_end = (void *)(unsigned long)skb->data_end; + data = (void *)(unsigned long)skb->data; ret = syncookie_part2(skb, data, data_end, &hdr, false); switch (ret) { diff --git a/tools/testing/selftests/bpf/progs/xdping_kern.c b/tools/testing/selftests/bpf/progs/xdping_kern.c index 4ad73847b8a5..6792d98ca6ac 100644 --- a/tools/testing/selftests/bpf/progs/xdping_kern.c +++ b/tools/testing/selftests/bpf/progs/xdping_kern.c @@ -58,8 +58,8 @@ static __always_inline __u16 ipv4_csum(void *data_start, int data_size) static __always_inline int icmp_check(struct xdp_md *ctx, int type) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct ethhdr *eth = data; struct icmphdr *icmph; struct iphdr *iph; @@ -89,8 +89,8 @@ static __always_inline int icmp_check(struct xdp_md *ctx, int type) SEC("xdp") int xdping_client(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct pinginfo *pinginfo = NULL; struct ethhdr *eth = data; struct icmphdr *icmph; @@ -153,8 +153,8 @@ int xdping_client(struct xdp_md *ctx) SEC("xdp") int xdping_server(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct ethhdr *eth = data; struct icmphdr *icmph; struct iphdr *iph; diff --git a/tools/testing/selftests/bpf/progs/xdpwall.c b/tools/testing/selftests/bpf/progs/xdpwall.c index 7a891a0c3a39..ab1fd62f89c1 100644 --- a/tools/testing/selftests/bpf/progs/xdpwall.c +++ b/tools/testing/selftests/bpf/progs/xdpwall.c @@ -317,8 +317,8 @@ static __always_inline __u8 parse_ipv6_gue(struct pkt_info *info, SEC("xdp") int edgewall(struct xdp_md *ctx) { - void *data_end = (void *)(long)(ctx->data_end); - void *data = (void *)(long)(ctx->data); + void *data_end = (void *)(unsigned long)(ctx->data_end); + void *data = (void *)(unsigned long)(ctx->data); struct fw_match_info match_info = {}; struct pkt_info info = {}; __u8 parse_err = NO_ERR; From patchwork Mon Jul 18 13:29:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pu Lehui X-Patchwork-Id: 12921238 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 5DA54CCA485 for ; Mon, 18 Jul 2022 12:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234920AbiGRM7d (ORCPT ); Mon, 18 Jul 2022 08:59:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234250AbiGRM70 (ORCPT ); Mon, 18 Jul 2022 08:59:26 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D0856460; Mon, 18 Jul 2022 05:59:23 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Lmhml4jb1z1M7tB; Mon, 18 Jul 2022 20:56:39 +0800 (CST) Received: from dggpemm500019.china.huawei.com (7.185.36.180) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:20 +0800 Received: from k04.huawei.com (10.67.174.115) by dggpemm500019.china.huawei.com (7.185.36.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:20 +0800 From: Pu Lehui To: , , CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Quentin Monnet , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "Jean-Philippe Brucker" , Pu Lehui Subject: [PATCH bpf-next v2 4/5] samples: bpf: Unify memory address casting operation style Date: Mon, 18 Jul 2022 21:29:37 +0800 Message-ID: <20220718132938.1031864-5-pulehui@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220718132938.1031864-1-pulehui@huawei.com> References: <20220718132938.1031864-1-pulehui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.115] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500019.china.huawei.com (7.185.36.180) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Memory addresses are conceptually unsigned, (unsigned long) casting makes more sense, so let's make a change for conceptual uniformity and there is no functional change. Signed-off-by: Pu Lehui Acked-by: Yonghong Song --- samples/bpf/parse_simple.c | 4 +- samples/bpf/parse_varlen.c | 4 +- samples/bpf/tc_l2_redirect_kern.c | 16 ++++---- samples/bpf/test_cgrp2_tc_kern.c | 4 +- samples/bpf/test_lwt_bpf.c | 4 +- samples/bpf/xdp_adjust_tail_kern.c | 12 +++--- samples/bpf/xdp_fwd_kern.c | 4 +- samples/bpf/xdp_redirect.bpf.c | 4 +- samples/bpf/xdp_redirect_cpu.bpf.c | 48 ++++++++++++------------ samples/bpf/xdp_redirect_map.bpf.c | 8 ++-- samples/bpf/xdp_redirect_map_multi.bpf.c | 4 +- samples/bpf/xdp_router_ipv4.bpf.c | 4 +- samples/bpf/xdp_rxq_info_kern.c | 4 +- samples/bpf/xdp_sample_pkts_kern.c | 4 +- samples/bpf/xdp_tx_iptunnel_kern.c | 20 +++++----- 15 files changed, 72 insertions(+), 72 deletions(-) diff --git a/samples/bpf/parse_simple.c b/samples/bpf/parse_simple.c index 4a486cb1e0df..9a58865079ce 100644 --- a/samples/bpf/parse_simple.c +++ b/samples/bpf/parse_simple.c @@ -26,11 +26,11 @@ struct eth_hdr { SEC("simple") int handle_ingress(struct __sk_buff *skb) { - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct eth_hdr *eth = data; struct iphdr *iph = data + sizeof(*eth); struct udphdr *udp = data + sizeof(*eth) + sizeof(*iph); - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; /* single length check */ if (data + sizeof(*eth) + sizeof(*iph) + sizeof(*udp) > data_end) diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c index d8623846e810..54e725efd576 100644 --- a/samples/bpf/parse_varlen.c +++ b/samples/bpf/parse_varlen.c @@ -112,9 +112,9 @@ static int parse_ipv6(void *data, uint64_t nh_off, void *data_end) SEC("varlen") int handle_ingress(struct __sk_buff *skb) { - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct ethhdr *eth = data; - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; uint64_t h_proto, nh_off; nh_off = sizeof(*eth); diff --git a/samples/bpf/tc_l2_redirect_kern.c b/samples/bpf/tc_l2_redirect_kern.c index fd2fa0004330..a3e10e43d560 100644 --- a/samples/bpf/tc_l2_redirect_kern.c +++ b/samples/bpf/tc_l2_redirect_kern.c @@ -59,9 +59,9 @@ SEC("l2_to_iptun_ingress_forward") int _l2_to_iptun_ingress_forward(struct __sk_buff *skb) { struct bpf_tunnel_key tkey = {}; - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct eth_hdr *eth = data; - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; int key = 0, *ifindex; int ret; @@ -110,9 +110,9 @@ SEC("l2_to_iptun_ingress_redirect") int _l2_to_iptun_ingress_redirect(struct __sk_buff *skb) { struct bpf_tunnel_key tkey = {}; - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct eth_hdr *eth = data; - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; int key = 0, *ifindex; int ret; @@ -151,9 +151,9 @@ SEC("l2_to_ip6tun_ingress_redirect") int _l2_to_ip6tun_ingress_redirect(struct __sk_buff *skb) { struct bpf_tunnel_key tkey = {}; - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct eth_hdr *eth = data; - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; int key = 0, *ifindex; if (data + sizeof(*eth) > data_end) @@ -206,9 +206,9 @@ SEC("drop_non_tun_vip") int _drop_non_tun_vip(struct __sk_buff *skb) { struct bpf_tunnel_key tkey = {}; - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct eth_hdr *eth = data; - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; if (data + sizeof(*eth) > data_end) return TC_ACT_OK; diff --git a/samples/bpf/test_cgrp2_tc_kern.c b/samples/bpf/test_cgrp2_tc_kern.c index 4dd532a312b9..c1468609ab14 100644 --- a/samples/bpf/test_cgrp2_tc_kern.c +++ b/samples/bpf/test_cgrp2_tc_kern.c @@ -41,10 +41,10 @@ struct bpf_elf_map SEC("maps") test_cgrp2_array_pin = { SEC("filter") int handle_egress(struct __sk_buff *skb) { - void *data = (void *)(long)skb->data; + void *data = (void *)(unsigned long)skb->data; struct eth_hdr *eth = data; struct ipv6hdr *ip6h = data + sizeof(*eth); - void *data_end = (void *)(long)skb->data_end; + void *data_end = (void *)(unsigned long)skb->data_end; char dont_care_msg[] = "dont care %04x %d\n"; char pass_msg[] = "pass\n"; char reject_msg[] = "reject\n"; diff --git a/samples/bpf/test_lwt_bpf.c b/samples/bpf/test_lwt_bpf.c index 1b568575ad11..dd1883415931 100644 --- a/samples/bpf/test_lwt_bpf.c +++ b/samples/bpf/test_lwt_bpf.c @@ -67,8 +67,8 @@ int do_test_cb(struct __sk_buff *skb) SEC("test_data") int do_test_data(struct __sk_buff *skb) { - void *data = (void *)(long)skb->data; - void *data_end = (void *)(long)skb->data_end; + void *data = (void *)(unsigned long)skb->data; + void *data_end = (void *)(unsigned long)skb->data_end; struct iphdr *iph = data; if (data + sizeof(*iph) > data_end) { diff --git a/samples/bpf/xdp_adjust_tail_kern.c b/samples/bpf/xdp_adjust_tail_kern.c index ffdd548627f0..7a182e133e6a 100644 --- a/samples/bpf/xdp_adjust_tail_kern.c +++ b/samples/bpf/xdp_adjust_tail_kern.c @@ -73,8 +73,8 @@ static __always_inline int send_icmp4_too_big(struct xdp_md *xdp) if (bpf_xdp_adjust_head(xdp, 0 - headroom)) return XDP_DROP; - void *data = (void *)(long)xdp->data; - void *data_end = (void *)(long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; if (data + (ICMP_TOOBIG_SIZE + headroom) > data_end) return XDP_DROP; @@ -119,8 +119,8 @@ static __always_inline int send_icmp4_too_big(struct xdp_md *xdp) static __always_inline int handle_ipv4(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; int pckt_size = data_end - data; int offset; @@ -136,8 +136,8 @@ static __always_inline int handle_ipv4(struct xdp_md *xdp) SEC("xdp_icmp") int _xdp_icmp(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct ethhdr *eth = data; __u16 h_proto; diff --git a/samples/bpf/xdp_fwd_kern.c b/samples/bpf/xdp_fwd_kern.c index 54c099cbd639..022f9fb926b8 100644 --- a/samples/bpf/xdp_fwd_kern.c +++ b/samples/bpf/xdp_fwd_kern.c @@ -42,8 +42,8 @@ static __always_inline int ip_decrease_ttl(struct iphdr *iph) static __always_inline int xdp_fwd_flags(struct xdp_md *ctx, u32 flags) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct bpf_fib_lookup fib_params; struct ethhdr *eth = data; struct ipv6hdr *ip6h; diff --git a/samples/bpf/xdp_redirect.bpf.c b/samples/bpf/xdp_redirect.bpf.c index 7c02bacfe96b..12969f2d58c7 100644 --- a/samples/bpf/xdp_redirect.bpf.c +++ b/samples/bpf/xdp_redirect.bpf.c @@ -19,8 +19,8 @@ const volatile int ifindex_out; SEC("xdp") int xdp_redirect_prog(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; u32 key = bpf_get_smp_processor_id(); struct ethhdr *eth = data; struct datarec *rec; diff --git a/samples/bpf/xdp_redirect_cpu.bpf.c b/samples/bpf/xdp_redirect_cpu.bpf.c index 87c54bfdbb70..46261792d74d 100644 --- a/samples/bpf/xdp_redirect_cpu.bpf.c +++ b/samples/bpf/xdp_redirect_cpu.bpf.c @@ -96,8 +96,8 @@ bool parse_eth(struct ethhdr *eth, void *data_end, static __always_inline u16 get_dest_port_ipv4_udp(struct xdp_md *ctx, u64 nh_off) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct iphdr *iph = data + nh_off; struct udphdr *udph; @@ -116,8 +116,8 @@ u16 get_dest_port_ipv4_udp(struct xdp_md *ctx, u64 nh_off) static __always_inline int get_proto_ipv4(struct xdp_md *ctx, u64 nh_off) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct iphdr *iph = data + nh_off; if (iph + 1 > data_end) @@ -128,8 +128,8 @@ int get_proto_ipv4(struct xdp_md *ctx, u64 nh_off) static __always_inline int get_proto_ipv6(struct xdp_md *ctx, u64 nh_off) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct ipv6hdr *ip6h = data + nh_off; if (ip6h + 1 > data_end) @@ -167,8 +167,8 @@ int xdp_prognum0_no_touch(struct xdp_md *ctx) SEC("xdp") int xdp_prognum1_touch_data(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; u32 key = bpf_get_smp_processor_id(); struct ethhdr *eth = data; struct datarec *rec; @@ -209,8 +209,8 @@ int xdp_prognum1_touch_data(struct xdp_md *ctx) SEC("xdp") int xdp_prognum2_round_robin(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; u32 key = bpf_get_smp_processor_id(); struct datarec *rec; u32 cpu_dest = 0; @@ -254,8 +254,8 @@ int xdp_prognum2_round_robin(struct xdp_md *ctx) SEC("xdp") int xdp_prognum3_proto_separate(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; u32 key = bpf_get_smp_processor_id(); struct ethhdr *eth = data; u8 ip_proto = IPPROTO_UDP; @@ -320,8 +320,8 @@ int xdp_prognum3_proto_separate(struct xdp_md *ctx) SEC("xdp") int xdp_prognum4_ddos_filter_pktgen(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; u32 key = bpf_get_smp_processor_id(); struct ethhdr *eth = data; u8 ip_proto = IPPROTO_UDP; @@ -396,8 +396,8 @@ int xdp_prognum4_ddos_filter_pktgen(struct xdp_md *ctx) static __always_inline u32 get_ipv4_hash_ip_pair(struct xdp_md *ctx, u64 nh_off) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct iphdr *iph = data + nh_off; u32 cpu_hash; @@ -413,8 +413,8 @@ u32 get_ipv4_hash_ip_pair(struct xdp_md *ctx, u64 nh_off) static __always_inline u32 get_ipv6_hash_ip_pair(struct xdp_md *ctx, u64 nh_off) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct ipv6hdr *ip6h = data + nh_off; u32 cpu_hash; @@ -437,8 +437,8 @@ u32 get_ipv6_hash_ip_pair(struct xdp_md *ctx, u64 nh_off) SEC("xdp") int xdp_prognum5_lb_hash_ip_pairs(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; u32 key = bpf_get_smp_processor_id(); struct ethhdr *eth = data; struct datarec *rec; @@ -494,8 +494,8 @@ int xdp_prognum5_lb_hash_ip_pairs(struct xdp_md *ctx) SEC("xdp/cpumap") int xdp_redirect_cpu_devmap(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct ethhdr *eth = data; u64 nh_off; @@ -522,8 +522,8 @@ int xdp_redirect_cpu_drop(struct xdp_md *ctx) SEC("xdp/devmap") int xdp_redirect_egress_prog(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct ethhdr *eth = data; u64 nh_off; diff --git a/samples/bpf/xdp_redirect_map.bpf.c b/samples/bpf/xdp_redirect_map.bpf.c index 8557c278df77..df8e9de0833f 100644 --- a/samples/bpf/xdp_redirect_map.bpf.c +++ b/samples/bpf/xdp_redirect_map.bpf.c @@ -37,8 +37,8 @@ const volatile __u8 tx_mac_addr[ETH_ALEN]; static __always_inline int xdp_redirect_map(struct xdp_md *ctx, void *redirect_map) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; u32 key = bpf_get_smp_processor_id(); struct ethhdr *eth = data; struct datarec *rec; @@ -71,8 +71,8 @@ int xdp_redirect_map_native(struct xdp_md *ctx) SEC("xdp/devmap") int xdp_redirect_map_egress(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; u8 *mac_addr = (u8 *) tx_mac_addr; struct ethhdr *eth = data; u64 nh_off; diff --git a/samples/bpf/xdp_redirect_map_multi.bpf.c b/samples/bpf/xdp_redirect_map_multi.bpf.c index 8b2fd4ec2c76..361b7ed1b34e 100644 --- a/samples/bpf/xdp_redirect_map_multi.bpf.c +++ b/samples/bpf/xdp_redirect_map_multi.bpf.c @@ -56,8 +56,8 @@ int xdp_redirect_map_native(struct xdp_md *ctx) SEC("xdp/devmap") int xdp_devmap_prog(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; u32 key = ctx->egress_ifindex; struct ethhdr *eth = data; __be64 *mac; diff --git a/samples/bpf/xdp_router_ipv4.bpf.c b/samples/bpf/xdp_router_ipv4.bpf.c index 0643330d1d2e..5a2a942decf9 100644 --- a/samples/bpf/xdp_router_ipv4.bpf.c +++ b/samples/bpf/xdp_router_ipv4.bpf.c @@ -73,8 +73,8 @@ struct { SEC("xdp") int xdp_router_ipv4_prog(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct ethhdr *eth = data; u64 nh_off = sizeof(*eth); struct datarec *rec; diff --git a/samples/bpf/xdp_rxq_info_kern.c b/samples/bpf/xdp_rxq_info_kern.c index 5e7459f9bf3e..0df286e2f30d 100644 --- a/samples/bpf/xdp_rxq_info_kern.c +++ b/samples/bpf/xdp_rxq_info_kern.c @@ -74,8 +74,8 @@ void swap_src_dst_mac(void *data) SEC("xdp_prog0") int xdp_prognum0(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; struct datarec *rec, *rxq_rec; int ingress_ifindex; struct config *config; diff --git a/samples/bpf/xdp_sample_pkts_kern.c b/samples/bpf/xdp_sample_pkts_kern.c index 9cf76b340dd7..78a8150ecd33 100644 --- a/samples/bpf/xdp_sample_pkts_kern.c +++ b/samples/bpf/xdp_sample_pkts_kern.c @@ -15,8 +15,8 @@ struct { SEC("xdp_sample") int xdp_sample_prog(struct xdp_md *ctx) { - void *data_end = (void *)(long)ctx->data_end; - void *data = (void *)(long)ctx->data; + void *data_end = (void *)(unsigned long)ctx->data_end; + void *data = (void *)(unsigned long)ctx->data; /* Metadata will be in the perf event before the packet data. */ struct S { diff --git a/samples/bpf/xdp_tx_iptunnel_kern.c b/samples/bpf/xdp_tx_iptunnel_kern.c index 0e2bca3a3fff..f3f11ff12858 100644 --- a/samples/bpf/xdp_tx_iptunnel_kern.c +++ b/samples/bpf/xdp_tx_iptunnel_kern.c @@ -76,8 +76,8 @@ static __always_inline void set_ethhdr(struct ethhdr *new_eth, static __always_inline int handle_ipv4(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct iptnl_info *tnl; struct ethhdr *new_eth; struct ethhdr *old_eth; @@ -112,8 +112,8 @@ static __always_inline int handle_ipv4(struct xdp_md *xdp) if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct iphdr))) return XDP_DROP; - data = (void *)(long)xdp->data; - data_end = (void *)(long)xdp->data_end; + data = (void *)(unsigned long)xdp->data; + data_end = (void *)(unsigned long)xdp->data_end; new_eth = data; iph = data + sizeof(*new_eth); @@ -151,8 +151,8 @@ static __always_inline int handle_ipv4(struct xdp_md *xdp) static __always_inline int handle_ipv6(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct iptnl_info *tnl; struct ethhdr *new_eth; struct ethhdr *old_eth; @@ -184,8 +184,8 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp) if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct ipv6hdr))) return XDP_DROP; - data = (void *)(long)xdp->data; - data_end = (void *)(long)xdp->data_end; + data = (void *)(unsigned long)xdp->data; + data_end = (void *)(unsigned long)xdp->data_end; new_eth = data; ip6h = data + sizeof(*new_eth); @@ -215,8 +215,8 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp) SEC("xdp.frags") int _xdp_tx_iptunnel(struct xdp_md *xdp) { - void *data_end = (void *)(long)xdp->data_end; - void *data = (void *)(long)xdp->data; + void *data_end = (void *)(unsigned long)xdp->data_end; + void *data = (void *)(unsigned long)xdp->data; struct ethhdr *eth = data; __u16 h_proto; From patchwork Mon Jul 18 13:29:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pu Lehui X-Patchwork-Id: 12921237 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 B7FF4C433EF for ; Mon, 18 Jul 2022 12:59:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234780AbiGRM71 (ORCPT ); Mon, 18 Jul 2022 08:59:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234385AbiGRM7Y (ORCPT ); Mon, 18 Jul 2022 08:59:24 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 270236437; Mon, 18 Jul 2022 05:59:22 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Lmhml2rgXzjX4G; Mon, 18 Jul 2022 20:56:39 +0800 (CST) Received: from dggpemm500019.china.huawei.com (7.185.36.180) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:21 +0800 Received: from k04.huawei.com (10.67.174.115) by dggpemm500019.china.huawei.com (7.185.36.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 18 Jul 2022 20:59:20 +0800 From: Pu Lehui To: , , CC: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Quentin Monnet , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , "Jean-Philippe Brucker" , Pu Lehui Subject: [PATCH bpf-next v2 5/5] selftests/bpf: Change the casting about jited_ksyms and jited_linfo Date: Mon, 18 Jul 2022 21:29:38 +0800 Message-ID: <20220718132938.1031864-6-pulehui@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220718132938.1031864-1-pulehui@huawei.com> References: <20220718132938.1031864-1-pulehui@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.115] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500019.china.huawei.com (7.185.36.180) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net We have unified data extension operation of jited_ksyms and jited_linfo into zero extension [0], so there's no need to cast __u64 memory address to long data type. And __u64 in some arch is unsigned long, so to avoid compiler warnings we just cast them to unsigned long long. [0] https://lore.kernel.org/bpf/20220530092815.1112406-2-pulehui@huawei.com/ Signed-off-by: Pu Lehui --- tools/testing/selftests/bpf/prog_tests/btf.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c index e852a9df779d..db10fa1745d1 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf.c +++ b/tools/testing/selftests/bpf/prog_tests/btf.c @@ -6613,8 +6613,9 @@ static int test_get_linfo(const struct prog_info_raw_test *test, } if (CHECK(jited_linfo[0] != jited_ksyms[0], - "jited_linfo[0]:%lx != jited_ksyms[0]:%lx", - (long)(jited_linfo[0]), (long)(jited_ksyms[0]))) { + "jited_linfo[0]:%llx != jited_ksyms[0]:%llx", + (unsigned long long)(jited_linfo[0]), + (unsigned long long)(jited_ksyms[0]))) { err = -1; goto done; } @@ -6632,16 +6633,17 @@ static int test_get_linfo(const struct prog_info_raw_test *test, } if (CHECK(jited_linfo[i] <= jited_linfo[i - 1], - "jited_linfo[%u]:%lx <= jited_linfo[%u]:%lx", - i, (long)jited_linfo[i], - i - 1, (long)(jited_linfo[i - 1]))) { + "jited_linfo[%u]:%llx <= jited_linfo[%u]:%llx", + i, (unsigned long long)jited_linfo[i], + i - 1, (unsigned long long)(jited_linfo[i - 1]))) { err = -1; goto done; } if (CHECK(jited_linfo[i] - cur_func_ksyms > cur_func_len, - "jited_linfo[%u]:%lx - %lx > %u", - i, (long)jited_linfo[i], (long)cur_func_ksyms, + "jited_linfo[%u]:%llx - %llx > %u", + i, (unsigned long long)jited_linfo[i], + (unsigned long long)cur_func_ksyms, cur_func_len)) { err = -1; goto done;