Module Name:    src
Committed By:   jym
Date:           Sat Oct 16 00:12:09 UTC 2010

Modified Files:
        src/sys/arch/xen/xen: if_xennet_xenbus.c

Log Message:
Features (like feature-rx-copy) are set during XenbusStateInitWait in
backend. So delay xennet_xenbus_resume() up to notification of
backend state change.

This avoids a race that happens during dynamic attach/detach of network
interfaces with xm(1), where frontend queries xenstore for features not
yet reported by backend. This does not happen during normal domU boot,
as the backend has enough time to fill in these entries before frontend
asks for them.

Issue was reported by sborrill@: detaching xennet interfaces with RX copy
mode enabled turns them back during attach to RX flip mode due to the race.

feature-rx-copy support is part of another patch.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/xen/xen/if_xennet_xenbus.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.41 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.42
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.41	Mon Apr  5 07:19:32 2010
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Sat Oct 16 00:12:08 2010
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_xennet_xenbus.c,v 1.41 2010/04/05 07:19:32 joerg Exp $      */
+/*      $NetBSD: if_xennet_xenbus.c,v 1.42 2010/10/16 00:12:08 jym Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.41 2010/04/05 07:19:32 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.42 2010/10/16 00:12:08 jym Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -369,9 +369,6 @@
 	rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev),
 	    RND_TYPE_NET, 0);
 #endif
-
-	/* initialise shared structures and tell backend that we are ready */
-	xennet_xenbus_resume(sc);
 }
 
 static int
@@ -500,12 +497,6 @@
 		errmsg = "writing event channel";
 		goto abort_transaction;
 	}
-	error = xenbus_printf(xbt, sc->sc_xbusd->xbusd_path,
-	    "state", "%d", XenbusStateConnected);
-	if (error) {
-		errmsg = "writing frontend XenbusStateConnected";
-		goto abort_transaction;
-	}
 	error = xenbus_transaction_end(xbt, 0);
 	if (error == EAGAIN)
 		goto again;
@@ -531,14 +522,16 @@
 
 	switch (new_state) {
 	case XenbusStateInitialising:
-	case XenbusStateInitWait:
 	case XenbusStateInitialised:
+	case XenbusStateConnected:
 		break;
 	case XenbusStateClosing:
 		sc->sc_backend_status = BEST_CLOSED;
 		xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateClosed);
 		break;
-	case XenbusStateConnected:
+	case XenbusStateInitWait:
+		xennet_xenbus_resume(sc);
+		xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateConnected);
 		break;
 	case XenbusStateUnknown:
 	default:

Reply via email to