linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: qrtr: send msgs from local of same id as broadcast
@ 2020-04-07 13:29 WANG Wenhu
  2020-04-08  1:38 ` David Miller
  2020-04-08  3:32 ` [PATCH v2] " WANG Wenhu
  0 siblings, 2 replies; 6+ messages in thread
From: WANG Wenhu @ 2020-04-07 13:29 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Bjorn Andersson, Allison Randal,
	Nicholas Mc Guire, Marc Kleine-Budde, WANG Wenhu,
	Thomas Gleixner, Arnd Bergmann, netdev, linux-kernel
  Cc: opensource.kernel

If the local node id(qrtr_local_nid) is not modified after its
initialization, it equals to the broadcast node id(QRTR_NODE_BCAST).
So the messages from local node should not be taken as broadcast
and keep the process going to send them out anyway.

The definitions are as follow:
static unsigned int qrtr_local_nid = NUMA_NO_NODE;

Fixes: commit fdf5fd397566 ("net: qrtr: Broadcast messages only from control port")
Signed-off-by: Wang Wenhu <wenhu.wang@vivo.com>
---
 net/qrtr/qrtr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index 5a8e42ad1504..5dbd248c5ffb 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -907,20 +907,21 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 
 	node = NULL;
 	if (addr->sq_node == QRTR_NODE_BCAST) {
-		enqueue_fn = qrtr_bcast_enqueue;
-		if (addr->sq_port != QRTR_PORT_CTRL) {
+		if (addr->sq_port != QRTR_PORT_CTRL &&
+				qrtr_local_nid != QRTR_NODE_BCAST) {
 			release_sock(sk);
 			return -ENOTCONN;
 		}
+		enqueue_fn = qrtr_bcast_enqueue;
 	} else if (addr->sq_node == ipc->us.sq_node) {
 		enqueue_fn = qrtr_local_enqueue;
 	} else {
-		enqueue_fn = qrtr_node_enqueue;
 		node = qrtr_node_lookup(addr->sq_node);
 		if (!node) {
 			release_sock(sk);
 			return -ECONNRESET;
 		}
+		enqueue_fn = qrtr_node_enqueue;
 	}
 
 	plen = (len + 3) & ~3;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] net: qrtr: send msgs from local of same id as broadcast
  2020-04-07 13:29 [PATCH] net: qrtr: send msgs from local of same id as broadcast WANG Wenhu
@ 2020-04-08  1:38 ` David Miller
  2020-04-08  3:32 ` [PATCH v2] " WANG Wenhu
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2020-04-08  1:38 UTC (permalink / raw)
  To: wenhu.wang
  Cc: kuba, bjorn.andersson, allison, hofrat, mkl, tglx, arnd, netdev,
	linux-kernel, opensource.kernel

From: WANG Wenhu <wenhu.wang@vivo.com>
Date: Tue,  7 Apr 2020 06:29:28 -0700

