Skip to content

Commit

Permalink
net: qrtr: Allow non-immediate node routing
Browse files Browse the repository at this point in the history
In order to reach non-immediate remote node services that are
accessed through an intermediate node, the route to the remote
node needs to be saved.

E.g for a [node1 <=> node2 <=> node3] network
- node2 forwards node3 service to node1
- node1 must save node2 as route for reaching node3

Signed-off-by: Loic Poulain <[email protected]>
Reviewed-by: Bjorn Andersson <[email protected]>
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Loic Poulain authored and kuba-moo committed Nov 11, 2020
1 parent 87f547c commit 0baa99e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions net/qrtr/qrtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,13 @@ static void qrtr_node_assign(struct qrtr_node *node, unsigned int nid)
{
unsigned long flags;

if (node->nid != QRTR_EP_NID_AUTO || nid == QRTR_EP_NID_AUTO)
if (nid == QRTR_EP_NID_AUTO)
return;

spin_lock_irqsave(&qrtr_nodes_lock, flags);
radix_tree_insert(&qrtr_nodes, nid, node);
node->nid = nid;
if (node->nid == QRTR_EP_NID_AUTO)
node->nid = nid;
spin_unlock_irqrestore(&qrtr_nodes_lock, flags);
}

Expand Down Expand Up @@ -494,6 +495,13 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len)

qrtr_node_assign(node, cb->src_node);

if (cb->type == QRTR_TYPE_NEW_SERVER) {
/* Remote node endpoint can bridge other distant nodes */
const struct qrtr_ctrl_pkt *pkt = data + hdrlen;

qrtr_node_assign(node, le32_to_cpu(pkt->server.node));
}

if (cb->type == QRTR_TYPE_RESUME_TX) {
qrtr_tx_resume(node, skb);
} else {
Expand Down

0 comments on commit 0baa99e

Please sign in to comment.