diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-08-08 18:39:48 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-08-08 18:39:48 +0200 |
commit | f6a589a59ea88c895d35a595c3d0580495dbc548 (patch) | |
tree | d68e4204289fc63eeca82254e4a8f4a0ddba2287 /libbpf | |
parent | e9ac14979a70d0b36684fb4bac031daa7dcb9a6a (diff) | |
download | hurd-f6a589a59ea88c895d35a595c3d0580495dbc548.tar.gz hurd-f6a589a59ea88c895d35a595c3d0580495dbc548.tar.bz2 hurd-f6a589a59ea88c895d35a595c3d0580495dbc548.zip |
libbpf: Fix long / int confusion
In network terms, long is 32bit, i.e. an int for us.
Diffstat (limited to 'libbpf')
-rw-r--r-- | libbpf/bpf_impl.c | 8 | ||||
-rw-r--r-- | libbpf/bpf_impl.h | 10 |
2 files changed, 9 insertions, 9 deletions
diff --git a/libbpf/bpf_impl.c b/libbpf/bpf_impl.c index 6eb9dda3..acd53409 100644 --- a/libbpf/bpf_impl.c +++ b/libbpf/bpf_impl.c @@ -66,7 +66,7 @@ bpf_do_filter(net_rcv_port_t infp, char *p, unsigned int wirelen, bpf_insn_t pc, pc_end; unsigned int buflen; - unsigned long A, X; + unsigned int A, X; int k; unsigned int mem[BPF_MEMWORDS]; @@ -114,9 +114,9 @@ bpf_do_filter(net_rcv_port_t infp, char *p, unsigned int wirelen, k = pc->k; load_word: - if ((u_int)k + sizeof(long) <= hlen) + if ((u_int)k + sizeof(int) <= hlen) data = header; - else if ((u_int)k + sizeof(long) <= buflen) { + else if ((u_int)k + sizeof(int) <= buflen) { k -= hlen; data = p; } else @@ -127,7 +127,7 @@ load_word: A = EXTRACT_LONG(&data[k]); else #endif - A = ntohl(*(long *)(data + k)); + A = ntohl(*(int *)(data + k)); continue; case BPF_LD|BPF_H|BPF_ABS: diff --git a/libbpf/bpf_impl.h b/libbpf/bpf_impl.h index 2b092b7e..76ce4e6c 100644 --- a/libbpf/bpf_impl.h +++ b/libbpf/bpf_impl.h @@ -59,17 +59,17 @@ typedef filter_t *filter_array_t; #ifndef BPF_ALIGN #define EXTRACT_SHORT(p) ((u_short)ntohs(*(u_short *)p)) -#define EXTRACT_LONG(p) (ntohl(*(u_long *)p)) +#define EXTRACT_LONG(p) (ntohl(*(u_int *)p)) #else #define EXTRACT_SHORT(p)\ ((u_short)\ ((u_short)*((u_char *)p+0)<<8|\ (u_short)*((u_char *)p+1)<<0)) #define EXTRACT_LONG(p)\ - ((u_long)*((u_char *)p+0)<<24|\ - (u_long)*((u_char *)p+1)<<16|\ - (u_long)*((u_char *)p+2)<<8|\ - (u_long)*((u_char *)p+3)<<0) + ((u_int)*((u_char *)p+0)<<24|\ + (u_int)*((u_char *)p+1)<<16|\ + (u_int)*((u_char *)p+2)<<8|\ + (u_int)*((u_char *)p+3)<<0) #endif #define HASH_ITERATE(head, elt) (elt) = (net_hash_entry_t) (head); do { |