xen-netback: windows frontend compatibility fixes
Subsystems (3)
PATCH v2 1/2 xen-netback: add a vif-is-connected flag
In reply to Paul DurrantHaving applied my patch to separate vif disconnect and free, I ran into a BUG when testing resume from S3 with a Windows frontend because the vif task pointer was not cleared by xenvif_disconnect() and so a double call to this function tries to stop the thread twice.
Rather than applying a point fix for that issue it seems better to introduce a boolean to indicate whether the vif is connected or not such that repeated calls to either xenvif_connect() or xenvif_disconnect() behave appropriately.
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/interface.c | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-)
drivers/net/xen-netback/common.h +1 -0
@@ -169,6 +169,7 @@ struct xenvif {/* Miscellaneous private stuff. */ struct net_device *dev; +bool connected; };static inline struct xenbus_device *xenvif_to_xenbus_device (struct xenvif *vif)
drivers/net/xen-netback/interface.c +13 -11
@@ -366,7 +366,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,int err = -ENOMEM ;/* Already connected through? */ -if (vif->tx_irq) +if (vif->connected)return 0 ; err =xenvif_map_frontend_rings (vif, tx_ring_ref, rx_ring_ref);
@@ -425,6 +425,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,wake_up_process (vif->task); + vif->connected =1 ;return 0 ; err_rx_unbind:
@@ -453,23 +454,24 @@ void xenvif_carrier_off(struct xenvif *vif)void xenvif_disconnect (struct xenvif *vif) { +if (!vif->connected) +return ; +if (netif_carrier_ok (vif->dev))xenvif_carrier_off (vif); -if (vif->tx_irq) { -if (vif->tx_irq == vif->rx_irq) -unbind_from_irqhandler (vif->tx_irq, vif); -else { -unbind_from_irqhandler (vif->tx_irq, vif); -unbind_from_irqhandler (vif->rx_irq, vif); - } - vif->tx_irq =0 ; +if (vif->tx_irq == vif->rx_irq) +unbind_from_irqhandler (vif->tx_irq, vif); +else { +unbind_from_irqhandler (vif->tx_irq, vif); +unbind_from_irqhandler (vif->rx_irq, vif); } -if (vif->task) -kthread_stop (vif->task); +kthread_stop (vif->task);xenvif_unmap_frontend_rings (vif); + + vif->connected =0 ; }void xenvif_free (struct xenvif *vif)
Signature · 1 line
1.7.10.4
PATCH v2 2/2 xen-netback: handle frontends that fail to transition through Closing
In reply to Paul DurrantSome old Windows frontends fail to transition through the xenbus Closing state and move directly from Connected to Closed. Handle this case properly.
--- drivers/net/xen-netback/xenbus.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/xen-netback/xenbus.c +7 -0
@@ -265,6 +265,13 @@ static void frontend_changed(struct xenbus_device *dev,break ;case XenbusStateClosed: +/* +* Handle frontends which erroneously transition +* directly from Connected to Closed. +*/ +if (dev->state == XenbusStateConnected) +disconnect_backend (dev); +xenbus_switch_state (dev, XenbusStateClosed);if (xenbus_dev_is_online (dev))break ;
Signature · 1 line
1.7.10.4
cover xen-netback: windows frontend compatibility fixes
The following patches fix a couple more issues found when testing with Windows frontends.
v2:
- Add comment in 2/2 to note that state transitions from Connected to Closed are incorrect.
PATCH v2 1/2 xen-netback: add a vif-is-connected flag
Having applied my patch to separate vif disconnect and free, I ran into a BUG when testing resume from S3 with a Windows frontend because the vif task pointer was not cleared by xenvif_disconnect() and so a double call to this function tries to stop the thread twice.
Rather than applying a point fix for that issue it seems better to introduce a boolean to indicate whether the vif is connected or not such that repeated calls to either xenvif_connect() or xenvif_disconnect() behave appropriately.
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/interface.c | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-)
drivers/net/xen-netback/common.h +1 -0
@@ -169,6 +169,7 @@ struct xenvif {/* Miscellaneous private stuff. */ struct net_device *dev; +bool connected; };static inline struct xenbus_device *xenvif_to_xenbus_device (struct xenvif *vif)
drivers/net/xen-netback/interface.c +13 -11
@@ -366,7 +366,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,int err = -ENOMEM ;/* Already connected through? */ -if (vif->tx_irq) +if (vif->connected)return 0 ; err =xenvif_map_frontend_rings (vif, tx_ring_ref, rx_ring_ref);
@@ -425,6 +425,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,wake_up_process (vif->task); + vif->connected =1 ;return 0 ; err_rx_unbind:
@@ -453,23 +454,24 @@ void xenvif_carrier_off(struct xenvif *vif)void xenvif_disconnect (struct xenvif *vif) { +if (!vif->connected) +return ; +if (netif_carrier_ok (vif->dev))xenvif_carrier_off (vif); -if (vif->tx_irq) { -if (vif->tx_irq == vif->rx_irq) -unbind_from_irqhandler (vif->tx_irq, vif); -else { -unbind_from_irqhandler (vif->tx_irq, vif); -unbind_from_irqhandler (vif->rx_irq, vif); - } - vif->tx_irq =0 ; +if (vif->tx_irq == vif->rx_irq) +unbind_from_irqhandler (vif->tx_irq, vif); +else { +unbind_from_irqhandler (vif->tx_irq, vif); +unbind_from_irqhandler (vif->rx_irq, vif); } -if (vif->task) -kthread_stop (vif->task); +kthread_stop (vif->task);xenvif_unmap_frontend_rings (vif); + + vif->connected =0 ; }void xenvif_free (struct xenvif *vif)
Signature · 1 line
1.7.10.4
PATCH v2 2/2 xen-netback: handle frontends that fail to transition through Closing
In reply to Paul DurrantSome old Windows frontends fail to transition through the xenbus Closing state and move directly from Connected to Closed. Handle this case properly.
--- drivers/net/xen-netback/xenbus.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/xen-netback/xenbus.c +7 -0
@@ -265,6 +265,13 @@ static void frontend_changed(struct xenbus_device *dev,break ;case XenbusStateClosed: +/* +* Handle frontends which erroneously transition +* directly from Connected to Closed. +*/ +if (dev->state == XenbusStateConnected) +disconnect_backend (dev); +xenbus_switch_state (dev, XenbusStateClosed);if (xenbus_dev_is_online (dev))break ;
Signature · 1 line
1.7.10.4
Re: [PATCH net-next v2 2/2] xen-netback: handle frontends that fail to transition through Closing
Quoted 2 lines · Paul Durrant
Some old Windows frontends fail to transition through the xenbus Closing state and move directly from Connected to Closed. Handle this case properly.
What happens in this case? Are there other state changes that will do unwanted things?
Bastian
Signature · 2 lines
If there are self-made purgatories, then we all have to live in them. -- Spock, "This Side of Paradise", stardate 3417.7
David Miller
maintainerRe: [PATCH net-next v2 1/2] xen-netback: add a vif-is-connected flag
In reply to Paul DurrantFrom: Paul Durrant <[email protected]>
Date: Fri, 20 Sep 2013 14:57:39 +0100
Quoted 8 lines
drivers/net/xen-netback/common.h +1
-0@@ -169,6 +169,7 @@ struct xenvif {/* Miscellaneous private stuff. */ struct net_device *dev; +bool connected; };static inline struct xenbus_device *xenvif_to_xenbus_device (struct xenvif *vif)
...
Quoted 1 line
drivers/net/xen-netback/interface.c +1
-0+ vif->connected =1 ;
...
drivers/net/xen-netback/interface.c void xenvif_carrier_off(struct xenvif *vif) · line 474
Quoted 1 line
drivers/net/xen-netback/interface.c +1
-0+ vif->connected =0 ;
Please use 'true' and 'false' when assigning values to something of "bool" type.
Also these look like bug fixes, and are thus more appropriately targetted at 'net' and even potentially -stable as well.
David Miller
maintainerRe: [PATCH net-next v2 1/2] xen-netback: add a vif-is-connected flag
In reply to Paul DurrantFrom: Paul Durrant <[email protected]>
Date: Fri, 20 Sep 2013 14:57:39 +0100
Quoted 8 lines
drivers/net/xen-netback/common.h +1
-0@@ -169,6 +169,7 @@ struct xenvif {/* Miscellaneous private stuff. */ struct net_device *dev; +bool connected; };static inline struct xenbus_device *xenvif_to_xenbus_device (struct xenvif *vif)
...
Quoted 1 line
drivers/net/xen-netback/interface.c +1
-0+ vif->connected =1 ;
...
drivers/net/xen-netback/interface.c void xenvif_carrier_off(struct xenvif *vif) · line 474
Quoted 1 line
drivers/net/xen-netback/interface.c +1
-0+ vif->connected =0 ;
Please use 'true' and 'false' when assigning values to something of "bool" type.
Also these look like bug fixes, and are thus more appropriately targetted at 'net' and even potentially -stable as well.
Re: [PATCH net-next v2 1/2] xen-netback: add a vif-is-connected flag
In reply to Paul DurrantQuoted 4 lines · Paul Durrant
Having applied my patch to separate vif disconnect and free, I ran into a BUG when testing resume from S3 with a Windows frontend because the vif task pointer was not cleared by
xenvif_disconnect()and so a double call to this function tries to stop the thread twice.
Or it is better to do more implements in windows netfront? For example, when the windows vm hibernates, disconnect the vif as required by netback: connect-> closing-> closed.
Thanks
Annie
Quoted 81 lines
Rather than applying a point fix for that issue it seems better to introduce a boolean to indicate whether the vif is connected or not such that repeated calls to either
xenvif_connect()orxenvif_disconnect()behave appropriately.Signed-off-by Paul Durrant <[email protected]>Cc David Vrabel <[email protected]>Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/interface.c | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-)drivers/net/xen-netback/common.h +1
-0@@ -169,6 +169,7 @@ struct xenvif {/* Miscellaneous private stuff. */ struct net_device *dev; +bool connected; };static inline struct xenbus_device *xenvif_to_xenbus_device (struct xenvif *vif)drivers/net/xen-netback/interface.c +13
-11@@ -366,7 +366,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,int err = -ENOMEM ;/* Already connected through? */ -if (vif->tx_irq) +if (vif->connected)return 0 ; err =xenvif_map_frontend_rings (vif, tx_ring_ref, rx_ring_ref);@@ -425,6 +425,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,wake_up_process (vif->task); + vif->connected =1 ;return 0 ; err_rx_unbind:@@ -453,23 +454,24 @@ void xenvif_carrier_off(struct xenvif *vif)void xenvif_disconnect (struct xenvif *vif) { +if (!vif->connected) +return ; +if (netif_carrier_ok (vif->dev))xenvif_carrier_off (vif); -if (vif->tx_irq) { -if (vif->tx_irq == vif->rx_irq) -unbind_from_irqhandler (vif->tx_irq, vif); -else { -unbind_from_irqhandler (vif->tx_irq, vif); -unbind_from_irqhandler (vif->rx_irq, vif); - } - vif->tx_irq =0 ; +if (vif->tx_irq == vif->rx_irq) +unbind_from_irqhandler (vif->tx_irq, vif); +else { +unbind_from_irqhandler (vif->tx_irq, vif); +unbind_from_irqhandler (vif->rx_irq, vif); } -if (vif->task) -kthread_stop (vif->task); +kthread_stop (vif->task);xenvif_unmap_frontend_rings (vif); + + vif->connected =0 ; }void xenvif_free (struct xenvif *vif)
Re: [Xen-devel] [PATCH net-next v2 1/2] xen-netback: add a vif-is-connected flag
In reply to Paul DurrantQuoted 4 lines · Paul Durrant
Having applied my patch to separate vif disconnect and free, I ran into a BUG when testing resume from S3 with a Windows frontend because the vif task pointer was not cleared by
xenvif_disconnect()and so a double call to this function tries to stop the thread twice.
Or it is better to do more implements in windows netfront? For example, when the windows vm hibernates, disconnect the vif as required by netback: connect-> closing-> closed.
Thanks
Annie
Quoted 81 lines
Rather than applying a point fix for that issue it seems better to introduce a boolean to indicate whether the vif is connected or not such that repeated calls to either
xenvif_connect()orxenvif_disconnect()behave appropriately.Signed-off-by Paul Durrant <[email protected]>Cc David Vrabel <[email protected]>Cc Wei Liu <[email protected]>Cc Ian Campbell <[email protected]>--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/interface.c | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-)drivers/net/xen-netback/common.h +1
-0@@ -169,6 +169,7 @@ struct xenvif {/* Miscellaneous private stuff. */ struct net_device *dev; +bool connected; };static inline struct xenbus_device *xenvif_to_xenbus_device (struct xenvif *vif)drivers/net/xen-netback/interface.c +13
-11@@ -366,7 +366,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,int err = -ENOMEM ;/* Already connected through? */ -if (vif->tx_irq) +if (vif->connected)return 0 ; err =xenvif_map_frontend_rings (vif, tx_ring_ref, rx_ring_ref);@@ -425,6 +425,7 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,wake_up_process (vif->task); + vif->connected =1 ;return 0 ; err_rx_unbind:@@ -453,23 +454,24 @@ void xenvif_carrier_off(struct xenvif *vif)void xenvif_disconnect (struct xenvif *vif) { +if (!vif->connected) +return ; +if (netif_carrier_ok (vif->dev))xenvif_carrier_off (vif); -if (vif->tx_irq) { -if (vif->tx_irq == vif->rx_irq) -unbind_from_irqhandler (vif->tx_irq, vif); -else { -unbind_from_irqhandler (vif->tx_irq, vif); -unbind_from_irqhandler (vif->rx_irq, vif); - } - vif->tx_irq =0 ; +if (vif->tx_irq == vif->rx_irq) +unbind_from_irqhandler (vif->tx_irq, vif); +else { +unbind_from_irqhandler (vif->tx_irq, vif); +unbind_from_irqhandler (vif->rx_irq, vif); } -if (vif->task) -kthread_stop (vif->task); +kthread_stop (vif->task);xenvif_unmap_frontend_rings (vif); + + vif->connected =0 ; }void xenvif_free (struct xenvif *vif)
Re: [PATCH net-next v2 1/2] xen-netback: add a vif-is-connected flag
Quoted 11 lines
-----Original Message-----
From: annie li [mailto:[email protected]]
Sent: 22 September 2013 03:57
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; David Vrabel; Ian Campbell
Subject: Re: [Xen-devel] [PATCH net-next v2 1/2] xen-netback: add a vif-is- connected flagOn 2013-9-20 21:57, Paul Durrant wrote:
Quoted 9 lines
Quoted 2 lines
Having applied my patch to separate vif disconnect and free, I ran into a BUG when testing resume from S3 with a Windows frontend because the
vif task
Quoted 2 lines
pointer was not cleared by
xenvif_disconnect()and so a double call to this function tries to stop the thread twice.Or it is better to do more implements in windows netfront? For example, when the windows vm hibernates, disconnect the vif as required by
netback: connect-> closing-> closed.
S3 != hibernation; that is S4. The backend does not go away when the VM goes into S3 as the domain remains intact. We do go through the correct closing->closed transition on the way down but, because of the way the D3->D0 code in the frontend needs to be generalized, we attempt a second closing->closed transition on the way back up. In the S4 case this ok because we have a fresh backend, but in the S3 case we don't and therefore hit the double-disconnect issue. The fact the backend BUGs in this case clearly shows a vulnerability in the backend and thus that is where the fix needs to be made; the frontend is doing nothing wrong.
Paul
RE: [Xen-devel] [PATCH net-next v2 1/2] xen-netback: add a vif-is-connected flag
In reply to annie liQuoted 11 lines
-----Original Message-----
From: annie li [mailto:[email protected]]
Sent: 22 September 2013 03:57
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; David Vrabel; Ian Campbell
Subject: Re: [Xen-devel] [PATCH net-next v2 1/2] xen-netback: add a vif-is- connected flagOn 2013-9-20 21:57, Paul Durrant wrote:
Quoted 9 lines
Quoted 2 lines
Having applied my patch to separate vif disconnect and free, I ran into a BUG when testing resume from S3 with a Windows frontend because the
vif task
Quoted 2 lines
pointer was not cleared by
xenvif_disconnect()and so a double call to this function tries to stop the thread twice.Or it is better to do more implements in windows netfront? For example, when the windows vm hibernates, disconnect the vif as required by
netback: connect-> closing-> closed.
S3 != hibernation; that is S4. The backend does not go away when the VM goes into S3 as the domain remains intact. We do go through the correct closing->closed transition on the way down but, because of the way the D3->D0 code in the frontend needs to be generalized, we attempt a second closing->closed transition on the way back up. In the S4 case this ok because we have a fresh backend, but in the S3 case we don't and therefore hit the double-disconnect issue. The fact the backend BUGs in this case clearly shows a vulnerability in the backend and thus that is where the fix needs to be made; the frontend is doing nothing wrong.
Paul
Re: [PATCH net-next v2 2/2] xen-netback: handle frontends that fail to transition through Closing
In reply to Bastian BlankQuoted 9 lines
-----Original Message-----
From: Bastian Blank [mailto:[email protected]]
Sent: 20 September 2013 17:15
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; David Vrabel; Ian Campbell
Subject: Re: [Xen-devel] [PATCH net-next v2 2/2] xen-netback: handle frontends that fail to transition through Closing
Quoted 8 lines
Quoted 2 lines · Paul Durrant
Some old Windows frontends fail to transition through the xenbus Closing state and move directly from Connected to Closed. Handle this case
properly.
What happens in this case? Are there other state changes that will do unwanted things?
Hmm, now you mention it I suspect a transition directly to an unknown state may also not do the right thing. Perhaps it would be better to go straight to a more robust state model as suggested by David Vrabel.
Paul
RE: [Xen-devel] [PATCH net-next v2 2/2] xen-netback: handle frontends that fail to transition through Closing
In reply to Bastian BlankQuoted 9 lines
-----Original Message-----
From: Bastian Blank [mailto:[email protected]]
Sent: 20 September 2013 17:15
To: Paul Durrant
Cc: [email protected]; [email protected]; Wei Liu; David Vrabel; Ian Campbell
Subject: Re: [Xen-devel] [PATCH net-next v2 2/2] xen-netback: handle frontends that fail to transition through Closing
Quoted 8 lines
Quoted 2 lines · Paul Durrant
Some old Windows frontends fail to transition through the xenbus Closing state and move directly from Connected to Closed. Handle this case
properly.
What happens in this case? Are there other state changes that will do unwanted things?
Hmm, now you mention it I suspect a transition directly to an unknown state may also not do the right thing. Perhaps it would be better to go straight to a more robust state model as suggested by David Vrabel.
Paul