]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - samples/bpf/tc_l2_redirect_user.c
1 /* Copyright (c) 2016 Facebook
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation.
7 #include <linux/unistd.h>
18 static void usage(void)
20 printf("Usage: tc_l2_ipip_redirect [...]\n");
21 printf(" -U <file> Update an already pinned BPF array\n");
22 printf(" -i <ifindex> Interface index\n");
23 printf(" -h Display this help\n");
26 int main(int argc
, char **argv
)
28 const char *pinned_file
= NULL
;
35 while ((opt
= getopt(argc
, argv
, "F:U:i:")) != -1) {
42 ifindex
= atoi(optarg
);
50 if (ifindex
< 0 || !pinned_file
) {
55 array_fd
= bpf_obj_get(pinned_file
);
57 fprintf(stderr
, "bpf_obj_get(%s): %s(%d)\n",
58 pinned_file
, strerror(errno
), errno
);
62 /* bpf_tunnel_key.remote_ipv4 expects host byte orders */
63 ret
= bpf_update_elem(array_fd
, &array_key
, &ifindex
, 0);
65 perror("bpf_update_elem");