/* eBPF example program: * * - Loads eBPF program * * The eBPF program loads a filter from file and attaches the * program to a cgroup using BPF_PROG_ATTACH */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include "libbpf.h" #include "bpf_load.h" static int usage(const char *argv0) { printf("Usage: %s cg-path filter-path [filter-id]\n", argv0); return EXIT_FAILURE; } int main(int argc, char **argv) { int cg_fd, ret, filter_id = 0; if (argc < 3) return usage(argv[0]); cg_fd = open(argv[1], O_DIRECTORY | O_RDONLY); if (cg_fd < 0) { printf("Failed to open cgroup path: '%s'\n", strerror(errno)); return EXIT_FAILURE; } if (load_bpf_file(argv[2])) return EXIT_FAILURE; printf("Output from kernel verifier:\n%s\n-------\n", bpf_log_buf); if (argc > 3) filter_id = atoi(argv[3]); if (filter_id > prog_cnt) { printf("Invalid program id; program not found in file\n"); return EXIT_FAILURE; } ret = bpf_prog_attach(prog_fd[filter_id], cg_fd, BPF_CGROUP_INET_SOCK_CREATE); if (ret < 0) { printf("Failed to attach prog to cgroup: '%s'\n", strerror(errno)); return EXIT_FAILURE; } return EXIT_SUCCESS; } xt plumbingsTobias Klauser
summaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2017-02-10switchdev: bridge: Offload mc router portsNogah Frankel1-0/+15
2017-02-10bridge: mcast: Merge the mc router ports deletions to one functionNogah Frankel1-15/+9
2017-02-10switchdev: bridge: Offload multicast disabledNogah Frankel1-0/+16
2017-02-08bridge: vlan tunnel id info range fill size calc cleanupsRoopa Prabhu1-18/+16
2017-02-07bridge: avoid unnecessary read of jiffiesstephen hemminger2-4/+8
2017-02-07bridge: remove unnecessary check for vtbegin in br_fill_vlan_tinfo_rangeRoopa Prabhu1-1/+1
2017-02-07bridge: tunnel: fix attribute checks in br_parse_vlan_tunnel_infoNikolay Aleksandrov1-4/+4
2017-02-07net: bridge: remove redundant check to see if err is setColin Ian King1-3/+0
2017-02-06bridge: fdb: write to used and updated at most once per jiffyNikolay Aleksandrov2-2/+4
2017-02-06bridge: move write-heavy fdb members in their own cache lineNikolay Aleksandrov1-4/+6
2017-02-06bridge: move to workqueue gcNikolay Aleksandrov10-23/+29
2017-02-06bridge: modify bridge and port to have often accessed fields in one cache lineNikolay Aleksandrov1-23/+20
2017-02-06net: remove ndo_neigh_{construct, destroy} from stacked devicesIdo Schimmel1-2/+0
2017-02-03Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf-nextDavid S. Miller3-32/+49
2017-02-03bridge: vlan dst_metadata hooks in ingress and egress pathsRoopa Prabhu6-2/+82
2017-02-03bridge: per vlan dst_metadata netlink supportRoopa Prabhu7-48/+641
2017-02-02netfilter: allow logging from non-init namespacesMichal Kubeček1-1/+1