From: jianhai luan <jianhai.luan@oracle.com>
To: xen-devel@lists.xensource.com
Cc: Ian Campbell <Ian.Campbell@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: [V2] xen-netback notify DomU to send ARP.
Date: Mon, 21 Jan 2013 15:26:23 +0800 [thread overview]
Message-ID: <50FCED9F.1050708@oracle.com> (raw)
In-Reply-To: <50EF7106.7000302@oracle.com>
[-- Attachment #1: Type: text/plain, Size: 353 bytes --]
By Jan and Ian's advice, I have modified the former patch and test some
platform, the below is test result:
Linux Pass (Send gratuitous ARP )
Window Pass (don't send ARP, but no other issue occur)
Solaris Pass (don't send ARP, but no other issue occur)
NetBsd Pass (don't send ARP, but no other issue occur)
Thanks,
Jason
[-- Attachment #2: 0001-xen-netback-notify-frontend-to-send-gratuitous-ARP.patch --]
[-- Type: text/plain, Size: 3140 bytes --]
>From c70af311cc22a1bb04004b03bd5973573360b942 Mon Sep 17 00:00:00 2001
From: Jason Luan <jianhai.luan@oracle.com>
Date: Fri, 28 Dec 2012 15:43:06 +0800
Subject: [PATCH] xen-netback notify frontend to send gratuitous ARP.
In the real network environment, some cause will lead
to Active-Backup mode bonding chose new actived port.
After that, the trffic, destinated to DomU by inactived
port (former actived port), will be unreachable at now.
DomU should send gratutious ARP initialtivly to find the
new corrected path.
By netback's Connected->Connected transition, frontend
will watch the change, and send gratuitous ARP.
Signed-off-by: Jason Luan <jianhai.luan@oracle.com>
---
drivers/net/xen-netback/xenbus.c | 51 ++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 410018c..23e3679 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -26,6 +26,7 @@ struct backend_info {
struct xenvif *vif;
enum xenbus_state frontend_state;
struct xenbus_watch hotplug_status_watch;
+ struct notifier_block vif_notifier;
u8 have_hotplug_status_watch:1;
};
@@ -34,11 +35,57 @@ static void connect(struct backend_info *);
static void backend_create_xenvif(struct backend_info *be);
static void unregister_hotplug_status_watch(struct backend_info *be);
+/*
+ * By Connected->Connected transition, netfront will watch the change and
+ * send gratuitous ARP.
+ */
+static void notify_front_arping(struct xenbus_device *dev)
+{
+ int err;
+
+ if (dev->state != XenbusStateConnected)
+ return;
+
+ err = xenbus_printf(XBT_NIL, dev->nodename, "state", "%d", dev->state);
+ if (err) {
+ pr_fmt("Error writing the state");
+ }
+
+ return;
+}
+
+#define nb_to_backend(nb) container_of(nb, struct backend_info, vif_notifier)
+/**
+ * When network condition of vif change, notify the frontend.
+ */
+static int netback_netdev_event(struct notifier_block *this,
+ unsigned long event, void *ptr)
+{
+ struct net_device *event_dev = ptr;
+ struct backend_info *be = nb_to_backend(this);
+
+ pr_debug("event_dev: %s, event: %lx\n",
+ event_dev ? event_dev->name : "None", event);
+
+ if (!be->vif)
+ return NOTIFY_DONE;
+
+ switch (event) {
+ case NETDEV_NOTIFY_PEERS:
+ /* Notify frontend to Send gratuitous ARP */
+ notify_front_arping(be->dev);
+ break;
+ }
+
+ return NOTIFY_DONE;
+}
+
static int netback_remove(struct xenbus_device *dev)
{
struct backend_info *be = dev_get_drvdata(&dev->dev);
unregister_hotplug_status_watch(be);
+ unregister_netdevice_notifier(&be->vif_notifier);
if (be->vif) {
kobject_uevent(&dev->dev.kobj, KOBJ_OFFLINE);
xenbus_rm(XBT_NIL, dev->nodename, "hotplug-status");
@@ -129,6 +176,10 @@ static int netback_probe(struct xenbus_device *dev,
/* This kicks hotplug scripts, so do it immediately. */
backend_create_xenvif(be);
+ /* Register Frontend Event Notify */
+ be->vif_notifier.notifier_call = netback_netdev_event;
+ register_netdevice_notifier(&be->vif_notifier);
+
return 0;
abort_transaction:
--
1.7.6.5
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2013-01-21 7:26 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-08 11:57 xen-netback notify DomU to send ARP jianhai luan
2013-01-08 13:13 ` [Xen-devel] " Jan Beulich
2013-01-08 13:42 ` Ian Campbell
2013-01-08 15:40 ` jianhai luan
2013-01-08 16:00 ` [Xen-devel] " Ian Campbell
2013-01-09 1:07 ` Jason Luan
2013-01-09 12:03 ` [Xen-devel] " Ian Campbell
2013-01-09 7:39 ` jianhai luan
2013-01-09 10:06 ` Jan Beulich
2013-01-09 12:28 ` jianhai luan
2013-01-09 13:44 ` Jan Beulich
2013-01-09 15:37 ` Jason Luan
2013-01-09 15:44 ` [Xen-devel] " Jan Beulich
[not found] ` <50ED950A.6010203@163.com>
2013-01-09 16:25 ` Jan Beulich
[not found] ` <50EDA624.1010008@163.com>
2013-01-10 7:00 ` [Xen-devel] " jianhai luan
2013-01-10 15:20 ` Jason Luan
2013-01-13 1:51 ` Jason Luan
2013-01-14 12:16 ` Ian Campbell
2013-01-14 13:39 ` Jason Luan
2013-01-14 14:24 ` Jan Beulich
2013-01-14 14:43 ` Jason Luan
2013-01-14 15:52 ` Jan Beulich
[not found] ` <50EF7106.7000302@oracle.com>
2013-01-21 7:26 ` jianhai luan [this message]
2013-01-21 11:04 ` [V2] " David Vrabel
2013-01-21 11:33 ` Jason Luan
2013-01-21 11:55 ` Jan Beulich
2013-01-21 12:23 ` Ian Campbell
2013-01-21 12:30 ` Ian Campbell
2013-01-21 12:38 ` Jason Luan
2013-01-21 13:49 ` Jason Luan
2013-01-21 13:52 ` Ian Campbell
2013-01-21 14:02 ` Jason Luan
2013-01-21 14:09 ` Ian Campbell
2013-01-21 14:16 ` Jan Beulich
2013-01-21 14:31 ` Jason Luan
2013-01-21 14:54 ` Jason Luan
2013-01-21 15:20 ` Jan Beulich
2013-01-21 15:30 ` Jason Luan
2013-01-21 15:44 ` Jan Beulich
2013-01-21 15:56 ` Jason Luan
2013-01-21 15:59 ` Jan Beulich
2013-01-21 16:02 ` Jason Luan
2013-01-21 15:59 ` Ian Campbell
2013-01-21 12:25 ` Jason Luan
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=50FCED9F.1050708@oracle.com \
--to=jianhai.luan@oracle.com \
--cc=Ian.Campbell@citrix.com \
--cc=JBeulich@suse.com \
--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).