Subject: [PATCH v2 1/2] Revert "xen-netback: remove 'hotplug-status' once it has served its purpose"

This reverts commit 1f2565780e9b7218cf92c7630130e82dcc0fe9c2.

The 'hotplug-status' node should not be removed as long as the vif
device remains configured. Otherwise the xen-netback would wait for
re-running the network script even if it was already called (in case of
the frontent re-connecting). But also, it _should_ be removed when the
vif device is destroyed (for example when unbinding the driver) -
otherwise hotplug script would not configure the device whenever it
re-appear.

Moving removal of the 'hotplug-status' node was a workaround for nothing
calling network script after xen-netback module is reloaded. But when
vif interface is re-created (on xen-netback unbind/bind for example),
the script should be called, regardless of who does that - currently
this case is not handled by the toolstack, and requires manual
script call. Keeping hotplug-status=connected to skip the call is wrong
and leads to not configured interface.

More discussion at
https://lore.kernel.org/xen-devel/[email protected]/T/#u

Cc: [email protected]
Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
Cc: Michael Brown <[email protected]>
Changes in v2:
- build fix, reported by kernel test robot <[email protected]>

---
drivers/net/xen-netback/xenbus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index d24b7a7993aa..3fad58d22155 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -256,6 +256,7 @@ static void backend_disconnect(struct backend_info *be)
unsigned int queue_index;

xen_unregister_watchers(vif);
+ xenbus_rm(XBT_NIL, be->dev->nodename, "hotplug-status");
#ifdef CONFIG_DEBUG_FS
xenvif_debugfs_delif(vif);
#endif /* CONFIG_DEBUG_FS */
@@ -675,7 +676,6 @@ static void hotplug_status_changed(struct xenbus_watch *watch,

/* Not interested in this watch anymore. */
unregister_hotplug_status_watch(be);
- xenbus_rm(XBT_NIL, be->dev->nodename, "hotplug-status");
}
kfree(str);
}
--
2.31.1


Subject: [PATCH v2 2/2] Revert "xen-netback: Check for hotplug-status existence before watching"

This reverts commit 2afeec08ab5c86ae21952151f726bfe184f6b23d.

The reasoning in the commit was wrong - the code expected to setup the
watch even if 'hotplug-status' didn't exist. In fact, it relied on the
watch being fired the first time - to check if maybe 'hotplug-status' is
already set to 'connected'. Not registering a watch for non-existing
path (which is the case if hotplug script hasn't been executed yet),
made the backend not waiting for the hotplug script to execute. This in
turns, made the netfront think the interface is fully operational, while
in fact it was not (the vif interface on xen-netback side might not be
configured yet).

This was a workaround for 'hotplug-status' erroneously being removed.
But since that is reverted now, the workaround is not necessary either.

More discussion at
https://lore.kernel.org/xen-devel/[email protected]/T/#u

Cc: [email protected]
Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
I believe this is the same issue as discussed at
https://lore.kernel.org/xen-devel/[email protected]/
Cc: James Dingwall <[email protected]
Cc: Michael Brown <[email protected]>
---
drivers/net/xen-netback/xenbus.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 3fad58d22155..990360d75cb6 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -824,15 +824,11 @@ static void connect(struct backend_info *be)
xenvif_carrier_on(be->vif);

unregister_hotplug_status_watch(be);
- if (xenbus_exists(XBT_NIL, dev->nodename, "hotplug-status")) {
- err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch,
- NULL, hotplug_status_changed,
- "%s/%s", dev->nodename,
- "hotplug-status");
- if (err)
- goto err;
+ err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch, NULL,
+ hotplug_status_changed,
+ "%s/%s", dev->nodename, "hotplug-status");
+ if (!err)
be->have_hotplug_status_watch = 1;
- }

netif_tx_wake_all_queues(be->vif->dev);

--
2.31.1

Subject: Re: [PATCH v2 2/2] Revert "xen-netback: Check for hotplug-status existence before watching"

