summaryrefslogtreecommitdiff
path: root/samples/bpf/xdp_tx_iptunnel_user.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2022-02-03 01:59:16 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2022-02-03 18:32:25 +0300
commit1e4edb6d8c4f045823291862e7e28591cb6f2067 (patch)
tree3c8240d57d32432db4e88d68f76d9258d98c7c15 /samples/bpf/xdp_tx_iptunnel_user.c
parente4e284a8c0d9823c07ee674445de05928be67231 (diff)
downloadlinux-1e4edb6d8c4f045823291862e7e28591cb6f2067.tar.xz
samples/bpf: Get rid of bpf_prog_load_xattr() use
Remove all the remaining uses of deprecated bpf_prog_load_xattr() API. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/bpf/20220202225916.3313522-7-andrii@kernel.org
Diffstat (limited to 'samples/bpf/xdp_tx_iptunnel_user.c')
-rw-r--r--samples/bpf/xdp_tx_iptunnel_user.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/samples/bpf/xdp_tx_iptunnel_user.c b/samples/bpf/xdp_tx_iptunnel_user.c
index 7370c03c96fc..2e811e4331cc 100644
--- a/samples/bpf/xdp_tx_iptunnel_user.c
+++ b/samples/bpf/xdp_tx_iptunnel_user.c
@@ -152,9 +152,6 @@ static int parse_ports(const char *port_str, int *min_port, int *max_port)
int main(int argc, char **argv)
{
- struct bpf_prog_load_attr prog_load_attr = {
- .prog_type = BPF_PROG_TYPE_XDP,
- };
int min_port = 0, max_port = 0, vip2tnl_map_fd;
const char *optstr = "i:a:p:s:d:m:T:P:FSNh";
unsigned char opt_flags[256] = {};
@@ -162,6 +159,7 @@ int main(int argc, char **argv)
__u32 info_len = sizeof(info);
unsigned int kill_after_s = 0;
struct iptnl_info tnl = {};
+ struct bpf_program *prog;
struct bpf_object *obj;
struct vip vip = {};
char filename[256];
@@ -259,15 +257,20 @@ int main(int argc, char **argv)
}
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
- prog_load_attr.file = filename;
- if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd))
+ obj = bpf_object__open_file(filename, NULL);
+ if (libbpf_get_error(obj))
return 1;
- if (!prog_fd) {
- printf("bpf_prog_load_xattr: %s\n", strerror(errno));
+ prog = bpf_object__next_program(obj, NULL);
+ bpf_program__set_type(prog, BPF_PROG_TYPE_XDP);
+
+ err = bpf_object__load(obj);
+ if (err) {
+ printf("bpf_object__load(): %s\n", strerror(errno));
return 1;
}
+ prog_fd = bpf_program__fd(prog);
rxcnt_map_fd = bpf_object__find_map_fd_by_name(obj, "rxcnt");
vip2tnl_map_fd = bpf_object__find_map_fd_by_name(obj, "vip2tnl");