xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: jianhai luan <jianhai.luan@oracle.com>
To: gmarsden_org_ww@oracle.com, LINUX-UEK_WW@oracle.com,
	xen-devel@lists.xensource.com
Subject: Re: [PATCH 4/4] review For Oracle bug 14470382
Date: Fri, 18 Jan 2013 09:57:48 +0800	[thread overview]
Message-ID: <50F8AC1C.3060300@oracle.com> (raw)
In-Reply-To: <50F8A979.6010709@oracle.com>

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]


On 2013-1-18 9:46, jianhai luan wrote:
> orabug: 14470382
>
> When Dom0's network environment change, for example the issue, DomU 
> should send send gratuitous ARP initially to notify how to reach it.
>
> To fix the bug, we should modify backend and frontend at the same 
> time. For fixing frontend, i filer the new bug 16182568. The review 
> only to backend.
>
> For fixing the backend, I have 4 patch for review.
[PATCH] Notify DomU to send gratuitous ARP initially by 
Connected->Connected transition
>
> Thanks,
> Jason


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0004-xen-netback-notify-frontend-to-send-gratuitous-ARP.patch --]
[-- Type: text/plain; charset=gb18030; name="0004-xen-netback-notify-frontend-to-send-gratuitous-ARP.patch", Size: 3567 bytes --]

From 6d27fe89373b000d750ae0a8b9fb831357e286ed 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>
---

diff -Nur linux-2.6.18.i686.orig/drivers/xen/netback/common.h linux-2.6.18.i686/drivers/xen/netback/common.h
--- linux-2.6.18.i686.orig/drivers/xen/netback/common.h	2013-01-17 14:21:50.000000000 +0800
+++ linux-2.6.18.i686/drivers/xen/netback/common.h	2013-01-17 14:32:48.000000000 +0800
@@ -151,6 +151,8 @@
 	void *netback_accel_priv;
 	/* The accelerator that this backend is currently using */
 	struct netback_accelerator *accelerator;
+
+	struct notifier_block vif_notifier;
 };
 
 #define NETBACK_ACCEL_VERSION 0x00010001
diff -Nur linux-2.6.18.i686.orig/drivers/xen/netback/xenbus.c linux-2.6.18.i686/drivers/xen/netback/xenbus.c
--- linux-2.6.18.i686.orig/drivers/xen/netback/xenbus.c	2013-01-17 14:21:50.000000000 +0800
+++ linux-2.6.18.i686/drivers/xen/netback/xenbus.c	2013-01-17 14:34:02.000000000 +0800
@@ -33,10 +33,73 @@
 static void connect(struct backend_info *);
 static void backend_create_netif(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)
+{
+	struct xenbus_transaction xbt;
+	int err;
+
+	if (xenbus_read_driver_state(dev->nodename) != XenbusStateConnected)
+		return;
+
+again:
+	err = xenbus_transaction_start(&xbt);
+	if (err) {
+		printk(KERN_ALERT "Error starting transaction");
+		return;
+	}
+
+	err = xenbus_printf(xbt, dev->nodename, "state", "%d", dev->state);
+	if(err) {
+		printk(KERN_ALERT "Error writing the state");
+		xenbus_transaction_end(xbt, 1);
+		return;
+	}
+	
+	err = xenbus_transaction_end(xbt, 0);
+	if (err == -EAGAIN)
+		goto again;
+	if (err)
+		printk(KERN_ALERT "Error ending transaction");
+
+	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->netif)
+		return NOTIFY_DONE;
+	
+	switch (event) {
+	case NETDEV_BONDING_FAILOVER:
+		/* 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->dev.driver_data;
 
+	unregister_netdevice_notifier(&be->vif_notifier);
+
 	netback_remove_accelerators(be, dev);
 
 	if (be->netif) {
@@ -132,6 +195,10 @@
 	/* This kicks hotplug scripts, so do it immediately. */
 	backend_create_netif(be);
 
+	/* Register Frontend Event Notify */
+	be->vif_notifier.notifier_call = netback_netdev_event;
+	register_netdevice_notifier(&be->vif_notifier);
+
 	return 0;
 
 abort_transaction:

[-- Attachment #3: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  parent reply	other threads:[~2013-01-18  1:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-18  1:46 review For Oracle bug 14470382 jianhai luan
2013-01-18  1:50 ` [PATCH 1/4]review " jianhai luan
2013-01-18  1:52 ` [PATCH 2/4] review " jianhai luan
2013-01-18  1:54 ` [PATCH 3/4] " jianhai luan
2013-01-18  1:57 ` jianhai luan [this message]
2013-01-18  6:45   ` [PATCH 4/4] " Dan Carpenter
2013-01-18 10:08     ` Ian Campbell
2013-01-18 10:26       ` Jan Beulich
2013-01-19  5:25         ` Jason Luan
2013-01-18  2:03 ` [Test Result] " jianhai luan
2013-01-18  2:38   ` jianhai luan
2013-01-18  2:44   ` jianhai 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=50F8AC1C.3060300@oracle.com \
    --to=jianhai.luan@oracle.com \
    --cc=LINUX-UEK_WW@oracle.com \
    --cc=gmarsden_org_ww@oracle.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).