cregit-Linux how code gets into the kernel

Release 4.18 tools/testing/selftests/bpf/sockmap_tcp_msg_prog.c

#include <linux/bpf.h>
#include "bpf_helpers.h"
#include "bpf_util.h"
#include "bpf_endian.h"

int _version SEC("version") = 1;


#define bpf_printk(fmt, ...)					\
({                                                              \
               char ____fmt[] = fmt;                            \
               bpf_trace_printk(____fmt, sizeof(____fmt),       \
                                ##__VA_ARGS__);                 \
})

SEC("sk_msg1")

int bpf_prog1(struct sk_msg_md *msg) { void *data_end = (void *)(long) msg->data_end; void *data = (void *)(long) msg->data; char *d; if (data + 8 > data_end) return SK_DROP; bpf_printk("data length %i\n", (__u64)msg->data_end - (__u64)msg->data); d = (char *)data; bpf_printk("hello sendmsg hook %i %i\n", d[0], d[1]); return SK_PASS; }

Contributors

PersonTokensPropCommitsCommitProp
John Fastabend100100.00%1100.00%
Total100100.00%1100.00%

char _license[] SEC("license") = "GPL";

Overall Contributors

PersonTokensPropCommitsCommitProp
John Fastabend145100.00%1100.00%
Total145100.00%1100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.