On 7/7/15 4:43 AM, He Kuang wrote:

--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -210,6 +210,9 @@ enum bpf_func_id {
         * Return: 0 on success
         */
        BPF_FUNC_l4_csum_replace,
+
+       /* int bpf_output_data(void *src, int size, void *regs) */

bpf_output_trace_data(struct pt_regs *ctx, void *data, int data_size)

+       BPF_FUNC_output_data,
        __BPF_FUNC_MAX_ID,
  };

+static u64 bpf_output_data(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
+{
+       void *src = (void *) (long) r1;
+       int dsize = (int) r2, __size, size;
+       void *regs = (void *) (long) r3;

please cast to 'struct pt_regs *', since that's what it is.

+       __size = sizeof(*entry) + dsize;
+       size = ALIGN(__size + sizeof(u32), sizeof(u64));
+       size -= sizeof(u32);
+
+       entry = perf_trace_buf_prepare(size, TRACE_BPF, NULL, &rctx);
+       if (!entry)
+               return -ENOMEM;
+
+       entry->size = dsize;

something wrong here. Either 'size' from bpf_trace_entry_head
should be used or from trace_bpf.

        (void *) BPF_FUNC_l4_csum_replace;
+static int (*bpf_output_data)(void *src, int size, void *regs) =
+       (void *) BPF_FUNC_output_data;

'struct pt_regs *ctx' here as well.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to