[2/2] net/memif: fix init handling when already connected

Message ID 20200219081916.GA11931@vbox (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [1/2] net/memif: enable loopback |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail Compilation issues
ci/travis-robot warning Travis build: failed

Commit Message

Július Milan Feb. 19, 2020, 8:19 a.m. UTC
  This patch fixes the situation when there is already connected pair of
memif interfaces and another slave tries to initiate the connection with
(already occupied) master. Expected behavior is that the second slave
is refused and gets disconnect message with reason: "Already connected",
while old connection remains functional.

Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")

Signed-off-by: Július Milan <jmilan.dev@gmail.com>
---
 drivers/net/memif/memif_socket.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
  

Comments

Jakub Grajciar -X (jgrajcia - PANTHEON TECH SRO at Cisco) Feb. 19, 2020, 1:06 p.m. UTC | #1
> -----Original Message-----
> From: Július Milan <jmilan.dev@gmail.com>
> Sent: Wednesday, February 19, 2020 9:19 AM
> To: dev@dpdk.org; Jakub Grajciar -X (jgrajcia - PANTHEON TECH SRO at Cisco)
> <jgrajcia@cisco.com>
> Subject: [dpdk-dev][PATCH 2/2] net/memif: fix init handling when already
> connected
> 
> This patch fixes the situation when there is already connected pair of memif
> interfaces and another slave tries to initiate the connection with (already
> occupied) master. Expected behavior is that the second slave is refused and
> gets disconnect message with reason: "Already connected", while old
> connection remains functional.
> 
> Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
> 
> Signed-off-by: Július Milan <jmilan.dev@gmail.com>

Reviewed-by: Jakub Grajciar <jgrajcia@cisco.com>
  
Ferruh Yigit March 9, 2020, 2:44 p.m. UTC | #2
On 2/19/2020 1:06 PM, Jakub Grajciar -X (jgrajcia - PANTHEON TECH SRO at Cisco)
wrote:
>> -----Original Message-----
>> From: Július Milan <jmilan.dev@gmail.com>
>> Sent: Wednesday, February 19, 2020 9:19 AM
>> To: dev@dpdk.org; Jakub Grajciar -X (jgrajcia - PANTHEON TECH SRO at Cisco)
>> <jgrajcia@cisco.com>
>> Subject: [dpdk-dev][PATCH 2/2] net/memif: fix init handling when already
>> connected
>>
>> This patch fixes the situation when there is already connected pair of memif
>> interfaces and another slave tries to initiate the connection with (already
>> occupied) master. Expected behavior is that the second slave is refused and
>> gets disconnect message with reason: "Already connected", while old
>> connection remains functional.
>>
>> Fixes: 09c7e63a71f9 ("net/memif: introduce memory interface PMD")
>>
>> Signed-off-by: Július Milan <jmilan.dev@gmail.com>
> 
> Reviewed-by: Jakub Grajciar <jgrajcia@cisco.com>
> 

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/memif/memif_socket.c b/drivers/net/memif/memif_socket.c
index 553f8b004..1a06c6850 100644
--- a/drivers/net/memif/memif_socket.c
+++ b/drivers/net/memif/memif_socket.c
@@ -204,6 +204,13 @@  memif_msg_receive_init(struct memif_control_channel *cc, memif_msg_t *msg)
 		pmd = dev->data->dev_private;
 		if (((pmd->flags & ETH_MEMIF_FLAG_DISABLED) == 0) &&
 		    (pmd->id == i->id) && (pmd->role == MEMIF_ROLE_MASTER)) {
+			if (pmd->flags & (ETH_MEMIF_FLAG_CONNECTING |
+					   ETH_MEMIF_FLAG_CONNECTED)) {
+				memif_msg_enq_disconnect(cc,
+							 "Already connected", 0);
+				return -1;
+			}
+
 			/* assign control channel to device */
 			cc->dev = dev;
 			pmd->cc = cc;
@@ -215,12 +222,6 @@  memif_msg_receive_init(struct memif_control_channel *cc, memif_msg_t *msg)
 				return -1;
 			}
 
-			if (pmd->flags & (ETH_MEMIF_FLAG_CONNECTING |
-					   ETH_MEMIF_FLAG_CONNECTED)) {
-				memif_msg_enq_disconnect(pmd->cc,
-							 "Already connected", 0);
-				return -1;
-			}
 			strlcpy(pmd->remote_name, (char *)i->name,
 				sizeof(pmd->remote_name));
 
@@ -772,6 +773,7 @@  memif_intr_handler(void *arg)
 	ret = memif_msg_receive(cc);
 	/* if driver failed to assign device */
 	if (cc->dev == NULL) {
+		memif_msg_send_from_queue(cc);
 		ret = rte_intr_callback_unregister_pending(&cc->intr_handle,
 							   memif_intr_handler,
 							   cc,