@@ -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)
@@ -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);
@@ -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;
@@ -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";
@@ -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) {
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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 {
@@ -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;
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> --- 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(-)