On Tue, Feb 22, 2022 at 09:31:31AM +0100, Roger Pau Monné wrote:
> On Tue, Feb 22, 2022 at 01:18:17AM +0100, Marek Marczykowski-Górecki wrote:
> > This reverts commit 2afeec08ab5c86ae21952151f726bfe184f6b23d.
> >
> > The reasoning in the commit was wrong - the code expected to setup the
> > watch even if 'hotplug-status' didn't exist. In fact, it relied on the
> > watch being fired the first time - to check if maybe 'hotplug-status' is
> > already set to 'connected'. Not registering a watch for non-existing
> > path (which is the case if hotplug script hasn't been executed yet),
> > made the backend not waiting for the hotplug script to execute. This in
> > turns, made the netfront think the interface is fully operational, while
> > in fact it was not (the vif interface on xen-netback side might not be
> > configured yet).
> >
> > This was a workaround for 'hotplug-status' erroneously being removed.
> > But since that is reverted now, the workaround is not necessary either.
> >
> > More discussion at
> > https://lore.kernel.org/xen-devel/[email protected]/T/#u
> >
> > Cc: [email protected]
> > Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
> > ---
> > I believe this is the same issue as discussed at
> > https://lore.kernel.org/xen-devel/[email protected]/
>
> Right - I believe we need to leave that workaround in place in libxl
> in order to deal with bogus Linux netbacks?

I'm afraid so, yes.

--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab


Attachments:
(No filename) (1.57 kB)
signature.asc (499.00 B)
Download all attachments

2022-02-24 03:55:45

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] Revert "xen-netback: remove 'hotplug-status' once it has served its purpose"

On Tue, 22 Feb 2022 01:18:16 +0100 Marek Marczykowski-Górecki wrote:
> This reverts commit 1f2565780e9b7218cf92c7630130e82dcc0fe9c2.
>
> The 'hotplug-status' node should not be removed as long as the vif
> device remains configured. Otherwise the xen-netback would wait for
> re-running the network script even if it was already called (in case of
> the frontent re-connecting). But also, it _should_ be removed when the
> vif device is destroyed (for example when unbinding the driver) -
> otherwise hotplug script would not configure the device whenever it
> re-appear.
>
> Moving removal of the 'hotplug-status' node was a workaround for nothing
> calling network script after xen-netback module is reloaded. But when
> vif interface is re-created (on xen-netback unbind/bind for example),
> the script should be called, regardless of who does that - currently
> this case is not handled by the toolstack, and requires manual
> script call. Keeping hotplug-status=connected to skip the call is wrong
> and leads to not configured interface.
>
> More discussion at
> https://lore.kernel.org/xen-devel/[email protected]/T/#u
>
> Cc: [email protected]
> Signed-off-by: Marek Marczykowski-Górecki <[email protected]>

Wei, Paul, do these look good?

2022-02-24 08:13:33

by Paul Durrant

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] Revert "xen-netback: Check for hotplug-status existence before watching"

On 22/02/2022 00:18, Marek Marczykowski-Górecki wrote:
> This reverts commit 2afeec08ab5c86ae21952151f726bfe184f6b23d.
>
> The reasoning in the commit was wrong - the code expected to setup the
> watch even if 'hotplug-status' didn't exist. In fact, it relied on the
> watch being fired the first time - to check if maybe 'hotplug-status' is
> already set to 'connected'. Not registering a watch for non-existing
> path (which is the case if hotplug script hasn't been executed yet),
> made the backend not waiting for the hotplug script to execute. This in
> turns, made the netfront think the interface is fully operational, while
> in fact it was not (the vif interface on xen-netback side might not be
> configured yet).
>
> This was a workaround for 'hotplug-status' erroneously being removed.
> But since that is reverted now, the workaround is not necessary either.
>
> More discussion at
> https://lore.kernel.org/xen-devel/[email protected]/T/#u
>
> Cc: [email protected]
> Signed-off-by: Marek Marczykowski-Górecki <[email protected]>

Reviewed-by: Paul Durrant <[email protected]>

2022-02-24 08:14:09

by Paul Durrant

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] Revert "xen-netback: remove 'hotplug-status' once it has served its purpose"

