From nobody Wed Nov 19 12:13:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1616037141; cv=none; d=zohomail.com; s=zohoarc; b=APiJG12IP9bQSZlEII3lkHOZ8bMm/tlZfRZ4bdM9bDQ6c8kV2U88baiaUVnWg96kEl2WM36bM2kyf/cUotzoPjN/Orfr+KgfpBPijGZDlNT0xpSYE4xc1SoaOKCU7KWmDYw5V551GTYovdNjMYxnP73gAgTnQkbNwrGNDKN9Evk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616037141; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JeR90vyGwjTCkvQhRJaJWqNcgYaHr9ErkXWr3PFnfao=; b=G9zuomxY2vkA5IcWGsuaTxWdOrHERmgVahirk6cfshgXhA5F9zLbtUmhw5YtXYm8FWH/QGt0K9GL6tm7nltjcYhv6nggvZAIU7Ufhq5yL/0SCrAYBFwbFvIPVpQBLCUKbq8FTGjX2Dgdea1FHW6J+JiVePSdMfpi/1KIATZKskE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616037141757456.45205409768766; Wed, 17 Mar 2021 20:12:21 -0700 (PDT) Received: from localhost ([::1]:53110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMj5A-00063F-DE for importer@patchew.org; Wed, 17 Mar 2021 23:12:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3f-0004Hg-To for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:47 -0400 Received: from mga09.intel.com ([134.134.136.24]:54698) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3d-0005re-Pk for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:47 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:39 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:37 -0700 IronPort-SDR: wC7nD/3PcYLUne/93nlvDyGPU0IsUxT8+5HC6Ox0vajR1iYc/kOYbK/fWkeesWNAn/MpK1ton2 hUVcaZSmNqeQ== X-IronPort-AV: E=McAfee;i="6000,8403,9926"; a="189681333" X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="189681333" IronPort-SDR: ata36DlWdHpFnPaX5n7HZG6RejG2k3i2JQswaxoTtQHyN0uHgbcUSOGzJ/Slwz3Kib+hxH/Nm8 gleUFsLc5IAg== X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="412898197" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Lukas Straub Subject: [PATCH V3 1/7] qapi/net.json: Add IP_PROTOCOL definition Date: Thu, 18 Mar 2021 11:04:54 +0800 Message-Id: <20210318030500.55352-2-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318030500.55352-1-chen.zhang@intel.com> References: <20210318030500.55352-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.24; envelope-from=chen.zhang@intel.com; helo=mga09.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add IP_PROTOCOL as enum include TCP,UDP, ICMP... for other QMP commands. Signed-off-by: Zhang Chen --- qapi/net.json | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/qapi/net.json b/qapi/net.json index c31748c87f..dc4c87dc7b 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -714,3 +714,33 @@ ## { 'event': 'FAILOVER_NEGOTIATED', 'data': {'device-id': 'str'} } + +## +# @IP_PROTOCOL: +# +# Transport layer protocol. +# +# Just for IPv4. +# +# @tcp: Transmission Control Protocol. +# +# @udp: User Datagram Protocol. +# +# @dccp: Datagram Congestion Control Protocol. +# +# @sctp: Stream Control Transmission Protocol. +# +# @udplite: Lightweight User Datagram Protocol. +# +# @icmp: Internet Control Message Protocol. +# +# @igmp: Internet Group Management Protocol. +# +# @ipv6: IPv6 Encapsulation. +# +# TODO: Need to add more transport layer protocol. +# +# Since: 6.0 +## +{ 'enum': 'IP_PROTOCOL', 'data': [ 'tcp', 'udp', 'dccp', 'sctp', 'udplite', + 'icmp', 'igmp', 'ipv6' ] } --=20 2.25.1 From nobody Wed Nov 19 12:13:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1616037243; cv=none; d=zohomail.com; s=zohoarc; b=STwSDxn2Xe/aYe39AypbHM3s3VEMZ3qZrpL8Qn2h7/TeAzjMjWqDK+X+faeJKj7iLuOjfzjS458mD9r8dESqE0QhGXDc85h2FnvBSTPLk73lI6Gtw/5TwkuG3M3rWC++sohQpb8mZ89sRBP+VbMxrPSryyi0j7dJr/M+6WspPz8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616037243; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C9v1NpZ5VHvynVbbfAdNS3b+K0uY1UWba43SIF95jAY=; b=WNA0RqHvePsIlATqtWATtipQOO4nMfTiLDeO8t1koSlIZcSKJ6S6SJEOQVA24/5g/yFnBn6YEETW7ST+nRnFE2lPGKyxztUJZFIk2U8cUeSj+QEcEAnur9QCyURQd3juWX18m5pLX+LlYHwZjhCGjOwgVoesKU8S0tX8Vi5C8RE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161603724369333.8130277696481; Wed, 17 Mar 2021 20:14:03 -0700 (PDT) Received: from localhost ([::1]:60226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMj6o-0000U5-Kd for importer@patchew.org; Wed, 17 Mar 2021 23:14:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55278) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3f-0004Ha-7g for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:47 -0400 Received: from mga09.intel.com ([134.134.136.24]:54700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3d-0005sv-G2 for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:47 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:41 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:39 -0700 IronPort-SDR: c3R9nWlKCrpn0Up6ZR0+hXMUTobzLAZ5g2DjJGdq223P300KFTgaf2SGFKnjQ+iHzUHtd+/tOH 9RBrsIqksZwQ== X-IronPort-AV: E=McAfee;i="6000,8403,9926"; a="189681337" X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="189681337" IronPort-SDR: VToqeDUO/HLPVVKLiEpM9uaE4O0aGDCyCu+pYPJAaz77fnIxLXcLQJiPrxI2weSBAPqKgTGD61 rqtfOkWsaKCg== X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="412898213" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Lukas Straub Subject: [PATCH V3 2/7] qapi/net.json: Add L4_Connection definition Date: Thu, 18 Mar 2021 11:04:55 +0800 Message-Id: <20210318030500.55352-3-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318030500.55352-1-chen.zhang@intel.com> References: <20210318030500.55352-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.24; envelope-from=chen.zhang@intel.com; helo=mga09.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add L4_Connection struct for other QMP commands. Except protocol field is necessary, other fields are optional. Signed-off-by: Zhang Chen --- qapi/net.json | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/qapi/net.json b/qapi/net.json index dc4c87dc7b..b4958447f2 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -744,3 +744,29 @@ ## { 'enum': 'IP_PROTOCOL', 'data': [ 'tcp', 'udp', 'dccp', 'sctp', 'udplite', 'icmp', 'igmp', 'ipv6' ] } + +## +# @L4_Connection: +# +# Layer 4 network connection. +# +# Just for IPv4. +# +# @protocol: Transport layer protocol like TCP/UDP... +# +# @id: For specific module with Qemu object ID, If there is no such part, +# it means global rules. +# +# @src_ip: Source IP. +# +# @dst_ip: Destination IP. +# +# @src_port: Source port. +# +# @dst_port: Destination port. +# +# Since: 6.0 +## +{ 'struct': 'L4_Connection', + 'data': { 'protocol': 'IP_PROTOCOL', '*id': 'str', '*src_ip': 'str', '*d= st_ip': 'str', + '*src_port': 'int', '*dst_port': 'int' } } --=20 2.25.1 From nobody Wed Nov 19 12:13:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1616037137; cv=none; d=zohomail.com; s=zohoarc; b=ngwC4veJHPgAgvZAYEFmM2QD1rCL1ArI+X1iPpKOdYwTb1WTP7t+Cy+LbO2lNmcXVhHsUCFXYCWPc3GqowsVctOOK0Z92Olp7Pcz7GL7nhxjq/kTgAaiW7LYQq/T4hz/ruu2/asJ1HlzV4vTHd92JqY9I/Y7p1hoS8ctiT1uvEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616037137; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nRIzGmlVEHdVcxMk4yQw0Tbs0pOVskqI1FJByEfmB6s=; b=ea9xix/KYDkVab03baAjm8TWmqjpCP+e6LfKEwlOrdEl3ErbhMNC8MrMHwxYU4qpCF3XSBh0cEazLAbZoiFuTK4UkvdadG42GItMyHs2chDPt8nWkfWeKhNOENKNL834LwF+yFok0/r9gxCy6JaR911tOc6tzrcYxeUYAV5v+d8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616037137084633.8257325182648; Wed, 17 Mar 2021 20:12:17 -0700 (PDT) Received: from localhost ([::1]:52994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMj55-00060Y-OO for importer@patchew.org; Wed, 17 Mar 2021 23:12:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3g-0004Hn-P0 for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:48 -0400 Received: from mga09.intel.com ([134.134.136.24]:54696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3f-0005qP-2x for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:48 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:44 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:42 -0700 IronPort-SDR: JCTv37OkvENCUhHWH5MutSbty33hTQxPgdbbATRB5XzDm2YvigMm1gmgTiUH3nPc0r8YP3rjvG Z8xXc41kyrlg== X-IronPort-AV: E=McAfee;i="6000,8403,9926"; a="189681343" X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="189681343" IronPort-SDR: GZDNlh46FIFXMFtGbVavHt4jQkwlIEIQcEjGQFScJadl9xMDFdYYaCnphlwnT18UNM0votpoDG 9XkyFZYKxIWw== X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="412898228" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Lukas Straub Subject: [PATCH V3 3/7] qapi/net: Add new QMP command for COLO passthrough Date: Thu, 18 Mar 2021 11:04:56 +0800 Message-Id: <20210318030500.55352-4-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318030500.55352-1-chen.zhang@intel.com> References: <20210318030500.55352-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.24; envelope-from=chen.zhang@intel.com; helo=mga09.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since the real user scenario does not need COLO to monitor all traffic. Add colo-passthrough-add and colo-passthrough-del to maintain a COLO network passthrough list. QMP demo usage: {'execute': 'colo-passthrough-add', 'arguments': {'protocol': 'tcp', 'id': = 'comp0', 'src_ip':'10.239.48.105', 'dst_ip':'10.239.48.128', 'src_port':123= 4, 'dst_port':1235}} Signed-off-by: Zhang Chen --- net/net.c | 10 ++++++++++ qapi/net.json | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/net/net.c b/net/net.c index e1035f21d1..037dcc5973 100644 --- a/net/net.c +++ b/net/net.c @@ -1151,6 +1151,16 @@ void qmp_netdev_del(const char *id, Error **errp) qemu_del_net_client(nc); } =20 +void qmp_colo_passthrough_add(L4_Connection *conn, Error **errp) +{ + /* Setup passthrough connection */ +} + +void qmp_colo_passthrough_del(L4_Connection *conn, Error **errp) +{ + /* Delete passthrough connection */ +} + static void netfilter_print_info(Monitor *mon, NetFilterState *nf) { char *str; diff --git a/qapi/net.json b/qapi/net.json index b4958447f2..e0c6e1d8f3 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -770,3 +770,43 @@ { 'struct': 'L4_Connection', 'data': { 'protocol': 'IP_PROTOCOL', '*id': 'str', '*src_ip': 'str', '*d= st_ip': 'str', '*src_port': 'int', '*dst_port': 'int' } } + +## +# @colo-passthrough-add: +# +# Add passthrough entry according to customer's needs in COLO-compare. +# +# Returns: Nothing on success +# +# Since: 6.0 +# +# Example: +# +# -> { "execute": "colo-passthrough-add", +# "arguments": { "protocol": "tcp", "id": "object0", "src_ip": "192.1= 68.1.1", +# "dst_ip": "192.168.1.2", "src_port": 1234, "dst_port": 4321 } } +# <- { "return": {} } +# +## +{ 'command': 'colo-passthrough-add', 'boxed': true, + 'data': 'L4_Connection' } + +## +# @colo-passthrough-del: +# +# Delete passthrough entry according to customer's needs in COLO-compare. +# +# Returns: Nothing on success +# +# Since: 6.0 +# +# Example: +# +# -> { "execute": "colo-passthrough-del", +# "arguments": { "protocol": "tcp", "id": "object0", "src_ip": "192.1= 68.1.1", +# "dst_ip": "192.168.1.2", "src_port": 1234, "dst_port": 4321 } } +# <- { "return": {} } +# +## +{ 'command': 'colo-passthrough-del', 'boxed': true, + 'data': 'L4_Connection' } --=20 2.25.1 From nobody Wed Nov 19 12:13:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1616037357; cv=none; d=zohomail.com; s=zohoarc; b=hG6inJo35/EvCcbqf6wVhTGYPgbR7l3IRjwecyx+Khxms2qa01+n9XHY3TFJ7QpyIFF9VJPDg+GzA7QM/hr+EQ0IUfL9PMkwQn0YeiyBPSIvgjFurBn/tItSIU50TW4TAw9eX49A8x7XxvdNcrhLMviAHxYpV28zUWqxxGS2rWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616037357; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=O2FLpiCUQM/kgF3Gjh8TywcMeI0FdEbryTR3ZM0EU38=; b=NejupmN17pRl0fKHd6qPQ8XFCp4BUAMXTG+2it78r81/NSuPKdnoOzb0gXfkxWnexDCi4I3wmugssCoL2blo8/5v7BplwiCDypZs+D4PUaTA0KBAqyNPiZDIwV2S1F7ffiTOq3K3v6NADvFvougp/ntiRmpNnZSndhF279nMyyI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616037357313628.6564302171594; Wed, 17 Mar 2021 20:15:57 -0700 (PDT) Received: from localhost ([::1]:36696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMj8e-0002Q7-BZ for importer@patchew.org; Wed, 17 Mar 2021 23:15:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3h-0004IU-EK for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:49 -0400 Received: from mga09.intel.com ([134.134.136.24]:54700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3f-0005sv-Kt for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:49 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:46 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:44 -0700 IronPort-SDR: Vuvw18XOw1/BKGU1NLpDR/KcmcYQil7hlKYdDfS5jmr0gNzyaZxC/zTzZKVIa+4u/KSzNMyoOc 8AFgzeAKODwA== X-IronPort-AV: E=McAfee;i="6000,8403,9926"; a="189681347" X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="189681347" IronPort-SDR: gTAU4Ib6i7UhvqhM6L1KSqTyGNB+Uyh+h2rtNueqB3WsWEm5WZu0S1UACV++TKnOUZ065+oVrT 0CF8qRQpjNYw== X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="412898243" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Lukas Straub Subject: [PATCH V3 4/7] hmp-commands: Add new HMP command for COLO passthrough Date: Thu, 18 Mar 2021 11:04:57 +0800 Message-Id: <20210318030500.55352-5-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318030500.55352-1-chen.zhang@intel.com> References: <20210318030500.55352-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.24; envelope-from=chen.zhang@intel.com; helo=mga09.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add hmp_colo_passthrough_add and hmp_colo_passthrough_del make user can maintain COLO network passthrough list in human monitor. Signed-off-by: Zhang Chen --- hmp-commands.hx | 26 ++++++++++++++++++++++++++ include/monitor/hmp.h | 2 ++ monitor/hmp-cmds.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 73e0832ea1..c71521303c 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1341,6 +1341,32 @@ SRST Remove host network device. ERST =20 + { + .name =3D "colo_passthrough_add", + .args_type =3D "protocol:s,id:s?,src_ip:s?,dst_ip:s?,src_port:i?,= dst_port:i?", + .params =3D "protocol [id] [src_ip] [dst_ip] [src_port] [dst_p= ort]", + .help =3D "Add network stream to colo passthrough list", + .cmd =3D hmp_colo_passthrough_add, + }, + +SRST +``colo_passthrough_add`` + Add network stream to colo passthrough list. +ERST + + { + .name =3D "colo_passthrough_del", + .args_type =3D "protocol:s,id:s?,src_ip:s?,dst_ip:s?,src_port:i?,= dst_port:i?", + .params =3D "protocol [id] [src_ip] [dst_ip] [src_port] [dst_p= ort]", + .help =3D "Delete network stream from colo passthrough list", + .cmd =3D hmp_colo_passthrough_del, + }, + +SRST +``colo_passthrough_del`` + Delete network stream from colo passthrough list. +ERST + { .name =3D "object_add", .args_type =3D "object:O", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index ed2913fd18..3c4943b09f 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -81,6 +81,8 @@ void hmp_device_del(Monitor *mon, const QDict *qdict); void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict); void hmp_netdev_add(Monitor *mon, const QDict *qdict); void hmp_netdev_del(Monitor *mon, const QDict *qdict); +void hmp_colo_passthrough_add(Monitor *mon, const QDict *qdict); +void hmp_colo_passthrough_del(Monitor *mon, const QDict *qdict); void hmp_getfd(Monitor *mon, const QDict *qdict); void hmp_closefd(Monitor *mon, const QDict *qdict); void hmp_sendkey(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index fd4d77e246..de675d16e7 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1660,6 +1660,40 @@ void hmp_netdev_del(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, err); } =20 +void hmp_colo_passthrough_add(Monitor *mon, const QDict *qdict) +{ + const char *prot =3D qdict_get_str(qdict, "protocol"); + L4_Connection *l4_conn =3D g_new0(L4_Connection, 1); + Error *err =3D NULL; + + l4_conn->id =3D g_strdup(qdict_get_try_str(qdict, "id")); + l4_conn->protocol =3D qapi_enum_parse(&IP_PROTOCOL_lookup, prot, -1, &= err); + l4_conn->src_ip =3D g_strdup(qdict_get_try_str(qdict, "src_ip")); + l4_conn->dst_ip =3D g_strdup(qdict_get_try_str(qdict, "dst_ip")); + l4_conn->src_port =3D qdict_get_try_int(qdict, "src_port", 0); + l4_conn->dst_port =3D qdict_get_try_int(qdict, "dst_port", 0); + + qmp_colo_passthrough_add(l4_conn, &err); + hmp_handle_error(mon, err); +} + +void hmp_colo_passthrough_del(Monitor *mon, const QDict *qdict) +{ + const char *prot =3D qdict_get_str(qdict, "protocol"); + L4_Connection *l4_conn =3D g_new0(L4_Connection, 1); + Error *err =3D NULL; + + l4_conn->id =3D g_strdup(qdict_get_try_str(qdict, "id")); + l4_conn->protocol =3D qapi_enum_parse(&IP_PROTOCOL_lookup, prot, -1, &= err); + l4_conn->src_ip =3D g_strdup(qdict_get_try_str(qdict, "src_ip")); + l4_conn->dst_ip =3D g_strdup(qdict_get_try_str(qdict, "dst_ip")); + l4_conn->src_port =3D qdict_get_try_int(qdict, "src_port", 0); + l4_conn->dst_port =3D qdict_get_try_int(qdict, "dst_port", 0); + + qmp_colo_passthrough_del(l4_conn, &err); + hmp_handle_error(mon, err); +} + void hmp_object_add(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; --=20 2.25.1 From nobody Wed Nov 19 12:13:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1616037148; cv=none; d=zohomail.com; s=zohoarc; b=h0uNshuu7GSlqmS3HLCL8Zh3Fjo4wEmiVdnVJstQDV/O/9zM/RxSqL3UVMMtfqF05hJ+H3ufudKC5apuZGrPHJkosN1CNWNqP2r7sbqown4Mnj9C2WCD/SQ9ZR0XcysdRj+n/R35P6BebOUwDqKcCUB5p+Mgscq1Y76gaSXOvGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616037148; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TtMtwxNjfyowPmMBgCEzuLspNOk9nmzWJDPH+2yfE58=; b=MnS70GSzOloyKWXY53134BSLvoDOOZECsiA8lnl2jH0iUgEtqguP6TFPOifyhujaZpkBskfPbDcULzPC0HP1/X6mM+R9B6RFnqW/ZBir9RkN+OnY+N1itTPz57tAzb6u0JibB7UMQ6fgxFPWVFGLF+VVPNy5V1rtdPzV7njj6Fg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616037148420979.5233501059053; Wed, 17 Mar 2021 20:12:28 -0700 (PDT) Received: from localhost ([::1]:53362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMj5G-00069R-D1 for importer@patchew.org; Wed, 17 Mar 2021 23:12:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3j-0004Lv-TF for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:51 -0400 Received: from mga09.intel.com ([134.134.136.24]:54700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3h-0005sv-QL for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:51 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:49 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:46 -0700 IronPort-SDR: boY9I/G2h4DQRe+mY/EygCdm2e83yjfBBq56A61L1nigh77d9jiIavIyUTen7mws5ZOEdX/VzR h1Pp4S1VFhHQ== X-IronPort-AV: E=McAfee;i="6000,8403,9926"; a="189681352" X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="189681352" IronPort-SDR: trFDh0fp6PurIXX5nUKbPRzLj92QiWLMMGue+NHaPYN4bG1TGa0KYVvErUOR1Ljyas3IQS1Zyq sl/yc9MSiUag== X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="412898258" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Lukas Straub Subject: [PATCH V3 5/7] net/colo-compare: Move data structure and define to .h file. Date: Thu, 18 Mar 2021 11:04:58 +0800 Message-Id: <20210318030500.55352-6-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318030500.55352-1-chen.zhang@intel.com> References: <20210318030500.55352-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.24; envelope-from=chen.zhang@intel.com; helo=mga09.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Make other modules can reuse COLO code. Signed-off-by: Zhang Chen --- net/colo-compare.c | 106 --------------------------------------------- net/colo-compare.h | 106 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 106 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 84db4978ac..a803f8b888 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -17,44 +17,24 @@ #include "qemu/error-report.h" #include "trace.h" #include "qapi/error.h" -#include "net/net.h" #include "net/eth.h" #include "qom/object_interfaces.h" #include "qemu/iov.h" #include "qom/object.h" #include "net/queue.h" -#include "chardev/char-fe.h" #include "qemu/sockets.h" -#include "colo.h" -#include "sysemu/iothread.h" #include "net/colo-compare.h" -#include "migration/colo.h" -#include "migration/migration.h" #include "util.h" =20 #include "block/aio-wait.h" #include "qemu/coroutine.h" =20 -#define TYPE_COLO_COMPARE "colo-compare" -typedef struct CompareState CompareState; -DECLARE_INSTANCE_CHECKER(CompareState, COLO_COMPARE, - TYPE_COLO_COMPARE) - static QTAILQ_HEAD(, CompareState) net_compares =3D QTAILQ_HEAD_INITIALIZER(net_compares); =20 static NotifierList colo_compare_notifiers =3D NOTIFIER_LIST_INITIALIZER(colo_compare_notifiers); =20 -#define COMPARE_READ_LEN_MAX NET_BUFSIZE -#define MAX_QUEUE_SIZE 1024 - -#define COLO_COMPARE_FREE_PRIMARY 0x01 -#define COLO_COMPARE_FREE_SECONDARY 0x02 - -#define REGULAR_PACKET_CHECK_MS 1000 -#define DEFAULT_TIME_OUT_MS 3000 - /* #define DEBUG_COLO_PACKETS */ =20 static QemuMutex colo_compare_mutex; @@ -64,92 +44,6 @@ static QemuCond event_complete_cond; static int event_unhandled_count; static uint32_t max_queue_size; =20 -/* - * + CompareState ++ - * | | - * +---------------+ +---------------+ +---------------+ - * | conn list + - > conn + ------- > conn + -- > .= ..... - * +---------------+ +---------------+ +---------------+ - * | | | | | | - * +---------------+ +---v----+ +---v----+ +---v----+ +---v----+ - * |primary | |secondary |primary | |secondary - * |packet | |packet + |packet | |packet + - * +--------+ +--------+ +--------+ +--------+ - * | | | | - * +---v----+ +---v----+ +---v----+ +---v----+ - * |primary | |secondary |primary | |secondary - * |packet | |packet + |packet | |packet + - * +--------+ +--------+ +--------+ +--------+ - * | | | | - * +---v----+ +---v----+ +---v----+ +---v----+ - * |primary | |secondary |primary | |secondary - * |packet | |packet + |packet | |packet + - * +--------+ +--------+ +--------+ +--------+ - */ - -typedef struct SendCo { - Coroutine *co; - struct CompareState *s; - CharBackend *chr; - GQueue send_list; - bool notify_remote_frame; - bool done; - int ret; -} SendCo; - -typedef struct SendEntry { - uint32_t size; - uint32_t vnet_hdr_len; - uint8_t *buf; -} SendEntry; - -struct CompareState { - Object parent; - - char *pri_indev; - char *sec_indev; - char *outdev; - char *notify_dev; - CharBackend chr_pri_in; - CharBackend chr_sec_in; - CharBackend chr_out; - CharBackend chr_notify_dev; - SocketReadState pri_rs; - SocketReadState sec_rs; - SocketReadState notify_rs; - SendCo out_sendco; - SendCo notify_sendco; - bool vnet_hdr; - uint64_t compare_timeout; - uint32_t expired_scan_cycle; - - /* - * Record the connection that through the NIC - * Element type: Connection - */ - GQueue conn_list; - /* Record the connection without repetition */ - GHashTable *connection_track_table; - - IOThread *iothread; - GMainContext *worker_context; - QEMUTimer *packet_check_timer; - - QEMUBH *event_bh; - enum colo_event event; - - QTAILQ_ENTRY(CompareState) next; -}; - -typedef struct CompareClass { - ObjectClass parent_class; -} CompareClass; - -enum { - PRIMARY_IN =3D 0, - SECONDARY_IN, -}; - static const char *colo_mode[] =3D { [PRIMARY_IN] =3D "primary", [SECONDARY_IN] =3D "secondary", diff --git a/net/colo-compare.h b/net/colo-compare.h index 22ddd512e2..2a9dcac0a7 100644 --- a/net/colo-compare.h +++ b/net/colo-compare.h @@ -17,6 +17,112 @@ #ifndef QEMU_COLO_COMPARE_H #define QEMU_COLO_COMPARE_H =20 +#include "net/net.h" +#include "chardev/char-fe.h" +#include "migration/colo.h" +#include "migration/migration.h" +#include "sysemu/iothread.h" +#include "colo.h" + +#define TYPE_COLO_COMPARE "colo-compare" +typedef struct CompareState CompareState; +DECLARE_INSTANCE_CHECKER(CompareState, COLO_COMPARE, + TYPE_COLO_COMPARE) + +#define COMPARE_READ_LEN_MAX NET_BUFSIZE +#define MAX_QUEUE_SIZE 1024 + +#define COLO_COMPARE_FREE_PRIMARY 0x01 +#define COLO_COMPARE_FREE_SECONDARY 0x02 + +#define REGULAR_PACKET_CHECK_MS 1000 +#define DEFAULT_TIME_OUT_MS 3000 + +typedef struct SendCo { + Coroutine *co; + struct CompareState *s; + CharBackend *chr; + GQueue send_list; + bool notify_remote_frame; + bool done; + int ret; +} SendCo; + +typedef struct SendEntry { + uint32_t size; + uint32_t vnet_hdr_len; + uint8_t *buf; +} SendEntry; + +/* + * + CompareState ++ + * | | + * +---------------+ +---------------+ +---------------+ + * | conn list + - > conn + ------- > conn + -- > .= ..... + * +---------------+ +---------------+ +---------------+ + * | | | | | | + * +---------------+ +---v----+ +---v----+ +---v----+ +---v----+ + * |primary | |secondary |primary | |secondary + * |packet | |packet + |packet | |packet + + * +--------+ +--------+ +--------+ +--------+ + * | | | | + * +---v----+ +---v----+ +---v----+ +---v----+ + * |primary | |secondary |primary | |secondary + * |packet | |packet + |packet | |packet + + * +--------+ +--------+ +--------+ +--------+ + * | | | | + * +---v----+ +---v----+ +---v----+ +---v----+ + * |primary | |secondary |primary | |secondary + * |packet | |packet + |packet | |packet + + * +--------+ +--------+ +--------+ +--------+ + */ +struct CompareState { + Object parent; + + char *pri_indev; + char *sec_indev; + char *outdev; + char *notify_dev; + CharBackend chr_pri_in; + CharBackend chr_sec_in; + CharBackend chr_out; + CharBackend chr_notify_dev; + SocketReadState pri_rs; + SocketReadState sec_rs; + SocketReadState notify_rs; + SendCo out_sendco; + SendCo notify_sendco; + bool vnet_hdr; + uint64_t compare_timeout; + uint32_t expired_scan_cycle; + + /* + * Record the connection that through the NIC + * Element type: Connection + */ + GQueue conn_list; + /* Record the connection without repetition */ + GHashTable *connection_track_table; + + IOThread *iothread; + GMainContext *worker_context; + QEMUTimer *packet_check_timer; + + QEMUBH *event_bh; + enum colo_event event; + + QTAILQ_ENTRY(CompareState) next; +}; + +typedef struct CompareClass { + ObjectClass parent_class; +} CompareClass; + +enum { + PRIMARY_IN =3D 0, + SECONDARY_IN, +}; + void colo_notify_compares_event(void *opaque, int event, Error **errp); void colo_compare_register_notifier(Notifier *notify); void colo_compare_unregister_notifier(Notifier *notify); --=20 2.25.1 From nobody Wed Nov 19 12:13:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1616037413; cv=none; d=zohomail.com; s=zohoarc; b=KYsBkQaAKw54p0QQIF57Qa1gwoO+O3P8yY3/IXZwAW4kaEgHllQrqs2aHlJxUjk1Vf8QzaC/4kg3CAiU8ndiPoqiiJOqJngfMwMC86ROEa6hyuZktap9LClorEzwPnWFLr4Ovi8T8Qa8FF7gjiZBMDDw7nSnDfxysrGK8GNvdGA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616037413; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2UPJttM3zNz9wngCequhXrK+sqVZfI/iEqebMTeezfk=; b=SZf0ScrVGkfTk452wfmwE+ZeasY168yznmEyjhhOhIxgu3l05qG6t3hg7vxb2jeOzdP1ujFlVa7+/8bKbzRLdrWeYUfqkVVATIb/a3neBeEFbkIXgWZbo8rbps1/6JfGfzZQV1e2ZydiavyJmuA2PK8cHxUlkjqzj4boHEjrurM= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616037413951518.7297695099579; Wed, 17 Mar 2021 20:16:53 -0700 (PDT) Received: from localhost ([::1]:38828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMj9Z-0003Og-00 for importer@patchew.org; Wed, 17 Mar 2021 23:16:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3n-0004Ob-AF for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:55 -0400 Received: from mga09.intel.com ([134.134.136.24]:54706) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3k-0005wD-HL for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:55 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:51 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:49 -0700 IronPort-SDR: b2jOrDz3uzt0EagMqak6dy7g5XZnZ6Dp9DDSilRp0aoeyHyDLE6j14BN376Y1IWktk02Vu2JQg MudugLa4L6ig== X-IronPort-AV: E=McAfee;i="6000,8403,9926"; a="189681354" X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="189681354" IronPort-SDR: 6tscJbnu7obPtbHWtrzlEk+HM+I3VNQcJ2bHDuZWuqyIGgR8a08DUbI3+EUAL7o2RAbhRIP48z lFAOtQEh6igA== X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="412898271" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Lukas Straub Subject: [PATCH V3 6/7] net/colo-compare: Add passthrough list to CompareState Date: Thu, 18 Mar 2021 11:04:59 +0800 Message-Id: <20210318030500.55352-7-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318030500.55352-1-chen.zhang@intel.com> References: <20210318030500.55352-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.24; envelope-from=chen.zhang@intel.com; helo=mga09.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add passthrough list for each CompareState. Signed-off-by: Zhang Chen --- net/colo-compare.c | 29 +++++++++++++++++++++++++++++ net/colo-compare.h | 11 +++++++++++ 2 files changed, 40 insertions(+) diff --git a/net/colo-compare.c b/net/colo-compare.c index a803f8b888..40af8cd501 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -141,6 +141,7 @@ static int packet_enqueue(CompareState *s, int mode, Co= nnection **con) ConnectionKey key; Packet *pkt =3D NULL; Connection *conn; + PassthroughEntry *bypass, *next; int ret; =20 if (mode =3D=3D PRIMARY_IN) { @@ -160,6 +161,32 @@ static int packet_enqueue(CompareState *s, int mode, C= onnection **con) } fill_connection_key(pkt, &key); =20 + /* Check COLO passthrough connenction */ + qemu_mutex_lock(&s->passthroughlist_mutex); + if (!QLIST_EMPTY(&s->passthroughlist)) { + QLIST_FOREACH_SAFE(bypass, &s->passthroughlist, node, next) { + if (((key.ip_proto =3D=3D IPPROTO_TCP) && (bypass->l4_protocol= =3D=3D 0)) || + ((key.ip_proto =3D=3D IPPROTO_UDP) && (bypass->l4_protocol= =3D=3D 1))) { + if (bypass->src_port =3D=3D 0 || bypass->src_port =3D=3D k= ey.dst_port) { + if (bypass->src_ip.s_addr =3D=3D 0 || + bypass->src_ip.s_addr =3D=3D key.src.s_addr) { + if (bypass->dst_port =3D=3D 0 || + bypass->dst_port =3D=3D key.src_port) { + if (bypass->dst_ip.s_addr =3D=3D 0 || + bypass->dst_ip.s_addr =3D=3D key.dst.s_add= r) { + packet_destroy(pkt, NULL); + pkt =3D NULL; + qemu_mutex_unlock(&s->passthroughlist_mute= x); + return -1; + } + } + } + } + } + } + } + qemu_mutex_unlock(&s->passthroughlist_mutex); + conn =3D connection_get(s->connection_track_table, &key, &s->conn_list); @@ -1224,6 +1251,7 @@ static void colo_compare_complete(UserCreatable *uc, = Error **errp) } =20 g_queue_init(&s->conn_list); + QLIST_INIT(&s->passthroughlist); =20 s->connection_track_table =3D g_hash_table_new_full(connection_key_has= h, connection_key_equal, @@ -1236,6 +1264,7 @@ static void colo_compare_complete(UserCreatable *uc, = Error **errp) if (!colo_compare_active) { qemu_mutex_init(&event_mtx); qemu_cond_init(&event_complete_cond); + qemu_mutex_init(&s->passthroughlist_mutex); colo_compare_active =3D true; } QTAILQ_INSERT_TAIL(&net_compares, s, next); diff --git a/net/colo-compare.h b/net/colo-compare.h index 2a9dcac0a7..2259abcd63 100644 --- a/net/colo-compare.h +++ b/net/colo-compare.h @@ -54,6 +54,15 @@ typedef struct SendEntry { uint8_t *buf; } SendEntry; =20 +typedef struct PassthroughEntry { + int l4_protocol; + int src_port; + int dst_port; + struct in_addr src_ip; + struct in_addr dst_ip; + QLIST_ENTRY(PassthroughEntry) node; +} PassthroughEntry; + /* * + CompareState ++ * | | @@ -110,6 +119,8 @@ struct CompareState { =20 QEMUBH *event_bh; enum colo_event event; + QLIST_HEAD(, PassthroughEntry) passthroughlist; + QemuMutex passthroughlist_mutex; =20 QTAILQ_ENTRY(CompareState) next; }; --=20 2.25.1 From nobody Wed Nov 19 12:13:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1616037246; cv=none; d=zohomail.com; s=zohoarc; b=JOnewkLURsFZOnShQWW9cBqUZzN7I4Ym9gR6se8vnyECqzYBtessPd5XkTeoOIeCoXpC4KgqdUVgbHgqDOOHhe7FAys42UbXkSx3yZvIz0etTflTbrqWx+HPDFpQQjsEANUpY8btKb85awSb/81DRNYz2TMcDYjWKpDFPegVcxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616037246; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0dD0EkFWrozwggBxYOkaBxWgqy/xBVo2YlOzn2+K1fU=; b=QQ25iqcFCW9cuUw1ff/ALLkLRlbxBXpLaulPLw3VgyEo8h5Im9XDEpjEu6K183iwk2wx0ItsYxhi92b67oYBKWwz15by47tpJg24VcJmz0uHuEyUiH/T6PpVk1u3gbQxc8pepQa3nTrKoE4uEhAyzZ9CKUV5c0vLvsI7krmahpA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1616037246585484.3335816924972; Wed, 17 Mar 2021 20:14:06 -0700 (PDT) Received: from localhost ([::1]:60474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lMj6r-0000a7-JN for importer@patchew.org; Wed, 17 Mar 2021 23:14:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3p-0004S7-By for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:57 -0400 Received: from mga09.intel.com ([134.134.136.24]:54700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lMj3n-0005sv-51 for qemu-devel@nongnu.org; Wed, 17 Mar 2021 23:10:57 -0400 Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:54 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Mar 2021 20:10:51 -0700 IronPort-SDR: 3AvUBeMgRQIBfC+yDTA9pjocnYwyW05qs8ibBzA8j5PAq51rINxNIOB1G7NC03DzvOiJAvisn9 EXuUcPvMWPIw== X-IronPort-AV: E=McAfee;i="6000,8403,9926"; a="189681359" X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="189681359" IronPort-SDR: 00vr1ULMk0fTAh7QFOV5zeBlig4BtTwwfAWaKxvTK84OBdy5VzdpVbx/lLCyt7fD2+kFcVjsUC UdzklnsLHKsw== X-IronPort-AV: E=Sophos;i="5.81,257,1610438400"; d="scan'208";a="412898313" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Lukas Straub Subject: [PATCH V3 7/7] net/net.c: Add handler for COLO passthrough connection Date: Thu, 18 Mar 2021 11:05:00 +0800 Message-Id: <20210318030500.55352-8-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210318030500.55352-1-chen.zhang@intel.com> References: <20210318030500.55352-1-chen.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.24; envelope-from=chen.zhang@intel.com; helo=mga09.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Use connection protocol,src port,dst port,src ip,dst ip as the key to bypass certain network traffic in COLO compare. Signed-off-by: Zhang Chen --- net/net.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) diff --git a/net/net.c b/net/net.c index 037dcc5973..84065ec74e 100644 --- a/net/net.c +++ b/net/net.c @@ -55,6 +55,8 @@ #include "sysemu/sysemu.h" #include "net/filter.h" #include "qapi/string-output-visitor.h" +#include "net/colo-compare.h" +#include "qom/object_interfaces.h" =20 /* Net bridge is currently not supported for W32. */ #if !defined(_WIN32) @@ -1151,14 +1153,165 @@ void qmp_netdev_del(const char *id, Error **errp) qemu_del_net_client(nc); } =20 +static CompareState *colo_passthrough_check(L4_Connection *conn, Error **e= rrp) +{ + Object *container; + Object *obj; + CompareState *s; + + if (!conn->id) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id", + "Need input colo-compare object id"); + return NULL; + } + + container =3D object_get_objects_root(); + obj =3D object_resolve_path_component(container, conn->id); + if (!obj) { + error_setg(errp, "colo-compare '%s' not found", conn->id); + return NULL; + } + + s =3D COLO_COMPARE(obj); + + if (conn->protocol =3D=3D -1) { + error_setg(errp, "COLO pass through get wrong protocol"); + return NULL; + } + + if ((conn->src_ip && !qemu_isdigit(conn->src_ip[0])) || + (conn->dst_ip && !qemu_isdigit(conn->dst_ip[0]))) { + error_setg(errp, "COLO pass through get wrong IP"); + return NULL; + } + + if (conn->src_port > 65536 || conn->src_port < 0 || + conn->dst_port > 65536 || conn->dst_port < 0) { + error_setg(errp, "COLO pass through get wrong port"); + return NULL; + } + + return s; +} + +static void compare_passthrough_add(CompareState *s, + L4_Connection *conn, + Error **errp) +{ + PassthroughEntry *bypass =3D NULL, *next =3D NULL, *origin =3D NULL; + + bypass =3D g_new0(PassthroughEntry, 1); + + bypass->l4_protocol =3D conn->protocol; + bypass->src_port =3D conn->src_port; + bypass->dst_port =3D conn->dst_port; + + if (!inet_aton(conn->src_ip, &bypass->src_ip)) { + bypass->src_ip.s_addr =3D 0; + } + + if (!inet_aton(conn->dst_ip, &bypass->dst_ip)) { + bypass->dst_ip.s_addr =3D 0; + } + + qemu_mutex_lock(&s->passthroughlist_mutex); + if (!QLIST_EMPTY(&s->passthroughlist)) { + QLIST_FOREACH_SAFE(origin, &s->passthroughlist, node, next) { + if ((bypass->l4_protocol =3D=3D origin->l4_protocol) && + (bypass->src_port =3D=3D origin->src_port) && + (bypass->src_ip.s_addr =3D=3D origin->src_ip.s_addr) && + (bypass->dst_ip.s_addr =3D=3D origin->dst_ip.s_addr)) { + error_setg(errp, "The pass through connection already exis= ts"); + g_free(bypass); + qemu_mutex_unlock(&s->passthroughlist_mutex); + return; + } + } + } + + QLIST_INSERT_HEAD(&s->passthroughlist, bypass, node); + qemu_mutex_unlock(&s->passthroughlist_mutex); +} + +static void compare_passthrough_del(CompareState *s, + L4_Connection *conn, + Error **errp) +{ + PassthroughEntry *bypass =3D NULL, *next =3D NULL, *origin =3D NULL; + + bypass =3D g_new0(PassthroughEntry, 1); + + bypass->l4_protocol =3D conn->protocol; + bypass->src_port =3D conn->src_port; + bypass->dst_port =3D conn->dst_port; + + if (!inet_aton(conn->src_ip, &bypass->src_ip)) { + bypass->src_ip.s_addr =3D 0; + } + + if (!inet_aton(conn->dst_ip, &bypass->dst_ip)) { + bypass->dst_ip.s_addr =3D 0; + } + + qemu_mutex_lock(&s->passthroughlist_mutex); + if (!QLIST_EMPTY(&s->passthroughlist)) { + QLIST_FOREACH_SAFE(origin, &s->passthroughlist, node, next) { + if ((bypass->l4_protocol =3D=3D origin->l4_protocol) && + (bypass->src_port =3D=3D origin->src_port) && + (bypass->src_ip.s_addr =3D=3D origin->src_ip.s_addr) && + (bypass->dst_ip.s_addr =3D=3D origin->dst_ip.s_addr)) { + QLIST_REMOVE(origin, node); + g_free(origin); + g_free(bypass); + qemu_mutex_unlock(&s->passthroughlist_mutex); + return; + } + } + error_setg(errp, "The pass through list can't find the connection"= ); + } else { + error_setg(errp, "The pass through connection list is empty"); + } + + g_free(bypass); + qemu_mutex_unlock(&s->passthroughlist_mutex); +} + void qmp_colo_passthrough_add(L4_Connection *conn, Error **errp) { /* Setup passthrough connection */ + CompareState *s; + Error *err =3D NULL; + + s =3D colo_passthrough_check(conn, &err); + if (err) { + error_propagate(errp, err); + return; + } + + compare_passthrough_add(s, conn, &err); + if (err) { + error_propagate(errp, err); + return; + } } =20 void qmp_colo_passthrough_del(L4_Connection *conn, Error **errp) { /* Delete passthrough connection */ + CompareState *s; + Error *err =3D NULL; + + s =3D colo_passthrough_check(conn, &err); + if (err) { + error_propagate(errp, err); + return; + } + + compare_passthrough_del(s, conn, &err); + if (err) { + error_propagate(errp, err); + return; + } } =20 static void netfilter_print_info(Monitor *mon, NetFilterState *nf) --=20 2.25.1