From nobody Fri May 3 10:32:22 2024 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=1616126723; cv=none; d=zohomail.com; s=zohoarc; b=n+6JcHFpAw6pFnB9YXeppV1qt5bO0JEak961uAgzaYgRorBAv0/dr5/1MFK6ce5BvpKmIslAmvQJHQBSVA5F0mvCj3wo3NW4w16O49wjpKIPg3cEQ8HkpO53YDkmOIY1FBZU4iuzHXqz7siso7cexXxvYVVwuIVpwtaz4/rDMMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616126723; 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=GSoBDSPJiWbznxGLLlrMrxVEV53ZjB8snfrf7a3vQ9s=; b=g9UG4BOovVFVbZpWrWBLGsHqFzmkwCOous+rdjz9EtBlnwS/vNzdyQ+s81sxDg4D84b3RsvhIlFK5cRR1F8ZK2/0U3xU8sj4Bpa5z0cLHOU7DxbiZf3ozNRx9MJtyWwwgUpdCb3O72XsTxVAZh/Nw7yis7+CZa77GBG37LgBpBQ= 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 1616126723720553.1815351650753; Thu, 18 Mar 2021 21:05:23 -0700 (PDT) Received: from localhost ([::1]:34034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN6O2-0002ur-NQ for importer@patchew.org; Fri, 19 Mar 2021 00:05:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jf-0006se-UQ for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:00:51 -0400 Received: from mga18.intel.com ([134.134.136.126]:65156) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jd-0004Ka-Ew for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:00:51 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:44 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:42 -0700 IronPort-SDR: Snasdljvm+korKMj6RHk6BLbdE9wuF4G7BJXbeQLBTdXYnpmh5QP4LnnOktUDW5b1Gj27C+82t KaF5FSzMdtdQ== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="177409904" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="177409904" IronPort-SDR: EktmGBKO5G1CAbGJsaZA+ga4XLSJB2YPxkSmBdtqRU44cY2DtvfhTMQWvAJ2RTvvobE3oXoqLe 8wmlieZCR2lg== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="606456621" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Li Zhijian Subject: [PATCH V4 1/7] qapi/net.json: Add IP_PROTOCOL definition Date: Fri, 19 Mar 2021 11:55:02 +0800 Message-Id: <20210319035508.113741-2-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319035508.113741-1-chen.zhang@intel.com> References: <20210319035508.113741-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.126; envelope-from=chen.zhang@intel.com; helo=mga18.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, 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 , Lukas Straub , 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 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/qapi/net.json b/qapi/net.json index 87361ebd9a..498ea7aa72 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -794,3 +794,34 @@ # ## { 'command': 'query-netdev', 'returns': ['NetdevInfo'] } + +## +# @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.1 +## +{ 'enum': 'IP_PROTOCOL', 'data': [ 'tcp', 'udp', 'dccp', 'sctp', 'udplite', + 'icmp', 'igmp', 'ipv6' ] } + --=20 2.25.1 From nobody Fri May 3 10:32:22 2024 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=1616126589; cv=none; d=zohomail.com; s=zohoarc; b=cTiwlM9zYktcG0f7xI/6bSCwPrTPmBWPHXK8sY5nFvu9izpiKGo1qvYHrIQ65s71fZqO9uNy4wund12lfj82jjnFL8LlrCluZvYZOupToTWr4LcxpnIEhZVsN5ogUE1QT8IcM7AS6EJW5Ffe3oKvrxqUrOnd7DTJlPf7kgEMCA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616126589; 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=XoN/4D8GCcv3l9SakoatH+v9kFFhizyNbgnABoqSzEU=; b=NpsR2Q5abv872CRwZrh8wiiyrMOY7aIE0QxSiiBllV1rH+3eXRXJCAlLMlREmN+ejn9xi5I45cgmpp1iuRzsIJcy+CxJormY+tMKvOukR24eQ0BsjIegBkWzj2VqxsqMW2MWYrVM7Dpg3zHyEBN6Itp5WxlY9G9+TrsDO9PwaSA= 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 1616126588999298.54690055628294; Thu, 18 Mar 2021 21:03:08 -0700 (PDT) Received: from localhost ([::1]:55676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN6Lr-00009x-JQ for importer@patchew.org; Fri, 19 Mar 2021 00:03:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jp-0006vJ-IH for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:01 -0400 Received: from mga18.intel.com ([134.134.136.126]:65160) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jf-0004P3-59 for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:00:59 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:48 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:45 -0700 IronPort-SDR: mKrAEJi88jUD2A/A1Bedrrc6YB3aoVRShBdr3Ry8nQtmVtaCgTF8Ya00MOkwSTm2rOzy1Ci2RV dZVrglg2F1rQ== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="177409906" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="177409906" IronPort-SDR: gQROqdB514rQXKH9NVCObihYXXkQTKh1jtRQ6PchPaL/0DKBQSSSJQpYqM/C+NFJ+J5MAc9wHQ d0QhzbepSkgQ== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="606456635" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Li Zhijian Subject: [PATCH V4 2/7] qapi/net.json: Add L4_Connection definition Date: Fri, 19 Mar 2021 11:55:03 +0800 Message-Id: <20210319035508.113741-3-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319035508.113741-1-chen.zhang@intel.com> References: <20210319035508.113741-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.126; envelope-from=chen.zhang@intel.com; helo=mga18.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, 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 , Lukas Straub , 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 498ea7aa72..cd4a8ed95e 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -825,3 +825,29 @@ { 'enum': 'IP_PROTOCOL', 'data': [ 'tcp', 'udp', 'dccp', 'sctp', 'udplite', 'icmp', 'igmp', 'ipv6' ] } =20 +## +# @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.1 +## +{ '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 Fri May 3 10:32:22 2024 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=1616126846; cv=none; d=zohomail.com; s=zohoarc; b=oLsqWtf4IJ3xKS8m0+rQwZBR1hmr+mMSGPdXusGIfzARAerd6f6CnXICwImCccebWJ28grPNGYa39xKZxiuMZV8d15IVIzf5rb/xySBqd64f2AAD/MGA0ZB4KtzPaoYeCMtyKCewvlOb91auWqH1lBGjNrsk9Mi+5dPf0FgiN4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616126846; 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=daOwIn/SdRdP8S+DlSWAhnBD35+dFPI8wEGI7uN9H1Y=; b=RX7uMqmKbuMIZ+Z6lWaGHlZyy4Wg5pV4kiwsKTg3oAYGDslf/kdV0z/iK0gAF9Dld7frxACQUXB+iBzgF9QxblcZlMvfgEpvbLI0Rym4lTu8U527jfx+H5sXOcbjFRLEYpN3p6rbXGBXtVpBX3ayBrgDCwsAqQyPyKSapjnSIlM= 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 1616126846741111.53597086938464; Thu, 18 Mar 2021 21:07:26 -0700 (PDT) Received: from localhost ([::1]:38252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN6Q1-0004mi-Pi for importer@patchew.org; Fri, 19 Mar 2021 00:07:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jt-0006xC-Hk for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:07 -0400 Received: from mga18.intel.com ([134.134.136.126]:65167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Ji-0004RO-K7 for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:02 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:51 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:47 -0700 IronPort-SDR: aXxdyPE+jqOwzQogHe/xdxFh2YCpx4MzbLiRcgBGgSV+yioIzVxH1JSjNVZQY8kvhOjM21GA3e 3sRw4iSdMK5w== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="177409914" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="177409914" IronPort-SDR: O8fRVmxRXzgGEdPkESruVaYGl4NMdsOg3t+zWK3iLdPz3apUOgbW83akxDoSFCVR7OuWHEaQED sHfGKsD2c93w== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="606456682" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Li Zhijian Subject: [PATCH V4 3/7] qapi/net: Add new QMP command for COLO passthrough Date: Fri, 19 Mar 2021 11:55:04 +0800 Message-Id: <20210319035508.113741-4-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319035508.113741-1-chen.zhang@intel.com> References: <20210319035508.113741-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.126; envelope-from=chen.zhang@intel.com; helo=mga18.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, 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 , Lukas Straub , 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. 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 725a4e1450..7c7cefe0e0 100644 --- a/net/net.c +++ b/net/net.c @@ -1199,6 +1199,16 @@ void qmp_netdev_del(const char *id, Error **errp) } } =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 cd4a8ed95e..ec7d3b1128 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -851,3 +851,43 @@ 'data': { 'protocol': 'IP_PROTOCOL', '*id': 'str', '*src_ip': 'str', '*d= st_ip': 'str', '*src_port': 'int', '*dst_port': 'int' } } =20 +## +# @colo-passthrough-add: +# +# Add passthrough entry according to customer's needs in COLO-compare. +# +# Returns: Nothing on success +# +# Since: 6.1 +# +# 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.1 +# +# 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 Fri May 3 10:32:22 2024 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=1616126593; cv=none; d=zohomail.com; s=zohoarc; b=DiRm00p/7OEsDckQ4NRqOJwOMord42HWyfzuNKipJrFWnCU0aEKkOGWikuo+oM9EJkt/wS/P+k43i9okeKUJknAF9PdJlziNWR4efOyto/lT/J1DVXpZ5rkUkr0Rd0ffJbVeUdnwczjxWtOGxDYnQSsASxlLGKAEObdj6Wcp57o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616126593; 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=Is8GOco+H3kQ3Dr+1BbbO49Kv0WQMxRqwWsNmDwJhC0=; b=h4cSwOC3A4E1pV0yRR9NN+PdoSjJlehdgkSsx/gLM5KHZ01dfDW9gHDAHw/BRNDhE54YTzAyazqviFE24SDYrSCTM0kGycew+ICKP5E6dAUg5dljGYlTOJKD0iNtu14oO4imVR4W2vzxtm0wPizV9NCngYovYgu9UZSySIhcEOU= 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 1616126593549187.7662299416686; Thu, 18 Mar 2021 21:03:13 -0700 (PDT) Received: from localhost ([::1]:56102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN6Lw-0000LH-9L for importer@patchew.org; Fri, 19 Mar 2021 00:03:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jv-0006xV-Oe for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:09 -0400 Received: from mga18.intel.com ([134.134.136.126]:65171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jm-0004V3-JS for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:07 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:54 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:51 -0700 IronPort-SDR: EwMGLq5pFiWAOrFs2UR8HJraS1xErE8wQp5o4Ypo0JalO69ctGsY1X2mwB+u2qGhVx2uW3tZBL z/pRBRNRZAqA== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="177409917" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="177409917" IronPort-SDR: NPTnpFf6uGCTXxJgn6jtwyZjnPTowhXJarMtRQl6tei18RSTgvg66fBtoS09v6C97kJ3/pND1V CN5YScUUieBg== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="606456693" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Li Zhijian Subject: [PATCH V4 4/7] hmp-commands: Add new HMP command for COLO passthrough Date: Fri, 19 Mar 2021 11:55:05 +0800 Message-Id: <20210319035508.113741-5-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319035508.113741-1-chen.zhang@intel.com> References: <20210319035508.113741-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.126; envelope-from=chen.zhang@intel.com; helo=mga18.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, 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 , Lukas Straub , 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 d4001f9c5d..b67a5a04cb 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1335,6 +1335,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 3c88a4faef..b57e3430ab 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1668,6 +1668,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 Fri May 3 10:32:22 2024 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=1616126735; cv=none; d=zohomail.com; s=zohoarc; b=FKCe+u+TEC7iXkZFFhs/OTUd9cCX76t5M9k1EY85EpSzrBkDJfhH9tQ5teU6/PZIDpsOMkF/V2RP3lgM7s+LT3VVl5Az48/Ja9omX/lM2Nt9BFb1TL29s4GKUOhzJX4EDfu0M9H5F6Tx30lw5KyxovU9+Ss+wHgtqPhhnH256vg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616126735; 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=f24zbO5Yu5wh22G6gN8tPaRSeXAm+BnHKg7osBx0e8w6c/0GtykG+nTe/ct0eOFzxhzFjDEntHuqjmUTa18jqv1BTj2CO+A/NJLWTRMf/MGn5PznwwG9kwRK/umG0M92SZzvK9WMM4ulRfZrN8qGFfeVwsZofgmnC+qkwn+JPjw= 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 1616126735113123.13974303035673; Thu, 18 Mar 2021 21:05:35 -0700 (PDT) Received: from localhost ([::1]:34226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN6OE-0002zX-0j for importer@patchew.org; Fri, 19 Mar 2021 00:05:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jx-0006yG-P0 for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:09 -0400 Received: from mga18.intel.com ([134.134.136.126]:65160) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Js-0004P3-VS for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:09 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:56 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:53 -0700 IronPort-SDR: sUSwz9AVrUPGJNb6NkEl+mrlGYAADR3FREGeGI/xLJZLi1OKnSZZ3SiMwQSP9TJcTjeBAdOp7L jQWTrPBy096w== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="177409922" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="177409922" IronPort-SDR: 7docK3uZ/Ues8h1WSUkLshfEvLuhScSfXOp5zyOQ5BIxpfHSOmKXTBboZFLib33mwcNRgEORuo 6RdLNdSQLohA== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="606456703" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Li Zhijian Subject: [PATCH V4 5/7] net/colo-compare: Move data structure and define to .h file. Date: Fri, 19 Mar 2021 11:55:06 +0800 Message-Id: <20210319035508.113741-6-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319035508.113741-1-chen.zhang@intel.com> References: <20210319035508.113741-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.126; envelope-from=chen.zhang@intel.com; helo=mga18.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, 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 , Lukas Straub , 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 Fri May 3 10:32:22 2024 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=1616126850; cv=none; d=zohomail.com; s=zohoarc; b=OxpnlW09vqPiBa8j9zUGf1aHgx53TO/p/FeAXsgWHFKrtawwO2ymRTiDfM5ug6vlLUPcvRylBl1400xux+vX6shbbD8RZ8Wh+z4DSqz5FXVaQekSXC10koqeQkyatfGS+sXWwZjYok9P/sG7TE6khXBHRTujLgs+MRpnPpah1S0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616126850; 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=F7n9KXoi06sQkob2jlP6zB/PLaQEc2hLdD2ToOzOp4UNq15RqhmsPJLNxl5HczN49CrS/NKg5s+3Q6ylE21bZpN4X12IK2OaiA8lby8Rj7qx977e41ScLJmtKXGUNOg7R5HOVg9TxzRVVwrEop+ICXKQ2g/OMBo/aPwK/jdtIgs= 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 16161268508244.355164709462656; Thu, 18 Mar 2021 21:07:30 -0700 (PDT) Received: from localhost ([::1]:38510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN6Q5-0004t7-S4 for importer@patchew.org; Fri, 19 Mar 2021 00:07:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jx-0006yY-U5 for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:09 -0400 Received: from mga18.intel.com ([134.134.136.126]:65167) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jv-0004RO-0x for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:09 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:59 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:56 -0700 IronPort-SDR: nGy0XTujBCW8i2LTindx+K2ylmAyZoDGPt7+cTXQ2j56prLT+cOPq7Nu6tz5vS4x9U9rbUl6Eo ZiuPNqfAw4HQ== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="177409924" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="177409924" IronPort-SDR: 0azxCiNkRZ4MO6e8peIeWx8ZvTDmHaTrcm7e6t68Q03d+0s0M6/plRD2MFGAt+izbWmuO+3k/V 7cjQ3+Lzc9Kw== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="606456711" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Li Zhijian Subject: [PATCH V4 6/7] net/colo-compare: Add passthrough list to CompareState Date: Fri, 19 Mar 2021 11:55:07 +0800 Message-Id: <20210319035508.113741-7-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319035508.113741-1-chen.zhang@intel.com> References: <20210319035508.113741-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.126; envelope-from=chen.zhang@intel.com; helo=mga18.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, 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 , Lukas Straub , 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 Fri May 3 10:32:22 2024 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=1616126593; cv=none; d=zohomail.com; s=zohoarc; b=fdNCCeEErtTmsGO4eEAIlNz1GRZUyKNdue21UStoAVjLzJL9A3SEIielmvVdPL45syiEppWS1SfXsT1gXJVSD+t5NB2bevPOrnUJwjdQG0UaSneK8gE8/xDotcFmtyctV4ed5Y8oKf7/V4qkqHS5Hpo/JqCOxHOUuSsZMbDobmQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616126593; 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=HQDKu1F+ykCQ754g7XcqIII7cbIgVF8YWHGPRAurGPk=; b=TTTns6uxkhYAdyKctrotRvznF+YhwOsZsTIRsCyvly/mEDqlUoqgZCg1ikLhWXanbjYfUoaKzbRBDAc0LrkDfUkWGYcSFDrxBWdyPU5Hnvgq5HxsEllnqdWAbSKZN0sbc2gjZ++Lokz8rMcz03lcNrZZ/5LLH51bMMi6/5ubOy4= 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 161612659357890.74347542996713; Thu, 18 Mar 2021 21:03:13 -0700 (PDT) Received: from localhost ([::1]:56104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN6Lw-0000LV-Gh for importer@patchew.org; Fri, 19 Mar 2021 00:03:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jz-00070O-KP for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:12 -0400 Received: from mga18.intel.com ([134.134.136.126]:65171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6Jx-0004V3-5l for qemu-devel@nongnu.org; Fri, 19 Mar 2021 00:01:11 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:01:01 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 21:00:59 -0700 IronPort-SDR: K2ekOhanxZhuqYUAcmfZKz34soNKI9V0zHdaUGgfb9NYClQEWO8+3EKmLYba7RUDVwi1ZjnJ3g 2vjsQ+5ddV4Q== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="177409927" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="177409927" IronPort-SDR: zv2k3sPmY+2ghq3z+H4dxg+HuVzVG/SJcKKw0Gn+NjsS4lODg5ipW3NxpSLM2/75vTBRbpTtRp 1xhBYHH8S21A== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="606456759" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , Li Zhijian Subject: [PATCH V4 7/7] net/net.c: Add handler for COLO passthrough connection Date: Fri, 19 Mar 2021 11:55:08 +0800 Message-Id: <20210319035508.113741-8-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210319035508.113741-1-chen.zhang@intel.com> References: <20210319035508.113741-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.126; envelope-from=chen.zhang@intel.com; helo=mga18.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, 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 , Lukas Straub , 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 7c7cefe0e0..4a9ab29cca 100644 --- a/net/net.c +++ b/net/net.c @@ -56,6 +56,8 @@ #include "net/filter.h" #include "qapi/string-output-visitor.h" #include "qapi/hmp-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) @@ -1199,14 +1201,165 @@ void qmp_netdev_del(const char *id, Error **errp) } } =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