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@intel.com>
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@lists.xensource.com
http://lists.xensource.com/xen-devel