From: Ian Campbell <ian.campbell@citrix.com>
To: xen-devel@lists.xensource.com
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
Ian Campbell <ian.campbell@citrix.com>,
Steven.Smith@citrix.com
Subject: [PATCH 3/6] xen: netback: wait for hotplug scripts to complete before signalling connected to frontend
Date: Tue, 23 Feb 2010 16:47:08 +0000 [thread overview]
Message-ID: <1266943630-17002-3-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1266943615.11737.6467.camel@zakaz.uk.xensource.com>
Avoid the situation where the frontend is sending packets but the
domain 0 bridging (or whatever) is not yet configured (because the
hotplug scripts are too slow) and so packets get dropped.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Steven.Smith@citrix.com
---
drivers/xen/netback/common.h | 2 +
drivers/xen/netback/xenbus.c | 45 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/drivers/xen/netback/common.h b/drivers/xen/netback/common.h
index ea617b9..51f97c0 100644
--- a/drivers/xen/netback/common.h
+++ b/drivers/xen/netback/common.h
@@ -147,6 +147,8 @@ struct backend_info {
struct xenbus_device *dev;
struct xen_netif *netif;
enum xenbus_state frontend_state;
+ struct xenbus_watch hotplug_status_watch;
+ int have_hotplug_status_watch:1;
/* State relating to the netback accelerator */
void *netback_accel_priv;
diff --git a/drivers/xen/netback/xenbus.c b/drivers/xen/netback/xenbus.c
index b114aa4..b89853a 100644
--- a/drivers/xen/netback/xenbus.c
+++ b/drivers/xen/netback/xenbus.c
@@ -32,6 +32,7 @@
static int connect_rings(struct backend_info *);
static void connect(struct backend_info *);
static void backend_create_netif(struct backend_info *be);
+static void unregister_hotplug_status_watch(struct backend_info *be);
static int netback_remove(struct xenbus_device *dev)
{
@@ -39,8 +40,10 @@ static int netback_remove(struct xenbus_device *dev)
//netback_remove_accelerators(be, dev);
+ unregister_hotplug_status_watch(be);
if (be->netif) {
kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
+ xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status");
netif_disconnect(be->netif);
be->netif = NULL;
}
@@ -218,6 +221,7 @@ static void disconnect_backend(struct xenbus_device *dev)
struct backend_info *be = dev_get_drvdata(&dev->dev);
if (be->netif) {
+ xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status");
netif_disconnect(be->netif);
be->netif = NULL;
}
@@ -337,6 +341,36 @@ static int xen_net_read_mac(struct xenbus_device *dev, u8 mac[])
return 0;
}
+static void unregister_hotplug_status_watch(struct backend_info *be)
+{
+ if (be->have_hotplug_status_watch) {
+ unregister_xenbus_watch(&be->hotplug_status_watch);
+ kfree(be->hotplug_status_watch.node);
+ }
+ be->have_hotplug_status_watch = 0;
+}
+
+static void hotplug_status_changed(struct xenbus_watch *watch,
+ const char **vec,
+ unsigned int vec_size)
+{
+ struct backend_info *be = container_of(watch,
+ struct backend_info,
+ hotplug_status_watch);
+ char *str;
+ unsigned int len;
+
+ str = xenbus_read(XBT_NIL, be->dev->nodename, "hotplug-status", &len);
+ if (IS_ERR(str))
+ return;
+ if (len == sizeof("connected")-1 && !memcmp(str, "connected", len)) {
+ xenbus_switch_state(be->dev, XenbusStateConnected);
+ /* Not interested in this watch anymore. */
+ unregister_hotplug_status_watch(be);
+ }
+ kfree(str);
+}
+
static void connect(struct backend_info *be)
{
int err;
@@ -356,7 +390,16 @@ static void connect(struct backend_info *be)
&be->netif->credit_usec);
be->netif->remaining_credit = be->netif->credit_bytes;
- xenbus_switch_state(dev, XenbusStateConnected);
+ unregister_hotplug_status_watch(be);
+ err = xenbus_watch_pathfmt(dev, &be->hotplug_status_watch,
+ hotplug_status_changed,
+ "%s/%s", dev->nodename, "hotplug-status");
+ if (err) {
+ /* Switch now, since we can't do a watch. */
+ xenbus_switch_state(dev, XenbusStateConnected);
+ } else {
+ be->have_hotplug_status_watch = 1;
+ }
netif_wake_queue(be->netif->dev);
}
--
1.5.6.5
next prev parent reply other threads:[~2010-02-23 16:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-23 16:46 [GIT] netback fixes from XCP kernel tree Ian Campbell
2010-02-23 16:47 ` [PATCH 1/6] xen: netback: remove unused xen_network_done code Ian Campbell
2010-02-23 16:47 ` [PATCH 2/6] xen: netback: factor disconnect from backend into new function Ian Campbell
2010-02-23 16:47 ` Ian Campbell [this message]
2010-02-23 16:47 ` [PATCH 4/6] xen/netback: Always pull through PKT_PROT_LEN bytes into the linear part of an skb Ian Campbell
2010-02-24 8:28 ` Jan Beulich
2010-02-24 8:55 ` Ian Campbell
2010-02-24 9:23 ` [PATCH 4/6] xen/netback: Always pull throughPKT_PROT_LEN " James Harper
2010-02-24 9:56 ` Ian Campbell
2010-02-23 16:47 ` [PATCH 5/6] xen/netback: try to pull a minimum of 72 bytes into the skb data area Ian Campbell
2010-02-23 17:04 ` Ian Campbell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1266943630-17002-3-git-send-email-ian.campbell@citrix.com \
--to=ian.campbell@citrix.com \
--cc=Steven.Smith@citrix.com \
--cc=jeremy@goop.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).