xen-netback: implement dynamic multicast control
Subsystems (3)
PATCH 1/1 xen-netback: implement dynamic multicast control
My recent patch to the Xen Project documents a protocol for 'dynamic multicast control' in netif.h. This extends the previous multicast control protocol to not require a shared ring reconnection to turn the feature off. Instead the backend watches the "request-multicast-control" key in xenstore and turns the feature off if the key value is written to zero.
This patch adds support for dynamic multicast control in xen-netback.
--- drivers/net/xen-netback/common.h | 1 + drivers/net/xen-netback/xenbus.c | 85 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 78 insertions(+), 8 deletions(-)
drivers/net/xen-netback/common.h +1 -0
@@ -251,6 +251,7 @@ struct xenvif {unsigned int stalled_queues;struct xenbus_watch credit_watch; +struct xenbus_watch mcast_ctrl_watch;spinlock_t lock;
drivers/net/xen-netback/xenbus.c +77 -8
121 lines not on this page · raw message
Signature · 1 line
2.1.4
On Mon, Feb 01, 2016 at 02:40:53PM +0000, Paul Durrant wrote:
[...]
Quoted 4 lines
drivers/net/xen-netback/xenbus.c +4
-0+static int xen_register_mcast_ctrl_watch (struct xenbus_device *dev, +struct xenvif *vif) +{ +int err =0 ;
drivers/net/xen-netback/xenbus.c static void xen_unregister_watchers(struct xenvif *vif) · line 756
Quoted 10 lines
drivers/net/xen-netback/xenbus.c +10
-0+char *node; +unsigned maxlen =strlen (dev->otherend) + +sizeof ("/request-multicast-control" ); + +if (vif->mcast_ctrl_watch.node) +return -EADDRINUSE ; + + node =kmalloc (maxlen,GFP_KERNEL ); +if (!node) +return -ENOMEM ;
This is one error path that has no logging, so please either add logging in each error patch ...
Quoted 26 lines
drivers/net/xen-netback/xenbus.c +26
-0+snprintf (node, maxlen,"%s/request-multicast-control" , + dev->otherend); + vif->mcast_ctrl_watch.node = node; + vif->mcast_ctrl_watch.callback = xen_mcast_ctrl_changed; + err =register_xenbus_watch (&vif->mcast_ctrl_watch); +if (err) { +pr_err ("Failed to set watcher %s\n" , + vif->mcast_ctrl_watch.node); +kfree (node); + vif->mcast_ctrl_watch.node =NULL ; + vif->mcast_ctrl_watch.callback =NULL ; + } +return err; +} + +static void xen_unregister_mcast_ctrl_watch (struct xenvif *vif) +{ +if (vif->mcast_ctrl_watch.node) { +unregister_xenbus_watch (&vif->mcast_ctrl_watch); +kfree (vif->mcast_ctrl_watch.node); + vif->mcast_ctrl_watch.node =NULL ; + } +} + +static void xen_register_watchers (struct xenbus_device *dev, +struct xenvif *vif)
drivers/net/xen-netback/xenbus.c static void xen_unregister_watchers(struct xenvif *vif) · line 792
Quoted 10 lines
drivers/net/xen-netback/xenbus.c +10
-0+{ +xen_register_credit_watch (dev, vif); +xen_register_mcast_ctrl_watch (dev, vif); +} + +static void xen_unregister_watchers (struct xenvif *vif) +{ +xen_unregister_mcast_ctrl_watch (vif); +xen_unregister_credit_watch (vif); +}
... or check if these register/unregister function calls' return value and log if something fails.
Wei.
Quoted 20 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 02 February 2016 11:09
To: Paul Durrant
Cc: [email protected]; [email protected]; Ian Campbell; Wei Liu
Subject: Re: [PATCH net-next v1] xen-netback: implement dynamic multicast controlOn Mon, Feb 01, 2016 at 02:40:53PM +0000, Paul Durrant wrote:
[...]Quoted 9 lines
drivers/net/xen-netback/xenbus.c +9
-0+static int xen_register_mcast_ctrl_watch (struct xenbus_device *dev, +struct xenvif *vif) +{ +int err =0 ; +char *node; +unsigned maxlen =strlen (dev->otherend) + +sizeof ("/request-multicast-control" ); + +if (vif->mcast_ctrl_watch.node)
Quoted 9 lines
drivers/net/xen-netback/xenbus.c static void xen_unregister_watchers(struct xenvif *vif) · line 756
Quoted 5 lines
drivers/net/xen-netback/xenbus.c +5
-0+return -EADDRINUSE ; + + node =kmalloc (maxlen,GFP_KERNEL ); +if (!node) +return -ENOMEM ;This is one error path that has no logging, so please either add logging in each error patch ...
Sure.
Quoted 31 lines
Quoted 31 lines
drivers/net/xen-netback/xenbus.c +31
-0+snprintf (node, maxlen,"%s/request-multicast-control" , + dev->otherend); + vif->mcast_ctrl_watch.node = node; + vif->mcast_ctrl_watch.callback = xen_mcast_ctrl_changed; + err =register_xenbus_watch (&vif->mcast_ctrl_watch); +if (err) { +pr_err ("Failed to set watcher %s\n" , + vif->mcast_ctrl_watch.node); +kfree (node); + vif->mcast_ctrl_watch.node =NULL ; + vif->mcast_ctrl_watch.callback =NULL ; + } +return err; +} + +static void xen_unregister_mcast_ctrl_watch (struct xenvif *vif) +{ +if (vif->mcast_ctrl_watch.node) { +unregister_xenbus_watch (&vif->mcast_ctrl_watch); +kfree (vif->mcast_ctrl_watch.node); + vif->mcast_ctrl_watch.node =NULL ; + } +} + +static void xen_register_watchers (struct xenbus_device *dev, +struct xenvif *vif) +{ +xen_register_credit_watch (dev, vif); +xen_register_mcast_ctrl_watch (dev, vif); +} +
Quoted 9 lines
drivers/net/xen-netback/xenbus.c static void xen_unregister_watchers(struct xenvif *vif) · line 792
Quoted 5 lines
drivers/net/xen-netback/xenbus.c +5
-0+static void xen_unregister_watchers (struct xenvif *vif) +{ +xen_unregister_mcast_ctrl_watch (vif); +xen_unregister_credit_watch (vif); +}... or check if these register/unregister function calls' return value and log if something fails.
Given that the similar failure path in credit watch registration never logged adding a check here may create noise where there was none before.
Paul
Quoted 1 line
Wei.
Quoted 20 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 02 February 2016 11:09
To: Paul Durrant
Cc: [email protected]; [email protected]; Ian Campbell; Wei Liu
Subject: Re: [PATCH net-next v1] xen-netback: implement dynamic multicast controlOn Mon, Feb 01, 2016 at 02:40:53PM +0000, Paul Durrant wrote:
[...]Quoted 9 lines
drivers/net/xen-netback/xenbus.c +9
-0+static int xen_register_mcast_ctrl_watch (struct xenbus_device *dev, +struct xenvif *vif) +{ +int err =0 ; +char *node; +unsigned maxlen =strlen (dev->otherend) + +sizeof ("/request-multicast-control" ); + +if (vif->mcast_ctrl_watch.node)
Quoted 9 lines
drivers/net/xen-netback/xenbus.c static void xen_unregister_watchers(struct xenvif *vif) · line 756
Quoted 5 lines
drivers/net/xen-netback/xenbus.c +5
-0+return -EADDRINUSE ; + + node =kmalloc (maxlen,GFP_KERNEL ); +if (!node) +return -ENOMEM ;This is one error path that has no logging, so please either add logging in each error patch ...
Sure.
Quoted 31 lines
Quoted 31 lines
drivers/net/xen-netback/xenbus.c +31
-0+snprintf (node, maxlen,"%s/request-multicast-control" , + dev->otherend); + vif->mcast_ctrl_watch.node = node; + vif->mcast_ctrl_watch.callback = xen_mcast_ctrl_changed; + err =register_xenbus_watch (&vif->mcast_ctrl_watch); +if (err) { +pr_err ("Failed to set watcher %s\n" , + vif->mcast_ctrl_watch.node); +kfree (node); + vif->mcast_ctrl_watch.node =NULL ; + vif->mcast_ctrl_watch.callback =NULL ; + } +return err; +} + +static void xen_unregister_mcast_ctrl_watch (struct xenvif *vif) +{ +if (vif->mcast_ctrl_watch.node) { +unregister_xenbus_watch (&vif->mcast_ctrl_watch); +kfree (vif->mcast_ctrl_watch.node); + vif->mcast_ctrl_watch.node =NULL ; + } +} + +static void xen_register_watchers (struct xenbus_device *dev, +struct xenvif *vif) +{ +xen_register_credit_watch (dev, vif); +xen_register_mcast_ctrl_watch (dev, vif); +} +
Quoted 9 lines
drivers/net/xen-netback/xenbus.c static void xen_unregister_watchers(struct xenvif *vif) · line 792
Quoted 5 lines
drivers/net/xen-netback/xenbus.c +5
-0+static void xen_unregister_watchers (struct xenvif *vif) +{ +xen_unregister_mcast_ctrl_watch (vif); +xen_unregister_credit_watch (vif); +}... or check if these register/unregister function calls' return value and log if something fails.
Given that the similar failure path in credit watch registration never logged adding a check here may create noise where there was none before.
Paul
Quoted 1 line
Wei.
On Mon, Feb 01, 2016 at 02:40:53PM +0000, Paul Durrant wrote:
[...]
Quoted 4 lines
drivers/net/xen-netback/xenbus.c +4
-0+static int xen_register_mcast_ctrl_watch (struct xenbus_device *dev, +struct xenvif *vif) +{ +int err =0 ;
drivers/net/xen-netback/xenbus.c static void xen_unregister_watchers(struct xenvif *vif) · line 756
Quoted 10 lines
drivers/net/xen-netback/xenbus.c +10
-0+char *node; +unsigned maxlen =strlen (dev->otherend) + +sizeof ("/request-multicast-control" ); + +if (vif->mcast_ctrl_watch.node) +return -EADDRINUSE ; + + node =kmalloc (maxlen,GFP_KERNEL ); +if (!node) +return -ENOMEM ;
This is one error path that has no logging, so please either add logging in each error patch ...
Quoted 26 lines
drivers/net/xen-netback/xenbus.c +26
-0+snprintf (node, maxlen,"%s/request-multicast-control" , + dev->otherend); + vif->mcast_ctrl_watch.node = node; + vif->mcast_ctrl_watch.callback = xen_mcast_ctrl_changed; + err =register_xenbus_watch (&vif->mcast_ctrl_watch); +if (err) { +pr_err ("Failed to set watcher %s\n" , + vif->mcast_ctrl_watch.node); +kfree (node); + vif->mcast_ctrl_watch.node =NULL ; + vif->mcast_ctrl_watch.callback =NULL ; + } +return err; +} + +static void xen_unregister_mcast_ctrl_watch (struct xenvif *vif) +{ +if (vif->mcast_ctrl_watch.node) { +unregister_xenbus_watch (&vif->mcast_ctrl_watch); +kfree (vif->mcast_ctrl_watch.node); + vif->mcast_ctrl_watch.node =NULL ; + } +} + +static void xen_register_watchers (struct xenbus_device *dev, +struct xenvif *vif)
drivers/net/xen-netback/xenbus.c static void xen_unregister_watchers(struct xenvif *vif) · line 792
Quoted 10 lines
drivers/net/xen-netback/xenbus.c +10
-0+{ +xen_register_credit_watch (dev, vif); +xen_register_mcast_ctrl_watch (dev, vif); +} + +static void xen_unregister_watchers (struct xenvif *vif) +{ +xen_unregister_mcast_ctrl_watch (vif); +xen_unregister_credit_watch (vif); +}
... or check if these register/unregister function calls' return value and log if something fails.
Wei.