> -		enqueue_fn = qrtr_bcast_enqueue;
> -		if (addr->sq_port != QRTR_PORT_CTRL) {
> +		if (addr->sq_port != QRTR_PORT_CTRL &&
> +				qrtr_local_nid != QRTR_NODE_BCAST) {

Please line up the second line of this if() statement with the column
after the openning parenthesis of the first line.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] net: qrtr: send msgs from local of same id as broadcast
  2020-04-07 13:29 [PATCH] net: qrtr: send msgs from local of same id as broadcast WANG Wenhu
  2020-04-08  1:38 ` David Miller
@ 2020-04-08  3:32 ` WANG Wenhu
  2020-04-08 19:56   ` David Miller
  2020-04-09 19:36   ` Bjorn Andersson
  1 sibling, 2 replies; 6+ messages in thread
From: WANG Wenhu @ 2020-04-08  3:32 UTC (permalink / raw)
  To: David S. Miller, Jakub Kicinski, Bjorn Andersson, Carl Huang,
	Thomas Gleixner, Arnd Bergmann, Nicholas Mc Guire, netdev,
	linux-kernel
  Cc: kernel, Wang Wenhu

From: Wang Wenhu <wenhu.wang@vivo.com>

If the local node id(qrtr_local_nid) is not modified after its
initialization, it equals to the broadcast node id(QRTR_NODE_BCAST).
So the messages from local node should not be taken as broadcast
and keep the process going to send them out anyway.

The definitions are as follow:
static unsigned int qrtr_local_nid = NUMA_NO_NODE;

Fixes: commit fdf5fd397566 ("net: qrtr: Broadcast messages only from control port")
Signed-off-by: Wang Wenhu <wenhu.wang@vivo.com>
---
Changlog:
 - For coding style, line up the newline of the if conditional judgement
   with the one exists before.

 net/qrtr/qrtr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
index 5a8e42ad1504..545a61f8ef75 100644
--- a/net/qrtr/qrtr.c
+++ b/net/qrtr/qrtr.c
@@ -907,20 +907,21 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
 
 	node = NULL;
 	if (addr->sq_node == QRTR_NODE_BCAST) {
-		enqueue_fn = qrtr_bcast_enqueue;
-		if (addr->sq_port != QRTR_PORT_CTRL) {
+		if (addr->sq_port != QRTR_PORT_CTRL &&
+			qrtr_local_nid != QRTR_NODE_BCAST) {
 			release_sock(sk);
 			return -ENOTCONN;
 		}
+		enqueue_fn = qrtr_bcast_enqueue;
 	} else if (addr->sq_node == ipc->us.sq_node) {
 		enqueue_fn = qrtr_local_enqueue;
 	} else {
-		enqueue_fn = qrtr_node_enqueue;
 		node = qrtr_node_lookup(addr->sq_node);
 		if (!node) {
 			release_sock(sk);
 			return -ECONNRESET;
 		}
+		enqueue_fn = qrtr_node_enqueue;
 	}
 
 	plen = (len + 3) & ~3;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] net: qrtr: send msgs from local of same id as broadcast
  2020-04-08  3:32 ` [PATCH v2] " WANG Wenhu
@ 2020-04-08 19:56   ` David Miller
  2020-04-09 19:36   ` Bjorn Andersson
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2020-04-08 19:56 UTC (permalink / raw)
  To: wenhu.wang
  Cc: kuba, bjorn.andersson, cjhuang, tglx, arnd, hofrat, netdev,
	linux-kernel, kernel

From: WANG Wenhu <wenhu.wang@vivo.com>
Date: Tue,  7 Apr 2020 20:32:47 -0700

> -		enqueue_fn = qrtr_bcast_enqueue;
> -		if (addr->sq_port != QRTR_PORT_CTRL) {
> +		if (addr->sq_port != QRTR_PORT_CTRL &&
> +			qrtr_local_nid != QRTR_NODE_BCAST) {

This is still not correct, it should be:

		if (addr->sq_port != QRTR_PORT_CTRL &&
		    qrtr_local_nid != QRTR_NODE_BCAST) {

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] net: qrtr: send msgs from local of same id as broadcast
  2020-04-08  3:32 ` [PATCH v2] " WANG Wenhu
  2020-04-08 19:56   ` David Miller
@ 2020-04-09 19:36   ` Bjorn Andersson
  2020-04-14  5:14     ` 王文虎
  1 sibling, 1 reply; 6+ messages in thread
From: Bjorn Andersson @ 2020-04-09 19:36 UTC (permalink / raw)
  To: WANG Wenhu
  Cc: David S. Miller, Jakub Kicinski, Carl Huang, Thomas Gleixner,
	Arnd Bergmann, Nicholas Mc Guire, netdev, linux-kernel, kernel

On Tue 07 Apr 20:32 PDT 2020, WANG Wenhu wrote:

> From: Wang Wenhu <wenhu.wang@vivo.com>
> 
> If the local node id(qrtr_local_nid) is not modified after its
> initialization, it equals to the broadcast node id(QRTR_NODE_BCAST).
> So the messages from local node should not be taken as broadcast
> and keep the process going to send them out anyway.
> 
> The definitions are as follow:
> static unsigned int qrtr_local_nid = NUMA_NO_NODE;
> 
> Fixes: commit fdf5fd397566 ("net: qrtr: Broadcast messages only from control port")
> Signed-off-by: Wang Wenhu <wenhu.wang@vivo.com>
> ---
> Changlog:
>  - For coding style, line up the newline of the if conditional judgement
>    with the one exists before.
> 
>  net/qrtr/qrtr.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
> index 5a8e42ad1504..545a61f8ef75 100644
> --- a/net/qrtr/qrtr.c
> +++ b/net/qrtr/qrtr.c
> @@ -907,20 +907,21 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
>  
>  	node = NULL;
>  	if (addr->sq_node == QRTR_NODE_BCAST) {
> -		enqueue_fn = qrtr_bcast_enqueue;
> -		if (addr->sq_port != QRTR_PORT_CTRL) {
> +		if (addr->sq_port != QRTR_PORT_CTRL &&
> +			qrtr_local_nid != QRTR_NODE_BCAST) {

So this would mean that if local_nid is configured to be the bcast
address then rather than rejecting messages to non-control ports we will
broadcast them.

What happens when some other node in the network replies? Wouldn't it be
better to explicitly prohibit usage of the bcast address as our node
address?


That said, in torvalds/master qrtr_local_nid is no longer initialized to
QRTR_NODE_BCAST, but 1. So I don't think you need this patch anymore.

Regards,
Bjorn

>  			release_sock(sk);
>  			return -ENOTCONN;
>  		}
> +		enqueue_fn = qrtr_bcast_enqueue;
>  	} else if (addr->sq_node == ipc->us.sq_node) {
>  		enqueue_fn = qrtr_local_enqueue;
>  	} else {
> -		enqueue_fn = qrtr_node_enqueue;
>  		node = qrtr_node_lookup(addr->sq_node);
>  		if (!node) {
>  			release_sock(sk);
>  			return -ECONNRESET;
>  		}
> +		enqueue_fn = qrtr_node_enqueue;
>  	}
>  
>  	plen = (len + 3) & ~3;
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] net: qrtr: send msgs from local of same id as broadcast
  2020-04-09 19:36   ` Bjorn Andersson
@ 2020-04-14  5:14     ` 王文虎
  0 siblings, 0 replies; 6+ messages in thread
From: 王文虎 @ 2020-04-14  5:14 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: David S. Miller, Jakub Kicinski, Carl Huang, Thomas Gleixner,
	Arnd Bergmann, Nicholas Mc Guire, netdev, linux-kernel, kernel


From: Bjorn Andersson <bjorn.andersson@linaro.org>
Date: 2020-04-10 03:36:00
To:  WANG Wenhu <wenhu.wang@vivo.com>
Cc:  "David S. Miller" <davem@davemloft.net>,Jakub Kicinski <kuba@kernel.org>,Carl Huang <cjhuang@codeaurora.org>,
Thomas Gleixner <tglx@linutronix.de>,Arnd Bergmann <arnd@arndb.de>,
Nicholas Mc Guire <hofrat@osadl.org>,netdev@vger.kernel.org,linux-kernel@vger.kernel.org,kernel@vivo.com
Subject: Re: [PATCH v2] net: qrtr: send msgs from local of same id as broadcast>On Tue 07 Apr 20:32 PDT 2020, WANG Wenhu wrote:
>
>> From: Wang Wenhu <wenhu.wang@vivo.com>
>> 
>> If the local node id(qrtr_local_nid) is not modified after its
>> initialization, it equals to the broadcast node id(QRTR_NODE_BCAST).
>> So the messages from local node should not be taken as broadcast
>> and keep the process going to send them out anyway.
>> 
>> The definitions are as follow:
>> static unsigned int qrtr_local_nid = NUMA_NO_NODE;
>> 
>> Fixes: commit fdf5fd397566 ("net: qrtr: Broadcast messages only from control port")
>> Signed-off-by: Wang Wenhu <wenhu.wang@vivo.com>
>> ---
>> Changlog:
>>  - For coding style, line up the newline of the if conditional judgement
>>    with the one exists before.
>> 
>>  net/qrtr/qrtr.c | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>> 
>> diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c
>> index 5a8e42ad1504..545a61f8ef75 100644
>> --- a/net/qrtr/qrtr.c
>> +++ b/net/qrtr/qrtr.c
>> @@ -907,20 +907,21 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
>>  
>>  	node = NULL;
>>  	if (addr->sq_node == QRTR_NODE_BCAST) {
>> -		enqueue_fn = qrtr_bcast_enqueue;
>> -		if (addr->sq_port != QRTR_PORT_CTRL) {
>> +		if (addr->sq_port != QRTR_PORT_CTRL &&
>> +			qrtr_local_nid != QRTR_NODE_BCAST) {
>
>So this would mean that if local_nid is configured to be the bcast
>address then rather than rejecting messages to non-control ports we will
>broadcast them.
>
>What happens when some other node in the network replies? Wouldn't it be
>better to explicitly prohibit usage of the bcast address as our node
>address?

>>
>That said, in torvalds/master qrtr_local_nid is no longer initialized to
>QRTR_NODE_BCAST, but 1. So I don't think you need this patch anymore.
>
>Regards,
>Bjorn

>

Hi Bjorn,
You are right. I see the patch that modified the nid to 1 in mainline v5.7-rc1,
and it is better to solve all the problems. As for this patch, the situation is that
I want to use qrtr in kernel to do something else(to develop another driver I name
it RPMON: Remote Processor Monitor), but the ns or service-route functionality
had been missing, so I write another file qsr.c as you had commetted which
did the same thing with ns.c.

The bad thing was I missed the patch from Manivannan.
So, anyway, this patch is not needed anymore.

Thanks,
Wenhu

>>  			release_sock(sk);
>>  			return -ENOTCONN;
>>  		}
>> +		enqueue_fn = qrtr_bcast_enqueue;
>>  	} else if (addr->sq_node == ipc->us.sq_node) {
>>  		enqueue_fn = qrtr_local_enqueue;
>>  	} else {
>> -		enqueue_fn = qrtr_node_enqueue;
>>  		node = qrtr_node_lookup(addr->sq_node);
>>  		if (!node) {
>>  			release_sock(sk);
>>  			return -ECONNRESET;
>>  		}
>> +		enqueue_fn = qrtr_node_enqueue;
>>  	}
>>  
>>  	plen = (len + 3) & ~3;
>> -- 
>> 2.17.1
>> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-14  5:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 13:29 [PATCH] net: qrtr: send msgs from local of same id as broadcast WANG Wenhu
2020-04-08  1:38 ` David Miller
2020-04-08  3:32 ` [PATCH v2] " WANG Wenhu
2020-04-08 19:56   ` David Miller
2020-04-09 19:36   ` Bjorn Andersson
2020-04-14  5:14     ` 王文虎

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).