katran/lib/bpf/xdp_root.c (19 lines of code) (raw):

/* Copyright (C) 2018-present, Facebook, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "bpf.h" #include "bpf_helpers.h" #define ROOT_ARRAY_SIZE 3 struct { __uint(type, BPF_MAP_TYPE_PROG_ARRAY); __type(key, __u32); __type(value, __u32); __uint(max_entries, ROOT_ARRAY_SIZE); } root_array SEC(".maps"); SEC("xdp-root") int xdp_root(struct xdp_md* ctx) { __u32* fd; #pragma clang loop unroll(full) for (__u32 i = 0; i < ROOT_ARRAY_SIZE; i++) { bpf_tail_call(ctx, &root_array, i); } return XDP_PASS; } char _license[] SEC("license") = "GPL";