WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] patch: event channel fixups

To: "xen-devel List" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] patch: event channel fixups
From: "King, Steven R" <steven.r.king@xxxxxxxxx>
Date: Mon, 17 Oct 2005 16:39:02 -0700
Delivery-date: Mon, 17 Oct 2005 23:36:21 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcXTc/RIdRh65Cm+SW6dxSwxHuXV8w==
Thread-topic: patch: event channel fixups
Hello all,

Here's a suggested patch for xen/common/event_channel.c

Summary:
Allows interdomain channels to bind DOMID_SELF to DOMID_SELF.  A couple
of quick fixes made this work, since support for loopback channels is
already there.
 
Stops a local port leak when an interdomain channel is rejected at the
remote end.
 
Thanks,
-steve

Signed-off-by: Steve King <steven.r.king@xxxxxxxxx>


diff -r 446aa56ca4fe xen/common/event_channel.c
--- a/xen/common/event_channel.c        Mon Oct 17 12:50:28 2005
+++ b/xen/common/event_channel.c        Mon Oct 17 16:12:21 2005
@@ -89,7 +89,10 @@
     chn = evtchn_from_port(d, port);
 
     chn->state = ECS_UNBOUND;
-    chn->u.unbound.remote_domid = alloc->remote_dom;
+    if( alloc->remote_dom == DOMID_SELF )
+        chn->u.unbound.remote_domid = current->domain->domain_id;
+    else
+        chn->u.unbound.remote_domid = alloc->remote_dom;
 
     alloc->port = port;
 
@@ -108,8 +111,14 @@
     struct domain *ld = current->domain, *rd;
     int            lport, rport = bind->remote_port;
     long           rc = 0;
-
-    if ( (rd = find_domain_by_id(bind->remote_dom)) == NULL )
+    domid_t        rdom;    
+
+    if( bind->remote_dom == DOMID_SELF )
+        rdom = current->domain->domain_id;
+    else
+        rdom = bind->remote_dom;
+
+    if ( (rd = find_domain_by_id(rdom)) == NULL )
         return -ESRCH;
 
     /* Avoid deadlock by first acquiring lock of domain with smaller
id. */
@@ -125,16 +134,21 @@
         spin_lock(&ld->evtchn_lock);
     }
 
-    if ( (lport = get_free_port(ld)) < 0 )
-        ERROR_EXIT(lport);
-    lchn = evtchn_from_port(ld, lport);
-
+    /*
+     * Failure paths do not deallocate the local port,
+     * so validate before allocating.
+     */
     if ( !port_is_valid(rd, rport) )
         ERROR_EXIT(-EINVAL);
     rchn = evtchn_from_port(rd, rport);
     if ( (rchn->state != ECS_UNBOUND) ||
          (rchn->u.unbound.remote_domid != ld->domain_id) )
         ERROR_EXIT(-EINVAL);
+
+    if ( (lport = get_free_port(ld)) < 0 )
+        ERROR_EXIT(lport);
+
+    lchn = evtchn_from_port(ld, lport);
 
     lchn->u.interdomain.remote_dom  = rd;
     lchn->u.interdomain.remote_port = (u16)rport;



 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>