diff options
author | Dan Williams <dcbw@redhat.com> | 2014-03-31 15:06:22 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2014-04-02 09:37:15 -0500 |
commit | 55704170caed97eb26b3853af04cbbf332845966 (patch) | |
tree | 8fbe5f49d76ec39453fff9a31252c2d553407de0 /src/nm-dcb.c | |
parent | 18fd3e45d8db3428d4840d7cb9ea1980a22ef7de (diff) | |
download | NetworkManager-55704170caed97eb26b3853af04cbbf332845966.tar.gz |
dcb: wait for carrier down/up after disabling FCoE
Diffstat (limited to 'src/nm-dcb.c')
-rw-r--r-- | src/nm-dcb.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/nm-dcb.c b/src/nm-dcb.c index 428c61e67d..3bdbf7d5ed 100644 --- a/src/nm-dcb.c +++ b/src/nm-dcb.c @@ -384,11 +384,43 @@ nm_dcb_setup (const char *iface, NMSettingDcb *s_dcb, GError **error) return success; } +static void +carrier_wait (const char *iface, guint secs, gboolean up) +{ + int ifindex, count = secs * 10; + + g_return_if_fail (iface != NULL); + + ifindex = nm_platform_link_get_ifindex (iface); + if (ifindex > 0) { + /* To work around driver quirks and lldpad handling of carrier status, + * we must wait a short period of time to see if the carrier goes + * down, and then wait for the carrier to come back up again. Otherwise + * subsequent lldpad calls may fail with "Device not found, link down + * or DCB not enabled" errors. + */ + nm_log_dbg (LOGD_DCB, "(%s): cleanup waiting for carrier %s", + iface, up ? "up" : "down"); + g_usleep (G_USEC_PER_SEC / 4); + while (nm_platform_link_is_connected (ifindex) != up && count-- > 0) { + g_usleep (G_USEC_PER_SEC / 10); + nm_platform_link_refresh (ifindex); + } + } +} + gboolean nm_dcb_cleanup (const char *iface, GError **error) { /* Ignore FCoE cleanup errors */ _fcoe_cleanup (iface, run_helper, GUINT_TO_POINTER (FCOEADM), NULL); + + /* Must pause a bit to wait for carrier-up since disabling FCoE may + * cause the device to take the link down, making lldpad return errors. + */ + carrier_wait (iface, 2, FALSE); + carrier_wait (iface, 4, TRUE); + return _dcb_cleanup (iface, run_helper, GUINT_TO_POINTER (DCBTOOL), error); } |