From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 12A40A0555; Wed, 19 Feb 2020 09:19:21 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D29A41BF9F; Wed, 19 Feb 2020 09:19:20 +0100 (CET) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by dpdk.org (Postfix) with ESMTP id D6A1E3B5 for ; Wed, 19 Feb 2020 09:19:18 +0100 (CET) Received: by mail-wm1-f67.google.com with SMTP id a9so5692370wmj.3 for ; Wed, 19 Feb 2020 00:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=vVlDEUkhy5V666kJNY9cobXpYKxmCrcUopw89vJgQ8U=; b=r9twQRa1QnXiljvJ/J6IEKmDblXQ627BR9PP/HFXOpoP6Fv/Cr0+MOLO3pAeFY04j8 9PRhw/7dFKWO55uoF1AZDLCbYMy6qu3pul5ZC5M3v7jpSAcux1tmMyiaOKktfmfffDn7 IfOzfN92xmxP/oHZEypfTPIKIKOgumK6Yo+Gjq0+a2gavD2gImyOQwASEmre6z0d5U2/ /YdFslg2MUSSL8icpeSSDghSC3Fy2m+Ugkx835uMEWSNVLUlsy+hQ3tk7tyzJLWsP5lO 09Zp2DycVtJ0SDK9HEWkK+2hPxI0FJ+4+l+DKJZHanX/ra8uPWcZzya7/gzypH/hBxyT o24w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=vVlDEUkhy5V666kJNY9cobXpYKxmCrcUopw89vJgQ8U=; b=hMco+rs+xF97hsZEaa8hFmYovceEQ9Qr0nh43bWDouvjpSixMwutdvOFZ5OZsONv2R r7H+IeHRJ4jq7AuqNlPfK4hNmkhnvw2urojSlfqL3ABLqaDRGV0lgG7oUOqMJKe9/sVu LOf7S7iBLHapw1oFi4IyW3EiUDCbEYz5/jn2QoNTXbSpalUQQFrVXhCN4ADG0rbkgkYG /G9HpvgbtKT16lDK4WmWoSXhL/OmAzFPKqr6gh8OLLw41ghrPWFEZGRu2CKy95E/nnD/ uqYdHBxC8t67D6p7qDwknuqRi4Ais/4Ke019d9IgnaKfDNgSQTMBwAEjuLTDCAKWvlvD J1LQ== X-Gm-Message-State: APjAAAVztmS02AoXhyPX/ZnjYGSU9nLS4sGVeb1r8QMZZin4JBkYCqJG 3m27UNBaEtn6qiR8a8aarrenlsJa6aY= X-Google-Smtp-Source: APXvYqydKCWDlKweev7T+6PuXiNymjCHeZZOYOSOQ7bHjaWyXkNiz91HHnX6Fx7b0Y9TCSN0hwEyWA== X-Received: by 2002:a1c:541b:: with SMTP id i27mr9002952wmb.137.1582100358278; Wed, 19 Feb 2020 00:19:18 -0800 (PST) Received: from vbox ([185.140.29.250]) by smtp.gmail.com with ESMTPSA id s65sm1956792wmf.48.2020.02.19.00.19.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 Feb 2020 00:19:17 -0800 (PST) Date: Wed, 19 Feb 2020 09:19:16 +0100 From: =?iso-8859-1?Q?J=FAlius?= Milan To: dev@dpdk.org, jgrajcia@cisco.com Message-ID: <20200219081916.GA11931@vbox> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.9.4 (2018-02-28) Subject: [dpdk-dev] [PATCH 2/2] net/memif: fix init handling when already connected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/net/memif/memif_socket.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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, -- 2.17.1