On 22/02/2022 00:18, Marek Marczykowski-Górecki wrote:
> This reverts commit 1f2565780e9b7218cf92c7630130e82dcc0fe9c2.
>
> The 'hotplug-status' node should not be removed as long as the vif
> device remains configured. Otherwise the xen-netback would wait for
> re-running the network script even if it was already called (in case of
> the frontent re-connecting). But also, it _should_ be removed when the
> vif device is destroyed (for example when unbinding the driver) -
> otherwise hotplug script would not configure the device whenever it
> re-appear.
>
> Moving removal of the 'hotplug-status' node was a workaround for nothing
> calling network script after xen-netback module is reloaded. But when
> vif interface is re-created (on xen-netback unbind/bind for example),
> the script should be called, regardless of who does that - currently
> this case is not handled by the toolstack, and requires manual
> script call. Keeping hotplug-status=connected to skip the call is wrong
> and leads to not configured interface.
>
> More discussion at
> https://lore.kernel.org/xen-devel/[email protected]/T/#u
>
> Cc: [email protected]
> Signed-off-by: Marek Marczykowski-Górecki <[email protected]>

Reviewed-by: Paul Durrant <[email protected]>

2022-02-24 09:33:39

by Michael Brown

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] Revert "xen-netback: Check for hotplug-status existence before watching"

On 24/02/2022 07:56, Durrant, Paul wrote:
> On 22/02/2022 00:18, Marek Marczykowski-Górecki wrote:
>> This reverts commit 2afeec08ab5c86ae21952151f726bfe184f6b23d.
>>
>> The reasoning in the commit was wrong - the code expected to setup the
>> watch even if 'hotplug-status' didn't exist. In fact, it relied on the
>> watch being fired the first time - to check if maybe 'hotplug-status' is
>> already set to 'connected'. Not registering a watch for non-existing
>> path (which is the case if hotplug script hasn't been executed yet),
>> made the backend not waiting for the hotplug script to execute. This in
>> turns, made the netfront think the interface is fully operational, while
>> in fact it was not (the vif interface on xen-netback side might not be
>> configured yet).
>>
>> This was a workaround for 'hotplug-status' erroneously being removed.
>> But since that is reverted now, the workaround is not necessary either.
>>
>> More discussion at
>> https://lore.kernel.org/xen-devel/[email protected]/T/#u
>>
>>
>> Cc: [email protected]
>> Signed-off-by: Marek Marczykowski-Górecki
>> <[email protected]>
>
> Reviewed-by: Paul Durrant <[email protected]>

In conjunction with patch 1/2 (which reverts the patch that caused the
original problem):

Reviewed-by: Michael Brown <[email protected]>

Thanks,

Michael

2022-02-24 18:29:28

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] Revert "xen-netback: remove 'hotplug-status' once it has served its purpose"

Hello:

This series was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

On Tue, 22 Feb 2022 01:18:16 +0100 you wrote:
> This reverts commit 1f2565780e9b7218cf92c7630130e82dcc0fe9c2.
>
> The 'hotplug-status' node should not be removed as long as the vif
> device remains configured. Otherwise the xen-netback would wait for
> re-running the network script even if it was already called (in case of
> the frontent re-connecting). But also, it _should_ be removed when the
> vif device is destroyed (for example when unbinding the driver) -
> otherwise hotplug script would not configure the device whenever it
> re-appear.
>
> [...]

Here is the summary with links:
- [v2,1/2] Revert "xen-netback: remove 'hotplug-status' once it has served its purpose"
https://git.kernel.org/netdev/net/c/0f4558ae9187
- [v2,2/2] Revert "xen-netback: Check for hotplug-status existence before watching"
https://git.kernel.org/netdev/net/c/e8240addd0a3

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html