dhcpcd-discuss

Re: Race between kernel and udevd uevents

Roy Marples

Wed Apr 11 16:13:21 2018

Hi Lukas

On 11/04/2018 16:28, Lukas Wunner wrote:
when resetting a USB-attached Ethernet interface using the USBDEVFS_RESET
ioctl(), the interface briefly disappears, then reappears.  This results
in add and remove uevents from both the kernel and udevd.

If those uevents are interleaved as
    kernel remove
    kernel add
    udevd remove
    udevd add
then dhcpcd fails to assign addresses on reappearance of the interface.

If on the other hand the uevents are ordered as
    kernel remove
    udevd remove
    kernel add
    udevd add
then everything works as expected.

Adding --nodev on the command line or nodev to dhcpcd.conf makes the
issue go away.

Detailed debug logs are available at
https://github.com/RPi-Distro/repo/issues/102

Does this patch help?

diff --git a/src/if-linux.c b/src/if-linux.c
index 152cffed..efd3ec79 100644
--- a/src/if-linux.c
+++ b/src/if-linux.c
@@ -770,7 +770,10 @@ link_netlink(struct dhcpcd_ctx *ctx, struct interface *ifp,
        }

        if (nlm->nlmsg_type == RTM_DELLINK) {
-               dhcpcd_handleinterface(ctx, -1, ifn);
+               /* If are listening to a dev manager, let that remove
+                * the interface rather than the kernel. */
+               if (dev_listening(ctx) < 1)
+                       dhcpcd_handleinterface(ctx, -1, ifn);
                return 0;
        }


Let me know!

Roy

Follow-Ups:
Re: Race between kernel and udevd ueventsLukas Wunner
Re: Race between kernel and udevd ueventsLukas Wunner
References:
Race between kernel and udevd ueventsLukas Wunner
Archive administrator: postmaster@marples.name