procd, possible hotplug issue?

e9hack e9hack at gmail.com
Tue Feb 20 14:47:49 PST 2024


Am 20.02.2024 um 14:14 schrieb Paul D:
> 
> Could you show an example of this?
> 

I modified /usr/lib/dnsmasq/dhcp-script.sh to see additional variables in the syslog:

--- dhcp-script.sh.orig 2024-02-14 16:22:53.000000000 +0100
+++ dhcp-script.sh      2024-02-20 22:55:33.000000000 +0100
@@ -50,4 +50,7 @@ esac

  json_close_array env

-[ -n "$hotplugobj" ] && ubus call hotplug.${hotplugobj} call "$(json_dump)"
+[ -n "$hotplugobj" ] && {
+       logger -t dhcp-script "ubus call hotplug.${hotplugobj} call \"$(json_dump)\""
+       ubus call hotplug.${hotplugobj} call "$(json_dump)"
+}


'logread -e 192.168.104.82' with HOSTNAME empty shows:
Tue Feb 20 23:14:33 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=update", "HOSTNAME=" ] }"
Tue Feb 20 23:14:33 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=update", "HOSTNAME=" ] }"
Tue Feb 20 23:14:34 2024 user.notice nft-qos-monitor: ACTION=update, MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
Tue Feb 20 23:14:34 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=add" ] }"
Tue Feb 20 23:14:34 2024 user.notice nft-qos-dynamic: ACTION=update, MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
Tue Feb 20 23:14:35 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=add" ] }"
Tue Feb 20 23:14:35 2024 user.notice nft-qos-monitor: ACTION=update, MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
Tue Feb 20 23:14:36 2024 user.notice nft-qos-dynamic: ACTION=update, MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9

'logread -e 192.168.104.84' with HOSTNAME set shows:
Tue Feb 20 23:14:34 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ "MACADDR=bb:bb:bb:bb:bb:bb", "IPADDR=192.168.104.84", "ACTION=update", "HOSTNAME=raspberrypi2" ] }"
Tue Feb 20 23:14:34 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ "MACADDR=bb:bb:bb:bb:bb:bb", "IPADDR=192.168.104.84", "ACTION=add" ] }"
Tue Feb 20 23:14:35 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ "MACADDR=bb:bb:bb:bb:bb:bb", "IPADDR=192.168.104.84", "ACTION=add" ] }"
Tue Feb 20 23:14:36 2024 user.notice nft-qos-monitor: ACTION=update, MACADDR=bb:bb:bb:bb:bb:bb, IPADDR=192.168.104.84, HOSTNAME=raspberrypi2
Tue Feb 20 23:14:36 2024 user.notice nft-qos-dynamic: ACTION=update, MACADDR=bb:bb:bb:bb:bb:bb, IPADDR=192.168.104.84, HOSTNAME=raspberrypi2

WLAN-DSL9 is the router name:
root at WLAN-DSL9:~# echo $HOSTNAME
WLAN-DSL9

If I replace HOSTNAME by DHCP_HOSTNAME in /usr/lib/dnsmasq/dhcp-script.sh, /etc/hotplug.d/dhcp/00-nft-qos-monitor and /etc/hotplug.d/dhcp/01-nft-qos-dynamic, I get the following output:

Tue Feb 20 23:44:43 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=update", "DHCP_HOSTNAME=" ] }"
Tue Feb 20 23:44:43 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=update", "DHCP_HOSTNAME=" ] }"
Tue Feb 20 23:44:44 2024 user.notice nft-qos-monitor: ACTION=update, MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
Tue Feb 20 23:44:44 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=add" ] }"
Tue Feb 20 23:44:44 2024 user.notice nft-qos-dynamic: ACTION=update, MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
Tue Feb 20 23:44:45 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=add" ] }"
Tue Feb 20 23:44:45 2024 user.notice nft-qos-monitor: ACTION=update, MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
Tue Feb 20 23:44:46 2024 user.notice nft-qos-dynamic: ACTION=update, MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=

If procd generates the hotplug call, it filters out empty variables. From procd hotplug-dispatch.c line 239:

		*tmp = '\0';
		if (validate_envvarname(enve))
			continue;
		*tmp = '=';

		if (!strlen(++tmp))
			continue;

Regards,
Hartmut


  




More information about the openwrt-devel mailing list