cregit-Linux how code gets into the kernel

Release 4.10 samples/bpf/sock_flags_kern.c

Directory: samples/bpf
#include <uapi/linux/bpf.h>
#include <linux/socket.h>
#include <linux/net.h>
#include <uapi/linux/in.h>
#include <uapi/linux/in6.h>
#include "bpf_helpers.h"

SEC("cgroup/sock1")

int bpf_prog1(struct bpf_sock *sk) { char fmt[] = "socket: family %d type %d protocol %d\n"; bpf_trace_printk(fmt, sizeof(fmt), sk->family, sk->type, sk->protocol); /* block PF_INET6, SOCK_RAW, IPPROTO_ICMPV6 sockets * ie., make ping6 fail */ if (sk->family == PF_INET6 && sk->type == SOCK_RAW && sk->protocol == IPPROTO_ICMPV6) return 0; return 1; }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern65100.00%1100.00%
Total65100.00%1100.00%

SEC("cgroup/sock2")
int bpf_prog2(struct bpf_sock *sk) { char fmt[] = "socket: family %d type %d protocol %d\n"; bpf_trace_printk(fmt, sizeof(fmt), sk->family, sk->type, sk->protocol); /* block PF_INET, SOCK_RAW, IPPROTO_ICMP sockets * ie., make ping fail */ if (sk->family == PF_INET && sk->type == SOCK_RAW && sk->protocol == IPPROTO_ICMP) return 0; return 1; }

Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern65100.00%1100.00%
Total65100.00%1100.00%

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

Overall Contributors

PersonTokensPropCommitsCommitProp
david aherndavid ahern166100.00%1100.00%
Total166100.00%1100.00%
Directory: samples/bpf
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.