aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2017-05-01 18:47:09 -0400
committerDavid S. Miller <davem@davemloft.net>2017-05-02 09:29:35 -0400
commiteb6211d3606971a957fea28f7532687f9d0f93f2 (patch)
tree5c59af3a6e75f1882b3e52e793ff147b942fdc0f
parente3bf4c61da801c7967d0efff0c3f6b22d2c0e544 (diff)
bpf, samples: fix build warning in cookie_uid_helper_example
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> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--samples/bpf/cookie_uid_helper_example.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/samples/bpf/cookie_uid_helper_example.c b/samples/bpf/cookie_uid_helper_example.c
index 9ce55840d61d..b08ab4e88929 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)
116 * is set by directly place a IMM value 1 into the stack. 116 * is set by directly place a IMM value 1 into the stack.
117 */ 117 */
118 BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0, 118 BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_0,
119 -32 + offsetof(struct stats, uid)), 119 -32 + (__s16)offsetof(struct stats, uid)),
120 BPF_ST_MEM(BPF_DW, BPF_REG_10, 120 BPF_ST_MEM(BPF_DW, BPF_REG_10,
121 -32 + offsetof(struct stats, packets), 1), 121 -32 + (__s16)offsetof(struct stats, packets), 1),
122 /* 122 /*
123 * __sk_buff is a special struct used for eBPF program to 123 * __sk_buff is a special struct used for eBPF program to
124 * directly access some sk_buff field. 124 * directly access some sk_buff field.
@@ -126,7 +126,7 @@ static void prog_load(void)
126 BPF_LDX_MEM(BPF_W, BPF_REG_1, BPF_REG_6, 126 BPF_LDX_MEM(BPF_W, BPF_REG_1, BPF_REG_6,
127 offsetof(struct __sk_buff, len)), 127 offsetof(struct __sk_buff, len)),
128 BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_1, 128 BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_1,
129 -32 + offsetof(struct stats, bytes)), 129 -32 + (__s16)offsetof(struct stats, bytes)),
130 /* 130 /*
131 * add new map entry using BPF_FUNC_map_update_elem, it takes 131 * add new map entry using BPF_FUNC_map_update_elem, it takes
132 * 4 parameters (R1: map_fd, R2: &socket_cookie, R3: &stats, 132 * 4 parameters (R1: map_fd, R2: &socket_cookie, R3: &stats,