]>
git.ipfire.org Git - thirdparty/linux.git/blob - samples/bpf/tc_l2_redirect_user.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2016 Facebook
4 #include <linux/unistd.h>
15 static void usage(void)
17 printf("Usage: tc_l2_ipip_redirect [...]\n");
18 printf(" -U <file> Update an already pinned BPF array\n");
19 printf(" -i <ifindex> Interface index\n");
20 printf(" -h Display this help\n");
23 int main(int argc
, char **argv
)
25 const char *pinned_file
= NULL
;
32 while ((opt
= getopt(argc
, argv
, "F:U:i:")) != -1) {
39 ifindex
= atoi(optarg
);
47 if (ifindex
< 0 || !pinned_file
) {
52 array_fd
= bpf_obj_get(pinned_file
);
54 fprintf(stderr
, "bpf_obj_get(%s): %s(%d)\n",
55 pinned_file
, strerror(errno
), errno
);
59 /* bpf_tunnel_key.remote_ipv4 expects host byte orders */
60 ret
= bpf_map_update_elem(array_fd
, &array_key
, &ifindex
, 0);
62 perror("bpf_map_update_elem");