qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] net/colo: check vnet_hdr_support flag when using virtio-net


From: Tao Xu
Subject: Re: [PATCH] net/colo: check vnet_hdr_support flag when using virtio-net
Date: Tue, 17 Aug 2021 15:37:29 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.12.0



On 8/17/2021 2:01 PM, Tao Xu wrote:

On 8/16/2021 10:58 AM, Jason Wang wrote:

在 2021/8/6 下午2:08, Tao Xu 写道:
When COLO use only one vnet_hdr_support parameter between
COLO network filter(filter-mirror, filter-redirector or
filter-rewriter and colo-compare, packet will not be parsed
correctly. Acquire network driver related to COLO, if it is
nirtio-net, check vnet_hdr_support flag of COLO network filter
and colo-compare.

Signed-off-by: Tao Xu <tao3.xu@intel.com>
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
---
   net/colo-compare.c    | 25 +++++++++++++++++++++++++
   net/colo.c            | 20 ++++++++++++++++++++
   net/colo.h            |  4 ++++
   net/filter-mirror.c   | 17 +++++++++++++++++
   net/filter-rewriter.c |  9 +++++++++
   5 files changed, 75 insertions(+)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index b100e7b51f..bc1cc951c0 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -838,6 +838,23 @@ static int compare_chr_can_read(void *opaque)
       return COMPARE_READ_LEN_MAX;
   }
+/* check vnet_hdr_support flag through COLO filter modules */
+static int colo_vnet_driver_check(void *opaque, QemuOpts *opts, Error **errp)
+{
+    const char *colo_obj_type;
+
+    colo_obj_type = qemu_opt_get(opts, "qom-type");
+
+    if (strcmp(colo_obj_type, "filter-mirror") == 0 ||
+        strcmp(colo_obj_type, "filter-redirector") == 0 ||
+        strcmp(colo_obj_type, "filter-rewriter") == 0) {
+        if (qemu_opt_get(opts, "vnet_hdr_support")) {
+            return 1;
+        }
+    }
+    return 0;
+}
+
   /*
    * Called from the main thread on the primary for packets
    * arriving over the socket from the primary.
@@ -1289,6 +1306,14 @@ static void colo_compare_complete(UserCreatable *uc, Error **errp)
           return;
       }
+    if (!s->vnet_hdr &&
+        qemu_opts_foreach(qemu_find_opts("object"),
+                          colo_vnet_driver_check, NULL, NULL)) {
+        error_setg(errp, "colo compare needs 'vnet_hdr_support' "
+                   "when colo filter modules work on virtio-net");
+        return;
+    }


I wonder if we can detect virtio-net and apply vnet_hdr automatically.

Thanks

For filter-mirror, filter-redirector and filter-rewriter, we can detect and add it automatically, because these netfilter is attached to netdev, for example,

     if (!s->vnet_hdr &&
         qemu_opts_foreach(qemu_find_opts("device"),
                          vnet_driver_check, nf->netdev_id, NULL)) {
         s->vnet_hdr = true.
     }


But for colo-compare, it isn't attached to netdev, only can check colo netfilter to check vnet_hdr_support. In this situation, if all netfilter vnet_hdr_support is missing, colo_vnet_driver_check() will return 0, it can't find vnet_hdr_support is missing.

So can we apply vnet_hdr automatically for filter-mirror, filter-redirector and filter-rewriter? And keep report error for colo-compare?

Sorry, I find the solution for colo-compare apply vnet_hdr automatically, I will submit V2 later.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]