summaryrefslogtreecommitdiff
path: root/kmodloader.c
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2017-01-14 01:00:35 +0800
committerFelix Fietkau <nbd@nbd.name>2017-01-15 18:54:24 +0100
commit14839f0acc15197e360299b7f714b8f9ff97ba17 (patch)
treeac7bcd9473f393774a31d9b3dbfeb80625298c10 /kmodloader.c
parent6e3c6dcf922e30282d2c49a643253e58fffab362 (diff)
downloadubox-14839f0acc15197e360299b7f714b8f9ff97ba17.tar.gz
kmodloader: make insert_module() idempotent
To fix spurious error messages in the following situation 1. scan loaded modules 2. load wireguard.ko and the module itself will request xt_hashlimit to be loaded 3. xt_hashlimit is still in PROBE state here so we also try to load it, but init_module() returns EEXIST Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Diffstat (limited to 'kmodloader.c')
-rw-r--r--kmodloader.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/kmodloader.c b/kmodloader.c
index bcb213b..729027a 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -574,8 +574,11 @@ static int insert_module(char *path, const char *options)
}
data = malloc(s.st_size);
- if (read(fd, data, s.st_size) == s.st_size)
+ if (read(fd, data, s.st_size) == s.st_size) {
ret = syscall(__NR_init_module, data, (unsigned long) s.st_size, options);
+ if (errno == EEXIST)
+ ret = 0;
+ }
else
ULOG_ERR("failed to read full module %s\n", path);