Commit 6d0b3fb9 authored by Josh Kunz's avatar Josh Kunz

Let non-node principals receive flow caps

parent dc18bf51
Pipeline #1388 passed with stage
......@@ -60,8 +60,12 @@ static int __handle_flow_grant(cn_node_t * receiver, cn_flow_t *flow) {
int cn_delete_flow_cb(struct cnode *flow_cnode, void * payload) {
int ret;
cn_node_t * owner = (cn_node_t *) cn_cnode_principal(flow_cnode)->owner;
assert(cn_cnode_type(flow_cnode) == CN_FLOW && "delete flow cb invoked on non-flow");
cn_node_t * owner = (cn_node_t *) cn_cnode_principal(flow_cnode)->owner;
/* No need to worry about flow stuff if the owner is not a node */
if (owner == NULL) { goto end; }
cn_flow_t * flow = (cn_flow_t *) cn_cnode_object(flow_cnode);
(void) __entry_decref(owner->node_table, flow->node);
......@@ -74,32 +78,39 @@ int cn_delete_flow_cb(struct cnode *flow_cnode, void * payload) {
c_log_debug("remove flow...");
cnc_remove_flow(owner, flow);
end:
c_log_debug("default cb...");
return cn_default_delete_cb(flow_cnode, payload);
}
int cnc_remove_flow(cn_node_t *src_node, cn_flow_t *flow);
int cn_insert_flow_cb(struct cnode *flow, void * payload) {
int ret;
if ((ret = cn_default_insert_cb(flow, payload)) != 0) { return ret; }
cn_node_t * cap_receiver = (cn_node_t *) cn_cnode_principal(flow)->owner;
assert(cn_cnode_type(flow) == CN_FLOW
&& "flow insert callback invoked for non-flow");
if ((ret = cn_default_insert_cb(flow, payload)) != 0) { return ret; }
cn_node_t * cap_receiver = (cn_node_t *) cn_cnode_principal(flow)->owner;
/* if we're not inserting into a node, then no need to need to
* worry about flow pushing */
if (cap_receiver == NULL) { return 0; }
cn_flow_t * cn_flow = (cn_flow_t *) cn_cnode_object(flow);
return __handle_flow_grant(cap_receiver, cn_flow);
}
int cn_grant_flow_cb(struct cnode *src, struct cnode *dst, void * payload) {
int ret;
assert(cn_cnode_type(src) == CN_FLOW
&& "flow grant callback invoked for non-flow");
if ((ret = cn_default_grant_cb(src, dst, payload)) != 0) { return ret; }
/* The node that owns the principal that the capability is being granted
* into is the node who we need to install flows for. */
cn_node_t * cap_receiver = (cn_node_t *) cn_cnode_principal(dst)->owner;
assert(cn_cnode_type(src) == CN_FLOW
&& "flow grant callback invoked for non-flow");
/* if we're not granting to a node, then no need to need to worry about
* flow pushing */
if (cap_receiver == NULL) { return 0; }
cn_flow_t * flow = (cn_flow_t *) cn_cnode_object(src);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment