Re: Race between kernel and udevd uevents
Lukas Wunner
Mon Apr 16 08:21:43 2018
On Wed, Apr 11, 2018 at 05:13:50PM +0100, Roy Marples wrote:
> 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?
Indeed this fixes the issue, I was able to carry out 30 consecutive
USB bus reset and dhcpcd always brought up the interface correctly,
regardless of uevent ordering. Thanks a lot!
(The patch was mangled, probably because of copypasta or Thunderbird,
I'm attaching a fixed up version in case anyone else wants to test it,
this applies cleanly with --fuzz=0 to current master.)
Kind regards,
Lukas
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;
}
Archive administrator: postmaster@marples.name