xdp-tools/SOURCES/xdp-tools-1.1.1-xdp-filter-...

31 lines
1.1 KiB
Diff

commit 5fb355a7c9a1fdd5842c4b9dbd5e48ba6b767921
Author: Toke Høiland-Jørgensen <toke@redhat.com>
Date: Wed Feb 10 16:59:08 2021 +0100
xdp-filter: Check whether we have already been loaded
Now that we can attach multiple programs to an interface, xdp-filter will
happily load itself multiple times on the same interface. Fix that by
checking if it's already loaded before attempting a new load.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
diff --git a/xdp-filter/xdp-filter.c b/xdp-filter/xdp-filter.c
index 08cfd722e169..895dbd5750b2 100644
--- a/xdp-filter/xdp-filter.c
+++ b/xdp-filter/xdp-filter.c
@@ -268,6 +268,13 @@ int do_load(const void *cfg, const char *pin_root_path)
}
features |= opt->policy_mode;
+ err = get_pinned_program(&opt->iface, pin_root_path, NULL, &p);
+ if (!err) {
+ pr_warn("xdp-filter is already loaded on %s\n", opt->iface.ifname);
+ xdp_program__close(p);
+ return EXIT_FAILURE;
+ }
+
print_flags(featbuf, sizeof(featbuf), print_features, features);
pr_debug("Looking for eBPF program with features %s\n", featbuf);