diff options
| author | Felix Fietkau | 2021-11-04 13:01:55 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2021-11-04 13:01:56 +0000 |
| commit | 675238bc2ce55d00ac842e63e40ad3951a3849cf (patch) | |
| tree | 19c4be70d51b850236a8e2da2a3fb21346305151 | |
| parent | f25ded617478296ae78cd127100859662c414d10 (diff) | |
| download | qosify-675238bc2ce55d00ac842e63e40ad3951a3849cf.tar.gz | |
loader: always reinitialize programs
Improves reliability of upgrading the package
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | loader.c | 17 | ||||
| -rw-r--r-- | main.c | 5 | ||||
| -rw-r--r-- | qosify.h | 2 |
3 files changed, 6 insertions, 18 deletions
@@ -39,24 +39,17 @@ static void qosify_fill_rodata(struct bpf_object *obj, uint32_t flags) } static int -qosify_create_program(const char *suffix, uint32_t flags, bool *force_init) +qosify_create_program(const char *suffix, uint32_t flags) { DECLARE_LIBBPF_OPTS(bpf_object_open_opts, opts, .pin_root_path = CLASSIFY_DATA_PATH, ); struct bpf_program *prog; struct bpf_object *obj; - struct stat st; char path[256]; int err; snprintf(path, sizeof(path), CLASSIFY_PIN_PATH "_" "%s", suffix); - if (!*force_init) { - if (stat(path, &st) == 0) - return 0; - - *force_init = true; - } obj = bpf_object__open_file(CLASSIFY_PROG_PATH, &opts); err = libbpf_get_error(obj); @@ -95,7 +88,7 @@ qosify_create_program(const char *suffix, uint32_t flags, bool *force_init) return 0; } -int qosify_loader_init(bool force_init) +int qosify_loader_init(void) { static const struct { const char *suffix; @@ -109,8 +102,7 @@ int qosify_loader_init(bool force_init) glob_t g; int i; - if (force_init && - glob(CLASSIFY_DATA_PATH "/*", 0, NULL, &g) == 0) { + if (glob(CLASSIFY_DATA_PATH "/*", 0, NULL, &g) == 0) { for (i = 0; i < g.gl_pathc; i++) unlink(g.gl_pathv[i]); } @@ -121,8 +113,7 @@ int qosify_loader_init(bool force_init) qosify_init_env(); for (i = 0; i < ARRAY_SIZE(progs); i++) { - if (qosify_create_program(progs[i].suffix, progs[i].flags, - &force_init)) + if (qosify_create_program(progs[i].suffix, progs[i].flags)) return -1; } @@ -14,7 +14,6 @@ static int usage(const char *progname) { fprintf(stderr, "Usage: %s [options]\n" "Options:\n" - " -f: force reload of BPF programs\n" " -l <file> Load defaults from <file>\n" " -o only load program/maps without running as daemon\n" "\n", progname); @@ -25,14 +24,12 @@ static int usage(const char *progname) int main(int argc, char **argv) { const char *load_file = NULL; - bool force_init = false; bool oneshot = false; int ch; while ((ch = getopt(argc, argv, "fl:o")) != -1) { switch (ch) { case 'f': - force_init = true; break; case 'l': load_file = optarg; @@ -45,7 +42,7 @@ int main(int argc, char **argv) } } - if (qosify_loader_init(force_init)) + if (qosify_loader_init()) return 2; if (qosify_map_init()) @@ -66,7 +66,7 @@ struct qosify_map_entry { extern int qosify_map_timeout; extern struct qosify_config config; -int qosify_loader_init(bool force_init); +int qosify_loader_init(void); int qosify_map_init(void); int qosify_map_dscp_value(const char *val); |