xdp-dns UI: change running state check

Status relies on checking if xdp_dns_log is running,
but xdp_dns_log could mysteriously disappear at some point,
which result in XDP DNS Blocklist shows Stopped,
let /etc/rc.d/init.d/xdpdns status relies on if the
xdp_dns_denylist XDP program is still attached
to green0 interface.

two related issues

https://github.com/vincentmli/BPFire/issues/50
https://github.com/vincentmli/BPFire/issues/49

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
This commit is contained in:
Vincent Li
2024-10-05 23:08:30 +00:00
parent 4c2fd11de2
commit 4d6f8d68a3
2 changed files with 11 additions and 2 deletions

View File

@@ -55,6 +55,15 @@ unload_dnsblock () {
fi
}
is_xdpdns_attached () {
/usr/sbin/xdp-loader status green0 | grep -w 'xdp_dns_denylist' >> /dev/null
if [ $? -eq 0 ]; then
echo "xdp_dns_denylist is attached to green0"
else
echo "xdp_dns_denylist is not attached to green0"
fi
}
case "$1" in
start)
@@ -74,7 +83,7 @@ case "$1" in
;;
status)
statusproc /usr/sbin/xdp_dns_log
is_xdpdns_attached
;;
restart)