openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
160 stars 96 forks source link

Bug: odhcp doesn't handle static lease (dhcp.@host[#]) entries with multiple MAC addresses #183

Closed ktetzlaff closed 2 years ago

ktetzlaff commented 2 years ago

In https://openwrt.org/docs/guide-user/base-system/dhcp#static_leases, OpenWrt defines the /mac/ option of a DHCP Static Lease as:

mac | string | no | (none) | The hardware address(es) of this host, separated by spaces.

This explicitly allows to define leases with multiple MAC addresses. However, /odhcpd/ skips such /leases/ during configuration.

Here's the code fragment which handles MAC addresses of static leases in set_lease(..) (found in config.c):

    if ((c = tb[LEASE_ATTR_MAC]))
        if (!ether_aton_r(blobmsg_get_string(c), &l->mac))
            goto err;

As can be seen, the code doesn't have any special handling for the multiple MAC case. So ether_aton_r(..) returns NULL which triggers goto err; and the lease doesn't make it into /leases/.

ktetzlaff commented 2 years ago

Just noticed that bugs should be reported in the main OpenWrt repo. So I created another issue: openwrt/openwrt#9598.