* [PATCH net-next] bpf, samples: fix build warning in cookie_uid_helper_example
@ 2017-05-01 22:47 Daniel Borkmann
2017-05-02 1:30 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Borkmann @ 2017-05-01 22:47 UTC (permalink / raw)
To: davem; +Cc: alexei.starovoitov, netdev, Daniel Borkmann
Fix the following warnings triggered by 51570a5ab2b7 ("A Sample of
using socket cookie and uid for traffic monitoring"):
In file included from /home/foo/net-next/samples/bpf/cookie_uid_helper_example.c:54:0:
/home/foo/net-next/samples/bpf/cookie_uid_helper_example.c: In function 'prog_load':
/home/foo/net-next/samples/bpf/cookie_uid_helper_example.c:119:27: warning: overflow in implicit constant conversion [-Woverflow]
-32 + offsetof(struct stats, uid)),
^
/home/foo/net-next/samples/bpf/libbpf.h:135:12: note: in definition of macro 'BPF_STX_MEM'
.off = OFF, \
^
/home/foo/net-next/samples/bpf/cookie_uid_helper_example.c:121:27: warning: overflow in implicit constant conversion [-Woverflow]
-32 + offsetof(struct stats, packets), 1),
^
/home/foo/net-next/samples/bpf/libbpf.h:155:12: note: in definition of macro 'BPF_ST_MEM'
.off = OFF, \
^
/home/foo/net-next/samples/bpf/cookie_uid_helper_example.c:129:27: warning: overflow in implicit constant conversion [-Woverflow]
-32 + offsetof(struct stats, bytes)),
^
/home/foo/net-next/samples/bpf/libbpf.h:135:12: note: in definition of macro 'BPF_STX_MEM'
.off = OFF, \
^
HOSTLD /home/foo/net-next/samples/bpf/per_socket_stats_example
Fixes: 51570a5ab2b7 ("A Sample of using socket cookie and uid for traffic monitoring")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
samples/bpf/cookie_uid_helper_example.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/samples/bpf/cookie_uid_helper_example.c b/samples/bpf/cookie_uid_helper_example.c
index 9ce5584..b08ab4e 100644
--- a/samples/bpf/cookie_uid_helper_example.c
+++ b/samples/bpf/cookie_uid_helper_example.c
@@ -116,9 +116,9 @@ static void prog_load(void)
* is set by directly place a IMM value 1 into the stack.
*/
BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0,
- -32 + offsetof(struct stats, uid)),
+ -32 + (__s16)offsetof(struct stats, uid)),
BPF_ST_MEM(BPF_DW, BPF_REG_10,
- -32 + offsetof(struct stats, packets), 1),
+ -32 + (__s16)offsetof(struct stats, packets), 1),
/*
* __sk_buff is a special struct used for eBPF program to
* directly access some sk_buff field.
@@ -126,7 +126,7 @@ static void prog_load(void)
BPF_LDX_MEM(BPF_W, BPF_REG_1, BPF_REG_6,
offsetof(struct __sk_buff, len)),
BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_1,
- -32 + offsetof(struct stats, bytes)),
+ -32 + (__s16)offsetof(struct stats, bytes)),
/*
* add new map entry using BPF_FUNC_map_update_elem, it takes
* 4 parameters (R1: map_fd, R2: &socket_cookie, R3: &stats,
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] bpf, samples: fix build warning in cookie_uid_helper_example
2017-05-01 22:47 [PATCH net-next] bpf, samples: fix build warning in cookie_uid_helper_example Daniel Borkmann
@ 2017-05-02 1:30 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-05-02 1:30 UTC (permalink / raw)
To: daniel; +Cc: alexei.starovoitov, netdev
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Tue, 2 May 2017 00:47:09 +0200
> Fix the following warnings triggered by 51570a5ab2b7 ("A Sample of
> using socket cookie and uid for traffic monitoring"):
...
> Fixes: 51570a5ab2b7 ("A Sample of using socket cookie and uid for traffic monitoring")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-02 1:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-01 22:47 [PATCH net-next] bpf, samples: fix build warning in cookie_uid_helper_example Daniel Borkmann
2017-05-02 1:30 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.