Current "hotplug" docs? (Lease Updates, in Particular)

I'd like to hook a new or updated DHCPv4 / DHCPv6 lease.

https://openwrt.org/docs/guide-user/base-system/hotplug_lede indicates that the two ACTION values are "ifup" and "ifdown". It's not clear to me if a renewal of a lease, or a change in leased IPv4 address, IA_NA, or IA_PD will trigger an "ifup" event. (It's well within my knowledge to be able to determine if there was a change, if the updated-lease event can be caught.)

However

suggests that there is an "ifupdate" action as well.

Will "ifup" capture changes in any of the IPv4/IPv6 leases as well as the initial lease granted?

(I'd normally "play" with this myself, but don't have a DHCPv6 server that hands out IA_PDs configured.)

https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=b32689afd6a661339861086c669e15c936293cf8

Will invoke /etc/hotplug.d/dhcp/* for lease updates, /etc/hotplug.d/neigh/* for neighbour discovery and expiry events and /etc/hotplug.d/tftp/* for TFTP request events.

For the specific action values and available vars refer to https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=package/network/services/dnsmasq/files/dhcp-script.sh

Note that this mechanism currently does not cover odhcpd (the default DHCPv6 server). So IPv6 related events only happen if you use dnsmasq to manage both IPv4 and IPv6 DHCP.

2 Likes

Network restart

There're only iface-type events:

# service network restart
# cat hotplug.log
ACTION='ifdown' DEVICENAME='' HOTPLUG_TYPE='iface' INTERFACE='loopback'
ACTION='ifdown' DEVICENAME='' HOTPLUG_TYPE='iface' INTERFACE='wan'
ACTION='ifdown' DEVICENAME='' HOTPLUG_TYPE='iface' INTERFACE='wan6'
ACTION='ifup' DEVICE='lo' DEVICENAME='' HOTPLUG_TYPE='iface' INTERFACE='loopback'
ACTION='ifup' DEVICE='eth0' DEVICENAME='' HOTPLUG_TYPE='iface' INTERFACE='wan'
ACTION='ifup' DEVICE='eth0' DEVICENAME='' HOTPLUG_TYPE='iface' INTERFACE='wan6'

IPv4 Lease Renew

# killall -SIGUSR1 udhcpc
# cat hotplug.log
ACTION='ifdown' DEVICENAME='' HOTPLUG_TYPE='iface' INTERFACE='wan'
ACTION='ifup' DEVICE='eth0' DEVICENAME='' HOTPLUG_TYPE='iface' INTERFACE='wan'

# ubus call network.interface.wan status
{
        ...
        "data": {
                ...
                "leasetime": 86400	# static
        }
}

Note, there's leasetime-parameter which is static.

IPv6 Lease Renew

# killall -SIGUSR1 odhcp6c

odhcp6c ignores SIGUSR1, there're no log events.

# ubus call network.interface.wan6 status
{
        ...
        "ipv6-address": [
                {
                        ...
                        "preferred": 3598,	# dynamic
                        "valid": 14398		# dynamic
                }
        ],
        ...
        "route": [
                ...
                {
                        ...
                        "valid": 298,		# dynamic
                        ...
                }
        ],
        ...
}

Note, those dynamic parameters are decreasing, but also restoring very quickly to their peak values, so it doesn't look like they ever expire.
And there's no leasetime, so I suspect we might not even see ifupdate-event.
It should be either DHCPv6-protocol specification, or DHCPv6-server implementation.


May be catch those with ubus?

1 Like