Skip to content

Commit 839349d

Browse files
Sricharan Ramabadhrandavem330
authored andcommitted
net: qrtr: Do not do DEL_SERVER broadcast after DEL_CLIENT
On the remote side, when QRTR socket is removed, af_qrtr will call qrtr_port_remove() which broadcasts the DEL_CLIENT packet to all neighbours including local NS. NS upon receiving the DEL_CLIENT packet, will remove the lookups associated with the node:port and broadcasts the DEL_SERVER packet. But on the host side, due to the arrival of the DEL_CLIENT packet, the NS would've already deleted the server belonging to that port. So when the remote's NS again broadcasts the DEL_SERVER for that port, it throws below error message on the host: "failed while handling packet from 2:-2" So fix this error by not broadcasting the DEL_SERVER packet when the DEL_CLIENT packet gets processed." Fixes: 0c2204a ("net: qrtr: Migrate nameservice to kernel from userspace") Reviewed-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Ram Kumar Dharuman <[email protected]> Signed-off-by: Sricharan Ramabadhran <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ad651d6 commit 839349d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

net/qrtr/ns.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static struct qrtr_server *server_add(unsigned int service,
274274
return NULL;
275275
}
276276

277-
static int server_del(struct qrtr_node *node, unsigned int port)
277+
static int server_del(struct qrtr_node *node, unsigned int port, bool bcast)
278278
{
279279
struct qrtr_lookup *lookup;
280280
struct qrtr_server *srv;
@@ -287,7 +287,7 @@ static int server_del(struct qrtr_node *node, unsigned int port)
287287
radix_tree_delete(&node->servers, port);
288288

289289
/* Broadcast the removal of local servers */
290-
if (srv->node == qrtr_ns.local_node)
290+
if (srv->node == qrtr_ns.local_node && bcast)
291291
service_announce_del(&qrtr_ns.bcast_sq, srv);
292292

293293
/* Announce the service's disappearance to observers */
@@ -373,7 +373,7 @@ static int ctrl_cmd_bye(struct sockaddr_qrtr *from)
373373
}
374374
slot = radix_tree_iter_resume(slot, &iter);
375375
rcu_read_unlock();
376-
server_del(node, srv->port);
376+
server_del(node, srv->port, true);
377377
rcu_read_lock();
378378
}
379379
rcu_read_unlock();
@@ -459,10 +459,13 @@ static int ctrl_cmd_del_client(struct sockaddr_qrtr *from,
459459
kfree(lookup);
460460
}
461461

462-
/* Remove the server belonging to this port */
462+
/* Remove the server belonging to this port but don't broadcast
463+
* DEL_SERVER. Neighbours would've already removed the server belonging
464+
* to this port due to the DEL_CLIENT broadcast from qrtr_port_remove().
465+
*/
463466
node = node_get(node_id);
464467
if (node)
465-
server_del(node, port);
468+
server_del(node, port, false);
466469

467470
/* Advertise the removal of this client to all local servers */
468471
local_node = node_get(qrtr_ns.local_node);
@@ -567,7 +570,7 @@ static int ctrl_cmd_del_server(struct sockaddr_qrtr *from,
567570
if (!node)
568571
return -ENOENT;
569572

570-
return server_del(node, port);
573+
return server_del(node, port, true);
571574
}
572575

573576
static int ctrl_cmd_new_lookup(struct sockaddr_qrtr *from,

0 commit comments

Comments
 (0)