netifd: add missing error checks to packet steering script
authorFelix Fietkau <nbd@nbd.name>
Mon, 15 Apr 2024 10:32:35 +0000 (12:32 +0200)
committerFelix Fietkau <nbd@nbd.name>
Mon, 15 Apr 2024 11:46:05 +0000 (13:46 +0200)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/config/netifd/files/usr/libexec/network/packet-steering.uc

index f146a96e419895abd5eb1770ef52fc8c4e62a76d..72f96024d8101b10213a1f0626030b0f01019e1d 100755 (executable)
@@ -27,6 +27,8 @@ for (let arg in ARGV) {
 function task_name(pid)
 {
        let stat = open(`/proc/${pid}/status`, "r");
+       if (!stat)
+               return;
        let line = stat.read("line");
        stat.close();
        return trim(split(line, "\t", 2)[1]);
@@ -35,8 +37,11 @@ function task_name(pid)
 function set_task_cpu(pid, cpu) {
        if (disable)
                cpu = join(",", map(cpus, (cpu) => cpu.id));
+       let name = task_name(pid);
+       if (!name)
+               return;
        if (debug || do_nothing)
-               warn(`taskset -p -c ${cpu} ${task_name(pid)}\n`);
+               warn(`taskset -p -c ${cpu} ${name}\n`);
        if (!do_nothing)
                system(`taskset -p -c ${cpu} ${pid}`);
 }