From f22370b1b7bbfc8c87e73c9e637cb9b896eb111e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20L=C3=BCssing?= Date: Mon, 5 Dec 2022 16:03:02 +0100 Subject: [PATCH] bpfcountd: remove incomplete/broken namespace feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The original idea of the extra namespace variable was to set up bpfcountd from other daemons etc. independent of what a user configured in /etc/config/bpfcountd for instance. Like: $ UCI_CONFIG_DIR=/var/run/bpfcountd/gluon-config \ /etc/init.d/bpfcountd start "" gluon However there are still issues with this approach: 1) Instance specific stop calls like: $ /etc/init.d/bpfcountd stop " will not stop the according namespaced instance, as the stop() in /etc/rc.common will call procd_kill() without the namespace prefix. And we can't overwrite that behaviour. And asking a user to use "... start " and "... stop ." is confusing. (and currently "... stop ." would not remove the correct unix socket). 2) A stop call without an instance/config name would always stop all instances. So the namespace variable would be ignored. While start without an instance "works", but: 3) It would stop any process that is not in the currently selected UCI_CONFIG_DIR. As all this is not easily fixable without changing OpenWrt internals, just remove the whole namespace idea for now. Signed-off-by: Linus Lüssing --- net/bpfcountd/files/etc/init.d/bpfcountd | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/net/bpfcountd/files/etc/init.d/bpfcountd b/net/bpfcountd/files/etc/init.d/bpfcountd index 1639da720c..2db2a4bac4 100755 --- a/net/bpfcountd/files/etc/init.d/bpfcountd +++ b/net/bpfcountd/files/etc/init.d/bpfcountd @@ -10,7 +10,6 @@ UNIXSOCKDIR=/var/run/bpfcountd bpfcountd_start() { local cfg="$1" - local namespace="$2" local disabled local ifname @@ -37,14 +36,12 @@ bpfcountd_start() { return 0 } - [ -z "$namespace" ] && namespace="bpfcountd" - - procd_open_instance "$namespace.$cfg" + procd_open_instance "$cfg" procd_set_param command /usr/sbin/bpfcountd procd_append_param command -i "$ifname" procd_append_param command -f "$filterfile" - procd_append_param command -u $UNIXSOCKDIR/"$namespace.$cfg".sock + procd_append_param command -u $UNIXSOCKDIR/"$cfg".sock [ -n "$prefilter" ] && procd_append_param command -F "$prefilter" [ -n "$buffersize" ] && procd_append_param command -b "$buffersize" @@ -56,7 +53,6 @@ bpfcountd_start() { start_service() { local cfg="$1" - local namespace="$2" local instance_found=0 . /lib/functions/network.sh @@ -75,22 +71,19 @@ start_service() { if [ -n "$cfg" ]; then [ "$instance_found" -gt 0 ] || return - bpfcountd_start "$cfg" "$namespace" + bpfcountd_start "$cfg" else - config_foreach bpfcountd_start bpfcountd "$namespace" + config_foreach bpfcountd_start bpfcountd fi } stop_service() { local cfg="$1" - local namespace="$2" - - [ -z "$namespace" ] && namespace="bpfcountd" if [ -n "$cfg" ]; then - rm $UNIXSOCKDIR/$namespace.$cfg.sock + rm $UNIXSOCKDIR/$cfg.sock else - rm $UNIXSOCKDIR/$namespace.*.sock + rm $UNIXSOCKDIR/*.sock fi }