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

Write leases then atomically rename lease file #160

Closed vii closed 3 years ago

vii commented 3 years ago

Problem

Consumers of this file need a consistent view.

For example, if /usr/lib/unbound/odhcpd.sh reads a partial file, it may remove many addresses from unbound DNS. Potentially it might also give an incomplete address entry to unbound.

Solution

Write to a temporary file in the same directory (so hopefully same filesystem). Then use the POSIX rename function to atomically replace the lease file when done.

Testing

This compiles, but not sure how to build an opkg to test. I have openwrt checked out, but I only build odhcpd-ipv6only for some reason and I need the full build to test on my network. Would love help!

dedeckeh commented 3 years ago

Did you notice the mentioned issues in combination with unbound ?

dedeckeh commented 3 years ago

Before I look into this further I would like to know if you hit the mentioned issues in combination with unbound as in my previous comment

dedeckeh commented 3 years ago

Closing as I pushed a slightly re-worked patch (https://git.openwrt.org/?p=project/odhcpd.git;a=commitdiff;h=fb55e80394c51d7502bb278f57520dec15a11355)