Skip to content

Commit

Permalink
net: ipconfig: Release the rtnl_lock while waiting for carrier
Browse files Browse the repository at this point in the history
While waiting for a carrier to come on one of the netdevices, some
devices will require to take the rtnl lock at some point to fully
initialize all parts of the link.

That's the case for SFP, where the rtnl is taken when a module gets
detected. This prevents mounting an NFS rootfs over an SFP link.

This means that while ipconfig waits for carriers to be detected, no SFP
modules can be detected in the meantime, it's only detected after
ipconfig times out.

This commit releases the rtnl_lock while waiting for the carrier to come
up, and re-takes it to check the for the init device and carrier status.

Signed-off-by: Maxime Chevallier <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
minimaxwell authored and davem330 committed Oct 28, 2021
1 parent 442e796 commit ee046d9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions net/ipv4/ipconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ static int __init ic_open_devs(void)
dev->name, able, d->xid);
}
}
/* Devices with a complex topology like SFP ethernet interfaces needs
* the rtnl_lock at init. The carrier wait-loop must therefore run
* without holding it.
*/
rtnl_unlock();

/* no point in waiting if we could not bring up at least one device */
if (!ic_first_dev)
Expand All @@ -274,9 +279,13 @@ static int __init ic_open_devs(void)
msecs_to_jiffies(carrier_timeout * 1000))) {
int wait, elapsed;

rtnl_lock();
for_each_netdev(&init_net, dev)
if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
if (ic_is_init_dev(dev) && netif_carrier_ok(dev)) {
rtnl_unlock();
goto have_carrier;
}
rtnl_unlock();

msleep(1);

Expand All @@ -289,7 +298,6 @@ static int __init ic_open_devs(void)
next_msg = jiffies + msecs_to_jiffies(20000);
}
have_carrier:
rtnl_unlock();

*last = NULL;

Expand Down

0 comments on commit ee046d9

Please sign in to comment.