From nobody Sun Nov 10 19:49:19 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=1618932328; cv=none; d=zohomail.com; s=zohoarc; b=NUWdC3fR8H10rPD+HoEtbuvSqNkSISsi0r54t2M24XJzkq5+llY+oF4gznu0HJtCqrCKj/TnZvR0A7+LcmNW3rM/UkHgruRKQcDWHpRJNNxm9nAlbcfNlo2f2M4cZDVF6EgCbnBasS/roHfGbCMyfeuKjiKCwR/GjjNToQEFHhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618932328; 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=vOxqgnCCeDvYuD8fBtbI22LYZkCzY+mzmqThdFDZkG0=; b=ePCH6MebD2T7JRjHaox0wdYHsqVl+xnLJapOrefdgLIz9TnZJoYBDfT8ttTLyG733goFpxgfIuJmz6nW6ljY5ttC+036vJUQ20GcNWtsclWWzBqXYVX0eG/nNuxbCrIXOELY8k0yiUR0ZhhOeCx4BCjVtDykJMal4LuJ403R5Sk= 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 1618932328965678.5233391372758; Tue, 20 Apr 2021 08:25:28 -0700 (PDT) Received: from localhost ([::1]:42968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYsFj-0000ji-TR for importer@patchew.org; Tue, 20 Apr 2021 11:25:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCO-0005es-SG for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:00 -0400 Received: from mga05.intel.com ([192.55.52.43]:37551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCM-0004UC-V9 for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:00 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:21:56 -0700 Received: from unknown (HELO tkid-nvme.lan) ([10.239.13.19]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:21:53 -0700 IronPort-SDR: AoNi0dDlQwATNu0+Pc7hS6aFsnETQQKrr7s4N/vCYf0PtMn/RD/OKNdu7uEx9hOdU09cqBXfhO NIIehvRimQyQ== X-IronPort-AV: E=McAfee;i="6200,9189,9960"; a="280854207" X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="280854207" IronPort-SDR: CCh69qPVenAqxwoZD5yVb4rHNJB37VhAivWUSxd0kVnQn5sRpJO8iN+OvmrLyveTEIlV443SuM hlKg9YtXpjtw== X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="523846687" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Li Zhijian Subject: [PATCH V6 1/6] qapi/net: Add IPFlowSpec and QMP command for COLO passthrough Date: Tue, 20 Apr 2021 23:15:32 +0800 Message-Id: <20210420151537.64360-2-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210420151537.64360-1-chen.zhang@intel.com> References: <20210420151537.64360-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=192.55.52.43; envelope-from=chen.zhang@intel.com; helo=mga05.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. Add IPFlowSpec struct for all QMP commands. Except protocol field is necessary, other fields are optional. Signed-off-by: Zhang Chen --- net/net.c | 10 ++++++++ qapi/net.json | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/net/net.c b/net/net.c index edf9b95418..2a6e5f3886 100644 --- a/net/net.c +++ b/net/net.c @@ -1196,6 +1196,16 @@ void qmp_netdev_del(const char *id, Error **errp) } } =20 +void qmp_colo_passthrough_add(IPFlowSpec *spec, Error **errp) +{ + /* TODO implement setup passthrough rule */ +} + +void qmp_colo_passthrough_del(IPFlowSpec *spec, Error **errp) +{ + /* TODO implement delete passthrough rule */ +} + static void netfilter_print_info(Monitor *mon, NetFilterState *nf) { char *str; diff --git a/qapi/net.json b/qapi/net.json index af3f5b0fda..f6e4e37526 100644 --- a/qapi/net.json +++ b/qapi/net.json @@ -7,6 +7,7 @@ ## =20 { 'include': 'common.json' } +{ 'include': 'sockets.json' } =20 ## # @set_link: @@ -694,3 +695,70 @@ ## { 'event': 'FAILOVER_NEGOTIATED', 'data': {'device-id': 'str'} } + +## +# @IPFlowSpec: +# +# IP flow specification. +# +# @protocol: Transport layer protocol like TCP/UDP... +# +# @object-name: Point out the IPflow spec effective range of object, +# If there is no such part, it means global spec. +# +# @source: Source address and port. +# +# @destination: Destination address and port. +# +# Since: 6.1 +## +{ 'struct': 'IPFlowSpec', + 'data': { 'protocol': 'str', '*object-name': 'str', + '*source': 'InetSocketAddressBase', + '*destination': 'InetSocketAddressBase' } } + +## +# @colo-passthrough-add: +# +# Add passthrough entry according to user's needs in COLO-compare. +# Source IP/port and destination IP/port both optional, If user just +# input parts of infotmation, it will match all. +# +# Returns: Nothing on success +# +# Since: 6.1 +# +# Example: +# +# -> { "execute": "colo-passthrough-add", +# "arguments": { "protocol": "tcp", "object-name": "object0", +# "source": {"host": "192.168.1.1", "port": "1234"}, +# "destination": {"host": "192.168.1.2", "port": "4321"} } } +# <- { "return": {} } +# +## +{ 'command': 'colo-passthrough-add', 'boxed': true, + 'data': 'IPFlowSpec' } + +## +# @colo-passthrough-del: +# +# Delete passthrough entry according to user's needs in COLO-compare. +# Source IP/port and destination IP/port both optional, If user just +# input parts of infotmation, it will match all. +# +# Returns: Nothing on success +# +# Since: 6.1 +# +# Example: +# +# -> { "execute": "colo-passthrough-del", +# "arguments": { "protocol": "tcp", "object-name": "object0", +# "source": {"host": "192.168.1.1", "port": "1234"}, +# "destination": {"host": "192.168.1.2", "port": "4321"} } } +# <- { "return": {} } +# +## +{ 'command': 'colo-passthrough-del', 'boxed': true, + 'data': 'IPFlowSpec' } --=20 2.25.1 From nobody Sun Nov 10 19:49:19 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=1618932477; cv=none; d=zohomail.com; s=zohoarc; b=Oa45MPs6k8eSt3OU70g8pMVyFvdYN+hh+SDp+GQX0OcqFECUTWVR82imJs1yq75Rj900BFeE3rq9vn8dCyqDhU5yGCKCXAqzTjiZuE1cGWPqSUlXSzOHDWnSp5BKIQ0SNvwtykVGREBnKTWIyE+lEMkCUjXuoSR8hEAoYRV5TEk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618932477; 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=ZfOGa1EwJFtyy0wn8IknWjhmIyP4Xc535+Yw4+9Ksw8=; b=inYkOIICCsngBolfF4f90UeovEBoIiHZPaZUeojMDe30JvTR0LYTAPIujj6T5y5Avhn0M9WwFotVbhTU46Y4yVSMgeJ6Bm1mHZxwHx16jATV4bXuxjkdTaq2/ShagoGO4Kxw1dzJelT3nS9ih6SV/5Jrb6wp2iOpC9rdjRbvhjM= 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 1618932477899101.26113550732441; Tue, 20 Apr 2021 08:27:57 -0700 (PDT) Received: from localhost ([::1]:48270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYsI5-0002zY-Oq for importer@patchew.org; Tue, 20 Apr 2021 11:27:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCQ-0005gU-CH for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:02 -0400 Received: from mga05.intel.com ([192.55.52.43]:37555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCO-0004Vw-I4 for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:02 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:21:59 -0700 Received: from unknown (HELO tkid-nvme.lan) ([10.239.13.19]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:21:56 -0700 IronPort-SDR: HrS8fdyoif+UBmTQ8OZP46cGHVGjPPKxLG9YszKE3Pu/vHyzTMd9AG43/5nQBpKTGlQsz8Jxns fg764o/DYqCg== X-IronPort-AV: E=McAfee;i="6200,9189,9960"; a="280854213" X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="280854213" IronPort-SDR: mpjETsMrO5wE8qR4iu+VGh2mrHE+VF+kdYyN4Uj5owhH3DtLCCyF6bDRvWz0AbyUtY1MSbgHMZ DPbKBmALUf5A== X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="523846701" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Li Zhijian Subject: [PATCH V6 2/6] util/qemu-sockets.c: Add inet_parse_base to handle InetSocketAddressBase Date: Tue, 20 Apr 2021 23:15:33 +0800 Message-Id: <20210420151537.64360-3-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210420151537.64360-1-chen.zhang@intel.com> References: <20210420151537.64360-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=192.55.52.43; envelope-from=chen.zhang@intel.com; helo=mga05.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" No need to carry the flag all the time in many scenarios. Signed-off-by: Zhang Chen --- include/qemu/sockets.h | 1 + util/qemu-sockets.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 7d1f813576..d5abc227eb 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -32,6 +32,7 @@ int socket_set_fast_reuse(int fd); int inet_ai_family_from_address(InetSocketAddress *addr, Error **errp); int inet_parse(InetSocketAddress *addr, const char *str, Error **errp); +int inet_parse_base(InetSocketAddressBase *addr, const char *str, Error **= errp); int inet_connect(const char *str, Error **errp); int inet_connect_saddr(InetSocketAddress *saddr, Error **errp); =20 diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 8af0278f15..c16eba1917 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -690,6 +690,20 @@ int inet_parse(InetSocketAddress *addr, const char *st= r, Error **errp) return 0; } =20 +int inet_parse_base(InetSocketAddressBase *base, const char *str, Error **= errp) +{ + InetSocketAddress *addr; + int ret =3D 0; + + addr =3D g_new0(InetSocketAddress, 1); + ret =3D inet_parse(addr, str, errp); + + base->host =3D addr->host; + base->port =3D addr->port; + + g_free(addr); + return ret; +} =20 /** * Create a blocking socket and connect it to an address. --=20 2.25.1 From nobody Sun Nov 10 19:49:19 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=1618932323; cv=none; d=zohomail.com; s=zohoarc; b=dsuBRr0t8azqW79BLGW//HTzCxh7IMI3QbTAFW/Gy72Y3RI5VTRcf2xWKnxJ1OwixIL2gWv8TmGC0xuGfSHX0aeRHVqnur0IWgPYtGc1EPL5OZt9povmjhInhfz2JZQ7aWny5zBU42TigoRa0/yomXtaL3xZEAtM7UeHJ3Qv9cs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618932323; 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=JcgoxX/gWTJBIKmytvfNqS5++tEMXuqwxv9AVKj5cGE=; b=Ri8Eho+fgqmK/WN42XcoiDfeQUUBi1EyaURHNVbEybP3klkWaPRogAuBH8BPNCUNDV6mWEdZx7BsCvS78LwpU6CyihP0Z5X4hPM2WmQu0At/yUrv4gYRMmiH15sFizbgYGuBH1N6hOPch4CeM5j0l1lNamkHiqJ/F2d4RfaTr+E= 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 161893232310155.808891609476404; Tue, 20 Apr 2021 08:25:23 -0700 (PDT) Received: from localhost ([::1]:42440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYsFd-0000Wp-3g for importer@patchew.org; Tue, 20 Apr 2021 11:25:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCS-0005h2-LW for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:06 -0400 Received: from mga05.intel.com ([192.55.52.43]:37555) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCQ-0004Vw-PH for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:04 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:22:01 -0700 Received: from unknown (HELO tkid-nvme.lan) ([10.239.13.19]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:21:59 -0700 IronPort-SDR: emEbazlew5gWhc3nmVncniMqXl6891wxiIoGxUcTjo6K42ImJu9pOqJBA0lNUq73DRo+1+MQ0m sbwO/ciXBQCg== X-IronPort-AV: E=McAfee;i="6200,9189,9960"; a="280854218" X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="280854218" IronPort-SDR: hNQ8/HiT6ZmzoZNMJWi0r5ZyGS9Wg7Fkr8x2mZZcefwrY7WxLOF05TMPbGioEjf9ZsMtflT1lH ENJm3Bxcbg3w== X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="523846719" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Li Zhijian Subject: [PATCH V6 3/6] hmp-commands: Add new HMP command for COLO passthrough Date: Tue, 20 Apr 2021 23:15:34 +0800 Message-Id: <20210420151537.64360-4-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210420151537.64360-1-chen.zhang@intel.com> References: <20210420151537.64360-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=192.55.52.43; envelope-from=chen.zhang@intel.com; helo=mga05.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 | 82 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 435c591a1c..cbb08623c7 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1290,6 +1290,32 @@ SRST Remove host network device. ERST =20 + { + .name =3D "colo_passthrough_add", + .args_type =3D "protocol:s,object-name:s?,src:s?,dst:s?", + .params =3D "protocol [object-name] [src] [dst]", + .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,object-name:s?,src:s?,dst:s?", + .params =3D "protocol [object-name] [src] [dst]", + .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:S", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 605d57287a..a784f98531 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -77,6 +77,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 0ad5b77477..6991b03075 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1634,6 +1634,88 @@ 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) +{ + IPFlowSpec *spec =3D g_new0(IPFlowSpec, 1); + char *src, *dst; + Error *err =3D NULL; + + spec->protocol =3D g_strdup(qdict_get_try_str(qdict, "protocol")); + spec->object_name =3D g_strdup(qdict_get_try_str(qdict, "object-name")= ); + + src =3D g_strdup(qdict_get_try_str(qdict, "src")); + if (src) { + spec->source =3D g_new0(InetSocketAddressBase, 1); + + if (inet_parse_base(spec->source, src, NULL)) { + monitor_printf(mon, "bad colo passthrough src address"); + goto out; + } + } + + dst =3D g_strdup(qdict_get_try_str(qdict, "dst")); + if (dst) { + spec->destination =3D g_new0(InetSocketAddressBase, 1); + + if (inet_parse_base(spec->destination, dst, NULL)) { + monitor_printf(mon, "bad colo passthrough dst address"); + goto out; + } + } + + qmp_colo_passthrough_add(spec, &err); + +out: + g_free(src); + src =3D NULL; + + g_free(dst); + dst =3D NULL; + + hmp_handle_error(mon, err); +} + +void hmp_colo_passthrough_del(Monitor *mon, const QDict *qdict) +{ + IPFlowSpec *spec =3D g_new0(IPFlowSpec, 1); + char *src, *dst; + Error *err =3D NULL; + + spec->protocol =3D g_strdup(qdict_get_try_str(qdict, "protocol")); + spec->object_name =3D g_strdup(qdict_get_try_str(qdict, "object-name")= ); + + src =3D g_strdup(qdict_get_try_str(qdict, "src")); + if (src) { + spec->source =3D g_new0(InetSocketAddressBase, 1); + + if (inet_parse_base(spec->source, src, NULL)) { + monitor_printf(mon, "bad colo passthrough src address"); + goto out; + } + } + + dst =3D g_strdup(qdict_get_try_str(qdict, "dst")); + if (dst) { + spec->destination =3D g_new0(InetSocketAddressBase, 1); + + if (inet_parse_base(spec->destination, dst, NULL)) { + monitor_printf(mon, "bad colo passthrough dst address"); + goto out; + } + } + + qmp_colo_passthrough_del(spec, &err); + +out: + g_free(src); + src =3D NULL; + + g_free(dst); + dst =3D NULL; + + hmp_handle_error(mon, err); +} + void hmp_object_add(Monitor *mon, const QDict *qdict) { const char *options =3D qdict_get_str(qdict, "object"); --=20 2.25.1 From nobody Sun Nov 10 19:49:19 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=1618932279; cv=none; d=zohomail.com; s=zohoarc; b=X8jEXUeE8HM6gf/jddMQ/bI+jEfZRkFVfDCHg+vS9LRv85tOsXdtBaWXodnSN1Yxyk/+mG5fSI3S6OrGMOo9a0+RATjkpnaT+l8xnPCcIw9XhVK1YFa/WkolFEucrkDFqPxNPss5gb+c0pq14ot30alm9QVeVjCNrqD2rOyi3JY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618932279; 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=0fne1+C65r/QRG8MVcKDgHZSLwctuZ7XWejS/aZD7rE=; b=kXb98M+C4mn9OO8zeHQ/FdPdF4MjX3ikPTmW0KKLESUzZa6KDPwmGvnYqj1ZGF8MZVI8D5k1L9AdCn241dVsxiq7SSaZ47EKrCdTpvoYmdHzx9ssp2YrtZg9hji67t+REVmyYxvW30GDerHfMJLoKESNRk7Dzqi7qSqbL0tTWbQ= 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 1618932279151281.9661476211653; Tue, 20 Apr 2021 08:24:39 -0700 (PDT) Received: from localhost ([::1]:39430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYsEv-0007jU-S4 for importer@patchew.org; Tue, 20 Apr 2021 11:24:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50308) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCW-0005jB-P6 for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:09 -0400 Received: from mga05.intel.com ([192.55.52.43]:37566) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCU-0004ah-9E for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:08 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:22:05 -0700 Received: from unknown (HELO tkid-nvme.lan) ([10.239.13.19]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:22:02 -0700 IronPort-SDR: bFbqxyWAkna8lQpX70EJyGgNipd4f6FiFeGRFwgXfJuALEQ4jq6mSXLhwFDNmWsoO0oUbUfO9z W/9El8t1vVEQ== X-IronPort-AV: E=McAfee;i="6200,9189,9960"; a="280854232" X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="280854232" IronPort-SDR: mR+Ouolb66+uVwDMmIiilcXdG/qtHPUK3Mz1XTkD0dyqr38yfvn+QxeyQ5gc5gU7lKqrHboDQ3 EIZAuACHcEFA== X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="523846734" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Li Zhijian Subject: [PATCH V6 4/6] net/colo-compare: Move data structure and define to .h file. Date: Tue, 20 Apr 2021 23:15:35 +0800 Message-Id: <20210420151537.64360-5-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210420151537.64360-1-chen.zhang@intel.com> References: <20210420151537.64360-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=192.55.52.43; envelope-from=chen.zhang@intel.com; helo=mga05.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" Rename structure with COLO index and move it to .h file, It make other modules can reuse COLO code. Signed-off-by: Zhang Chen --- net/colo-compare.c | 134 +++++---------------------------------------- net/colo-compare.h | 106 +++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 120 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 9d1ad99941..b51b1437ef 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", @@ -737,19 +631,19 @@ static void colo_compare_connection(void *opaque, voi= d *user_data) =20 static void coroutine_fn _compare_chr_send(void *opaque) { - SendCo *sendco =3D opaque; + COLOSendCo *sendco =3D opaque; CompareState *s =3D sendco->s; int ret =3D 0; =20 while (!g_queue_is_empty(&sendco->send_list)) { - SendEntry *entry =3D g_queue_pop_tail(&sendco->send_list); + COLOSendEntry *entry =3D g_queue_pop_tail(&sendco->send_list); uint32_t len =3D htonl(entry->size); =20 ret =3D qemu_chr_fe_write_all(sendco->chr, (uint8_t *)&len, sizeof= (len)); =20 if (ret !=3D sizeof(len)) { g_free(entry->buf); - g_slice_free(SendEntry, entry); + g_slice_free(COLOSendEntry, entry); goto err; } =20 @@ -766,7 +660,7 @@ static void coroutine_fn _compare_chr_send(void *opaque) =20 if (ret !=3D sizeof(len)) { g_free(entry->buf); - g_slice_free(SendEntry, entry); + g_slice_free(COLOSendEntry, entry); goto err; } } @@ -777,12 +671,12 @@ static void coroutine_fn _compare_chr_send(void *opaq= ue) =20 if (ret !=3D entry->size) { g_free(entry->buf); - g_slice_free(SendEntry, entry); + g_slice_free(COLOSendEntry, entry); goto err; } =20 g_free(entry->buf); - g_slice_free(SendEntry, entry); + g_slice_free(COLOSendEntry, entry); } =20 sendco->ret =3D 0; @@ -790,9 +684,9 @@ static void coroutine_fn _compare_chr_send(void *opaque) =20 err: while (!g_queue_is_empty(&sendco->send_list)) { - SendEntry *entry =3D g_queue_pop_tail(&sendco->send_list); + COLOSendEntry *entry =3D g_queue_pop_tail(&sendco->send_list); g_free(entry->buf); - g_slice_free(SendEntry, entry); + g_slice_free(COLOSendEntry, entry); } sendco->ret =3D ret < 0 ? ret : -EIO; out: @@ -808,8 +702,8 @@ static int compare_chr_send(CompareState *s, bool notify_remote_frame, bool zero_copy) { - SendCo *sendco; - SendEntry *entry; + COLOSendCo *sendco; + COLOSendEntry *entry; =20 if (notify_remote_frame) { sendco =3D &s->notify_sendco; @@ -821,7 +715,7 @@ static int compare_chr_send(CompareState *s, return 0; } =20 - entry =3D g_slice_new(SendEntry); + entry =3D g_slice_new(COLOSendEntry); entry->size =3D size; entry->vnet_hdr_len =3D vnet_hdr_len; if (zero_copy) { @@ -1274,17 +1168,17 @@ static void colo_compare_complete(UserCreatable *uc= , Error **errp) =20 if (!s->compare_timeout) { /* Set default value to 3000 MS */ - s->compare_timeout =3D DEFAULT_TIME_OUT_MS; + s->compare_timeout =3D COLO_DEFAULT_TIME_OUT_MS; } =20 if (!s->expired_scan_cycle) { /* Set default value to 3000 MS */ - s->expired_scan_cycle =3D REGULAR_PACKET_CHECK_MS; + s->expired_scan_cycle =3D COLO_REGULAR_PACKET_CHECK_MS; } =20 if (!max_queue_size) { /* Set default queue size to 1024 */ - max_queue_size =3D MAX_QUEUE_SIZE; + max_queue_size =3D MAX_COLO_QUEUE_SIZE; } =20 if (find_and_check_chardev(&chr, s->pri_indev, errp) || diff --git a/net/colo-compare.h b/net/colo-compare.h index 22ddd512e2..ab649c9dbe 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_COLO_QUEUE_SIZE 1024 + +#define COLO_COMPARE_FREE_PRIMARY 0x01 +#define COLO_COMPARE_FREE_SECONDARY 0x02 + +#define COLO_REGULAR_PACKET_CHECK_MS 1000 +#define COLO_DEFAULT_TIME_OUT_MS 3000 + +typedef struct COLOSendCo { + Coroutine *co; + struct CompareState *s; + CharBackend *chr; + GQueue send_list; + bool notify_remote_frame; + bool done; + int ret; +} COLOSendCo; + +typedef struct COLOSendEntry { + uint32_t size; + uint32_t vnet_hdr_len; + uint8_t *buf; +} COLOSendEntry; + +/* + * + 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; + COLOSendCo out_sendco; + COLOSendCo 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 Sun Nov 10 19:49:19 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=1618932391; cv=none; d=zohomail.com; s=zohoarc; b=BmyjiE6hOJVC9TNXTMXGyOz+ri4+y9jgXBhrxkuBf/k9ElFF302Ve/zCPfB9dvwHUzbT6Bxqj0fQTMQx6pm559hrkXlC2o1hfjYD14teOF86hhhqsupaCpmXuj/JfnB2os94tm56afgdYbgoPwAHMrA1cy1Rwijnmbz5IBfHeq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618932391; 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=cOrTymbNVyOXtCAmb+fy6JDiB35fUNQqS4d++xWNMvk=; b=DFNEuw9WVRlJ0uKIdspbNbYX1ZKXZ/wbDT3MEMxWrj17h9TSnG3WB6QItDjbAz0GS2Ne83N3aLH/krYL6/zw8MN/d4h57bK9yth5epWAbNP5YP27dJHt1Uf1yBq2654tzv2ut09mky76KS5Mx8QxgVUct4UnAu6grV+RpZc0tao= 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 1618932391762346.32644772761023; Tue, 20 Apr 2021 08:26:31 -0700 (PDT) Received: from localhost ([::1]:45820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYsGk-0001sT-96 for importer@patchew.org; Tue, 20 Apr 2021 11:26:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50322) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCZ-0005kM-5k for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:14 -0400 Received: from mga05.intel.com ([192.55.52.43]:37566) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCX-0004ah-6T for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:10 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:22:08 -0700 Received: from unknown (HELO tkid-nvme.lan) ([10.239.13.19]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:22:05 -0700 IronPort-SDR: Q9/qXqiEO5bSz1HXfwB6qHjGId6iDqkGNUBDSRABQB4hhwNHorZoEOAff8I55I/Bt0PllTfDC4 G/d81cLAJL/A== X-IronPort-AV: E=McAfee;i="6200,9189,9960"; a="280854241" X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="280854241" IronPort-SDR: Oiw3tQdxDlr0zUGX0gSi30LXKXZj0+sOfEZ5Ox21bxfnbKgoMQcwtHT99k+eWcNh5f5sb9wX2r Hlx3q85b3hQA== X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="523846751" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Li Zhijian Subject: [PATCH V6 5/6] net/colo-compare: Add passthrough list to CompareState Date: Tue, 20 Apr 2021 23:15:36 +0800 Message-Id: <20210420151537.64360-6-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210420151537.64360-1-chen.zhang@intel.com> References: <20210420151537.64360-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=192.55.52.43; envelope-from=chen.zhang@intel.com; helo=mga05.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 | 28 ++++++++++++++++++++++++++++ net/colo-compare.h | 12 ++++++++++++ 2 files changed, 40 insertions(+) diff --git a/net/colo-compare.c b/net/colo-compare.c index b51b1437ef..7109e2ed30 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; + COLOPassthroughEntry *pass, *next; int ret; =20 if (mode =3D=3D PRIMARY_IN) { @@ -160,6 +161,31 @@ static int packet_enqueue(CompareState *s, int mode, C= onnection **con) } fill_connection_key(pkt, &key); =20 + /* Check COLO passthrough specifications */ + qemu_mutex_lock(&s->passthroughlist_mutex); + if (!QLIST_EMPTY(&s->passthroughlist)) { + QLIST_FOREACH_SAFE(pass, &s->passthroughlist, node, next) { + if (key.ip_proto =3D=3D pass->l4_protocol->p_proto) { + if (pass->src_port =3D=3D 0 || pass->src_port =3D=3D key.d= st_port) { + if (pass->src_ip.s_addr =3D=3D 0 || + pass->src_ip.s_addr =3D=3D key.src.s_addr) { + if (pass->dst_port =3D=3D 0 || + pass->dst_port =3D=3D key.src_port) { + if (pass->dst_ip.s_addr =3D=3D 0 || + pass->dst_ip.s_addr =3D=3D key.dst.s_addr)= { + 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); @@ -1225,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, @@ -1237,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 ab649c9dbe..7ca74de840 100644 --- a/net/colo-compare.h +++ b/net/colo-compare.h @@ -23,6 +23,7 @@ #include "migration/migration.h" #include "sysemu/iothread.h" #include "colo.h" +#include =20 #define TYPE_COLO_COMPARE "colo-compare" typedef struct CompareState CompareState; @@ -54,6 +55,15 @@ typedef struct COLOSendEntry { uint8_t *buf; } COLOSendEntry; =20 +typedef struct COLOPassthroughEntry { + struct protoent *l4_protocol; + int src_port; + int dst_port; + struct in_addr src_ip; + struct in_addr dst_ip; + QLIST_ENTRY(COLOPassthroughEntry) node; +} COLOPassthroughEntry; + /* * + CompareState ++ * | | @@ -110,6 +120,8 @@ struct CompareState { =20 QEMUBH *event_bh; enum colo_event event; + QLIST_HEAD(, COLOPassthroughEntry) passthroughlist; + QemuMutex passthroughlist_mutex; =20 QTAILQ_ENTRY(CompareState) next; }; --=20 2.25.1 From nobody Sun Nov 10 19:49:19 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=1618932503; cv=none; d=zohomail.com; s=zohoarc; b=no0CKTnQchYERf8Bkq96WakcY27HjNFSWzr2JE2+dfNCr8uq7kWu1yKYAZYPiSK0s3aWm9/CzNKdJIb/hXPq+Q+GifqmV3YBMKczUiCShNOONrlhr3uwqYxQiAm2KOUEB8C9+dR5m5mib2BjPNFrclr0TDjQOiq6wTUnnBJtjmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618932503; 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=NSCzlXNwYx4/FwMkkG062i584udTr1vGOl6TE2bgwi8=; b=XD2S8GZf2PbWWTlwttAjIo5mgmNgPJyNW28SXL4/Z/ecD+1DiO/EkTJ8MS3XRAGRqmrIZjVyjJobqYvZPNfhfF8LCl7F8nTphPep98PjTZbfsLHUhcp9+hhtjBbAJgZob5J8iwLKqHghmuG94epxxGA8ZeFO2irXZo3g3D5Y96g= 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 1618932503218675.2507978004311; Tue, 20 Apr 2021 08:28:23 -0700 (PDT) Received: from localhost ([::1]:50164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYsIX-0003kP-Tb for importer@patchew.org; Tue, 20 Apr 2021 11:28:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCh-0005ko-Mp for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:20 -0400 Received: from mga05.intel.com ([192.55.52.43]:37580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYsCb-0004eD-2p for qemu-devel@nongnu.org; Tue, 20 Apr 2021 11:22:19 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:22:11 -0700 Received: from unknown (HELO tkid-nvme.lan) ([10.239.13.19]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2021 08:22:08 -0700 IronPort-SDR: ptioplYskxzkeWG+fIyUAVh0o4W66OKDHnwpf/gP6lgmDX0UQYXC659WwwERLBgWsgq1oFBzMH hfC3+Clutf0Q== X-IronPort-AV: E=McAfee;i="6200,9189,9960"; a="280854248" X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="280854248" IronPort-SDR: k8OF5vJ5zPnD8ok00oIOmxpMmxNIigYmv56hI5pVp1A3TqaoaxW5mSODPv+8jVHMGfYcTAKjRP VIK2DRl3bXlg== X-IronPort-AV: E=Sophos;i="5.82,237,1613462400"; d="scan'208";a="523846771" From: Zhang Chen To: Jason Wang , qemu-dev , Eric Blake , "Dr. David Alan Gilbert" , Markus Armbruster , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Li Zhijian Subject: [PATCH V6 6/6] net/net.c: Add handler for COLO passthrough connection Date: Tue, 20 Apr 2021 23:15:37 +0800 Message-Id: <20210420151537.64360-7-chen.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210420151537.64360-1-chen.zhang@intel.com> References: <20210420151537.64360-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=192.55.52.43; envelope-from=chen.zhang@intel.com; helo=mga05.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 | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 2 deletions(-) diff --git a/net/net.c b/net/net.c index 2a6e5f3886..9b0de0f332 100644 --- a/net/net.c +++ b/net/net.c @@ -56,6 +56,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) @@ -1196,14 +1198,168 @@ void qmp_netdev_del(const char *id, Error **errp) } } =20 +static CompareState *colo_passthrough_check(IPFlowSpec *spec, Error **errp) +{ + Object *container; + Object *obj; + CompareState *s; + + if (!spec->object_name) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "object-name", + "Need input colo-compare object name"); + return NULL; + } + + container =3D object_get_objects_root(); + obj =3D object_resolve_path_component(container, spec->object_name); + if (!obj) { + error_setg(errp, "colo-compare '%s' not found", spec->object_name); + return NULL; + } + + s =3D COLO_COMPARE(obj); + + if (!getprotobyname(spec->protocol)) { + error_setg(errp, "COLO pass through get wrong protocol"); + return NULL; + } + + if ((spec->source->host && !qemu_isdigit(spec->source->host[0])) || + (spec->destination->host && + !qemu_isdigit(spec->destination->host[0]))) { + error_setg(errp, "COLO pass through get wrong IP"); + return NULL; + } + + if (atoi(spec->source->port) > 65536 || atoi(spec->source->port) < 0 || + atoi(spec->destination->port) > 65536 || + atoi(spec->destination->port) < 0) { + error_setg(errp, "COLO pass through get wrong port"); + return NULL; + } + + return s; +} + +static void compare_passthrough_add(CompareState *s, + IPFlowSpec *spec, + Error **errp) +{ + COLOPassthroughEntry *pass =3D NULL, *next =3D NULL, *origin =3D NULL; + + pass =3D g_new0(COLOPassthroughEntry, 1); + + pass->l4_protocol =3D getprotobyname(spec->protocol); + pass->src_port =3D atoi(spec->source->port); + pass->dst_port =3D atoi(spec->destination->port); + + if (!inet_aton(spec->source->host, &pass->src_ip)) { + pass->src_ip.s_addr =3D 0; + } + + if (!inet_aton(spec->destination->host, &pass->dst_ip)) { + pass->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 ((pass->l4_protocol->p_proto =3D=3D origin->l4_protocol->p_= proto) && + (pass->src_port =3D=3D origin->src_port) && + (pass->dst_port =3D=3D origin->dst_port) && + (pass->src_ip.s_addr =3D=3D origin->src_ip.s_addr) && + (pass->dst_ip.s_addr =3D=3D origin->dst_ip.s_addr)) { + error_setg(errp, "The pass through connection already exis= ts"); + g_free(pass); + qemu_mutex_unlock(&s->passthroughlist_mutex); + return; + } + } + } + + QLIST_INSERT_HEAD(&s->passthroughlist, pass, node); + qemu_mutex_unlock(&s->passthroughlist_mutex); +} + +static void compare_passthrough_del(CompareState *s, + IPFlowSpec *spec, + Error **errp) +{ + COLOPassthroughEntry *pass =3D NULL, *next =3D NULL, *origin =3D NULL; + + pass =3D g_new0(COLOPassthroughEntry, 1); + + pass->l4_protocol =3D getprotobyname(spec->protocol); + pass->src_port =3D atoi(spec->source->port); + pass->dst_port =3D atoi(spec->destination->port); + + if (!inet_aton(spec->source->host, &pass->src_ip)) { + pass->src_ip.s_addr =3D 0; + } + + if (!inet_aton(spec->destination->host, &pass->dst_ip)) { + pass->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 ((pass->l4_protocol->p_proto =3D=3D origin->l4_protocol->p_= proto) && + (pass->src_port =3D=3D origin->src_port) && + (pass->dst_port =3D=3D origin->dst_port) && + (pass->src_ip.s_addr =3D=3D origin->src_ip.s_addr) && + (pass->dst_ip.s_addr =3D=3D origin->dst_ip.s_addr)) { + QLIST_REMOVE(origin, node); + g_free(origin); + g_free(pass); + 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(pass); + qemu_mutex_unlock(&s->passthroughlist_mutex); +} + + void qmp_colo_passthrough_add(IPFlowSpec *spec, Error **errp) { - /* TODO implement setup passthrough rule */ + CompareState *s; + Error *err =3D NULL; + + s =3D colo_passthrough_check(spec, &err); + if (err) { + error_propagate(errp, err); + return; + } + + compare_passthrough_add(s, spec, &err); + if (err) { + error_propagate(errp, err); + return; + } } =20 void qmp_colo_passthrough_del(IPFlowSpec *spec, Error **errp) { - /* TODO implement delete passthrough rule */ + CompareState *s; + Error *err =3D NULL; + + s =3D colo_passthrough_check(spec, &err); + if (err) { + error_propagate(errp, err); + return; + } + + compare_passthrough_del(s, spec, &err); + if (err) { + error_propagate(errp, err); + return; + } } =20 static void netfilter_print_info(Monitor *mon, NetFilterState *nf) --=20 2.25.1