@@ -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);
@@ -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,
@@ -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;
@@ -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;
}
@@ -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);
@@ -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",
@@ -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;
@@ -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;
@@ -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)
@@ -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;
@@ -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;
@@ -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))
@@ -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;
@@ -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:
@@ -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;
}
@@ -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;
@@ -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;
@@ -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 */
@@ -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);
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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);
@@ -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 */
@@ -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;
@@ -15,7 +15,7 @@
#include <bpf/bpf_endian.h>
#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 */
@@ -15,7 +15,7 @@
#include <bpf/bpf_endian.h>
#ifndef ctx_ptr
-# define ctx_ptr(field) (void *)(long)(field)
+# define ctx_ptr(field) (void *)(unsigned long)(field)
#endif
#define AF_INET 2
@@ -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;
}
@@ -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 */
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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)) {
@@ -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);
@@ -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)
@@ -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),
@@ -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++;
@@ -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;
@@ -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;
@@ -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;
@@ -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 };
@@ -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),
@@ -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;
@@ -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) {
@@ -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;
@@ -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;
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 <pulehui@huawei.com> --- 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(-)