summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2021-11-04 13:01:55 +0000
committerFelix Fietkau2021-11-04 13:01:56 +0000
commit675238bc2ce55d00ac842e63e40ad3951a3849cf (patch)
tree19c4be70d51b850236a8e2da2a3fb21346305151
parentf25ded617478296ae78cd127100859662c414d10 (diff)
downloadqosify-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.c17
-rw-r--r--main.c5
-rw-r--r--qosify.h2
3 files changed, 6 insertions, 18 deletions
diff --git a/loader.c b/loader.c
index 539aae4..0b9449f 100644
--- a/loader.c
+++ b/loader.c
@@ -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;
}
diff --git a/main.c b/main.c
index 0352183..e8ddda5 100644
--- a/main.c
+++ b/main.c
@@ -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())
diff --git a/qosify.h b/qosify.h
index f9d8026..1fc1999 100644
--- a/qosify.h
+++ b/qosify.h
@@ -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);