ionic: wait on queue start until after IFF_UP
Subsystems (3)
PATCH 1/1 ionic: wait on queue start until after IFF_UP
The netif_running() test looks at __LINK_STATE_START which gets set before ndo_open() is called, there is a window of time between that and when the queues are actually ready to be run. If ionic_check_link_status() notices that the link is up very soon after netif_running() becomes true, it might try to run the queues before they are ready, causing all manner of potential issues. Since the netdev->flags IFF_UP isn't set until after ndo_open() returns, we can wait for that before we allow ionic_check_link_status() to start the queues.
On the way back to close, __LINK_STATE_START is cleared before calling ndo_stop(), and IFF_UP is cleared after. Both of these need to be true in order to safely stop the queues from ionic_check_link_status().
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +2 -2
@@ -116,7 +116,7 @@ static void ionic_link_status_check(struct ionic_lif *lif)netif_carrier_on (netdev); } -if (netif_running (lif->netdev)) +if (lif->netdev->flags &IFF_UP &&netif_running (lif->netdev))ionic_start_queues (lif); }else {if (netif_carrier_ok (netdev)) {
@@ -124,7 +124,7 @@ static void ionic_link_status_check(struct ionic_lif *lif)netif_carrier_off (netdev); } -if (netif_running (lif->netdev)) +if (lif->netdev->flags &IFF_UP &&netif_running (lif->netdev))ionic_stop_queues (lif); }
Signature · 1 line
2.17.1
David Miller
maintainerFrom: Shannon Nelson <[email protected]>
Date: Mon, 8 Jun 2020 20:41:43 -0700
Quoted 10 lines
The
netif_running()test looks at__LINK_STATE_STARTwhich gets set beforendo_open()is called, there is a window of time between that and when the queues are actually ready to be run. Ifionic_check_link_status()notices that the link is up very soon afternetif_running()becomes true, it might try to run the queues before they are ready, causing all manner of potential issues. Since thenetdev->flagsIFF_UPisn't set until afterndo_open()returns, we can wait for that before we allowionic_check_link_status()to start the queues.
Quoted 7 lines
On the way back to close,
__LINK_STATE_STARTis cleared before callingndo_stop(), andIFF_UPis cleared after. Both of these need to be true in order to safely stop the queues fromionic_check_link_status().Fixes 49d3b493673a ("ionic: disable the queues on link down")Signed-off-by Shannon Nelson <[email protected]>
What will make sure the queues actually get started if this event's queue start gets skipped in this scenerio?
This code is only invoked when the link status changes or when the firmware is started.
Quoted 18 lines · David Miller
From: Shannon Nelson <[email protected]>
Date: Mon, 8 Jun 2020 20:41:43 -0700Quoted 15 lines
The
netif_running()test looks at__LINK_STATE_STARTwhich gets set beforendo_open()is called, there is a window of time between that and when the queues are actually ready to be run. Ifionic_check_link_status()notices that the link is up very soon afternetif_running()becomes true, it might try to run the queues before they are ready, causing all manner of potential issues. Since thenetdev->flagsIFF_UPisn't set until afterndo_open()returns, we can wait for that before we allowionic_check_link_status()to start the queues.On the way back to close,
__LINK_STATE_STARTis cleared before callingndo_stop(), andIFF_UPis cleared after. Both of these need to be true in order to safely stop the queues fromionic_check_link_status().
Quoted 7 lines
Quoted 2 lines
Fixes 49d3b493673a ("ionic: disable the queues on link down")Signed-off-by Shannon Nelson <[email protected]>What will make sure the queues actually get started if this event's queue start gets skipped in this scenerio?
This code is only invoked when the link status changes or when the firmware is started.
If the link is already seen as up before ionic_open() is called it starts the queues at that point.
If link isn't seen until after ionic_open(), then the queues are started in this periodic link check.
sln
David Miller
maintainerFrom: Shannon Nelson <[email protected]>
Date: Tue, 9 Jun 2020 12:51:17 -0700
Quoted 24 lines · David Miller
Quoted 23 lines
From: Shannon Nelson <[email protected]>
Date: Mon, 8 Jun 2020 20:41:43 -0700Quoted 10 lines
The
netif_running()test looks at__LINK_STATE_STARTwhich gets set beforendo_open()is called, there is a window of time between that and when the queues are actually ready to be run. Ifionic_check_link_status()notices that the link is up very soon afternetif_running()becomes true, it might try to run the queues before they are ready, causing all manner of potential issues. Since thenetdev->flagsIFF_UPisn't set until afterndo_open()returns, we can wait for that before we allowionic_check_link_status()to start the queues.Quoted 7 lines
On the way back to close,
__LINK_STATE_STARTis cleared before callingndo_stop(), andIFF_UPis cleared after. Both of these need to be true in order to safely stop the queues fromionic_check_link_status().Fixes 49d3b493673a ("ionic: disable the queues on link down")Signed-off-by Shannon Nelson <[email protected]>What will make sure the queues actually get started if this event's queue start gets skipped in this scenerio?
Quoted 8 lines
Quoted 2 lines
This code is only invoked when the link status changes or when the firmware is started.
If the link is already seen as up before
ionic_open()is called it starts the queues at that point.If link isn't seen until after
ionic_open(), then the queues are started in this periodic link check.
I'm saying if it happens in the race condition you mention that you are protecting against, where running is true and IFF_UP is not.
The link check is periodic? It looks like it triggers when the link state changes to me.
Quoted 32 lines · David Miller
From: Shannon Nelson <[email protected]>
Date: Tue, 9 Jun 2020 12:51:17 -0700Quoted 29 lines · David Miller
Quoted 18 lines
From: Shannon Nelson <[email protected]>
Date: Mon, 8 Jun 2020 20:41:43 -0700Quoted 15 lines
The
netif_running()test looks at__LINK_STATE_STARTwhich gets set beforendo_open()is called, there is a window of time between that and when the queues are actually ready to be run. Ifionic_check_link_status()notices that the link is up very soon afternetif_running()becomes true, it might try to run the queues before they are ready, causing all manner of potential issues. Since thenetdev->flagsIFF_UPisn't set until afterndo_open()returns, we can wait for that before we allowionic_check_link_status()to start the queues.On the way back to close,
__LINK_STATE_STARTis cleared before callingndo_stop(), andIFF_UPis cleared after. Both of these need to be true in order to safely stop the queues fromionic_check_link_status().Quoted 7 lines
Quoted 2 lines
Fixes 49d3b493673a ("ionic: disable the queues on link down")Signed-off-by Shannon Nelson <[email protected]>What will make sure the queues actually get started if this event's queue start gets skipped in this scenerio?
This code is only invoked when the link status changes or when the firmware is started.
If the link is already seen as up before
ionic_open()is called it starts the queues at that point.
Quoted 7 lines
Quoted 2 lines
If link isn't seen until after
ionic_open(), then the queues are started in this periodic link check.I'm saying if it happens in the race condition you mention that you are protecting against, where running is true and
IFF_UPis not.The link check is periodic? It looks like it triggers when the link state changes to me.
Yes, the link check is triggered by the periodic watchdog ionic_watchdog_cb(), every 5 seconds.
sln
David Miller
maintainerFrom: Shannon Nelson <[email protected]>
Date: Tue, 9 Jun 2020 13:11:28 -0700
Quoted 2 lines
Yes, the link check is triggered by the periodic watchdog
ionic_watchdog_cb(), every 5 seconds.
Thanks for explaining.
Applied and queued up for v5.7 -stable, thank you.